Find duplicated files

check md5 between similarly named file (toto.ext and toto 2.ext)

for i in *2.???; do
  baseclean=${base% 2};
  md5sum "$base.$ext";
  md5sum "$baseclean.$ext";
while read line;
  name=`echo $line|cut -f2 -d\ `;
  ref=`echo $line| cut -f1 -d\ `;
  actual=`md5sum ./$name|cut -f1 -d\ `;
  if [ "$ref" != "$actual" ] then
    echo "file $name differ";
done < ~/filelist.md5

Calendar, import and delete

After I have imported (multitimes) an ics calandar into my google calendar, and it was a tedious work to removes all event that corresponds to this import.

I found a simple and efficient solution to delete them all with google script. Fortunatly the events share a common description, which allow to get them by search.
Another possibility would have to search them by creation date.

function deleteSomeEvents(){
    var start = new Date("September 1, 2014");
    var end = new Date("December 31, 2015");
    var events = CalendarApp.getDefaultCalendar().getEvents(start, end, {search: 'something that I want to delete'});
    Logger.log('Number of events: ' + events.length);
    for(var i =0; i&lt; events.length;i++){
        Logger.log( events[i].getStartTime()+" "+events[i].getTitle());

Cleanup hardlink from a backup with hardlink (rsync like)

Here is a small script to remove hard link of a rsync based backup, by days.
I have use it to cleanup my backup and find when different version of file have been created.

find . -type d > dir_list0
# my dir list is of the form ./2010/07/22/home
cat dir_list0 | cut -f1-5 -d/ | grep home | sort | uniq  > dir_list
# delete all hardlink, keep just the one is the oldest dir
cat dir_list | while read i; 
    find "$i" -type f -links +1 -delete
#delete broken symlink
find . -type l -xtype l -delete
#delete emtpy dirs
find . -type d -empty -delete

My one line usefull commands

convert png file, keeping full color (either convert will reduce color space to 1bit our colormap) if it do not loose anything
Apply convert @ -crop 600x580+100+0 -gravity Center -auto-level -define png:format=png32 output/@ to *

Copy a webpage for local viewing, recursive but not the entire www 😉

wget -r -k

ubuntu package related :

dpkg -l nvidia* #list all package starting with nvidia
dpkg -S /usr/include/GL/glext.h #find which package provide a file compil problem

From time to time, on my ubuntu 11.10, i have link error like “undefined reference to glGetQueryObjectui64v”.
This is because an unidentify package update break symlink in
/usr/lib or /usr/lib/x86_64-linux-gnu

The best solution I found is to manually
“sudo rm”
and to “ln -s nvidia-current/ .” in usr/lib
and “ln -s ../ .” in /usr/lib/x86_64-linux-gnu
and so on with if needed ..

Title Capitalization

Not to myself : how to capitalize an English paper title :
Rule 8
Always capitalize the first and last words of titles of publications regardless of their parts of speech. Capitalize other words within titles, including the short verb forms Is, Are, and Be.
Do not capitalize little words within titles such as a, an, the, but, as, if, and, or, nor, or prepositions, regardless of their length.

The Day of the Jackal
What Color Is Your Parachute?
A Tale of Two Cities
From :
and referenced by Siggraph publications instructions

Release and Debug with Cmake and QtCreator

I have used qmake for a while and the debug_and_release facilities to have both debug and release version of my code (with different executable, different build tress …)
Now I use cmake and qtcreator on a regular basis, to obtain the same behavior I have found the following approach :

in my CMakeLists.txtm something like


in QtCreator :
First time you open a CMakeLists.txt, simply choose a build dir (some thing like XXX/qtcreator-build) and run cmake,
then go to Tab projects->edit build configuration -> add -> clone selected
Chage build dir (something like XXX/qtcreator-build-dbg) and click “Run cmake”
In the Arguments edit line enter -DCMAKE_BUILD_TYPE=Debug
You can check that in run settings, working directory has changed to the new bin-dbg directory …

Install (and develop in) cuda under ubuntu 11.10

What you need for cuda with ubuntu 11.10 :

Download and install cudatoolkit (4.1.28) and gpucomputingsdk nvidia download page
You also need last driver (either with a ppa package or direct from nvidia).

chmod +x
#-> /home/XXX/cuda for instance
chmod +x
#-> /home/XXX/NVIDIA_GPU_Computing_SDK
# indicate cuda install dir

I choose to install both in my home dir. Cuda need gcc 4.4 (not 4.6 which is default in ubuntu 11.10) if not installed
sudo apt-get install gcc-4.4 g++-4.4
then the simplest solution i’ve found is

ln -s /usr/bin/gcc-4.4 ~/cuda/bin/gcc
ln -s /usr/bin/g++-4.4 ~/cuda/bin/g++

Add lib and bin dir to path
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH/XXX/cuda/lib64; export PATH=$PATH:XXX/cuda/bin

cuda sdk needs also Xi Xmu and glut
sudo apt-get install libxi-dev libxmu-dev freeglut3-dev
and I don’t know why, but wasn’t linked from /usr/lib/nvidia-current to /usr/lib/ so you need to add the symlink
sudo ln -s nvidia-current/ .

And to compile NVIDIA_GPU_Computing,
one need also to modify to use g++-4.4/gcc-4.4 in place of g++/gcc
in ~/NVIDIA_GPU_Computing_SDK/C/common/
CXX := g++ -fPIC
CC := gcc -fPIC
LINK := g++ -fPIC

CXX := g++-4.4 -fPIC
CC := gcc-4.4 -fPIC
LINK := g++-4.4 -fPIC

A last thing is cuda sdk provides GL/* headers which are not compatible with some of my code, so I need to remove the directory found here ~/NVIDIA_GPU_Computing_SDK/CUDALibraries/common/inc/GL