Planet Open Ghana

March 02, 2010

Joachim Breitner

Talking at CeBIT tomorrow

Today, I arrived at the CeBIT conference in Hannover, and had a first look around. I find trade fairs like that quickly boring, and I was glad to meet some some other Debian folk and listen to some of the talks at the CeBIT Open Source Forum in hall 2, including tolimar’s talk about Debian GNU/kFreeBSD.

Tomorrow (Wednesday), I will talk at the same place at 13:45, explaining some basic stuff about patches and bug tracker. The target audience are users of Free Software who modify it for their private or company-wide use and would like to see their changes included in the official project. There will be a live stream of the talk, which I am officially holding as an employee of the ITOMIG GmbH.

by mail@joachim-breitner.de (nomeata) at March 02, 2010 08:02 PM

March 01, 2010

Joachim Breitner

Teeth fashion

Has anyone ever considered wearing his teeth consistent with the rest of ones cloths?

by mail@joachim-breitner.de (nomeata) at March 01, 2010 11:49 AM

February 28, 2010

Joachim Breitner

Exploiting sharing in arbtt

My automatic rule-based time tracker (arbtt), which is written in Haskell, collects every minute a data sample consisting mainly of the list of currently open windows (window title and program name). Naturally, this log grows rather large. Since October of last year, I collected 70,000 samples. I already went from a text-based file format to a binary format using Data.Binary, which gave a big performance boost.

But by now, I was afraid that this is not enough. My log file is now 30MB large. Looking at the memory graph of gnome-panel, it is taking up more than half of my memory. When running arbtt-stats, the Haskell run time system reports 569 MB total memory in use and the command finishes after 28.5 seconds.

Naturally, the log file is highly redundant: Compressing it with bzip2 shrinks it to 1.6MB. But as I would like to preserve the ability to just append samples at the end, without having to read the file, I chose not just to add bzip2 or gzip compression. Rather, I am now exploiting a very obvious redundancy: Two adjacent samples usually list exactly the same windows, and a focus change only changes a flag. So now, when storing a string that is part of a sample, it will check if this string was already present in the previous sample and, in this case, just store the number of that string (one byte). Only if the string was not present it will write a zero byte and then the string. When reading the sample, the process is reversed.

This greatly reduces the file size: It is down to 6.2MB. It also improves the memory consumption, due to Haskell’s abilities with regard to sharing: When a reference to a string in a previous sample is read, then only one instance of this string is in memory, even if it occurs several times in the log. This brings the memory consumption down to 264 MB and the runtime to 17 seconds.

I released the changes as version 0.4.5.1 to Hackage, Debian and as a Windows installer. The log file is not automatically converted, but new samples will be written in the compressed format. If you want to convert your whole file, you have to stop arbtt-capture, run arbtt-recover, and then move the hopefully noticeable smaller ~/.arbtt/capture.log.recovered  to ~/.arbtt/capture.log.

The required code changes were not too big. I somewhat isolated the relevant code in the Data.Binary.StringRef module. Unfortunately, I have to use OverlappingInstances to be able to provide the special instance for String – is there a cleaner way (besides the trick used for the Show class)?

by mail@joachim-breitner.de (nomeata) at February 28, 2010 10:04 PM

February 21, 2010

Odzangba Dake

Optimize Your Internet Speed With Namebench DNS Benchmarking Tool


DNS Crash Course
The Domain Name System (DNS) resolves domain names like www.wordpress.com into a series of digits (74.200.247.60) that computers can understand. Your browser typically hands over website names to a DNS server and receives IP Addresses in return. Most Internet Service Providers provide a DNS server for their customers to help speed up browsing and downloads.

In Comes Namebench
Namebench is a DNS benchmarking application available for the Linux, Windows and Mac OS X. It uses either your web browser’s history or a standardized test data set to find out which DNS service returns the fastest results for your location.

Installing Namebench
Download and run Namebench from the Google Code repository here.

Ubuntu Users
The people at GetDeb have packaged a deb for Namebench. You can add their repository here.

Using Namebench
Close all internet-aware applications before you start Namebench. We don’t want those applications competing with Namebench for your bandwidth and distorting the results. Launch Namebench (Internet –> namebench for Ubuntu users.) You’ll see an interface like this:

