Snow Leopard and PHP
Earlier versions of Mac OS X always had pretty outdated versions of PHP in their default installation, so what you usually did was to go to entropy.ch and fetch the packages provided there.
Now, after updating to Snow Leopard you'll notice that the entropy configuration has been removed and once you add it back in, you'll see Apache segfaulting and some missing symbol errors.
Entropy has not updated the packages to snow leopard yet, so you could have a look at PHP that came with stock snow leopard: This time it's even bleeding edge: Snow Leopard comes with PHP 5.3.0.
Unfortunately though, some vital extensions are missing, most notably for me, the PostgeSQL extension.
This time around though, Snow Leopard comes with a functioning PHP development toolset, so there's nothing stopping you to build it yourself, so here's how to get the official PostgreSQL extension working on Snow Leopard's stock php:
- Make sure that you have installed the current Xcode Tools. You'll need a working compiler for this.
- Make sure that you have installed PostgreSQL and know where it is on your machine. In my case, I've used the One-click installer from EnterpriseDB (which persisted the update to 10.6).
- Now that Snow Leopard uses a full 64bit userspace, we'll have to make sure that the PostgreSQL client library is available as a 64 bit binary - or even better, as an universal binary.Unfortunately, that's not the case with the one-click installer, so we'll have to fix that first:
- Download the sources of the PostgreSQL version you have installed from postgresql.org
- Open a terminal and use the following commands:
% tar xjf postgresql-[version].tar.bz2 % cd postgresql-[version] % CFLAGS="-arch i386 -arch x86_64" ./configure --prefix=/usr/local/mypostgres % make
make will fail sooner or later because you the postgres build scripts can't handle building an universal binary server, but the compile will progress enough for us to now build libpq. Let's do this:
% make -C src/interfaces % sudo make -C src/interfaces install % make -C src/include % sudo make -C src/include install % make -C src/bin % sudo make -C src/bin install
- Download the php 5.3.0 source code from their website. I used the bzipped version.
- Open your Terminal and cd to the location of the download. Then use the following commands:
% tar -xjf php-5.3.0.tar.bz2 % cd php-5.3.0/ext/pgsql % phpize % ./configure --with-pgsql=/usr/local/mypostgres % make -j8 # in case of one of these nice 8 core macs :p % sudo make install % cd /etc % cp php.ini-default php.ini
- Now edit your new php.ini and add the line
extension=pgsql.so
And that's it. Restart Apache (using apachectl or the System Preferences) and you'll have PostgreSQL support.
All in all this is a tedious process and it's the price us early adopters have to pay constantly.
If you want an honest recommendation on how to run PHP with PostgreSQL support on Snow Leopard, I'd say: Don't. Wait for the various 3rd party packages to get updated.
No more hard drives for me!
Last week I noticed that the hardware store of my choice had these fancy new (and fast) Intel SSDs in stock - reason enough for me to go ahead and buy two to try them out in my two MacPro desktop machines. Kos-Mos, my home mac was the first to be converted.
But before that, there was this hardware problem to overcome. See: The SSDs are 2.5 inch drives whereas the MacPro has 3.5 inch slots. While the connectors (SATA) are compatible, the smaller form factor of the Intel drives prevents the usual drive sliders of the MacPro from working.
The solution was to buy one of these adapters for the SSDs. Before doing that, I read about other solutions, some of them involving duct tape, but this felt like it was the cleanest way and it was: The kits fit perfectly, so installing the drive was a real piece of cake.
The next problem was about logistics:
pilif@kosmos /Volumes/Macintosh HD % df -h | grep Macintosh /dev/disk2s2 365Gi 319Gi 46Gi 88% /Volumes/Macintosh HD |
Whereas the largest Intel SSD available to date has just 160GB of capacity (149 "really usable"), so at least some kind of reorganization had to be done.
Seeing that the installation running on the traditional drive was ages old anyways (dating back to the last quarter of 2006), I decided that the sanest way to proceed was to just install another copy of Leopard to the new drive and use that as the boot device, coping over the applications and parts of the user profile I really needed.
Been there, done that.
I didn't do any real benchmark, but boot-time is now sub 10 seconds. Eclipse starts up in sub 5 seconds. The installation of all the updates since the pristine 10.5.1 that was on the DVDs that came with the machine took less than three minutes - including the reboots (I've installed the 10.5.7 update this morning and it took around 10 minutes on the same machine).
And to make things even better: The machine is significantly quieter than before - at least once the old hard drive powers down.
I will never, ever, again use non-SSD drives in any machine I'm working at from now on.
The perceived speedup was as significant as going from 8MB or RAM to 32MB back in the days. The machine basically feels like a new computer.
Of course I ran into one really bad issue:
The idea was to symlink ~/Music to my old drive because my iTunes Library (mostly due to Podcasts and audio books) was too large to conveniently copy to the SSD. I renamed ~/Music to ~/Music.old, created the symlink and started iTunes for the first time, only to get screwed with an empty library.
According to the preferences though, iTunes did correctly follow the symlink and was pointing to the right path (WTF?). I tried to manually re-add the library folder which did kind of work, but screwed over all my podcasts - completely.
This is where I noticed that somehow iTunes still found ~/Music.old and used that one. A quick ps turned out my best friend, the iTunes helper was running, so I shut that one down and moved ~/Music.old away to /, just to be sure.
Restarted iTunes just to run into the very same problems again (now, this is a serious WTF).
The only way to get this to work was to quit iTunes (that includes killing the helper) and to completely remove all traces of that Music folder.
Now iTunes is finally using the Music folder on my traditional hard drive. This kind of work should not be needed and I seriously wonder what kind of magic was going on behind the scenes there - after killing the helper and renaming the folder, it should not have used it any more.
Still: SSDs are fun. And I would never again want to miss the kind of speed I'm now enjoying.
celes in the office is next
Playing Worms Armageddon on a Mac
Last weekend, I had a real blast with the Xbox 360 Arcade version of worms. Even after so many years, this game still rules them all, especially (if not only) in multiplayer mode.
The only drawback of the 360 version is the lack of weapons.
While the provided set is all well, the game is just not the same without the Super Banana Bomb or the Super Sheep.
So this is why I looked for my old Worms Armageddon CD and tried to get it to work on todays hardware.
Making it work under plain Vista was easy enough (get the latest beta patch for armageddon, by the way):
Right-Click the Icon, select the compatibility tab, chose Windows XP, Disable Themes and Desktop composition and run the game with administrative privileges.
You may get away with not using one option or the other, but this one worked consistently.
To be really useful though, I wanted to make the game run under OS X as this is my main environment and I really dislike going through the lengthy booting process that is bootcamp.
I tried the various virtualization solutions around - something that should work seeing that the game doesn't really need much in terms of hardware support.
But unfortunately, this was way harder than anticipated:
- The initial try was done using VMWare Fusion which looked very good at first, but failed miserably later on: While I was able to launch (and actually use) the games frontend, the actual game was a flickery mess with no known workaround.
- Parallels failed by displaying a black menu. It was still clickable, but there was nothing on the screen but blackness and a white square border. Googling around a bit led to the idea to set SlowFrontendWorkaround in the registry to 0 which actually made the launcher work, but the game itself crashed consistenly without error message.
In the end, I've achieved success using VirtualBox. The SlowFrontendWorkaround is still needed to make the launcher work and the mouse helper of the VirtualBox guest tools needs to be disabled (on the Machine menu, the game still runs with the helper enabled, but you won't be able to actually control the mouse pointer consistently), but after that, the game runs flawlessly.
Flickerless and with a decent frame rate. And with sound, of course.
To enable the workaround I talked about, use this .reg file.
Now the slaughter of worms can begin
New MacMini (early 09) and Linux
The new MacMinis that were announced this week come with a Firewire 800 port which was reason enough for me to update shion yet again (keeping the host name of course).
All my media she's serving to my various systems is stored on a second generation Drobo which is currently connected via USB2, but has a lingering FW800 port.
Of course the upgrade to FW800 will not double the transfer rate to and from the drobo, but it should increase it significantly, so I went ahead and got one of the new Minis.
As usual, I entered the Ubuntu (Intrepid) CD, hold c while turning the device on and completed the installation.
This left the Mini in an unbootable state.
It seems that this newest generation of Mac Hardware isn't capable of booting from an MBR partitioned harddrive. Earlier Macs complained a bit if the harddrive wasn't correctly partitioned, but then went ahead and booted the other OS anyways.
Not so much with the new boxes it seems.
To finally achieve what I wanted I had to do the following complicated procedure:
- Install rEFIt (just download the package and install the .mpkg file)
- Use the Bootcamp assistant to repartition the drive.
- Reboot with the Ubuntu Desktop CD and run parted (the partitioning could probably be accomplished using the console installer, but I didn't manage to do it correctly).
- Resize the FAT32-partition which was created by the Bootcamp partitioner to make room at the end for the swap partition.
- Create the swap partition.
- Format the FAT32-partition with something useful (ext3)
- Restart and enter the rEFIt partitioner tool (it's in the boot menu)
- Allow it to resync the MBR
- Insert the Ubuntu Server CD, reboot holding the C key
- Install Ubuntu normally, but don't change the partition layout - just use the existing partitions.
- Reboot and repeat steps 7 and 8
- Start Linux.
Additionally, you will have to keep using rEFIt as the boot device control panel item does not recognize the linux partitions any more, so can't boot from them.
Now to find out whether that stupid resistor is still needed to make the new mini boot headless.
Dropbox
Dropbox is cloud storage on the next level: You install their little application - available for Linux, Mac OS X and Windows - which will create a folder which will automatically be kept synchronized between all the computers where you have installed that little application on.
Because it synchronizes in the background and always keeps the local copy around, the access-speed isn't different from a normal local folder - mainly because it is, after all, a local folder you are accessing. Dropbox is not one of these slow "online hard drives" it's more like rsync in the background (and rsync it is - the application is intelligent enough to only transmit deltas - even from binary files).
They do provide you with a web interface of course, but the synchronizing aspect is the most interesting.
The synchronized data ends up somewhere in Amazon's S3 service, which is fine with me.
Unfortunately, while the data stored in an encrypted fashion on S3, the key is generated by the Dropbox server and thus known to them, which makes Dropbox completely unusable for sensitive unencrypted data. They do state in the FAQ that this will maybe change sometime in the future, but for not it is as it is.
Still, I found some use for Dropbox: ~/Library/Preferences, ~/.zshrc and ~/.ssh all are now stored in ~/Dropbox/System and symlinked back to their original place. This means that a large chunk of my user profile is availalbe on all the computers I'm working on. I would even try the same trick with ~/Library/Application Support, but that seems risky due to the missing encryption and due to the fact that Application Support sometimes contains database files which get corrupted for sure when moved around while they are open - like the Firefox profile.
This naturally even works when the internet connection is down - DropBox synchronizes changes locally, so when the internet (or Dropbox) is down, I just have the most recent copy of when the service was still working - that's more than good enough.
Another use that comes to mind for Dropbox storage are game save files or addons you'd want to have access to on every computer you are using - just move your stuff to ~/Dropbox and symlink it back to the original place.
Very convenient.
Now if only they'd provide me with a way to provide my own encryption key. That way I would instantly buy the pro account with 25GB of storage and move lots and lots of data in there.
Dropbox is the answer to the ever increasing amount of computers in my life because now I don't care about setting up the same stuff over and over again. It's just there and ready. Very helpful.
Listen to your home music from the office
My MP3 collection is safely stored on shion, on a drobo mounted as /nas. Naturally, I want to listen to said music from the office - especially considering my fully routed VPN access between the office and my home infrastructure and the upstream which suffices for at least 10 concurrent 128bit streams (boy - technology has changed in the last few years - I remember the times where you couldn't reliably stream 128 bit streams - let alone my 160/320 mp3s).
I've tried many things so far to make this happen:
- serve the files with a tool like jinzora. This works, but I don't really like jinzora's web interface and I was never able to get it to work correctly on my Ubuntu box. I was able to trace it down to null bytes read from their tag parser, but the code is very convoluted and practically unreadable without putting quite some effort into that. Considering that I didn't much like the interface in the first place, I didn't want to invest time into that.
- Use a SlimServer (now Squeezecenter) with a softsqueeze player. Even though I don't use my squeezebox (an original model with the original slimdevices brand, not the newer Logitech one) any more because the integrated amplifier in the Sonos players works much better for my current setup. This solution worked quite ok, but the audio tends to stutter a bit at the beginning of tracks, indicating some buffering issues.
- Use iTune's integrated library sharing feature. This seemed both undoable and unpractical. Unpractical because it would force me to keep my main mac running all the time and undoable because iTunes sharing can't pass subnet boundaries. Aside of that, it's a wonderful solution as audio doesn't stutter, I already know the interface and access is very quick and convenient.
But then I found out how to make the iTunes thing both very much doable and practical.
The network boundary problem can be solved using Network Beacon, a ZeroConf proxy. Start the application, create a new beacon. Chose any service name, use «_daap._tcp.» as service type, set the port number to 3689, enable the host proxy, keep the host name clear and enter the IP address of the system running iTunes (or firefly - see below).
Oh, and the target iTunes refuses to serve out data to machines in different subnets, so to be able to directly access a remote iTunes, you'd also have to set up an SSH tunnel.
Using Network Beacon, ZeroConf quickly begins working across any subnet boundaries.
The next problem was about the fact that I was forced to keep my main workstation running at home. I fixed that with Firefly Media Server for which even a pretty recent prebuilt package exists for Ubuntu (apt-get install mt-daapd).
I've installed that, configured iptables to drop packets for port 3689 on the external interface, configured Firefly to use the music share (which basically is a current backup of the itunes library of my main workstation - rsync for the win).
Firefly in this case even detects the existing iTunes playlists (as the music share is just a backup copy of my iTunes library - including the iTunes Library.xml), though smart playists don't work, but can easily be recreated in the firefly web interface.
This means that I can access my complete home mp3 library from the office, stutter free, using an interface I'm well used to, without being forced to keep my main machine running all the time.
And it isn't even that much of a hack and thus easy to rebuild should the need arise.
I'd love to not be forced to do the Network Beacon thing, but avahi doesn't relay ZeroConf information across VPN interfaces.
VMWare Fusion Speed
This may be totally placebo, but I noticed that using Vista inside a VMWare Fusion VM has just turned from nearly unbearable slow to actually quite fast by updating from 2.0 Beta 2 to 2.0 Final.
It may very well be that the beta versions contained additional logging and/or debug code which was keeping the VM from reaching its fullest potential.
So if you are too lazy to upgrade and still running one of the Beta versions, you should consider updating. For me at least, it really brought a nice speed-up.
iTunes 8 visualization

Up until now I have not been a very big fan of iTunes' visualization engine, probably because I've been spoiled with MilkDrop in my Winamp days (which still owns the old iTunes display on so many levels).
But with the release of iTunes 8 and their new visualization, I have to admit that, when you chose the right music (in this case it's Liberi Fatali from Final Fantasy 8), you can really get something out of this.
The still picture really doesn't do it justice, so I have created this video (it may be a bit small, but you'll see what I'm getting at) to visualize my point. Unfortunately, near the end it gets worse and worse, but the beginning is something of the more impressive shows I have ever seen generated out of this particular piece of music.
This may even beat MilkDrop and I could actually see myself assembling a playlist of some sort and put this thing on full screen.
Nice eyecandy!
Altering the terminal title bar in Mac OS X
After one year of owning a MacBook Pro, I finally got around to fix my precmd() ZSH-hack to really make the current directory and stuff appear in the title bar of Terminal.app and iTerm.app.
This is the code to add to your .zshrc:
case $TERM in *xterm*|ansi) function settab { print -Pn "\e]1;%n@%m: %~\a" } function settitle { print -Pn "\e]2;%n@%m: %~\a" } function chpwd { settab;settitle } settab;settitle ;; esac |
settab sets the tab contents in iTerm and settitle does the same thing for the title bar both in Terminal.app and iTerm.
The sample also shows the variables ZSH replaces in the strings (the parameter -P to print lets ZSH do prompt expansion. See zshmisc(1) for a list of all variables): %n is the currently logged on user, %m the hostname up until the first dot and %~ is displaying the current directory or ~ if you are in $HOME. You can certainly add any other environment variable of your choice if you need more options, but this more or less does it for me.
Usually, the guides in the internet make you use precmd to set the title bar, but somehow, Terminal wasn't pleased with that method and constantly kept overwriting the title with the default string.
And this is how it looks in both iTerm (above) and Terminal (below):

