Convert .approject to .aplibrary

If you ever backed up Aperture projects outside your standard library, you probably noticed the default format for exported albums changed from .approject to .aplibrary in the update from Aperture 2 to Aperture 3.

The Finder correctly reports these new .aplibrary as “Aperture Library”, but it seems to have forgotten everything about the old .approject who now appear as standard folders (it appears to be a weird bug on my machine, but still).

So how do we convert our .approject to .aplibrary?

  • In Aperture 3, pick File > Import > Library/Project… and select your .approject folder. This will effectively re-import your project in the current Aperture Library.
  • Right-click on the project and select Export > Project as New Library…
  • Once it’s done, delete the project from the current Aperture Library (unless you want a backup or if you have other mischievous plans for your pictures, of course)


That’s it! Quite straightforward indeed, but a bit puzzling at first.

Can’t find the PostgreSQL client library (libpq)

You might encounter this error while trying to install the pg gem (v0.10.1), or when updating from v0.10.

My stacktrace on Mac OS X Snow Leopard 10.6.6 with Rubygems 1.4.2, Ruby 1.8.7 and Postgres 9.0.2 was the following:

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
	ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Oookay, so let’s try to find out what’s going wrong. A quick Google search shows that errors like this one happens on Linux too, and usually suggests that ARCHFLAGS definitions may be a problem. Indeed, /Library/Ruby/Gems/1.8/gems/pg-0.10.1/ext/mkmf.log contains this error message:

ld: warning: in /usr/local/Cellar/postgresql/9.0.2/lib/libpq.dylib, file was built for unsupported file format which is not the architecture being linked (i386)

The problem seems to come from the way Homebrew installs Postgres.

Homebrew install notes include the following informative message:

If you want to install the postgres gem, including ARCHFLAGS is recommended:
    env ARCHFLAGS="-arch x86_64" gem install pg

There! Now the only problem is if you install your gems as root, you can’t merely put a sudo before the “gem”, but you have to sudo su then execute the command:

Air:~ florent$ sudo su
sh-3.2# env ARCHFLAGS="-arch x86_64" gem install pg
Building native extensions.  This could take a while...
Successfully installed pg-0.10.1
1 gem installed
Installing ri documentation for pg-0.10.1...
Installing RDoc documentation for pg-0.10.1...


Edit 18 Dec. Chad provided a simpler solution in the comments that doesn’t require you to log in as root and works just as well:

sudo env ARCHFLAGS="-arch x86_64" gem install pg

Tunalysis – analyse your iTunes music library


Tunalysis is a small(ish) Ruby script that will read your iTunes library, crunch numbers, and gives you a few interesting facts about it, such as:

  • Total number of songs
  • Total number of playlists
  • Average song length
  • Average bitrate
  • Average play count
  • Average skip count
  • Total time spent listening to music

Some of these statistics are already available in iTunes, but Tunalysis ultimate goal is to expand iTunes (limited) stats and to give you hindsight on your musical habits and tastes.


Tunalysis is written in Ruby and uses Bleything’s plist to parse iTunes’ XML library.

At the time being, Tunalysis only works on OS X. I’m not planning to do a Windows port, but will gladly accept a patch if you do. :)

Tunalysis is licensed under the GPLv3.

Features to come

  • You don’t like that: suggest music to delete based on the skip count, the play count, and the last played date
  • Preferred artists (by number of songs)

I’m open to suggestions. If you’re interested in a particular piece of data, leave a comment or send me an email and I’ll add it.

Get Tunalysis on GitHub!

A bit of Terminal-fu

Yesterday, my little brother was typing something on a linux bash and suddenly went back to the beginning of the line with a simple Ctrl-a. It blew my mind.

I don’t know why, but it never occurred to me to look for shortcuts in Terminal (and bash in general), other than Ctrl-c for badly behaving processes. I just cursed myself and frantically typed on the left arrow key each time I typed cd instead of cp.

Turns out bash has plenty of them, and here are a few useful ones I’m really glad to know now:
Beginning of the line: Ctrl+a
End of the line: Ctrl+e
Delete the word under the cursor or before: Ctrl+w
Delete all chars before the cursor: Ctrl+u
Delete all chars after the cursor: Ctrl+k

Apparently these shortcuts work in a lot of text fields, everywhere.

You can also move the cursor word-by-word by typing Esc, then f or b. It’s not really practical though, so you’d be better of remapping the following keys in Terminal Settings > Settings > Keyboard:
control cursor left: \033b (\033 is actually Esc)
control cursor right: \033f

Now you can swiftly move word-by-word with Alt+left arrow and Alt+right arrow.

I guess the lesson here is there’s always to learn from your siblings — especially the geeky ones.