« Tu sais ce qui est le plus dur, là dedans ? avait-il repris doucement. C'est de se rendre compte d'un coup qu'on a passé toute sa vie justement à ne pas penser à cet instant précis. À faire comme si l'on avait jamais soi-même à passer par ce moment incontournable, le moment où l'on découvre qu'il n'y a plus d'avenir devant soi, plus de choix possible, même plus le rêve de changer de vie. Quand on doit abandonner jusqu'à l'illusion qu'on peut encore tout changer… La fin de la route, quoi. »

L'homme qui voulait vivre sa vie (ISBN 978-2-266-19460-0), p. 72, Douglas Kennedy

Publié dans quote | Commentaires fermés sur

TOTD: purge

Tip Of The Day: purge

On Mac OSX, the `purge' command can be used to free up the disk caches.

It's seems to be the equivalent of the `sync && echo 3 > /proc/sys/vm/drop_caches' on Linux.

Publié dans regular | Commentaires fermés sur TOTD: purge

Echo

Publié dans photo | Commentaires fermés sur

flock in bash script

util-linux(-ng) flock

On Linux systems, there is a `flock' command (from `util-linux' or `util-linux-ng') that can be used to run a command inside a file lock/unlock block.

function run_lock_flock {
  LOCK=$1
  shift
  touch "$LOCK"
  flock "$LOCK" "$@"
}

portable way with perl

On other Unix systems, a portable way could be to use perl to mimic the util-linux(-ng) command shown above:

function run_lock_perl {
  LOCK=$1
  shift
  perl -e '
    use Fcntl":flock";
    $l=shift;
    open(L,">>",$l)||die"Error open: $!\n";flock(L,LOCK_EX)||die"Error lock: $!\n";
    system(@ARGV);$?==-1&&die"Error executing command!";
    flock(L,LOCK_UN);close(L);
    exit($?>>8)
  ' "$LOCK" "$@"
}

autodetect flock

Finally, a main `run_lock' function to autodetect which type of flock to use, and run the given command with the given lock file.

function run_lock {
  type -p flock
  if [ $? -eq 0 ]; then
    run_lock_flock "$@"
  else
    run_lock_perl "$@"
  fi
}

run_lock mylock.lck /usr/bin/foo -c bar -l baz
Publié dans code | Commentaires fermés sur flock in bash script

Avec les mots on ne se méfie jamais suffisamment, ils ont l'air de rien les mots, pas l'air de dangers bien sûr, plutôt de petits vents, de petits sons de bouche, ni chauds, ni froids, et facilement repris dès qu'ils arrivent par l'oreille par l'énorme ennui gris mou du cerveau. On ne se méfie pas d'eux des mots et le malheur arrive

Voyage au bout de la nuit (ISBN 2070360284), p. 487, Louis-Ferdinand Céline

Publié dans quote | Commentaires fermés sur

GameBoy Emulation in JavaScript

Link: GameBoy Emulation in JavaScript

Publié dans link | Commentaires fermés sur GameBoy Emulation in JavaScript

Postgresql 9.0 Hot-Standby and Streaming-Replication Overview [fr]

Link: Postgresql 9.0 Hot-Standby and Streaming-Replication Overview [fr]

Un petit mémo suite à des tests de mise en œuvre du hot-standby et streaming-replication de PostgreSQL 9.0.

Publié dans code, link, network | Commentaires fermés sur Postgresql 9.0 Hot-Standby and Streaming-Replication Overview [fr]

Le peer-to-peer évolue

Link: Le peer-to-peer évolue

Publié dans link | Commentaires fermés sur Le peer-to-peer évolue

France Inter c’était mieux avant ?

Depuis qu'il n'y a plus Guillon j'avais arrêté d'écouter France Inter le matin.

Mais voilà que j'apprend qu'il y a quelque chose d'interéssant le matin pour aller au boulot <http://www.dailymotion.com/video/xfet2e_gerald-dahan_fun>, et en même temps j'apprend que c'est fini !?!

Merde, j'arrive toujours en retard !

En même temps, pour un humoriste, se faire virer de France Inter ça devient un peu une consécration, une récompense, un « label qualité ».

Imaginer la scène, façon Victoires de la musique, César, ou autre :

Présentateur : « Sont nominés pour être virer de France Inter les humoristes [blah blah blah], Gérald Dahan pour son billet sur Michèle Alliot-Marie, et [blah blah blah]. »

P : « Et le lauréat est… »

P : « Gérald Dahan ! pour son billet sur MAM donné sur France Inter le 27 Octobre 2010. »

P : « Mais laissons la place au lauréat. »

Gérald Dahan : « Merci, merci beaucoup… Wahou… Je ne sais pas quoi dire… »

GD : « Je voudrais remercier France Inter, pour la confiance qu'ils ont mis en moi ; et tout particulièrement Philippe Val sans qui je ne serais pas là aujourd'hui. »

GD : « Ce titre à un goût particulier, puisqu'il vient récompenser une longue carrière au moment le plus improbable. »

GD : « Être récompensé ainsi quelques mois à peine après Stéphane Guillon et Didier Porte… c'est… inimaginable, et je n'en reviens toujours pas.. »

GD : « Merci à tous, merci P. Val et longue vie à France Inter. »

Musique

Standup ovation de la salle

Publié dans regular | Commentaires fermés sur France Inter c’était mieux avant ?

Identifying constant disk writes on Mac OS X

A couple of month ago, I noticed that I was having a constant stream of disk write of about 1MB/s on my MacBook (as seen in Activity Monitor.app). That would eventually drain my battery faster when running unplugged.

First thing to do was to identify the culprit, the process, that generate those writes.

As I'm not familiar with the BSD sub-system internals, I Googled and found a list of DTrace one-liners that proved to be handy:

– http://www.brendangregg.com/DTrace/dtrace_oneliners.txt

The first one:

# dtrace -n 'io:::start { printf("%d %s %d",pid,execname,args[0]->b_bcount); }'

It shows you the names of the process doing I/O operations.

From the result I immediatly spotted a process from Postgresql that was generating a fair amount of I/O while no queries/vacuum where running.

Now, I know the source might be in Postgresql, but what was happenning? what files were concerned by theses I/O?

I needed to know what files where opened, so this DTrace gave me the next answer :

# dtrace -n 'syscall::open*:entry { printf("%s %s", execname, copyinstr(arg0) ); }'

This one prints the name of the files being opened by the running processes :

  0  18514              open_nocancel:entry postgres global/pg_database
  0  18514              open_nocancel:entry postgres pg_stat_tmp/pgstat.stat
  0  18514              open_nocancel:entry postgres pg_stat_tmp/pgstat.stat
  1  17728                          open:entry mdworker /.vol/234881026/52307726//Contents/PkgInfo
  1  17728                          open:entry mdworker /opt/local/var/db/postgresql84/defaultdb/pg_stat_tmp/pgstat.stat
  1  17728                          open:entry mds .
  0  18514              open_nocancel:entry postgres pg_stat_tmp/pgstat.stat
  0  18514              open_nocancel:entry postgres pg_stat_tmp/pgstat.stat
  0  18514              open_nocancel:entry postgres pg_stat_tmp/pgstat.stat

From this output, I found that it would be related to the pg_stat mecanism.

I edited the `postgresql.conf' file and disabled the stat collection by setting:

track_activities = off
track_counts = off

Then, after restarting postgresql, the continuous flow of writes was gone.

Thank you DTrace!

Publié dans regular | Commentaires fermés sur Identifying constant disk writes on Mac OS X