Index ¦ Archives ¦ RSS > Category: hacking ¦ RSS

Recent contributions

Estimated read time: 1 minutes


Sorting photos by date using exif date info

Estimated read time: 2 minutes

For a family event I received photos from about 6 persons, and wanted to view all of them, sorted by date. The problem was that the timestamps of the files were sometimes incorrect, and also in all but one cases the exif timestamp was incorrect as well (but at least that was consistently incorrect, e.g. all behind of time by 20 mins, etc.)

So first I searched for a photo where a clock is shown, then matched photos by different authors showing the same action to know the time delta of each camera. The rest can be scripted: just read the exif info, apply the necessary time correction based on the camera model, and touch the file with the correct date. Then any image viewer can show the photos, sorted by date.

Here is the script I came up with:

for i in *.jpg
do
    # 2012:01:01 01:01:01 -> 2012-01-01 01:01:01
    date=$(exiv2 $i |grep timestamp|sed 's/.* : //'|sed 's/^\([0-9][0-9][0-9][0-9]\):\([0-9][0-9]\):\([0-9][0-9]\)/\1-\2-\3/')
    # date string -> epoch
    unix=$(date --date="$date" +%s)

    model=$(exiv2 $i |grep model|sed 's/.*: //')

    if [ "$model" == "NIKON D40" ]; then
        unix=$(($unix-1320)) # Alice
    else
        unix=$(($unix+3600)) # Bob
    fi

    # epoch -> date string
    date=$(python -c "import time; print time.strftime('%Y-%m-%d %H:%M:%S', time.localtime($unix))")
    # profit!
    touch --date="$date" $i
done
# write back the timestamps to the exif info (thx boobaa)
jhead -dsft *.jpg

And additionally if you don’t want to mess up the settings of the image viewer, you can use:

c=0; for i in $(ls -lhtr *.jpg|sed 's/.* //'); do c=$((c+1)); cp -a $i new/$(printf "%03d" $c).jpg; done

to order filenames based on the file timestamp.


Recent contributions

Estimated read time: 1 minutes

  • BitlBee: a patch for skyped got merged, helping to avoid the cryptic openssl error messages when the certificate is missing.

  • openSUSE: the mutt package now contains one more patch from Frugalware’s mutt-ng package, which means my mutt config can be used unmodified (no more unknown config settings)

  • jBPM and bpm-console: these were part of my MSc thesis, github branches are available, upstreaming is in progress (on IRC they confirmed that they are interested in the feature, at least)


Patience, please!

Estimated read time: 1 minutes

So Lennart already had great slides about what is the preferred attitude when you’re hacking Free Software (don’t expect gratefulness && be grateful), but recently there was such a great example, I wanted to mention it. :)

So I saw there is a new etckeeper release and I checked its changelog, mentioning me. What the hell? I didn’t contribute anything to that project in the past 3 years! It turned out it was a patch that was considered "too new" at that time, but now got merged. ;) Remember, if you contribute, usually integration takes much less time, so no need to whine about it.


From gammu to Google Contacts

Estimated read time: 1 minutes

One typical migration people do when changing phones is migration of contacts and calendar items. In case of mine, this is about migrating data from an S40 phone to Google apps, where every smartphone can sync from.

Migrating calendar items is easy: gammu can save the data from the phone to a .ics file and Google Calendar can just import that. The situation is a bit harder for the phonebook, as Google Contacts would take a .csv, while gammu as its own ini-like format for storing this data.

I already found a script doing something similar, but the result was unusable. ;) Given that the whole task is not that complex, I decided to write my own converter, available here.


Replying to SCM commits using Gmane

Estimated read time: 1 minutes

SCM commit mailing lists are handy in case you want to comment others' commits in an email. OTOH they are problematic, as they generate a lot of mails, and in case I subscribe to the list, usually I don’t read those commits at all. (In case you have time to read them, that’s a different use case.)

So here is an example how to reply properly — without having to subscribe.

  • search for the commit ID you want to comment (here b863767bd1ddc2af18900fa1df0cd61ef2fa6edb)

  • extract the article ID associated to the push from the link (here 1643)

  • download the article in mbox format, so you can reply to it from mutt (or your other favorite MUA).


systemctl now supports auto-paging

Estimated read time: 1 minutes

If you use systemd, you know systemctl. That’s the command that controls systemd: you can use it to start, stop or list (and so on) services. Now in case you use list, there is a lot of output, probably it won’t fit your screen. git already invented auto-paging, which means it’ll feed its output to a pager if the output is more than a screen, for example when using git log. With my recent commit this now the case with systemctl as well. :)


CSP

Estimated read time: 1 minutes

CSP, as in Constraint satisfaction problem. A while back I wrote a custom sudoku solver in Erlang, and now I hit something similar. Of course, since then I learned that there are nice CSP engines, so this time I did not try to write my own. :)

First, I checked out python-constraint, and then I sticked with it, as it fulfilled my needs.

So, the problem. Here is a Christmas tree:

/pic/csp.t.png

The tree has 4 chains, each one contains 7 items. A few ones already has a number. The exercise: number the empty items with numbers between 1 and 7 so that:

  • Each chain contains the numbers 1..7 exactly once.

  • All the horizontal and diagonal lines cannot contain the same number twice.

A possible solution is here. If you get less or more than one solution, you did something wrong. :) (I’m not pasting here the output of the script to leave some exercise for the readers. ;) )

Note
As an experiment this time I draw the image using TikZ. Based on these ideas I converted the source to PNG using tikz2png.

pcal

Estimated read time: 1 minutes

I wanted to create some calendar present for Christmas in the family with pictures and Hungarian year / month order, national holidays, etc.

After looking at a few solutions, pcal seemed to be the best choice.

There are 3 key points here:

  • The order of the year / month can be changed only in build-time. If your locale has "year month" and not "month year" order, then you need this patch.

  • You need some config for each locale, here is mine, containing the Hungarian national holidays.

  • Finally you need a script like this to put in the pictures.

The result fully localized, free software, contains my custom images and support custom marks for days using a quite flexible syntax.

(Let me know if you know some other project where you can set the year/month order runtime and the result can be still generated from a script, ie. it’s not some LibreOffice or similar template. ;) )


idl2dot

Estimated read time: 1 minutes

I needed a tiny tool to generate something classdiagram-like from CORBA IDL files. Given that I did not find such a tool, I wrote it.

You can find it here.

An example: idlscalable output.

Note
Right now it does not support typedefs, enums and exceptions. If you need such a feature, patches are welcome. :)

© Miklos Vajna. Built using Pelican. Theme by Giulio Fidente on github.