Saving some space


The png file format has become the de-facto lossless file format for pixmaps. One of interesting aspects of this format, is that a given image can be compressed in multiple ways, and that most tools only use one. This means that given the right tools, png files can be made smaller without any loss of quality. On Mac OS X, it is very easy to find all the png files in one’s home directory and reduce their size, assuming your have the Developer Tools and Mac ports installed:

sudo port install optipng
mdfind -0 -onlyin ~ "kMDItemContentType=public.png" | xargs -n 5 -0 optipng -preserve

The first line install the optipng tool.
The second line involves three command-line tools:

  • mdfind searches for all files of type public.png in the home directory (~) separating each item with a null character
  • xargs takes the file paths in bunches of 5 (completely arbitrary value) and passes them as parameters to the next command:
  • optipng compresses the files, preserving the file attributes

To be honest I did not bother checking how much space this save me, I just wanted to play around with mdfind… Adding the parameter -o 3 to optipng could save more space, but increase the processing time. Technically you could run this command on the System directory to compress all the png files there, but I don’t think this would be wise. I realise the same technique could be used for jpeg files using jpegtran, if I have some time, I’ll explain how to do it.

Flattr this!

Screen Capture iTunes and Doodle Logo in

Use old style Next-Step icons for commercial e-mail

Screen Capture iTunes and Doodle Logo in

One feature of on OS X that I like is that it shows the picture associated with the sender of an e-mail. The normal way of associating a picture with an e-mail is using the Address Book. While this makes sense for the humans I’m interacting with, I don’t want to add an address book entry for

The good news is, there is an old Next-Step era mechanism that still works, even under Mac OS X 10.7: just add a tiff file with a name e-mail.tiff into the folder ~/Library/Images/People, restart and you are done. So for instance the Flattr logo goes into file ~/Library/Images/People/ If you want to reuse the icon of a desktop application, just open the application’s package (context menu) and go down into the Resources folder and open the Application-name.ics file with copy paste the high-resolution icon into a new file and save it as tiff.

While there is no way to have a file match multiple e-mail addresses, you can avoid duplicating files using symbolic or hard links. On the other hand, those images, contrary to the ones added in address book can contain an α-channel (transparency).

Flattr this!

Python shell with Snake Emoji in the Title

Use Emoticons to distinguish shells

Python shell with Snake Emoji in the Title

One application that has been updated in Mac OS X Lion is the venerable which finally supports 256 colours. While playing around with emoji characters, I realised they were quite useful to mark different terminals. I typically have multiple windows open with local and remote shells, along with a python interpreter. Previously I used the background colour of the terminal to distinguish the various contexts, but now I also add a relevant emoji in the title. Among the useful characters for this use

  • Shell 🐚
  • Snake (Python) 🐍
  • Camel 🐫
  • Computer 💻
  • Bug 🐛
  • Ant 🐜

To add the character to a terminal’s title, just go into Terminal/Preferences, select the Settings Icon and the Window tab. In the Title item, you can enter the emoticon in the title text.

Flattr this!

How to build shairport on Mac OS X


Building and running shairport on Mac OS X might seem like an academic exercise, still it is useful if you want to stream music from a iOS device to your Mac. Assuming you have macport and XCode installed on your machine, the process is quite straightforward: just install the needed packages, download the source code, compile it and run it.

Compiler et exécuter shairport sur Mac OS X peut sembler être un exercice académique, cela reste néanmoins utile si on veut streamer de la musique depuis un appareil qui tourne sous iOS vers votre Mac. Pour peu que vous ayez installé macport et XCode sur votre machine, c’est très simple  : il suffit de télécharger les librairies nécessaires, le code source, compiler le programme et l’exécuter.

Shairport auf Mac OS X zu kompilieren kann wie eine Akademische Übung scheinen, trotzdem kann das nützlich sein die Musik von einem iOS device auf einem OS X Computer hören. Sobald Sie XCode und macport auf ihrem Komputer installiert haben, ist es sehr einfach: mann muss nur die benötigte libraries installieren, den source code down zu loaden und das alles kompilieren und exekutieren.

sudo port install git-core
sudo port install libao
sudo port install p5-io-socket-inet6
sudo port install p5-libwww-perl
sudo port install p5-crypt-openssl-rsa
git clone
cd shairport

Additional instructions can be found in the file, in particular to start the binary as a dæmon. On thing I had to change in the configuration was to add the following lines to the org.mafipulation.shairport.plist file, so that the script it picked the port version of perl (the one with the additional libraries). I also made the file point directly to the binary in the directory where I build it.

This worked like a charm under Mac OS X 10.6.7, with the sound coming from my iPhone, for instance from Buddha Machine. Now if only this could run this on my PS3, that would be awesome…
Des instructions additionelles (en anglais) sont disponibles dans le fichier Une chose que j’ai du changer, c’est ajouter les lignes suivantes au fichier org.mafipulation.shairport.plist afin que le script utilise la version port de perl, celle pour laquelle toutes les librairies additionnelles ont été installées. J’ai aussi changé le chemin d’accès du binaire pour utiliser directement la version que j’ai compilé.

Le tout fonctionne parfaitement sous Mac OS X 10.6.7 avec la musique venant de mon iPhone, par exemple depuis Buddha Machine. Maintenant si seulement ce code pouvait tourner sur ma PS3, cela serait génial…
Zusätzliche Einleitungen (auf English) kann man im file finden. Eine Sache, dass ich ändern müsste, war die folgenden Zeilen im org.mafipulation.shairport.plist File änderen, so das port die Lokale version von perl brauchte. Die selbe version wofür wir alle diese Libraries installiert haben. Ich habe auch den Path verändert um direkt die Binärdatei die wir Kompiliert haben, zu brauchen. Alles funktioniert perfekt auf Mac OS X 10.6.7: die Musik von Buddha Machine
meines iPhone kann ich auf dem Laptop hören. Jetzt wäre es geil, wenn ich dieses Program auf meiner PS3 laufen lassen könnte…

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Flattr this!