Skip to content

Created a flattr account

January 10, 2011

So, about a month ago I created for myself a flattr account, and today I decided to add my blog as a product that you can flattr if you feel like it. Ideally I would prefer that I could add a clickable icon as a signature to each post, but I do not see any way to do this on WordPress? Does anyone out there have a recommendation on how to best integrate Flattr to a WordPress blog?

Oh, and most of you two readers out there might ask yourself what flattr is? Well, it is a site where you set up an account and add funds. Then you decide how much should go out of your account. Afterwards, you can click on a simple flattr button when you want to donate some money to a product, which could be a video on Vimeo, an article like this one, a linux distribution or whatever other product you can think of really. The monthly amount will automatically be divided between all the things you flattered in a given month. In other words, it is one of the easiest ways I’ve seen yet where you can donate a small amount of money quickly and easily without spending everything on credit card charges. I think this concept has a lot going for it!

Flattr this


Tip of the day: partial git log

December 3, 2010

This entry is a short one. Do you have a large project and are curious about the changes done in a subfolder only, or perhaps just one file? I noticed today (perhaps this is obvious to anyone but me), that if you use the command "git log <file>" or "git log <folder>", you only get the log from the commits where there was changes in that file or within that folder. This can quite often be useful when you want to track down a version of a particular file…

Latexdiff and git

November 7, 2010

A lot of scientists have latex as their preferred format for writing articles. A very nice tool when working on latex projects with several people is latexdiff, a perl script that based on two versions of a latex document creates a "diff document" which shows all new (text) additions in blue with curly underline, and all removals in red with a through line.

Latexdiff works well with svn and cvs repositories, where you ask latexdiff to simply compare a given file in two given revisions. However, to my knowledge this has not yet been extended to git. Hence I decided to write a bash script that works on a latex project in a git repository.

In the current form, the script compares the current version against a specified version in the repository. The specified version can be a branch, tag or a revision id. It will include any uncommitted changes as well. It does require that you are currently on a branch. It could probably be extended to work under more general circumstances, but this works fine for me.

One limitation in latexdiff is that it doesn’t work on more than one latex file. On certain big projects (like my PhD thesis), the document is written from several subdocuments using \include{} (or \input{}) statements. I added this to the bash script, so that you can specify several files that have changes you want to include in your pdf document. It actually currently does not fix \input statements since I don’t use them.

You could probably rewrite the script for e.g. mercurial rather easily. If you do, please add a link to it in the comments here.

Update: Instead of just leaving the script in pastebin I added it to gitorious, so it will be easier for you to make changes to it. You can get it with this command:
git clone git://
If you have the git plugin for Mercurial installed, you can of course use the same command:
hg clone git://

Update 2: Thanks to Paul Anton, I figured out a much better way to solve the problem. The script is now updated so that it must be set up with a command that it can use to get latexdiff in your repository, and then it will work without any need to be in a branch or similar. It does work for me using git, could someone test in mercurial and post here? If you don’t want to check out the repository, you can also have a look at it online:

Credit also goes to amonakov for giving information on how to set this up for git.

4 million euros to produce

August 18, 2010

Technocrunch had another article today about the price of 4 million euros, which is an amazing number for a website. Granted it looks good, but at 4 million it pretty darn should look good as well! I cannot understand any part of developing a web page that can give it such a price tag. Nothing.

Then I read some comments and searched around a bit, and figured that one of their southern neighbours has them beaten by an order of magnitude. was a whopping 45 million euros to produce according to this site.

It doesn’t stop there though, Romania will be spending 500 million euros in the next three years on their e-portal according to this site. That is a total of 25 euros per person living there, to be compared with their GDP which according to wikipedia is 12 600 USD. That almost makes me sad.

You got worse stories? I would be curious to know about pricetags of similar Norwegian projects. I would not be surprised if some of them were rather ridiculous as well.

Git backup with Dropbox

August 18, 2010

Today I wanted to write how I have set up my git repositories for backup. At work I have quite limited backed up space, but scratch space which is not backed up I get plenty of. I keep my different projects in git repositories, and I also mirror the svn repositories for the programs I use at CERN (they just recently moved from CVS to SVN).

Just to point out this to users that might get confused: The command && just means that I combine two lines, to save linespace in this blog.. It is basically for me to point out where you have to use a certain command.

First I create the repositories on the server space I have. If you do not know how to do that (git init && git add <file> && git commit), then have a look at a brief tutorial to git before you continue.

Next in each repository I create a remote repository with the name "dropboxbackup", like this:

git remote add dropboxbackup file:///home/myusername/Dropbox/git/nameofgitrepo/

Next I need to initialize the new repository in Dropbox. It is purely backup, so I choose a bare repository:

cd ~/Dropbox/git/nameofgitrepo/ && git init --bare

Now, I can backup my repository with the following command (inside the repository on my server)

git push --mirror dropboxbackup

In order to simplify things, you can add a new alias in git:

cd /path/to/gitrepo/on/server/ && git config alias.backup "push --mirror dropboxbackup"

This way you can run the backup with

git backup

