After MySQL upgrade on OS X, all tables are missing

When upgrading MySQL on OS X (anno domini 2010),  I learned the hard way that the “data” folder containing your databases and tables does not get moved. Look into /usr/local; you will probably have the old mysql-* folder there containing just the “data” folder. /usr/local/mysql is a symlink to the current MySQL installation, so move its data folder elsewhere, and put the old one in there.

PHP on Mac no longer able to connect to MySQL

It’s been a while since I did web development on my Mac, and MySQL ceased to work. Could be related to that one time that I accidentally removed a bunch of dot-files from my home directory, could be related to MySQL upgrade. In any case, it no longer worked.
What I figured out was that the /var/mysql/mysql.sock UNIX domain socket was no longer generated. The /var/mysql folder was missing. When just creating it and assigning it to user _mysql (chown _mysql /var/mysql) did not help, I knew something was wrong with configuration.

MySQL tries to read configuration from /etc/my.cnf. To get its UNIX domain socket where PHP expects it, this needs to be contained in this configuration file:

[client]
port = 3306
socket = /var/mysql/mysql.sock


[mysqld]
port = 3306
basedir = /usr/local/mysql/
socket = /var/mysql/mysql.sock
; datadir = /servers/raiddrive/databases/

Please read the manual for details, and this is not administration advice; I’m not sure if this opens security holes, but I only use MySQL for development purposes. (Because you should know better than letting programmers near mission critical production servers.)

Testing for presence of Apple platform in C/C++/ObjC code

Are we running on an Apple platform?
#ifdef __APPLE__
#endif
Prerequisite for other tests
#ifdef __APPLE__
// let Apple define 
// various TARGET_OS_ 
// constants
#include  
#else
// not on Apple platform
TARGET_OS_MAC 0
TARGET_OS_IPHONE 0
#endif
Are we running on Mac OS X?
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
….
#endif
Are we running on an iOS device?
#if TARGET_OS_IPHONE
….
#endif
// updated on Oct13 2010, previous method was flawed. sorry everyone!

Half Life 2: "Failed to load the launcher DLL"

All of a sudden, without touching anything (in fact, without booting Windows during last few days) I got this upon trying to launch Half Life 2:

Failed to load the launcher DLL: 


The specified procedure could not be found. 




Verifying files did not help me. The solution (for me)? I went to:


C:\Program Files\Steam\steamapps\ivucica\half-life 2\bin


and I moved all the .dll files away. Then I relaunched the game. Steam happily recreated all .dlls, and the game now works. I safely removed old copies of the DLLs.


Since I didn’t think of making a screenshot, image from http://www.hl2world.com/bbs/-vp666240.html

Apache 403 — one cause on Mac (and other Unixes)

Things suddenly broke, without installing web-server-related stuff, without touching apache config?

It’s probably permissions.
No really, you checked out permissions, and it looks ok. Really, “Sites” (or “public_html”) looks ok. However, the entire path needs to be fixed.

Check if each directory in full path to the file you want to serve contains at least executable permission for the web group, or “other” group. That is, on Mac this helped me:

chmod o+x /Users
chmod o+x /Users/ivucica
chmod 755 /Users/ivucica/Sites

What went wrong for me? I suspect Mac OS X 10.6’s disk check, or perhaps one other disk utility I recently used, messed up the executable permission flag of /Users/ivucica. I have no other explanation.

This tip would probably help under GNU/Linux too.

Steam Mac: Proxy error when accepting gifts

Getting the following error on Steam Mac when attempting to accept gift by clicking on link in the email?

Unable to connect to HTTP Proxy. Your proxy may be misconfigured or offline. -336

Unable to connect to HTTP Proxy. Your proxy may be misconfigured or offline.

Woah! But you don’t use a proxy, do you? Solution is simple. For all your Internet connections (just to be safe), in System Preferences, disable Auto Proxy Discovery. Click on screenshots to enlarge.

This worked for me, but your mileage may vary. Now, let’s report this on the Steam Mac forum…