Archive for October, 2007...
Filed under: apple
I installed Leopard and like some people on the net, MySQL was no longer running. MySQL would not start from the preferences pane and running mysqld from the command line got me:
wayne-pans-computer-2:bin Wayne$ mysqld
071026 17:29:55 [Warning] Can't create test file /usr/local/mysql-5.0.45-osx10.4-i686/data/wayne-pans-computer-2.lower-test
071026 17:29:55 [Warning] Can't create test file /usr/local/mysql-5.0.45-osx10.4-i686/data/wayne-pans-computer-2.lower-test
mysqld: Can't change dir to '/usr/local/mysql-5.0.45-osx10.4-i686/data/' (Errcode: 13)
071026 17:29:55 [ERROR] Aborting
...
Turns out for some reason the data directory has the wrong permissions.
wayne-pans-computer-2:mysql-5.0.45-osx10.4-i686 Wayne$ pwd
/usr/local/mysql-5.0.45-osx10.4-i686
wayne-pans-computer-2:mysql-5.0.45-osx10.4-i686 Wayne$ ls -la
total 96
drwxr-xr-x 19 root wheel 646 Jul 4 10:54 .
drwxr-xr-x 14 root wheel 476 Oct 26 17:29 ..
-rw-r--r-- 1 root wheel 19071 Jul 4 06:06 COPYING
-rw-r--r-- 1 root wheel 5139 Jul 4 06:06 EXCEPTIONS-CLIENT
-rw-r--r-- 1 root wheel 8528 Jul 4 10:15 INSTALL-BINARY
-rw-r--r-- 1 root wheel 1410 Jul 4 06:05 README
drwxr-xr-x 73 root wheel 2482 Oct 26 17:29 bin
-rwxr-xr-x 1 root wheel 801 Jul 4 10:53 configure
drwxr-x--- 4 _mysql wheel 136 Oct 26 17:29 data
drwxr-xr-x 4 root wheel 136 Jul 4 10:53 docs
drwxr-xr-x 67 root wheel 2278 Jul 4 10:54 include
drwxr-xr-x 21 root wheel 714 Jul 4 10:54 lib
drwxr-xr-x 4 root wheel 136 Jul 4 10:53 man
drwxr-xr-x 15 root wheel 510 Jul 4 10:54 mysql-test
drwxr-xr-x 3 root wheel 102 Jul 4 10:54 scripts
drwxr-xr-x 9 root wheel 306 Jul 4 10:54 share
drwxr-xr-x 31 root wheel 1054 Jul 4 10:54 sql-bench
drwxr-xr-x 15 root wheel 510 Jul 4 10:54 support-files
drwxr-xr-x 20 root wheel 680 Jul 4 10:54 tests
So I simply chmodded data (with -R) to 777 and mysqld works again (along with the MySQL pref pane). Not the most secure way, but I said quick and dirty didn’t I? Before doing that I also tried chowning to root and starting mysqld with sudo but it complained about starting mysqld as root. Hopefully this helps someone out there.
On a side note, I hate the new dock. Try to figure out which one my apps are running by quickly glancing at the picture below. It takes some time for you to focus in on those light blue dots. Give me back the black arrow! (Also in the screenshot below, Eclipse is running but a second Eclipse icon is generated as the real Eclipse process. Not sure if I can blame Apple for this one.)