Namebench Application Window

The Nameservers are the DNS servers you are currently using. You can add other nameservers to this list (separate them with a comma or space.) The default settings are usually okay for most people so just click Start Benchmark. Google has a more detailed explanation of the settings here. The test takes 10 – 20 minutes so you can take a sandwich break or something. :)

Nambench Results
After the test completes, your web browser starts up to show you the results.

Namebench Results
As you can see, my primary DNS server’s performance is pretty sweet. That’s to be expected though… it’s a local server so some cached queries must have been involved. On the right, Namebench recommends the optimum nameserver setup for my machine. It seems I’ll have to switch my fall-back namservers from OpenDNS to one in the Netherlands and another in Kenya.

This table shows the DNS servers that were used in the test, resonse times, notes and errors if any. I’ve got some tweaking to do, it seems.

Moving on…

Average and Fastest Responses

This graph shows the average and fastest response times for the top 10 nameservers.

Response Distribution Chart (First 200ms)

This one shows the percentage of times a response was received from a server within the first 200 milliseconds.

Response Distribution Chart (Full)
This last graph shows the percentage of times a response was received from a server for the entire test duration.

Making Changes
There’s a great article here on how to change your DNS servers in Ubuntu. Use the fastest servers from your Namebench test. Windows and Mac users can take a look here to learn how to change DNS settings. Have fun. :)

by Odzangba at February 21, 2010 07:29 PM

February 20, 2010

Odzangba Dake

How To Free Reserved Space On EXT4 Partitions


This one came in handy when I bought a 1TB hard drive last week. Most linux distributions reserve 5% of new partitions for the root user and system services. The idea here is even when you run out of disk space, the root user should still be able to log in and system services should still run… this won’t happen if there is no space on the partition. This policy may have been appropriate in the 90s when hard disk capacities were relatively low but this is 2010 and one can get a 1TB hard drive for a couple of hundred Ghana Cedis. 5% of that is about 14GB and those system services need only a couple of hundred megabytes.

So I decided to reclaim all that disk real estate with this command:

sudo tune2fs -m 0 /dev/sdb1

This sets the reserved blocks to 0%. This is an additional storage drive, I have no need to reserve disk space for system services. You can verify that this actually worked with:

sudo tune2fs -l /dev/sdb1 | grep Reserved

As usual, modify /dev/sdb1 to suit your partition setup. Have fun. :D

by Odzangba at February 20, 2010 08:46 PM

February 11, 2010

Joachim Breitner

Diploma Thesis Finished

Earlier today, I went to a local copy shop and had my diploma thesis printed. This afternoon, I will hand it in. The title is “Loop subgroups of Fr and the images of their stabilizer subgroups in GLr(ℤ)” and discusses a group-theoretical result. I assume that very few readers care about the content of the thesis, but maybe some are interested in a few assorted LaTeX hints. I’m also publishing the full TeX source code, maybe someone can make use of it.

Less chatty varioref

I’m using the varioref package, in conjunction with the cleveref package. This provides a command \vref{fig:S3S4l} which will expand to, for example, to “Figure 1 on page 11”. But if the referenced figure is actually on the current page, the next page, the previous page or the facing page (in two-side layouts), it will say so: “Figure 1 on this page.”

This is very nice, but I assume that the reader of my thesis is able to find Figure 1 when it is visible, i.e. on the current or facing page. One can remove the referencing texts with the commands \def\reftextfaceafter{}, \def\reftextfacebefore{} and \def\reftextcurrent{}. But because varioref puts a space between “Figure 1” and this text, we will get a superfluous space – even before punctuation.

The remedy is the command \unskip, which removes this space again. So I use in my preamble:

\def\reftextfaceafter {\unskip}%
\def\reftextfacebefore{\unskip}%
\def\reftextcurrent   {\unskip}%

Palatino and extra leading

I chose the Palatino font for my thesis, using the mathpazo package. Various sources (such as the KOMA-Script manual) suggest to use 5% extra leading:

\linespread{1.05}

Counting figures independently from chapters

