Recent blog entries for TazForEver

CVSspam
I've installed CVSspam on my company CVS repository, this tool is amazing. Much better than poor old cvssyncmail. CVSspam sends HTML mail with coloured diff on CVS activity. Moreover, mail's subject includes cvs project name :)
17 Sep 2005 (updated 17 Sep 2005 at 17:12 UTC) »
Maintenant les ASSEDIC
Et ça continue : aujourd'hui 17 septembre, je reçois un courrier des ASSEDIC daté du 13 septembre qui m'informe que je dois régulariser ma situation avant le 16 septembre.
D'une part, c'est la toute première fois que les ASSEDIC me contactent, d'autre part, je veux bien régulariser, mais faudrait il encore que je puisse terminer mon inscription. Bref, je suis rayé des demandeurs d'emploi alors que je n'ai même pas terminé les formalités.
L'administration française est tellement lente et minable, on se fait virer avant même d'avoir pu s'inscrire.
Ça fait mal de penser qu'un site web permet de remplir un dossier complet et de l'activer en 15 minutes alors qu'actuellement l'ANPE n'est au courant que de mon nom et que je dois leur ramener un formulaire dans lequel on me demande si je sais construire un mur.

MAJ: Pire, mon premier courrier de la part des ASSEDIC me communiquent des identifiants pour leur web. Je vais sur le site pour régulariser ma situation. Manque de bol, aux ASSEDIC, on ne régularise qu'une fois par mois, il me faudra donc attendre le 29 setptembre 23h59m59s (sic).
Lundi, je vais les exploser, rendez-vous ou pas.
L'ANPE responsable du chômage
Je viens juste de rentrer d'un entretien d'embauche prometteur chez EDS pour un travail d'administateur système UNIX, et je trouve dans ma boîte aux lettres un courier de l'ANPE.
Je suis à la recherche d'un premier emploi depuis en peu plus de 2 mois. Je me suis inscrit à l'ANPE le 8 août 2005, ce qui m'a valu de recevoir une invitation pour le 7 septembre au plus tard. Je me présente donc le 6 septembre à l'ouverture. Je repars 2 minutes plus tard avec un rendez-vous le 21 septembre. Quelle efficacité ! J'en arrive à cette lettre que j'ai ouverte à l'instant : on m'annonce que je vais être radier de la liste des demandeurs d'emplois parce que je me suis pas présenté à mon entretien du 13 septembre. Cherchez l'erreur. Lundi je vais les exploser ces fonctionnaires. Faut pas chercher plus loin : l'ANPE est la garrante du non-retour à l'emploi.
Merci le service publique.
Python : the socket.error trap

I spent my lunch hacking a dirty remote shell in python.

signal.signal(signal.SIGCHLD, reaper)
# ...
while True:
    client, who = server.accept()

Blam ! When the server process receives SIGCHLD, accept() is interrupted. So I added a try/except around the accept() :

  while True:
        try:
            client, who = server.accept()
        except OSError, e:
            if e.errno != errno.EINTR:
                sys.exit(e)
            else:
                continue

Re-blam. I didn't paid attention to the previous exception's type. It was socket.error. I though it was a subclass of OSError ... it's not. issubclass(socket.error, OSError) == False. pydoc socket :/

The correct except statement is :

   while True:
        try:
            client, who = server.accept()
        except socket.error, e:
            if e.args[0] != errno.EINTR:
                sys.exit(e)
            else:
                continue

The socket.* error classes are just Exception. It would be nice to turn them into OSError :)

12 Jun 2005 (updated 12 Jun 2005 at 21:18 UTC) »
Drivel 2.0

Wow, Drivel 2.0 is amazing :)

GObject *_get_type() + G_GNUC_CONST

When you define your own GObject class, you have to define 2 casts macro (instance cast and class cast). So you write :

#define MY_TYPE (My_Type_get_type())
#define MY_TYPE(inst) (G_TYPE_CHECK_INSTANCE_CAST((inst), MY_TYPE, My_Type))

e.g :
#define GTK_TYPE_LABEL (gtk_label_get_type ())
#define GTK_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LABEL, GtkLabel))

Now have a look at My_Type_get_type() declaration and definition. My_Type_get_type() always return the same GType. So if you write multiple cast, only one call to My_Type_get_type() is really necessary. But gcc is a good servant and does what you ask him : calls My_Type_get_type() whenever you call it. Think about this kind of loop :

for( ... ) {
    GtkWidget* widget= ...;
    gtk_box_pack_start(GTK_BOX(hbox), widget, ...);
}

To avoid such a waste, you have to tell gcc that all calls to My_Type_get_type() return the same GType.

GType My_Type_get_type (void) G_GNUC_CONST;

e.g:
GType gtk_label_get_type (void) G_GNUC_CONST;

Yes, it's that simple. Just add a G_GNUC_CONST attribute, and gcc will optimize all your to My_Type_get_type(), therefore all your MY_TYPE(inst).

Be smart, don't forget G_GNUC_CONST when you create your GObject class :)
Of course, glib and gtk+ already do this kind of optimization.

The gboolean trap

gboolean is just int !

#include <stdbool.h>
#include <stdio.h>

#include <glib.h>

int main() { float f; gboolean gb; bool b;

f = 0.5f; gb = f; b = f;

printf("gboolean %d\n" "bool %d\n", (int)gb, (int)b);

return 0; }

Ouput :

gboolean 0
bool     1

0.5f is converted to int 0. But 0.5f is obsviously not zero and therefore should be evaluated as TRUE. So be carefull with gboolean.

NB: <stdbool.h>, bool, true and false are C99.

sizeof troubles

I always took for granted that my name -- Benoît -- was 6 chars long. I was wrong.
It's 7, UTF-8 speaking.
It took me some time this afternoon to understand why sizeof "Benoît" == 8 where i would expect 7. So i hexdump'ed my C file and realized that î is encoded as 0xC3AE. I'm glad that ASCII chars are still encoded on a single byte in UTF-8 so hacks like this one:
char buf[magic]; /* enough to hold "plop" */
are still 0k. I'll try to be less lazy and always code :
char buf[sizeof "plop"];

WTF is î ?
U+00EE LATIN SMALL LETTER I WITH CIRCUMFLEX
UTF-8 : 0xC3 0xAE
In French, circumflexes '^' on vowels often replace old French 's' :
- hôpital for hospital
- hôtel for hostel (= hotel)
- Benoît for Benoist
- côte for coste (= coast)
- etc
Benoît is the french for Benedict.
Linux.Conf.Au 2004
May be some of you have missed the LCA2004 DVD event record. I have.
Here's the BitTorrent and MD5

Linux.Conf.Au 2004 Videos
24 Sep 2004 (updated 24 Sep 2004 at 07:51 UTC) »
PyPMU
I've hacked a small python wrapper for PowerMac Power Management Unit.

PyPMU 0.1.1

I'll soon make a control-based desklets on it.
I'd like to get the C backend used by GNOME battstat applet (supports only ACPI/APM, but i steel haven't been able to contact its maintainer. I think I'll have to provide a full patch to get a chance to get PMU support in ...

LibGTop
I'm working hard on libgtop. Fixed a nasty bug on Linux/Sparc64.
I've been granted access to 5 Solaris (sparcs) machines in a German University, and started to fix Solaris support. I still haven't decided if this will go 2.8.1 or 2.9.0 ...

9 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!