Archive for April, 2007

My Alphabet question for interview

Part of my job is to sometimes give interviews for people we want to hire. One of my favorite question is to ask the person to write a problem that will print the alphabet on the console. So let’s say I have a c file my_program.c, I want to be able to compile it, execute, and get the alphabet on the console. Something like: $./my_program
a
b
c
...
z

I really like this question as I think it’s easy enough to know if the person is able to write a simple program in C. I will post here the several code I got… and sometimes it’s really surprising.

What do you think about the question? Do you think it’s a dumb question? Is it too hard/easy?

Le lien du jour qui dechire!

Comment repasser sa chemise…
Merci ra7or!

29% of the U.S.A…

15 states, so 29% of the U.S.A. That’s much better than for the world…

create your own visited states map

Only 4% of this world…

That’s on much I saw about planet earth….

create your own visited countries map

I cannot wait to have even more vacation to visit the rest :)

Seulement 4% du monde d’explore…

Il me reste 96% du monde a decouvrir….

create your own visited countries map

Bulk replace with perl

There is a very cool set of options in perl that allows you to replace a string in a file.

perl -pi -e ‘s/str1/str2/g’ file

and when you need it for a full directory, it becomes even more powerful

for i in *; do perl -pi -e ‘s/str1/str2/g’ $i; done

And the ultimate option, perl -pi.bak [...] which backup the old version of the file with the extension “.bak”.

I knew this option since a while, but I never remember it… so when I need it, I always have to look right and left to find it again… Now it’s blogged!

Pourquoi un blog…

Les blogs occupent desormais une part non negligeable de l’internet. Pour etre honnete, je n’y ai jamais cru… Au debut je trouvais que le blog etait un outil pour les personnes incapables de faire un site web… et mon cote geek me laissait penser que ces personnes n’avaient pas leur place sur le net…

Apres ces quelques annees, je me rend compte que j’etais dans le noir absolu, et je me rejouis de voir cette explosion de blogs.

Alors pourquoi aurais-je un blog? effet de mode? ou il y a-t-il un interet?

Certes l’effet de mode a peut-etre joue dans ma decision, mais c’est surtout une conversation avec un copain qui m’a pousse a me lancer (il se reconnaitra :) ). Il m’a fait realiser que j’avais des connaissances que je pouvais partager avec un plus grand nombre que les seules personnes de mon quotidien… et le meilleur moyen de le faire c’est de blogger.

Je pense que la section anglaise sera plus orientee “geeky” alors que la section francaise sera plus orientee sur mes reflexions sur certains sujets.

Bonne lecture…

Samuel

Coup de gueule sur les impots…

Ca y est… c’est arrive… c’est le moment de faire son “tax return” pour les personnes vivant aux USA. J’ai repousse l’echeance depuis le debut de fevrier, mais la j’ai du m’y mettre… et paf… je dois payer. Franchement quel sentiment d’injustice que d’avoir a payer des impots… Ok c’est normal d’en payer, mais il n’empeche qu’au moment de faire le cheque… on se sent un peu radin.

Read Line ‘n’ of a file with sed

sed has some options that are not really known, but that are so useful

Print line 10 of a file:

sed -n 10p file

Print last line of a file:

sed -n \$p /etc/passwd

Print every other lines:

sed -n 1~2p /etc/passwd

And much more… So sometimes it’s interesting to RTFM :)