lundi 24 septembre 2007

Unusual Git usage : temporary commit into a local SVN checkout

I really love Git, the distributed source code management designed by Linus Torvald. It is VERY easy to setup a new local repository (just type git init in the root of your working directory). I do it all the time, even for a simple bash script creation. Even for the simple text files I use as TODO lists.

A few days ago, I add to work offline in an old SVN checkout. I wish I could have used git-svn but it was an old checkout, and I was offline now. So much for git-svn for now...

I had to find something to be able to undo my changes while I was offline. So why not try Git in a local SVN checkout ? After all, the only thing that Git does is to create a .git file, it does not modify the local files if I don't want to.

So, at the root of my SVN checkout directory :
git init
Then, I must hide the .svn metadata directory, so I modify .git/info/exclude and I add the line :
.svn


Now Git will ignore the .svn directories and I can type :
git add .
git commit

Now at least I can regularly commit my changes into Git and go back in time if
I badly break my unit tests during my TDD session. Of course when I'll be back online
and I'll commit into the SVN repository I'll lose the commit history in Git, but as I
was offline anyway, at least I could work with a safety net.

Even used in this unusual way, Git is still useful.

jeudi 20 septembre 2007

JAgraffe : quickly send your pictures by email

I had coded JAgraffe two years ago for my own use. I still use it almost on a weekly basis.

mardi 18 septembre 2007

Usual GnuPG commands

I tend to forget these very usual GnGPG commands as I use them only once in while. Now I won't forget them, or at least I'll known how to quickly find them :

Sign a file :

Encrypt and decrypt a file for my own use :

Encrypt a free text for someone :

Get my own fingerprint :

samedi 15 septembre 2007

Mix RJ45 and coaxial (10Base-2) ethernet cables

Problem : how do you add a WIFI AP (Access Point) to an already existing network wired with 10Base-2 coaxial ethernet cables ?

Of course this is an old network with old PC, and you can not replace the 10Base-2 network adapters of the PC in order to rewire with RJ45 cables.

Answer : just find one more 10Base-2 network adapter in a drawer, and add it in an old Linux box that already has a RJ45 network adapter.

Setup two subnetworks, one on each adapter of the Linux box, with routing of the traffic from one subnetwork, to another (or even better, build a bridge, in order to have one single subnetwork).

Plug in the AP to the linux box with a crossover RJ45 ethernet cable.

This linux box can even be used as a gateway both for the LAN and for the WLAN !

vendredi 14 septembre 2007

Simple iptable gateway script

It's the second time I must setup a Linux gateway connected to a DSL line. The DSL modem interface is ppp0 and the LAN interface is eth0. Here is the script I use to setup the iptables :

lundi 10 septembre 2007

Sort JPG images by EXIF date in Ruby

Everybody now has a digital camera, and, during special events everybody takes plenty of pictures, and you end up with all these JPG images from different cameras. Each set of pictures tells the same story from the beginning, so it would be great to be able to reinterleave all of them in order to tell one single story.

That what the folllowing little Ruby script does, thanks to the libexif-ruby library. If you run it in a directory with JPG images, it will create a subdirectory and copy all images, renaming them, prefixing with the EXIF date set by the camera.

First, install the libexif-ruby library. On Ubuntu you can type :

Then copy the following script in a ruby script file :

samedi 8 septembre 2007

Linux and Logitech MX mouses resolution

Without its real driver, my Logitech MX 510 mouse is seen by Linux as a 400 cpi resolution mouse. Actually it can be used in 800 cpi thanks to lmctl

I've added this script to the 'Startup Program' list of Gnome :

The xmodmap call allows to properly configure the thumb buttons.

An other Nautilus script : create directory with date

I've already described how to add custom scripts for Gnome file manager, Nautilus. So here is a an other simple script : it allows to create a directory with the name prefixed by the current date, via the contextual menu (right click) of Nautilus in the window of an other directory.
Just type the name of the directory in the popup dialogue ; spaces will automatically replaced by underscores.

You must install XDialog to be able to use this script.
On Ubuntu :

And here is the script :

jeudi 6 septembre 2007

Nautilus File Manager scripts : Scale JPG images

I really appreciate the feature of Nautilus (Gnome file manager) that allows the use of custom scripts via the right click contextual menu. To be seen by Nautilus, the scripts must be copied in a specific directory ; you can reach this directory with :
Right clic in any directory window --> Scripts --> Open Scripts Folder

For example here is a bash script that can be used to scale all JPG images in a directory (a directory is created and the scaled images are copied into this directory).

You must install XDialog and ImageMagick to be able to use this script.
On Ubuntu :


Then copy the script in the script directory of nautilus :

mardi 4 septembre 2007

Simple CruiseControl + Ant example

I always have a hard time finding online a simple example of CruiseControl + Ant file whenever I need to quickly setup a Continuous Integration server for a project. So here is the configuration I had set up for the open source project TSP (Transport Sample Protocol) :


For TSP the Ant build file was there to trigger the C build :

For TSP the setup instruction were :
  • install a binary distribution of cruise control
  • replace the config.xml file with the previous file. Change the email addresses of the 'returnaddress', and the 'always address'. You can add as many 'always address' as you want
  • go to the 'projects' directory of the cruisecontrol install and perform an anonymous check out of tsp :


you can test the build without cruise control if Ant is available :
go to projects/tsp/make and launch :

If everything is OK, with the build, run the cruisecontrol.sh script. you're done,
cruisecontrol is up and running.