Stir Fried Stupid

05/01/2010

A well structured library will contain functions that are grouped together in a same logical unit to help you perform a set of tasks more easily. This could be reading graphics files, or managing time and dates. Good libraries include just enough functions so that you have access to the complete functionality, but nothing superfluous.

Too often, libraries catch featuritis and grow large with less used functions that were added at some point to scratch a minor hitch. Worst, you discover functions hidden in a library that you’re not sure what to do with them, but sometimes, you find functions that are positively stupid. What is even more surprising is where you can find them. I found a couple in the GNU C Library.

Read the rest of this entry »


Sleepless Koala

18/12/2009

A few days ago, I changed my machine and upgraded to Ubuntu 9.10 (Karmic Koala) and everything went fine, except for the screen-saver that would activate properly but not switch the screen into sleep mode after a while. I found a couple of fixes because despite being a documented bug, there’s not definitive fixes yet.

Read the rest of this entry »


Affinities and ulimit

01/12/2009

The Bash ulimit built-in can be used to probe and set the current user limits. Such limits include the amount of memory a process may use or the maximum number of opened files a user can have. While ulimit is generally understood to affect a whole session, it can be used to change the limits of a group of processes using, for example, a sub-shell.

However, the ulimit command is quirky (it expects a particular order for parameters and not all may be set on the same command line) and does not seems to be ageing all that well. For one thing, one cannot set the affinity of processes—indirectly controlling the number of and which cores one can use in a multi-core machine.

Read the rest of this entry »


Log Watching

03/11/2009

Very often, you have to keep an eye on a log, or maybe more than one log, and a couple of other things while a long-term simulation is running. The GNU/Linux distributions offer the program watch that allows the periodical execution of a command in the current interactive shell. While watch is convenient, you still have the problem of displaying the needed information in a terminal geometry aware way. Turns out, there are tools to query the terminal geometry and we can use them to write simple, effective, well displayed scripts.

telescope-small

So let us see how we can make BASH somewhat aware of the terminal it runs in.

Read the rest of this entry »


Code Style: Vertical vs Horizontal?

20/10/2009

The only difference between coding styles and religion discussions is that coding styles have claimed fewer victims—at least until now. A few post back I discussed color schemes, and this week I’ll be discussing code geometry for enhanced clarity.

fish-on-stilts

Read the rest of this entry »


The Zune Freezes: More on Unit Testing

22/09/2009

Do you remember the epic fail that bricked the Zune a whole day on the last day of last year, a bisextile year? I described here and here how this error could have been entirely avoided using basic unit testing.

brick-small

You probably remember (if you read the original post) that I first claimed that it’d take a few seconds to check all possible dates but in fact it ended up taking something like 90 minutes. This week, I come back on unit testing of a very large domain under a time constraint.

Read the rest of this entry »


A quick Bash Fix

16/09/2009

Remember, not too long ago I told you how to shorten path names in a Bash prompt? Well two things. Apparently, there’s a similar mechanism in Bash 4.0 with PROMPT_DIRTRIM(which I haven’t tried yet). Second, noticed that I’m frequently using many terminals opened on many machines, and I’m not always sure which is which. Using uname -n in the terminal spews the machine name, but it’d be much better if the name appeared in the terminal title bar. To do so, use the same prompt I used previously, and add $HOSTNAME (a Bash variable that holds the machine’s name) in there:

PS1='\[\033]0;$HOSTNAME: $(shorten_path "${PWD}" 50)\007\]$(shorten_path "${PWD}" 50) >'

(again, use the view plain mode if WordPress messes up the syntax again)


What’s a Good Color Scheme?

15/09/2009

Although EMACS is growing old, filled with passé idiosyncrasies, and rather complicated to tweak, I grew accustomed to it and is now my main editor. I use it for shell scripting, C++, HTML, even. But to use EMACS properly, or a least make it enjoyable a little bit, one must do a fair bit of configuration. Key bindings to match modern keyboards, adding the macros you’re using the most, and, finally, adjusting the color scheme so that your eyes do not bleed after a few hours of work.

yeux-saignants

But what is a good color scheme?

Read the rest of this entry »


Suggested Reading: La Nouvelle Grammaire en Tableaux

11/09/2009

Marie-Éva de Villiers — La Nouvelle Grammaire en Tableaux et Recueil de Conjugaison — Québec Amérique, 2009, 324 pp. ISBN 978-2-7644-0690-8

(<del>Buy at Amazon.com</del>)

(Buy at Amazon.com)

Normally, I suggest English books, but since I know a certain part of my lectorate is French-speaking, I will make, now and then, an exception.

Un ouvrage de référence indispensable s’il en est un. Ce guide de la grammaire Française en plus d’être le plus à jour, a la particularité d’être très clair et complet; comme son titre le laisse entendre, l’information est présentée par tableaux, du genre if-then-else, chacun d’une grande simplicité mais aussi très complet. Pour comprendre l’usage du subjonctif plus-que-parfait (dont l’usage rare se fait trop souvent le prétexte aux phrases phonétiquement ambiguës — et aux farces salées) il suffit de consulter le tableau « concordance des temps dans la phrase. » Des néologismes ? Aucun problème ! Consultez le guide d’usage et de formation des néologismes.

Une lecture obligatoire pour tout bloggueur, thésard ou communicateur!

(hit Google Translate for fun)


Can you survive your Data Hiroshima?

08/09/2009

Even expensive and top-of-the-line hardware is fallible. Last night (at the time of writing) my main workstation’s PSU burned. I mean, not soft-failed and powered down, I mean burned. With the acrid smell filling the room, I knew something went very wrong the instant I entered my study. I found my computer powered down, non-responsive. I wasn’t too worried because I knew that even if the computer went dead for good, I would not loose much data since, you know, I have backups.

nuclear-test-(unknown)

Are you capable of surviving your own little Data Hiroshima?

Read the rest of this entry »