My biggest reason for upgrading is actually to see if Leopard will fix my annoying freezing issues!
Filed under: admob
If you’re free on Oct 31 and you’re in the San Mateo area and you happen to be hungry and you happen to be broke, stop by the AdMob offices for a free lunch!
That’s right, AdMob is hosting a Lunch 2.0 event. This is not Lunch 1.0, but Lunch 2.0! Where everything looks good, has a Beta stamp on it, cross-linked, and the content is completely user driven! Just avoid the food “mash-ups”, they’re known to cause stomach aches 
Filed under: apple, rails
I was reading on Mac OS X Leopard and it’s new features and ran across this gem:
Ruby on Rails
Work in a developer’s dreamland. Leopard is the perfect platform for Ruby on Rails development, with Rails, Mongrel, and Capistrano built in.
Thank god! Getting RoR on OS X was a bit of pain if I recall (things you do once and forget about). The more Apple does of this the better… How about making a decent apt-get?
Filed under: php
Fresh from ZendCon, a technique I learned from Eli White…
Ever wanted to process things out of band in your php scripts? The ignore_user_abort() function allows you just to do that.
Description
int ignore_user_abort ( [bool $setting] )
Sets whether a client disconnect should cause a script to be aborted.
Parameters
setting
If not set, the function will only return the current setting.
Basically, when you use ignore_user_abort(true) in your php script, the script will continue running even if the user pressed the esc or stop on his browser. How do you use this? One use would be to return content to the user and allow the connection to be closed while processing things that don’t require user interaction.
The following example sends out $response to the user, closing the connection (making the browser’s spinner/loading bar stop), and then executes do_function_that_takes_five_mins();
ignore_user_abort(true);
header("Connection: close");
header("Content-Length: " . mb_strlen($response));
echo $response;
flush();
do_function_that_takes_five_mins();
It’s that easy! You can also redirect the user in the same fashion. In the example below I’ve added the line session_write_close() which forces the session to be written. If this is not done, any modifications to $_SESSION will not take affect to user’s other sessions until do_function_that_takes_five_mins(); has finished.
ignore_user_abort(true);
session_write_close(); // optional, this will close the session.
header("Location: $redirect_url");
flush();
do_function_that_takes_five_mins();
Also, if your max execution time is set to something low, you can increase the time limit for scripts by using set_time_limit(). Just keep in mind, the php process will still take up an apache process until it’s completed. This is a great technique to give the user immediate response and speed up your web apps!
Comments (0) Posted by Wayne on Thursday, October 11th, 2007
Filed under: php, ZendCon07
The past couple days I attend ZendCon 2007. I had low expectations for the event but planned to attend most of the break out sessions. My company, AdMob, also sent me to do some recruiting but with the job market so tight not many attendees were looking for jobs.
I tried to hit up every session about scaling web sites hoping to learn something new. However, all techniques end up being the same. Some combination of load balanced front end server, a memcached server pool, partitioned databases with purpose divided read only slaves, and if needed a jobs/queue server.
The most useful talk of the two days was done by Eli White on PHP Features You Didn’t Know Existed. (Slides available here.) Take aways for me were:
- http_build_query - easy function to rebuild get parameters.
- ignore_user_abort / connection_aborted - allows a php script to continue even after the user has ended the connection
- register_shutdown_function - a destructor for your scripts, no matter how they end
- set_time_limit - increase execution time on a script. Already a well known function, but didn’t realize it resets the counter every time, so you can throw this in a loop and you have N seconds from when the line gets executed
- pspell - built in spell check library, great for English. Not sure about i18n support
Also Joel Spolsky of JoelOnSoftware.com fame gave Day 2’s afternoon keynote. Very entertaining speech, mainly because he showed numerous pictures of Angelina Jolie… and Brad Pitt so all the PHP women in the room wouldn’t feel left out. Then proceeded to BLAST Microsoft, from the Brown Zune to a hilarious Windows ME simulator. However, the main take away from his speech were his 3 tips to building great software.
- Make People Happy - put people in control, even if it’s faux control. People that feel helpless or not in control are not happy. Software should do things for you, not ask you to do things (insert original Windows CD-ROM is a classic example).
- Think About Emotions - Apple does this well. People connect to their devices because they evoke emotion. His example was SUVs make people feel safer due to small things such as cup holders and things being soft and round.
- Obsess over Aethetics - Rounded corners are king. Mentioned French buildings which contain no fire escape stairs versus buildings in New York which all have them.
I’m obviously butchering his presentation. If you ever have a chance to hear Joel talk, take it.
Other than those 2 sessions, the rest of the conference was a waste of time in my opinion. If I didn’t work 3 exits away from the conference, I definitely wouldn’t have attended.
Comments (1) Posted by Wayne on Thursday, October 11th, 2007
Filed under: tech