Content

Coding

Jan
25

Posted on January 25th, 2009 at 5:55 pm Meta-note-taking with Tomboy

Just wrote a Tomboy add-in allowing the user to keep notes in Tomboy notes. The idea? If just like me you rely a lot on short tags such as TODO or FIXME, you find it convenient to have the editor highlight them. It is exactly what the add-in has been designed for.

Mandatory screenshot:

tomboy-todo screenshot
Editing notes with FIXMEs and TODOs.

For more info and downloads, have a look to the Tomboy-Todo project's page.

Oct
11

Posted on October 11th, 2008 at 9:56 am Writting consistent tests

I recently encountered a somewhat funny problem when porting Labyrinth to FreeBSD, python complaining about some locale.bindtextdomain that does not exist.

Having a look at the source code, I could read:

if hasattr(gettext, 'bind_textdomain_codeset'):
       gettext.bind_textdomain_codeset('labyrinth','UTF-8')
gettext.textdomain('labyrinth')
if not os.name == 'nt':
       locale.bindtextdomain('labyrinth', localedir)
       if hasattr(locale, 'bind_textdomain_codeset'):
               locale.bind_textdomain_codeset('labyrinth','UTF-8')
       locale.textdomain('labyrinth')

gtk.glade.bindtextdomain('labyrinth')
gtk.glade.textdomain('labyrinth')
Aug
7

Posted on August 7th, 2008 at 3:21 am Writing Free Software

A quick post to mention the beginning of a serie of mini-howtos on C.J. Adams-Collier's weblog entitled Writing Free Software.

Aug
2

Posted on August 2nd, 2008 at 11:15 am BSD#: Mono on FreeBSD

A few weeks ago, I joined the BSD# project which aim to maintain Mono (an open source implementation of the Microsoft .NET framework) on FreeBSD. It was the occasion for giving svk a try.

Apr
22

Posted on April 22nd, 2008 at 1:43 am You, bash users, are driving me crazy!

This is a visceral message with a lot of emotion (I mean I am not thinking before writing) so I will exceptionally use my big voice:

WILL YOU EVER BASH SCRIPTS WRITERS STOP THIS INSANE MESS WITH THIS SHELL?

Details bellow... with some words in capital letters as proposed by [RFC2119].

Nov
13

Posted on November 13th, 2007 at 2:44 am Efficient strlen(3) implementation in C (part 2)

Some times ago, I wrote [1] a few words about strlen(3) implementation and how inefficient it is on most systems. Although optimizing this function is utterly not the best way to make your program run faster (refer to Reducing complexity in the previous strlen(3) post), it is interesting to digg deeper in how modern CPUs can help us to compute a string length faster.

Aug
29

Posted on August 29th, 2007 at 2:04 am Learning GEOM: Tasting

I have been quite busy these last days and didn't got as much time as expected to have fun with geom(4) — the FreeBSD modular disk transformation framework. Since documentation is quite sparse compared to the rocket science inside GEOM, I spend a lot of time in man pages and reading existing GEOM classes source code... However, as recently said on the freebsd-geom mailing list:

Ahh you're believing the code comment :( (Rule #1: Never believe the code comments).

Well, this doesn't make things easy, but I can cope with that (or at least I hope so). I have already located interesting classes to study for the purpose of geom_lvm2:

geom/geom_bsd.c
This class looks relatively simple and is well commented. It seems to be a good starting point for learning how GEOM works (687 SLOC);
geom/concat/g_concat.c
This class seems a little more complex. Concatenation will have to be handled when a logical volume has physical extends on different physical volumes. Maybe will it be possible to rely directly on this class for this purpose (876 SLOC);
geom/vinum/*
Gvinum is a really complex^Wcool piece of code. Since it internally relies on various representation of disk chunks to provide services such as RAID, it can be a good source of inspiration for geom_lvm2's internals (7637 SLOC).
Aug
6

Posted on August 6th, 2007 at 11:14 pm Efficient strlen(3) implementation in C

Yesterday, somebody reached my website googling for efficient strlen implementation. This remind me an old discussion on code optimisation and how it was possible to dramatically reduce execution time of some basic functions.

Common implementation

Let's see how strlen(3) is implemented under FreeBSD 6.2 (the system I'm running). Chances are an equivalent implementation exists for nearly every operating system):

size_t
strlen(str)
  const char *str;
{
  const char *s; 

  for (s = str; *s; ++s); /* 1 */
  return(s - str); /* 2 */
}

The design is simple: a pointer (s) runs along the given string (str) looking for an end-of-string character ('\0' == *s) [1]. The string length is then computed by substracting the address of the pointer (s) from the address of the beginning of the string [2]. While simple and portable, this implementation is not efficient: each loop iteration only performs a simple operation and the breaking condition is based on its result. Consequently, no pipeline effect occurs in the CPU.

Aug
4

Posted on August 4th, 2007 at 7:17 pm Dumping LVM2 logical volumes under FreeBSD

At work, I generally use the Debian GNU/Linux operating system: as all our servers run Debian, it avoids loads of clashes when we put in production our work. But I am frequently complaining about how Debian works and globally can't bear it's frustrating package management system (which becomes even worth than ever when you run a advanced-user / developer / desktop machine). Anyway, there are many situations I could do my job with another operating system that fits much more my needs, let's say FreeBSD... The problem is that as a paranoid sysadmin, my current /home directory is a LVM2 logical volume on top of software RAID controlled by mdadm.

FreeBSD features a cool abstraction layer in the kernel called GEOM and documented as a modular disk I/O request transformation framework. Basically, it fits between your devices as represented by files in /dev and the physical disks, providing on the fly mirroring / stripping / whatever, without the need of any external tool (it's a bit more complex in fact, but keep it simple :)).

Unfortunately, all this is uterly not compatible with either MD or LVM2.

Jul
23

Posted on July 23rd, 2007 at 12:40 am Efficient tests with optional diagnostic in C

I love C because it is a low level high level programming language.
I hate C for exactly the same reason.

If you have already wrote a C program that rely on a lot of system calls and tests to check the execution environment before doing something, you have probably entered the hell of verifying loads of return values and displaying diagnostic messages for each failure case.