Archive for October, 2009

Melding Git

October 29th, 2009 subogero Comments off

After switching to Linux, one feels the need to switch to an equally cool version control system as well. And none is cooler than the one invented by Linus Torvalds himself: Git.

It’s called the Fast Version Control System. Being an MKS user professionally, git was a bit on the scary side. No GUI, strange commands and a completely different workflow. Instead of the central repo, there is cloning, pulling and pushing. Instead of the rigid but readable version numbering, there are unreadable SHA1 hashes but, at the same time, user-defined tags as well. Instead of locking, there is branching and merging. Instead of dealing with separate files, there is the universal commit. Main advantage: FAST! And I feel the workflow more and more natural.

I could not get used to one thing, however. The “git diff” command displaying source differences. I’m a huge fan of command lines, but there are limits. So I googled for a visual difference tool. I found meld.

sudo apt-get install meld

Then I looked for a way to integrate git and meld, so when I type git diff, it would open meld, instead of displaying that unreadable mess on the terminal. I found Nathan Hoad’s website.

First step is to tell git it should use meld. While the Bash Guru types

git config --global diff.external meld

the Config Wizard adds a few lines to ~/.gitconfig:

  external = /usr/bin/meld

It does not work, however. Git sends 5 parameters to the diff tool, while meld expects only the 2 filenames to compare. So a little filter is needed. Nathan Hoad proposes a Python script:

import sys
import os
os.system('meld "%s" "%s"' % (sys.argv[2], sys.argv[5]))

I know that Python is the language of the day, but in this case I felt it was a bit like Shooting a Sparrow with a Cannon, if you allow me this Hungarism. If one is lazy, one needs a one-liner. And the language of choice is non other than the Bourne Again Shell. The filter is called ~/gitvdiff:

git config --global diff.external ~/gitvdiff

And it contents:

meld $2 $5

Let’s see the results.





On the right side you may notice the entire source file displayed. With syntax highlighting. With a map of the diffs. And with the diffs nicely highlighted.

Categories: Uncategorized Tags: , ,

Nautilus Image Converter – My New Toy

October 26th, 2009 subogero Comments off

I’ve got that other blog. About Psychlismo. Which, while being the hard sport that it is, has its advantages as well. You may be out of oxigen, but at the same time, a spectacular view may just take your breath away.

Which means photographs. Which in turn get uploaded to the blog. WordPress has a nice interface to do that, a thumbnail image will be created automatically, which you can insert into the text right away. There are a few problems though. If the image is too big, the thumbnail is not generated. And it’s rather cumbersome to upload a high number of images one by one via this GUI.

The bulk upload is sorted out easily. During the brief history of computing, humanity has invented various protocols to transfer files. But these protocols do not create thumbnails. Bulk thumbnailing, and rotating for that matter, has to be done before and, in my case, Google has found the solution very quickly:

sudo apt-get install nautilus-image-converter

Become Mr Rightclickalot, open Nautilus (Gnome’s file manager), navigate to the directory of the new images, select and right-click a bunch of them, select “Resize Images…” and a dialog-box appears with the options. You can chose the new size. You can resize them in place or make a copy with “.resized” appended to the filename. Or you can change that to “.thumbnail” to please WordPress.

Now try it with another bunch of images. Yes, all your previous settings are forgotten, and the suffix is “.resized” again. And Gnome, being the Epitomy of Usability, offers exactly zero options to change the default settings.

But don’t give up just yet! If Mr Rightclickalot has failed, the Config Wizard will sort it out. Every program has some sort of config file:


Search for “.resized”, replace by “.thumbnail” and enjoy. It’s easy to find all the other default settings as well. Bonus: nautilus-image-converter can rotate pictures as well. I’ve not uploaded any image via the WordPress GUI ever since.