Author Archives: François Maillet

Restore sparsebundle extended attributes after rsync

If you rsync a sparse bundle to another Mac without the -E flag (or if you copy it to a non Mac system), you will loose the ability to double click on it in the Finder to mount it. This is because the extended attributes telling the Finder the folder is actually a bundle are lost in the transfer.

The following piece of code I found here fixed the problem for me. Simply compile and run the code giving the path to the bundle in parameter and it will restore the attributes.

 setxattrs -
 Properly sets sparse bundle extended attributes lost when rsyncing
 sparse bundle data to a platform that does not support extended
 attributes.  This is only need when restoring/retrieving the
 To use, sync/copy all bundle files, then run this tool on the
 sparse bundle:
 % gcc -o setxattrs setxattrs.c
 % ./setxattrs mybackup.sparsebundle
 % xattr -l mybackup.sparsebundle
int main (int argc, const char * argv[]) {
   if (argc != 2) {
        printf("Usage: %s [sparse bundle directory]\n", argv[0]);
        printf("Sets extended attributes for sparse bundle disk image\n");
        return 0;
   int sxr;
   int options = XATTR_NOFOLLOW;
   char theValue1[] = { 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00};
  char theValue2[] = { 0x59, 0x48, 0x60, 0x38,
            0x65, 0x7C, 0x09, 0x22, 0x33, 0xAD, 0xA5, 0x73,
            0x12, 0xAD, 0xF3, 0x7F, 0xEE, 0x90, 0x5B, 0x92};
   size_t   theSize1 = sizeof(theValue1);
   size_t   theSize2 = sizeof(theValue2);
   sxr = setxattr(argv[1], "", (void *)theValue1, theSize1, 0, options);
   sxr = setxattr(argv[1], "", (void *)theValue2, theSize2, 0, options);
   return 0;

Make OSX’s top behave like Linux’s top

OSX’s top program doesn’t quite behave like its Linux counterpart out of the box. For me, the two biggest problems are that processes aren’t sorted by CPU usage and the top program itself uses 10% of the CPU because it calculates all sorts of statistics about memory and shared library usage that I personally don’t care about.

There are a series of flags that you can pass to OSX’s top to have its behavior be closer to Linux’s top. I have created the following alias to that effect :

alias mytop='top -s1 -o cpu -R -F'

The display is updated every second, processes sorted by CPU usage and no unnecessary statistics are calculated. Instead of 10%, top uses only 2% of the CPU.

pfSense : a software alternative to your old router/firewall

My old D-Link router, like pretty much every other router I’ve ever owned, wasn’t very reliable in some way and so I was looking for open-source alternative firmwares like Tomato to flash it with. With the clear lack of effort put into the official firmwares, I thought it couldn’t hurt to try. Unfortunately, my router wasn’t supported by any third party firmware.

During my search, I however stumbled upon pfSense, a Free-BSD based router/firewall distro. It’s small (<100mb), runs on a 100MHz PC and includes all the features you would get on a very expensive commercial router (Firewall, NAT, VPN server, usage graphs, dynamic DNS support, per-ip bandwidth usage, QoS, etc).

Throughput on WAN interface

I already had a dedicated fileserver so I installed pfSense as a VM on it using VMWare (I could also have done it with VirtualBox, a free alternative to VMWare). All you need are two NICs. I now only use my old router as a wireless access point because pfSense naturally has a DHCP server. I could even completely let go of my D-Link router if I added a wireless NIC in my server.

If you have an old PC lying around or one that could be a host to a pfSense VM, all you might need is an extra NIC to get an enterprise-grade router that will cooperate a lot more than any cheap 50$ D-Link/Linksys/Netgear/etc router.

Using filemerge for mercurial diffs

A friend of mine found a script that brings up OSX’s FileMerge program instead of the text-based file comparisons you get with mercurial with doing an “hg diff”.

  1. download this script and make sure its location is in your PATH
  2. add the following to .hg/hgrc:
    hgext.extdiff =
    cmd.opendiff = fmdiff
  3. Now type hg opendiff <filename> (hg op is enough), instead of hg diff <filename>


SQLite3, php5 and MAMP

The version of php5 bundled with MAMP doesn’t come with sqlite3 support built-in out of the box. Here’s how to add it, considering the following setup :

  • SQLite3 installed through MacPorts
  • php5 used through MAMP

I used the php-sqlite3 extension. When you run phpize, make sure you are actually using the one from MAMP by calling it with its full path  /Applications/MAMP/bin/php5/bin/phpize.

I then complied the extension with the following flags (both paths are the defaults for macports and MAMP) :

./configure --with-sqlite3=/opt/local/ --with-php-config=/Applications/MAMP/bin/php5/bin/php-config

The make install didn’t copy the librarie to the right php folder :

&gt;make install
Installing shared extensions:     /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/

Make sure that folder is the right one. You can find your dynamic extensions folder in your php.ini file.

Achat de musique en ligne? Finalement oui!

Je refusais systématiquement de considérer l’achat de musique en ligne pour deux simples raisons :

  1. Protections DRM (détails sur Wikipedia)
  2. Mauvaise qualité d’encodage

Avant hier, j’ai découvert une artiste dont la musique semblait intéressante. Comme j’essaye toujours d’encourager les artistes inconnus qui tentent de percer et que c’était en plus une Québécoise, j’ai décidé d’acheter son CD. Mais pourquoi devoir encombrer mon étagère d’une autre pochette que je ne retoucherai plus jamais après avoir copié le CD sur mon laptop ??

Ce n’est pas le scoop de l’heure, le service étant disponible depuis 2007, iTunes offre une partie de son catalogue en format Plus, ce qui signifie des fichiers libres de DRM et encodés en AAC 256kbps, un niveau de qualité largement suffisant.

En deux clics et 9.99$ plus tard (au lieu de 13.99$+taxes en magasin), je téléchargeais le CD à 1MB par seconde. Moins d’une minute plus tard, j’étais donc en train de profiter de ma nouvelle musique en ayant sauvé de l’argent et en ayant diminué mon empreinte écologique par rapport à l’achat d’un vrai disque.

Un achat concluant. Ce sera probablement comme cela que j’achèterai toute ma musique à l’avenir, tant que les maisons de disque consentent à vendre leur musique libre de DRM. Vérifions quelques artistes québécois sur iTunes :

  • Dumas : aucun album en format Plus.
  • Les Cowboys Fringants : seul l’Expédition est en format Plus.
  • Pierre Lapointe : aucun album en format Plus.
  • Ariane Moffatt : aucun album en format Plus.

LaTeX en WordPress

En cherchant un peu sur le net pour trouver comment insérer du LaTeX dans une entré de blog, je suis tombé sur le site Using LaTeX in WordPress qui fournit toutes les informations nécessaires pour le faire.

Certains sites offrent même un service web qui permet d’insérer une image avec une adresse contenant l’équation LaTeX désirée dans son document et leur serveur la générera automatiquement sur demande.

Par exemple, cette adresse :

<img src="\tiny \int_{-\infty }^{\infty }e^{-x^{2}}\;dx=\sqrt{\pi }" />

donnera  : .

Ways of setting a CSS property to an element in GWT [UPDATED]

When I needed to add or modify a CSS property of an element in Google Web Toolkit (GWT), I’d always do it like this :

widget.getElement().setAttribute("style", "align:right;");

However, if there was already any style information for defined for that element, it would be overwritten. You could get the current attributes first and then readd them along with your new info but there is a much cleaner way :

widget.getElement().getStyle().setProperty("align", "right");

Important! Note that when setting a style property, your need to use camel case for the property name.

myWidget.getElement().getStyle().setProperty("background-color", "red");
myWidget.getElement().getStyle().setProperty("backgroundColor", "red");