Skip to content

Round double after cast from String

While happily coding on my genetic algorithm framework, a weird thing occurred when parsing doubles from strings.
Java has trouble with the exact presentation of numeric values such as 0.1, 0.02 in a binary floating-point number. It will try to near down the exact presentation and usually ends up with 0.09999999, 0.020000001 and so on.
Of course 0.1 is not 0.09999999, so we need to somehow round this value to 0.1 again.
I have coded a little fragment to do exactly that, and I want to share it with you (I couldn't find a valid solution on the net):

int d_str="0.01";

Trailing whitespaces in MSSQL

Legacy is hell. It has been proven to me again while writing an application that replaces the old Visual Basic 1.0 scripts.
These scripts copied data from an MS Access database to an MSSQL database.
The effort to write these scripts was clearly less than porting the scripts that access the MS Access database.

I noticed that when I did inserts from Ms Access to MSSQL some fields values were padded with white space.
These white spaces were not present in the corresponding fields in Ms Access, so it was clearly MSSQL that manipulated the values before they were stored in these fields.

Youtube API

Once and a while I dive into the HTML, PHP, Javascript, jQuery world. This time I planned to make a website that lists songs that should be played on a party. I came on the idea to have all song entries automatically linked to YouTube, so that users could watch and hear the song.

Find log4j logger of some class in your classpath

Every time I was running my Java application, I first saw a log4j error saying it couldn't write to the $JAVA_HOME/somelog.log file. Apparently this is the default location where log4j stores its logfiles. This directory is default not writable by non-root users.
The logfile itself didn't contain any indication of which classes are really logging content, or which logger is used to do this.

To find out which loggers are used, launch your program with the following system property:


Monitor MaxDB data volume usage

While I was configuring some monitoring on our SAP servers, I was looking for a way to do some automated volume usage checks. It turns out there's no real command provided to do so. However, a system table stores all related information about the configured data (and log) volumes. This command will provide the necessary information to monitor data volume usage on a MaxDB database. Be sure to replace 'XX' with a numeric treshold value (e.g. 90 will print volumes that have at least used 90% of a volume disk):

dbmcli -u username,password -d database \

Including custom *.py scripts with Jython

I have an application where I use pickle to do data serialization. In a development environment, I didn't have a single issue with running my Jython scripts through Java (by including the jython.jar).
After packaging and deploying on a production environment, I've experienced an error with Jython that it couldn't find the pickle module for inclusion.
After some analysis, I found out that a special lib folder 'Lib' in the Jython source directory exists where these custom scripts live.
The easiest way to solve this, was creating a custom Jython jar file that include all these *.py scripts.

How to obtain WWNs of Fibre Channel Cards in Windows, Linux and Netware 6


While you could use the tools provided by vendors (such as SANSurfer for QLogic, ...), there is a Microsoft tool available that will give various information about Fibre Channel Cards in Windows.
This tool is available for all architectures and can be downloaded at this link:


huge font-size on xfce4

Some days ago I've noticed that, after installing xfce4 via apt-get on a Debian Lenny 5.0 machine, the font-size was HUGE. I was even unable to click through the menu to adapt screen resolution or font properties. After some google-work I've found out that it has to do with the DPI setting that is given with your X server. On some sites they advise you to modify the DPI setting in the Monitor or Device section of your xorg.conf, but that didn't help here.

Proximus GPRS/3G on Nexus One

Here is the configuration to be used for accessing the internet through mobile data via Proximus on your Google Nexus One:

APN type: default

Leave all other settings unchanged.
To have it working, reboot your Nexus One (power off and on again).

Especially the APN type value took me some time to figure out.

Usplash resolution Lenovo W500

The usplash resolution for Ubuntu Karmic is really broken with the default installation. The maximum resolution that can be obtained by the ATI Mobility Radeon HD 3650 is 1920x1200. This resolution (16:10) is also used in the usplash, which will break the Ubuntu logo.
Changing the resolution to 1680x1050 will display the logo nicely.

To do this, change the resolution in /etc/usplash.conf:


Finally, update the initrd image for the current linux kernel:

# update-initramfs -u