Format prices as swiss francs (CHF) in PHP - painless!

Formatting prices as swiss francs in PHP is actually very easy .. if you know how.
Requires: PHP 5 >= 5.3.0, PECL intl >= 1.0.0

The number formatter handles all pitfalls like rounding to "5 Rappen", fraction, apostrophe's, etc.

$formatter = new NumberFormatter('de_CH', NumberFormatter::DECIMAL );
echo $formatter->formatCurrency(123456.759,'CHF')."<br />\n";
// Output: 123'456.75
echo $formatter->formatCurrency(123456,'CHF')."<br />\n";
// Output: 123'456.00
echo $formatter->formatCurrency(123456.97,'CHF')."<br />\n";
// Output: 123'456.95
echo $formatter->formatCurrency(123456.98,'CHF')."<br />\n";
// Output: 123'457.00
echo $formatter->formatCurrency(.2,'CHF')."<br />\n";
// Output: 0.20


Preise als Schweizer Franken zu Formatieren geht in PHP sehr einfach .. wenn man weiss wie.
Die NumberFormatter Klasse kann auf 5 Rappen runden, Hochkomma setzen, etc.
Benötigt wird PHP 5 >= 5.3.0, PECL intl >= 1.0.0.
Beispiel siehe oben.

Fix crashing Unreal Tournament 2004 (on mac osx)


Until recently I played unreal tournament 2004 on my macbook pro without any trouble.
Then one day, I quit the game, tried to start it again and since then it always crashed imediately after launch.
It didn't even recreate the deleted preferences folder, it crashed that early.

The error report says this:

Dyld Error Message:
Library not loaded: @executable_path/libSDL-1.2.0.dylib
Referenced from: /Applications/games/Unreal Tournament Tournament 2004
Reason: image not found

Google found some people with the same problem, but no solution.
So here is the solution for all you out there with the same problem ;-)

After trying various things, fixing permissions, etc. I finaly found the solution.
I copied the library (libSDL-1.2.0.dylib) mentioned in the error message to /usr/local/lib and voilà, ut2004 runs again.

Open a console, go to the folder where your "Unreal Tournament" is, then copy the library file:

sudo cp Unreal\ Tournament\ /usr/local/lib

Release des für Address Book


Vor einiger Zeit hatte ich das "Google Map Of" Script für das OSX Address Book entdeckt. (Unterdessen gibts das mächtigere "Google Map Plugin".)

Von dem "Google Map Of" Script hatte ich mir eine Kopie angefertigt die verwendet. Dieses habe ich jetzt noch ein wenig verfeinert und online gestellt unter " Address Book Plugin". Long live applescript ;-)

adresse menu.png telefon menu.png

Filesystem for external harddrive

Which format?
Recently I bought a new external harddrive. I asked myself is there a good reason today to leave it formated with fat32 (sometimes even in fat16!). Many of todays filesystems have superior features, but is there also a filesystem with the cross platform compatibility of FAT?

My requirements for the filesystem
  • good compatibility with my main operating system: mac os x
  • high filesize limits
  • unix filesystem permissions
  • journaling if possible
  • cross-platform:
    • linux
    • mac os x
    • windows
While writing this entry I found an excellent article that covers many point's (so I don't have to): move your data.
It explores the positives and negatives of the different filesystems. It's main focus is on a filesystem that is accessable by windows and linux.

The idea of two partitions
My personal focus is on data that is read&writable with linux and mac os x and at least readable under windows.
I begun conducting research on this filesystem question. I discovered the idea of two partitions on a jumpdrive.
A small partition formatted with fat32 which is readily mountable in windows and everywhere. The second,larger and main partition is formatted with the more "special" filesystem.
On the small partition I place a driver or other applications that allow access to the more specially formatted partition. Furthermore if you can't or don't want to install the driver you can store some files directly on the FAT partition.

First run with EXT3
Ext3 was my main filesystem with linux, has unix permissions, journaling and a driver for windows and osx. It covers all my requirements (at least I thought so). No journaling with windows, but I won't use it often with windows so I could live with that. Thus I decided to take this way.
As I didn't have my macbook pro back then I couldn't test the filesystem with osx. As the future showed the osx driver is not stable. The first and only time I had kernel crashes was while using this driver. Alternatively I tried to use the fuse ext2 driver with macfuse - no success. Time to find a new filesystem.

Success with HFS+
My next try with hfs+ - the standard os x filesystem - was successful.
It mounts without manual work in my Ubuntu GNU/Linux box and has limited support for windows.
A fileexplorer (readonly) for Windows XP is HFSExplorer.
For more drivers and information see the wikipedia article for HFS+.
HFS+ is mounted readonly, to enable the write support within linux I had to disable the journal of the HFS+ partition, see It's sad I have to disabe the journal, but at least I get write support if I need it. Don't forget to reenable the journal afterwards ;-)