I don’t have too many figures and tables in my thesis, and I want them to be numbered simple 1, 2, ... By default, LaTeX would say 1.1, 1.2, 2.1, ... This can be fixed using the remreset package and these commands:

\makeatletter
\@removefromreset{figure}{chapter}
\renewcommand{\thefigure}{\arabic{figure}}
\@removefromreset{table}{chapter}
\renewcommand{\thetable}{\arabic{table}}
\makeatother

No widows and club lines

LaTeX already avoids these, but I wanted to get rid of them completely. This can be done with:

% Disable single lines at the start of a paragraph (Schusterjungen)
\clubpenalty = 10000
% Disable single lines at the end of a paragraph (Hurenkinder)
\widowpenalty = 10000 \displaywidowpenalty = 1000

Struck table lines

I had to typeset tables with some lines struck, and I could not find a ready command for that. I used the following definition, based on the code for \hline. Note that it probably does not adjust well to other font sizes and needs to be adjusted manually:

\makeatletter
\def\stline{%
  \noalign{\vskip-.7em\vskip-\arrayrulewidth\hrule \@height \arrayrulewidth\vskip.7em}}
\makeatother

Title page in one-sided layout

According to the KOMA manual, the title page as set by LaTeX is not meant to be the cover of a publication, and therefore has to be set with the margins of a right page – i.e. a larger right margin and a smaller left margin. But when printing cheaply, one often just put a transparent sheet on top of the print, so the title page is the cover. You can convince KOMA that you are right by using

\KOMAoptions{twoside=false}
\begin{titlepage}
...
\end{titlepage}
\KOMAoptions{twoside=true}

Not flushing the page for chapter heads

LaTeX would put the list of algorithms on a new right page. I found this a waste of paper for my few algorithms, and preferred to put the list right after the table of contents. You can override the LaTeX behavior using:

\tableofcontents
{
\let\cleardoublepage\relax  % book
\let\clearpage\relax        % report
\let\chapter\section
\listofalgorithms
}

This code also reduces the size of the heading to that of a section. The same trick also works with \chapter.

Math in headings vs. PDF bookmarks

LaTeX with the hyperref package creates nice PDF bookmarks from your chapter and section titles. Unfortunately, PDF bookmark names can only be plain strings, while the titles in the document might contain some math symbols. You can make both happy with \texorpdfstring:

\section{Stabilizer subgroups in \texorpdfstring{$\GL_r(\Z/2\Z)$}{GL\_r(Z/2Z)}}

Setting lines for the signature

The diploma thesis contains a small note which I have to sign, saying that I created it on my own etc. Below that, I put two labeled lines for date and signature, using the tabbing environment:

\begin{tabbing}
\rule{4cm}{.4pt}\hspace{1cm} \= \rule{7cm}{.4pt} \\
Ort, Datum \> Unterschrift
\end{tabbing}

by mail@joachim-breitner.de (nomeata) at February 11, 2010 01:11 PM

February 07, 2010

Joachim Breitner

If I were a caricaturist

I’d draw a caricature involving a Toyota car, representing capitalism, with a stuck gas petal and Barack Obama trying to fix it. But as I cannot draw very well, especially recognizable people, I created this collage:

The photo of Obama was created by Beth Rankin.

by mail@joachim-breitner.de (nomeata) at February 07, 2010 08:33 PM

February 04, 2010

Joachim Breitner

FontForge-Article in the German Linux-Magazin

Yesterday, I found the 3/10-issue of the German “Linux-Magazin” in my mailbox. (I don’t dare to call it the March issue – they are a bit off schedule...) On page 62, you can find my 3½ page article about creating a symbol font with FontForge. I briefly covered the topic on my blog and later thought that it would made a nice article, even though I’m not an expert on this area. The article will be freely available in about three years.This is already my third publication, after my article on the Cross-Site-Authentication attack that was published in the same magazine (circulation ~63.000) and in its international counterpart in 2005 and my recent article in the “freeX” magazine (circulation ~15.000). Looks like I’ll have to add a  “Publications” section to my website soon...

by mail@joachim-breitner.de (nomeata) at February 04, 2010 09:50 PM