Boot from CD in Open Firmware

Ok, you’re a security conscious Mac user so you’ve enabled the Open Firmware password. Now you want to boot from a CD and just holding down the “C” key while the computer starts up won’t work. What do you do?

You boot into Open Firmware (hold down command-option-O-F while the computer starts up), hit return and, when prompted, enter your Open Firmware password. Then at the prompt type

boot cd:,\\tbxi

47DN8DWPETEH

Converting a database to Unicode with Perl

It’s happened a few times—I’m transfering data from one database to another and the old one has a few accented characters in it, but came from the days before Unicode. So if you’re using Perl to pull data from the first database and you have a string with a a word like “façade”, when you try to insert it into the second database you get an error like DBD::Pg::db selectrow_array failed: ERROR: invalid byte sequence for encoding “UNICODE”: 0xe76164.

Fortunately, Unicode::MapUTF8 makes it easy with its to_utf8 function. For instance, if the source data is in iso-8859-1:

    use Unicode::MapUTF8 qw(to_utf);
    #
    # ... snip
    #
    # query $source for the value, and put a converted version
    # into $dest
    my $value = $source->selectrow_array('get my_val from my_table');
    $dest->do('insert into my_new_table (my_val) values (?)', {},
            to_utf8( { -string => $value, -charset => 'ISO-8859-1' });

Based on information found here: Problem with LATIN1 characters from Perl-DBI



Adding a Background to Transparent PNGs in Bulk

So I had a bunch of PNGs with transparent backgrounds that needed instead to be white. This is the kind of thing that ImageMagick is so good for, but this turned out to be a little bit harder.

I couldn’t find a way to add a background (or any kind of layer at all) to an existing image, but you can add one image to another.

  1. Make an all white graphic the same size as the PNGs (I don’t know what you’d do if you had images of different sizes). It seems like this is the step that you should be able to do on the fly.
  2. (Enter all on one line) for i in *.png; do composite -compose Over $i background.png ${i:r}-on-white.png; done