perhaps a slightly easier way to make SD cards bootable for CHDK under OS X

Now that CHDK has a working beta in the source tree for my Canon PowerShot SD790is, I actually have to prepare SD cards for it. The Bootable SD card – OS X instructions seem a bit contrived, so I took a look at the linux instructions, and modified them accordingly. These instructions should work for FAT16-formatted SD cards of 2GB capacity and under. It will not work for SDHC cards, which are generally formatted to FAT32.

This is all command-line only for here on in. It seems to work. Please note that you will be modifying raw file systems with root permissions here; there is no safety net. If you b0rk your main hard drive, don’t say I didn’t warn you.

Firstly, you’re going to have to find out where the SD card in mounted. Do this with:
I got:

Filesystem    512-blocks      Used Available Capacity  Mounted on
/dev/disk0s2   487463200 318749896 168201304    66%    /
devfs                222       222         0   100%    /dev
map -hosts             0         0         0   100%    /net
map auto_home          0         0         0   100%    /home
/dev/disk2s1     3969280      3328   3965952     1%    /Volumes/CANON_DC

There are three important concepts to note when looking at the mounted card:

  1. The mount point (or volume) – in this case /Volumes/CANON_DC. This is the location that you see in Finder when moving files around.
  2. The filesystem – here /dev/disk2s1. This is the partition on the disk, arranged according to a certain formatting scheme like MS-DOS FAT16.
  3. The disk device – which for me is /dev/disk2. This is the disk device itself, and it may contain several filesystems.

Your locations for these three could well be different, so please substitute your values.

You’ll need to unmount the device, as writing to a raw filesystem while the OS thinks it has control often results in hilariously unexpected results. I used the OS X-specific command

diskutil unmount /Volumes/CANON_DC

You should get a message like Volume CANON_DC on disk2s1 unmounted. Now you need to write the boot instruction:

echo -n BOOTDISK | sudo dd bs=1 count=8 seek=64 of=/dev/disk2s1

This will prompt you for your password.

If you need to, you can remount the filesystems on the card with

diskutil mountDisk /dev/disk2

(Note that we used the disk name here, not the filesystem. If there were several partitions on the disk, this command would mount all of them that it could. It’s also kinda handy for remounting USB devices that you’ve accidentally ejected from Finder.)

Update: Knowing a difficulty getting the firmware update method of getting CHDK to work on a Mac? Running a Leopard or newer machine? Then you need to learn all about Apple’s quarantine attribute and how to remove it with xattr: FAQ/Mac – Still having trouble?.

like a virtual workspace manager for the shell

How did I manage to go for so long without knowing about screen? screen allows you to create several connection sessions to a terminal, switch between them, detach from them, then reconnect from anywhere. I’d previously had to to set up long-running remote jobs as background jobs, relying on nohup and various methods to prevent terminal output. But no more!

This page taught me all I know about screen: screen: Keep Your Processes Running Despite A Dropped Connection

Dexit® INSTEAD? No, Dexit is dead

dexit tag

I see that the number of Dexit terminals has reduced to almost nothing, and now they’re offering refunds of outstanding balance. Looks like it’s dead.

I’ve had a love/hate relationship with Dexit. It was almost a great idea, but offered no significant advantage over cash from the bank machine. I wonder how long it will be before you can buy the old terminals in Active Surplus?

free food from Dexit

Though I still hate Dexit, I have found a place to use the remaining balance — the Pizza Pizza at the corner of Vic Park and Sheppard. Yes, their pizza is still like damp cardboard, but they have passable salads.

They still need to work on the reliability of their terminals, and training staff. The other day they said my debit was authorised, when clearly nothing had come off the tag. They wouldn’t take the cash I offered (their screen showed a green thing), so yay Dexit, free food!

batch renaming iTunes directories

In partial response to the Ask Metafilter question “How can I rename my music folders on my Mac based on ID3 tags?“:

# - fix dir names created by iTunes
# only works for mp3s, and not actually tested on a Mac
# created by scruss on Sun Sep 4 22:05:00 EDT 2005

find "$@" -type d -mindepth 1 | while read directory
  artistdir=$(dirname "$directory")
  firstfile=$( find "$directory" -type f -iname '*.mp3' | head -n1 )
  year=$( id3info "$firstfile" | egrep ' TYE ' | sed 's/=== TYE (Year): //; s/[^0-9]*//;' )
  album=$( id3info "$firstfile" | egrep ' TAL ' | sed 's,=== TAL (Album/Movie/Show title): ,,;' )
  echo mv \'$directory\' \'$artistdir/\[$year\] $album\'

So if you were in the terminal, in your music library (one up from the individual artist directories), and you did: Dan\ Jones Tripping\ Daisy

you’d get:

mv 'Dan Jones/Get Sounds Now' 'Dan Jones/[2005] Get Sounds Now'
mv 'Dan Jones/One Man Submarine' 'Dan Jones/[2003] One Man Submarine'
mv 'Tripping Daisy/Jesus Hits Like the Atom Bomb' 'Tripping Daisy/[1998] Jesus Hits Like the Atom Bomb'

If that looks okay, run the output through the shell: Dan\ Jones Tripping\ Daisy | sh

and all should be well.

You’ll need id3lib, which is probably most easily installed from Fink. Also, this only works for mp3 files; I can’t grok the tag info for AAC files. And finally, this might go seriously screwy on weird characters in filenames. You know my feelings on that …


Okay, so if I were to buy an iBook, I must be able to:

  • have virtual workspaces, like X11
  • use a compose key for accented characters
  • be able to do my usual Perl/Bash things in the terminal
  • get basic, useful applications for free.

Since I can do these things on Linux now, there’s no point in me switchin’ in the kitchen.