Saturday, September 12, 2009

The Generic Chaining Pattern

Have a look at the following situation:

Another example:

I used Generics to get around this flaw:

The example above therefore could be handled as follows:

Used this Generic Chaining Pattern while developing an abstraction layer for database access in an old fashioned jdbc environment. It looked like this:

Thursday, September 10, 2009

0xCAFEBABE

For those who are curious about the URL of this blog (http://cafebab3.blogspot.com) take a look at this discussion.

Wednesday, September 9, 2009

Solid State Disk vs. Sudden Motion Sensor

Lucky owners of a Solid State Disk (SSD) should think about disabling their Suddden Motion Sensor (SMS) which is primary used to protect mechanic hard disks from head crashes. With SSDs head crashes are history - you can work without fear, even if your hardware rumbles.

However, follow these instructions to disable the sensor:
  • open a terminal
  • disable sensor: sudo pmset -a sms 0 (0 = disable, 1 = enable)
  • check actual settings: sudo pmset -g

Switching to Snow Leopard (SL)

Mac OS 10.6 aka Snow Leopard
Unfortunately I wasn't fast enough snatching one of the popular copies of SL at the local store. After waiting four cruelly days I got my copy and spent another day preparing my system for installation. In contrast to the opinion that only windows users have to format their hard disk when installing a new system I chose that way because I like the nerdy 'fresh' feeling of a vanilla system :)

Installation ran smoothly on my unibody MBP. In addition to the installation of several applications I manually copied settings and application data from a time machine backup:
  • Address Book (/Library/Application Support/AddressBook)
  • iCal (/Library/Calendars)
  • Mail (/Library/Mail)
  • Safari (/Library/Safari)
  • VirtualBox (/Library/VirtualBox)
- et voilĂ , it works! (basically at least)

Deleting Time Machine Backup
After manually copying the latest Time Machine backup (@see /Backups.backupdb) to a safe location I tried to purge the Time Machine backup dir. Moving that dir to trash and emptying trash results in an error. Also a simple sudo rm -rdf Backups.backupdb doesn't work. The reason is that apple uses Access Control Lists (ACLs) for Time Machine backups as you can read here and here. After spending a night trying to delete that skit I reconnected Time Machine to my Leopard backup an manually deleted each backup :-/ The remove all option didn't worked for me (nothing happened).

Activate 64-bit Kernel
SL brings 64-bit to the kernel. But you have to activate it manually! Out of the box only applications run in 64-bit mode, the kernel is 32-bit. The actual configuration can be checked by
  1. Choose Apple menu > About This Mac.
  2. Click More Info to open System Profiler. (Or open the Apple System Profiler application located in /Applications/Utilities.)
  3. Click the topic 'Software' on the left. On the right hand you can read the value of '64-bit kernel and extensions'.
To activate the 64-bit kernel follow these steps:

Test your CPU
Not every CPU is capable of running the kernel in 64-bit mode. Open a console and type
ioreg -l -p IODeviceTree | grep firmware-abi
If the output contains the string
EFI64 then your CPU is ready for the 64-bit kernel.

Testrun the 64-bit kernel
There are some secret keys with SL. When booting the machine, press 6 4 (at the same time) to boot the 64-bit kernel. (If you are using the 64-bit kernel by default you can press 3 2 (at the same time) to boot the 32-bit kernel.)

Make changes permanent
If you feel comfortable running the 64-bit kernel (here are some benchmarks) edit the file
/Library/Preferences/SystemConfiguration/com.apple.Boot.plist
to make changes permanent.
Change the key Kernel Flags to the value arch=x86_64. That's all. (but beware of the side effects)

Side Effects
Installing MySQL 5.1 x86_64 from .DMG doesn't work actually because the .DMG is packed with the HFS file system, which is a 32-bit kernel extension and doesn't run on the 64-bit kernel. Workaround: Boot with the magic keys 3 2 and install mysql. Reboot and you're fine.
Another glitch is that the Safari hack Safari Stand does not work with 64-bit (workaround). It is build on SIMBL (32-bit) which is an InputManager, but InputManagers have to be 64-bit with the 64-bit kernel. Update: Yesterday a new Snow Leopard ready beta of SIMBL was released - but I haven't tried it out yet.