# 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.

# trafshow : Display current network traffic

trafshow is a simple little program that displays the current traffic on a network interface.

It listens on a given interface in promiscuous mode and displays information on each connection, its remote address and the amount of traffic going back and forth.

It can easily be installed on a Mac via Macport.

# 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 :

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).

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: 3. Now type hg opendiff <filename> (hg op is enough), instead of hg diff <filename> Source # 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) : The make install didn’t copy the librarie to the right php folder : Make sure that folder is the right one. You can find your dynamic extensions folder in your php.ini file. # Shrinking sparse bundle images A sparse bundle image in Mac OS X will grow as you add files to it but never shrink if you remove files inside of it. To reclaim the disk space, you must run the following command : If your account is protected with FileVault, this is done automatically for you when you logout of your account. # 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 :

donnera  : $\tiny \int_{-\infty }^{\infty }e^{-x^{2}}\;dx=\sqrt{\pi }$.

# 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 :

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 :

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