Subtlety with C const pointers

It may be tricky to figure out what the difference is between these statements:

const char *foo;
char * const bar;
const char * const baz;

It would help to visualize this syntax like:

[const char] * [const baz];

in which the first group describes the pointee, while the second one defines the pointer.

const char *foo

foo is a mutable pointer pointing to an immutable string.

const char *foo = "you cannot change this content";
foo++;        /* valid, foo now points to the second char */
foo[0] = 'X'; /* compile-time error */
free(foo);    /* compile-time error */

Also interesting:

char *goo = (char *) foo;
goo[0] = 'a'; /* runtime error, trying to modify read only data */

char * const bar

bar is an immutable pointer pointing to a mutable string.

char * const bar = "you can change this content";
bar[0] = 'L'; /* valid, the first word is now "Lou" */
bar++;        /* compile-time error, frozen pointer value */
free(bar);    /* valid */

const char * const baz

baz is an immutable pointer pointing to an immutable string.

const char * const baz = "I'm frozen!";
foo++;        /* compile-time error */
foo[0] = 'X'; /* compile-time error */
free(foo);    /* compile-time error */

Bash OR operator as an error handler

Clear for some, tricky for others, the || Bash operator can be considered as an exception handler:

a && b && c || d

will execute d if a, b, or c fails, not only c.

You can imagine a Makefile “clean” target, which cleans a sub repository if it exists, but does not fail if it has not been cloned yet:

clean:
    rm -f output/image
    test -d repos/foo.git && make -C repos/foo.git clean || true

Un byte n'est pas un octet !

Dire qu'un byte est un octet est un abus de language. Un byte est la plus petite unité adressable. Cette unité d'adressage est souvent 8 bits, d'où la confusion. Cependant, en télécommunication ou autre domaine, il est possible de trouver des bytes de 9, 4, voire 1 bit. Le terme byte a été inventé pour l'informatique, il n'a pas de traduction exacte en Français. D'ailleurs, les mots byte et octet sont tous deux corrects en Français et en anglais.

Cette précision permettra d'être moins choqué devant des définitions de macros comme celle-ci (c.f. include/linux/bitops.h) :

#define BITS_PER_BYTE        8


Voir l'article Byte de Wikipedia pour plus de précision.

Faire le tour du poteau à Montréal

P2090422

Si vous attendez votre PVT ou votre permis de travail pour un stage ou autre au Canada et que vous l'avez pas encore reçu, vous pouvez tout de même rentrer au Canada comme touriste.
Quand vous recevrez le mail comme quoi votre permis est prêt, il vous faudra sortir du Canada et rerentrer pour le faire valider . C'est ce qu'on appelle "faire le tour du poteau".

Le plus simple est de passer la frontière des états-unis et revenir au Canada.
Pour cela, 2 options :

  • louer une voiture ;
  • prendre le bus pour une ville des États-Unis proche de la frontière.

J'ai choisi le bus.
Je suis allé à la gare d'autocars (Greyhound) de la station de métro Berri-UQÀM à et pris un billet de bus aller-retour pour Plattsburg (É-U) pour 9h du matin. J'en ai eut pour 40$CAN. En une heure environ on se retrouve à la frontière, on descend du bus et on précise qu'on doit retourner au Canada pour faire valider son working Visa. Là ils vous feront un "refus administratif" d'entrer aux É-U, vous traverserez l'autoroute à pied ou en voiture (si vous en avez loué une) et vous passerez le péage Canadien comme tout le monde. Une fois là vous donnerez les papiers nécessaires pour faire valider votre permis et le tour est joué.

Pour le retour, le problème du bus est qu'il faut attendre le prochain venant des É-U. J'avais validé mon permis vers 10h45 et j'aurais dû attendre le prochain bus vers 16h. Coup de chance, un français (Rachid, que je remercie !) venait faire lui aussi le tour du poteau en voiture et s'est proposé de me ramener.

D'ailleurs, une autre option qu'il m'a indiquée, est de parcourir le site des PVTistes (http://pvtistes.com) sur lequel il avait fait l'annonce de son voyage. C'est donc possible par ce moyen de trouver de quoi faire la route gratuitement ou moyennant une faible participation ;)

Bon séjour au Canada !
Vivien.

Tiny Ruby AlloURL API

Here is a small function I wrote in order to get rid of the boring AlloURL service (especially used on websites such as allowshowtv.com):

Example:

AlloURL.retrieve("http://209.212.147.251/?w=0Cg1J28hx64c9fksA7rgUjwGP6dezxq_xKw9mLk2S1_x0NIdJhERenx7jqEgbx1otbizgS9IVLAUB9r6e1_xZdIbw_o_o")
 # => "http://www.videobb.com/video/K7EJfnlZtmhL"

It will wait the 6 seconds and give the URL back to you for you.

Fell free to use it and/or contribute to it.

I also thank Doud for a Javascript trick used by AlloURL.

Veronica Mars Streaming VF

On m'avait demandé les Veronica Mars saison 1, 2 et 3 en Français, mais c'est pas évident de les trouver, car seuls quelques liens sont bons.
Alors voici la liste des épisodes des 3 saisons valides en Streaming version Française :

