Removing obsolete kernel versions

A couple of days ago I ran into a problem with an Ubuntu server I use. It has a fairly small root partition, but after an update it seemed I ran out of disk space. As it turns out, when updating to a new kernel some older files are not properly removed when using the sudo apt-get autoremove command.

Luckily, with a few command line tricks the obsolete files can be removed. The first command will just tell you which files can be removed, the second command will perform the actual cleanup.

dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get --dry-run remove
dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get -y purge

Calculate a duration between dates in Drupal 7.

For a small project I'm working on I need to log the amount of hours I spend on it. The internet lists a great number of applications which can achieve this, but either they cost a lot of money are are bloated far beyond my needs.

Luckily I have some Drupal experience, so I quickly put together a content type with a title, and a date field that contains a start and an end date. Using views I also quickly created a table which provides an overview. It looks something like the following:

project name setup, theming 2011/09/19 - 09:00 to 17:30 8.5

The last column was the tricky one. I wanted to show the actual number of hours for the specified period. Luckily, there's a module for that: Computed Field. Assume the field that contains the date is called field_datefield the following computed field configuration can be used:

Computed code

$start_value = $entity->field_datefield[LANGUAGE_NONE][0]['value'];
$end_value = $entity->field_datefield[LANGUAGE_NONE][0]['value2'];
$timezone = $entity->field_datefield[LANGUAGE_NONE][0]['timezone'];
 
$start_date = new DateObject($start_value, $timezone);
$end_date = new DateObject($end_value, $timezone);
 
$duration = $start_date->difference($end_date, 'hours');
$entity_field[0]['value'] = $duration;

Display code

$display_output = $entity_field_item['value'];

In order to use this in a views table we also need to store the field in the database. So enable the save functionality and enable the following:
Data type: float
Data length: 5,2

TomTom XL QuickGPSFix Update Issue

I have a TomTom XL GPS and I am quite happy about it. One of the nice features TomTom provides is QuickGPSFix. It basically contains ephemeris data of where the different GPS satellites will be for the next 7 days and easily reduces the time it takes to get a GPS signal, in my car at least, from over 3 minutes to under 20 seconds. Big plus.

Unfortunately this seemed to have stopped updating a couple of weeks ago and I couldn't quite figure out why. My device was still listed under the supported devices and I did not disable any option yet no QuickGPSFix updates were available.

As it turns out I guess one of the updates failed and blocked the entire process. Removing all the data in the C:\Documents and Settings\Username\My Documents\TomTom\HOME\Download\complete\ephemeris\ and restarting the TomTom HOME application fixed it. When I checked for updates a new QuickGPSFix update was available and has been successfully transfered to my device.

Happy again. :-)

PokerTracker and PostgreSQL Installation

I have been playing online poker for quite some time now and I noticed that I recently started playing more and more. I think I went from one or two hours per month to around one hour per day. I also never cared much about my plays. Did I play a lot, did I win a lot, what were my chances when I played certain hands. Across many forums people post advanced graphs of their hands and overall progress so I set out to find something similar. Wine has come far, yet certain Windows applications still cause a lot of problems.

I opted to use PokerTracker. It was recommended by me and has a free 60 day trial. The installation of PokerTracker was easy. Much like any normal Windows application. Troubles came afterwards.

PokerTracker uses a PostgreSQL database to store all the information about your hands. After an hour of trying to install the Windows version of PostgreSQL without any success I gave up and attempted to install PostgreSQL on my Ubuntu installation. Installing stuff on Ubuntu is fairly easy:
$ sudo apt-get install postgresql postgresql-client postgresql-contrib pgadmin3
Done. All I needed to do was set some passwords and PostgreSQL was finished. (Make sure to replace the word mynewpassword with your new password.)
$ sudo su postgres -c psql template1
template1=# ALTER USER postgres WITH PASSWORD 'mynewpassword';
template1=# \q
After I changed the password for within the database I needed to change the password of the Linux postgres user. Easily done as follows:
$ sudo passwd -d postgres
$ sudo su postgres -c passwd
For future usage I also enabled the admin pack.
$ sudo su postgres -c psql < /usr/share/postgresql/8.3/contrib/adminpack.sql
Almost done. The only thing we need is a PostgreSQL ODBC driver which we can download from here. Extract the zip file and install it like any other Windows application using Wine.

The last thing I had to do (found here) was to change some registry settings:
wget <a title="<a href="http://www.holdemresources.net/hr/linuxpoker/pokertracker/ptrack-reg.txt"">http://www.holdemresources.net/hr/linuxpoker/pokertracker/ptrack-reg.txt"</a> href="<a href="http://www.holdemresources.net/hr/linuxpoker/pokertracker/ptrack-reg.txt">http://www.holdemresources.net/hr/linuxpoker/pokertracker/ptrack-reg.txt</a>
regedit">http://www.holdemresources.net/hr/linuxpoker/pokertracker/ptrack-reg.txt...</a> ptrack-reg.txt
When I started PokerTracker it asked me to install PostgreSQL. When I clicked the cancel button it asked me for my PostgreSQL database information. I entered my password since I kept everything else to its defaults and of it went.

Linux iPod Music Players

I am a Linux user with an iPod. Like people in my situation will know, the iPod support from the various Linux music applications is not that good. (I know there are several external applications, but I want an all-in-one iTunes alike solution.) They all lack something which makes me don't want to use it and up until now I've only found 2 players who actually do a decent job: Banshee and Amarok.

Banshee lacks compilations support though, which is a problem for me since I have lots of compilation discs. They hacked together some sort of implementation in the latest version but it still seems to cause iPod synchronization issues and you have to apply weird tricks to your MP3 tags. Not user friendly at all, thus not usable. I really like the Banshee project, but they seem to keep doing things wrong somehow.

Amarok works OK on all fields. They have compilation support, MP4 video support,... The current Amarok version is quite perfect for my needs. Until you read the release notes of Amarok 2.0. If it works and everybody's happy with it, don't change it. When will they learn?

So, unless anyone can provide me with a decent alternative I'm afraid I will stay with the current Amarok version...

Microsoft C Implementation Weirdness

After over an hour of debugging 10 lines of code today I came to the conclusion that there is a difference between the implementation of strlen() in C on Windows using the compiler shipped with Visual Studio and GCC on Linux resulting in different return values because some characters are included and others are not.

Over. An. Hour.

Can’t they get anything right?