This is getting quite easy, but one thing which is easy to forget is to actually back up. This is where cron come into play. First make sure the cron daemon is running on your system. Next, you write a small script "" with the following content:


cd /path/to/gitrepo/on/server/
git backup
cd /path/to/gitrepo2/on/server/
git backup

Finally you add the job to cron with the command "crontab -e"

@hourly ID=backupgitrepos nice -n 19 /path/to/script/ >> /path/to/script/backupLog.txt 2>&1

Notice that I used “>>”, which means the file backupLog.txt must exist before the job is ran. You can do this with “touch /path/to/script/backupLog.txt“. This will make sure that every hour your git repositories will be backed up to Dropbox. Have a look in the backupLog.txt file where you can see if everything is going as expected. You can of course still backup manually with "git backup" in addition to the automatic backup whenever you want. For me this means that I will have a copy of the repositories on the server, on all my computers that have installed the dropbox client and on the dropbox server itself. That is actually significantly better than the daily backup they offer at work! 🙂

If something was confusing, or you have suggestions for a better setup, let the comments flow! 🙂

First meeting with the Nokia Qt SDK

August 4, 2010

A long time since I have written anything now, so I thought I could write my early experiences with Qt-creator, and development for the Maemo platform. Last weekend I decided I wanted to see how difficult it would be to write a "Hello World" application for the N900, using the development kit available. I would just like to point out from the get-go that my experiences with GUI programming is fairly limited. It extends to one course in Java I had about five years ago at the university. Most of it is long forgotten. What I do with computers is programming and running simulation codes, calculating physics stuff. For this it suffices to just have a script available and input/output files. No need for graphical stuff for most of what I do.

I started by installing the QtCreator and playing around with it. It is really easy to get started with. Create a new project and you are greeted with an example code consisting of an empty .ui file (Qt graphical files in XML format), a header/source for the window and a main.cpp file. Open the UI file and you are greeted with a designer, where you can add/remove buttons, lists, layouts etc, and connect them with signals/slots. I don’t think it gets much easier than this.

Qt-Creator Welcome Screen

The image above shows the welcome screen. The Qt Creator has a nice set of features, with drop down menus of functions inside classes, at least for Qt. This helps a lot when writing your code. Below is an example of how the source code window looks.

And finally a screenshot of how the Qt Designer window looks:

In all screenshots you see the current source code of my hello world application. I called it "shoppinglist", and it basically is a list-able thing that probably wont get far. I just needed a simple concept to play around with. I also tried out Github, so you can find my source here if you are curious.

Initially I installed QtCreator from the Arch repositories, and the Maemo SDK virtual image. I then created a "standard" C++ project. To install your application you then need (from what I understood, there might be easier ways) to run the virtual image in e.g. VirtualBox, then you need to copy your project to this virtual machine (I use Dropbox for this), then you need to log into "scratchbox" inside this virtual machine, and generate/modify the debian packages. Finally you need to build the package and move the *.deb file to your mobile. This takes a while to figure out the first time, let me tell you!

A much easier way I found later on, was to download the "Nokia Qt SDK" instead, which comes complete with a mobile simulator and possibility to build for Maemo (and Symbian S60 in the Windows edition from what I could understand). What you then do is simply open a new project, select Mobile Qt Application and select where to install (let the boxes for Maemo and the simulator be checked). Then you have a one-click compile&run to get your application shown inside a simulator, as shown in the screenshot below.

If you then want to build for your phone, you simply select Maemo instead of simulator in the bottom left, and click build. It then automatically compiles for ARM architecture and creates a *.deb file of your project. This file you can then install on your phone by first getting root access (e.g. with the gainroot script), and then run "dpkg -i <debfile>".

By default the binary is installed in /usr/local/bin/ which isn’t part of the Maemo path. You also need to do some other modifications to the debian files in order to get them properly working, but at least it is a very good starting point. There are some quirks here and there, like how the simulator isn’t entirely accurate all the time, but all in all I am very pleased to see just how much easier this has gotten! Perhaps the joy for people that have seen the hard way is larger, but all in all quite impressive right? 🙂

Finally, a screenshot of my application running on my N900:

Create your own background for the N900

June 12, 2010
tags: , ,

A quick post, since I haven’t been blogging in quite some time now. Today I created my own background image for my phone, the Nokia N900 running on Maemo. The background in general consists of N number of images, where N is a number which is maximum of 4. I had a panorama image from Aiguille du Midi which I wanted to use, which was created using Hugin. I needed a way to split the panorama correctly in four, so that the stitching wouldn’t show when I switched desktops.

The solution I found was in Gimp. Load the panoramic picture into Gimp (this could also be a panoramic crop of a normal image obviously). Use the choice "Image – Guides – New Guide (by percent)" three times, so that you end up with a vertical guide at 25%, 50% and 75%. The result is shown below.

A screenshot from Gimp

Then, go to "Image – Transform – Guillotine" and split the image by guides. The four pictures will pop up with reasonable naming, save those and add them as background images on the respective desktops on your mobile. Screenshot below.

A screenshot showing my new background image

Edit: If you want this particular background on your phone, you can find it here.