Saison 1  
1 http://www.videobb.com/video/ut81SJa70C97
2 http://www.videobb.com/video/upGmSwfPQbLQ
3 http://www.videobb.com/video/ZHSNNXAE7ulU
4 http://www.videobb.com/video/ApDTgqYQLBhu
5 http://www.videobb.com/video/RPJGYwdeuu6K
6 http://www.videobb.com/video/8Fli4GM57bXd
7 http://www.videobb.com/video/LpaRmBILbOik
8 http://www.videobb.com/video/Y0AoMPM0VbhV
9 http://www.videobb.com/video/t4sx594fZruv
10 http://www.videobb.com/video/CHQSrhVFyWyX
11 http://www.videobb.com/video/0T9LlJnBr7yb
12 http://www.videobb.com/video/eWmCCeLT4k5Z
13 http://www.videobb.com/video/aALrNAfYx4Uj
14 http://www.videobb.com/video/BEJkmKQ78ULF
15 http://www.videobb.com/video/nW3wRbOZMs7J
16 http://www.videobb.com/video/OPhOIhiYWeAL
17 http://www.videobb.com/video/jYxV2ZVfSSGp
18 http://www.videobb.com/video/nKnflo6u0Mr5
19 http://www.videobb.com/video/boiWAODVR8gu
20 http://www.videobb.com/video/oVoiyxapcBNo
21 http://www.videobb.com/video/rXpd3SMTeOVv
22 http://www.videobb.com/video/Tv49eWLA2UoY
Saison 2  
1 http://www.videobb.com/video/vMLUWz9mbP3U
2 http://www.videobb.com/video/fjQiTRRhVo9k
3 http://www.videobb.com/video/4Dq8vmB9WK0A
4 http://www.videobb.com/video/oZiZzYf00oZc
5 http://www.videobb.com/video/W7Pu1Lp9IP3T
6 http://www.videobb.com/video/AwdDYfDr7SHH
7 http://www.videobb.com/video/DMtOmxWzgk3U
8 http://www.videobb.com/video/vEre5NGlRKU6
9 http://www.videobb.com/video/6cuD4LfiAHNf
10 http://www.videobb.com/video/rA3Lf8cABoIO
11 http://www.videobb.com/video/ujqJSsFu7TI5
12 http://www.videobb.com/video/epCjghw4dLjg
13 http://www.videobb.com/video/44d11kXChFyp
14 http://www.videobb.com/video/tbBFtR8wSg0T
15 http://www.videobb.com/video/1Cg4D77aGzg6
16 http://www.videobb.com/video/uXUlDlvBBqja
17 http://www.videobb.com/video/hYys3v4roVM8
18 http://www.videobb.com/video/9CdfUJvKOegf
19 http://www.videobb.com/video/ZB0AAluQyenT
20 http://www.videobb.com/video/0U8JTefwy2VQ
21 http://www.videobb.com/video/zXunYprfNBfV
22 http://www.videobb.com/video/ezEfPVD4NFIm
Saison 3  
1 http://www.videobb.com/video/K7EJfnlZtmhL
2 http://www.videobb.com/video/HgjwjRnpgVQt
3 http://www.videobb.com/video/ogBGR1XYLE5o
4 http://www.videobb.com/video/HvcA8kycNuI7
5 http://www.videobb.com/video/vZ1uEWeqTcnX
6 http://www.videobb.com/video/xXwLAzFG8ikd
7 http://www.videobb.com/video/2VF36Q0N84y8
8 http://www.videobb.com/video/DnMbUr7fbX7R
9 http://www.videobb.com/video/k605wDeYnFDg
10 http://www.videobb.com/video/Ss7n9iFdXBIu
11 http://www.videobb.com/video/2NFHo9c99TLj
12 http://www.videobb.com/video/BVV5rMVsDxMW
13 http://www.videobb.com/video/C17FAaGT8OSC
14 http://www.videobb.com/video/9FkAIn9HDZsP
15 http://www.videobb.com/video/o1qKuqLY30CW
16 http://www.videobb.com/video/G4nV7DKRPVh8
17 http://www.videobb.com/video/WuZxHk8Tdgs6
18 http://www.videobb.com/video/H0ASnTvSAgs6
19 http://www.videobb.com/video/NYGCyM4GzREh
20 http://www.videobb.com/video/03b8CWy9GRxd

Stratégie vs Tactique

La stratégie est un art

La stratégie concerne ce qu’on ne connaît pas ou peu, ce sont les choix dont on ne peut pas être certain qu’ils soient meilleurs que d’autres avant de les avoirs effectués et souvent en cas de réussite on est incapable de savoir si un autre choix aurait pu être meilleur.

Le stratège doit avoir une vision générale et à long-terme.

Le métier de référence : Le PDG

La tactique est une science

Une tactique concerne ce qu’on connaît plutôt bien, l’objectif est lisible, les expériences précédentes permettent d’obtenir une bonne vision de ce qu’il peut se passer. Par ailleurs, l’atteinte de l’objectif est finie dans le temps.

Le tacticien doit analyser le maximum de possibilités pour atteindre un objectif précis.

Le métier de référence : L’organisateur des attaques commandos / GIGN

dog better than cat

Since Ubuntu Hardy, the dog utility tool (a cat improved) has been removed because it is not yet maintained.
But you can easily install dog 1.7-12 on Ubuntu Maverick amd64 thanks to epii:

sudo add-apt-repository ppa:epii/ppa
 sudo aptitude update
sudo aptitude install dog

If you're using another plateform you can check out others 1.7-10 dog deb packages on Debian.org's FTP, or download and install dog 1.7-10:

wget http://ftp.de.debian.org/debian/pool/main/d/dog/dog_1.7-10.dsc
 wget http://ftp.de.debian.org/debian/pool/main/d/dog/dog_1.7.orig.tar.gz
wget http://ftp.de.debian.org/debian/pool/main/d/dog/dog_1.7-10.diff.gz
 dpkg-source -x dog_1.7-10.dsc
 cd dog-1.7/
dpkg-buildpackage
sudo make install

Non Debian-based plateforms users can download and compile dog 1.7:

wget http://ftp.de.debian.org/debian/pool/main/d/dog/dog_1.7.orig.tar.gz
 tar xzf dog_1.7.orig.tar.gz
cd dog-1.7.orig/
make