Cristian KLEIN's Technical Blog


Improving wrapping in Thunderbird

Filed under: Uncategorized — cristiklein @ 10:43

TL;DR: see pictures at the bottom.

I often receive HTML messages whose width is too large. This implies that I need to scroll horizontally, hence reading these messages is pretty cumbersome. One could switch to Plain Text View, but this would lose the original formatting. Fortunately, Thunderbird allows you to add your custom CSS rules to HTML messages that are displayed. Just follow these simple steps:

  1. Locate your Thunderbird profile. On my Ubuntu Trusty (14.04.1 LTS) installation, this is located in ~/.thunderbird/2fr5pfvl.default
  2. Create a folder chrome.
  3. Inside that folder, create a file userContent.css, with the following content:
    body {
        max-width: 50em;
    pre {
        max-width: 50em;
        white-space: pre-wrap;
  4. Restart Thunderbird

Check the result below:

Message view before fix:
Message view before fix
Message view after fix:
Message view after fix


Generating a Master Password in Your Native Language

Filed under: Uncategorized — Tags: — cristiklein @ 23:35

I recently discovered PasswordMaker a solution which solves all password management problems. In order to guarantee that your on-line passwords are unique, hard-to-crack, but still easy to access, PasswordMaker deterministically generates a unique password for each site, based on a master password and the URL of the website, by applying a one-way hashing algorithm. Assuming hashing algorithms are actually one-way, the approach is perfectly secure. Moreover, PasswordMaker is available as a command-line tool, Firefox plugin, Android App, etc. which means that you can always have easy access to all your passwords, without needing to write them down or synchronize them among devices. One issues remains: how do you generate a secure (i.e., high-entropy), easy-to-remember master password?

A long time ago, I read about Diceware. The author proposes generating a passphrase using the following procedure. First, random numbers are generated using dices. Next, a word corresponding to the generated numbers is looked up using a provided list (the Diceware word list). Each word provides 12.9 bits of entropy. Multiple thus obtained words are joined to form a passphrase of the desired entropy. With a little bit of imagination, these passphrases are easy to remember. That is, assuming you are a native English speaker.

So how would you generate a master password in other languages? I have created a simple Python script that reads a word-list file and randomly picks 5 words for you. In my case, I chose the official word-list of the Romanian Scrabble Federation. Many countries have similar associations, which allow you to have  access to a frequently used corpus of words.

The source code can be downloaded from GitHub.

Personally, I recommend writing the password down on a sheet of paper and storing it in a secure location. In my case, the damage of definitely losing the master password is way bigger, than having it exposed.

NOTE: In contrast to Diceware, I have chosen to “trust” the random-number generator of my computing platform. In my opinion, if you seriously consider this a source of insecurity, you should also make sure you have cold fingers while typing the master password, otherwise thermal residue from your keyboard might give it away. Also, you should short-circuit your RAM before leaving your computer.


Car Radios and USB Sticks

Filed under: Workarounds — cristiklein @ 18:19

My car has an Easy Touch EC-37310 Car Radio. It is a pretty cool device, considering its price. Among others it has a USB and a SD slot, so you can listen to your MP3 from your USB stick. However, making it actually work, gave me some headaches.

Short story: you must use a FAT system with 255 heads.

Long story: the exact requirements are:

  • Your stick must have a partition table with one active FAT32 partition (system ID 0x0b)
  • The partition must be formatted FAT16 or FAT32 (standard stuff until now)
  • The file system must have 255 heads (tricky!)

This is how I achieved this configuration on an Ubuntu 10.04 LTS Lucid:

  1. Install mtools:
    sudo aptitude install mtools
  2. Prevent udisks from automounting any stick:
    sudo udisks --inhibit

    Leave it running until told so and open another terminal.

  3. Insert the stick and configure mtools to access it. After inserting the stick, dmesg should show something like:
    [29051.184600] sd 11:0:0:0: [sdX] Attached SCSI removable disk

    Replace sdX with the your actual value. Using your favourite editor, open /etc/mtools.conf (sudo required) and add a line like this:

    drive z: file="/dev/sdX1"
  4. Create a fresh partition:
    sudo fdisk /dev/sdX
  5. Format file-system:
    sudo mformat -h 255 -F z:
  6. Done! You can now un-inhibit udisks, remove and reinsert the USB stick and copy your favourite music. Don’t hesitate to leave me a comment if it doesn’t work for you.


Less and Unicode 5.1

Filed under: Productivity — cristiklein @ 16:49

I do not expect “normal” people to stumble upon this problem, but I thought I would describe it anyway, just in case it might help someone.

The problem is the following: I wrote a program, those debugging output I wanted to organise a little bit. So I used pipe (|), U+26BB QUINCUNX (⚻) and U+26BA SEMISEXTILE (⚺) to group related messages together. Unfortunately, less does not show the latter two characters, instead it prints their code point (U+XXXX).

This happens because less has an internal Unicode table, storing which characters can be safely output to the terminal and which should not, likely because they are control characters, or because their behaviour is unknown or undefined (they are not yet allocated in the Unicode table).

At the time of this writing, less‘s database was synchronised to Unicode 5.0, but the two problematic characters only appeared in Unicode 5.1. Since less does not know about these characters, it prefers to play safe and displays their code point instead.

To overwrite this behaviour, you can use the following command:

LESSUTFBINFMT=*n%lc less -S log.txt

This will tell less to go ahead and output to the terminal even those characters that it does not consider safe.

Nowadays, I prefer to use the dedicated drawing characters, from U+250C to U+25A9, which exist since Unicode 1.1.


Why Webmail Prevails

Filed under: Uncategorized — cristiklein @ 17:33

This year I had the chance of teaching PCI (Pratique et Compétences en Informatique), something like the Computer Driving Licence, where my students learned about basic File Management, Networking, Web Browsing, E-mail, Word Processing etc. They are all outside the field of Computer Science and many of them have only basic computer knowledge. As so many people told me before, it is only when we try to explain to somebody new to that topic, that we realise whether our arguments are sound and whether our choices were the best. In this post, I would like to highlight a field where computers are far from being user-friendly.

Have you recently configured an e-mail client (say Thunderbird)? Have you tried to explain your mother how to do this? How did you explain her the fact that there are three protocols (POP3, IMAP, SMTP) with several options (clear, TLS, SSL) and that you have to type a different server for each one? Oh, and BTW, why do you have to type your e-mail address and your full name, especially since this information is already known by the server?

I finally understand why webmail prevails. You need to know only three things to “configure” it: domain name, username and password. What crosses your mind when you think about this:

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.

Why can’t we have the same for e-mail clients? Why did we impose an artificially steep learning curve, without ever looking back at how we could improve it? Why can’t an e-mail client auto-detect all necessary configuration with only three pieces of information?

We don’t even need to change the current protocols, we must only change current practices. I propose the following steps:

  • Deprecate POP3 and don’t mention it again. Explaining to a new user the difference between POP3 and IMAP is just too complicated. Usually it goes something like: “IMAP keeps the files on the server, while POP3 deletes them … by default … but you can choose to keep them.”
  • Force SMTP AUTH. We should have noticed by now that open-relays are not a desirable thing.
  • Auto-detect servers using DNS RR, just like XMPP does. (I bet none of you know the hostname of the server your XMPP client is connected to.)
  • Deprecate SSL. All protocols present whether the server has TLS capability, so we can auto-detect whether to go clear-text or TLS, obviously showing the user a big warning if the connection is clear-text.
  • Let the SMTP server fill the From header. I believe relay SMTP servers should not trust this information anyway.

Voilà! Few simple steps to make the e-mail more user-friendly, without having to reinvent the wheel (just tune it a little bit). Also, these steps would maintain fairly good backwards compatibility. So, what are we waiting for?

P.S. Shall I add the fact that for shared calendar and contacts you use two more protocols: LDAP and HTTP (or WebDAV)? Have you tried explaining your mother what are the binddn and the basedn?


Quickly Testing New Linux Branches

Filed under: OSS Development — cristiklein @ 01:19

Sometimes, I just can’t help myself and feel like going cutting-edge (i.e. crashing my system). Recently, I became increasingly interested in the drm-radeon-testing branch and patches that have been submitted to the dri-devel mailing list. So how do you quickly try out such stuff and return your comments to the community?

Before going into this adventurous voyage, make sure that you cannot use any alternative which would not require you to compile the kernel, such as the Kernel PPA.

Until recenty, testing a kernel was a very time-consuming lose-lose situation. You either compiled as much as possible from the kernel, falling asleep while compilation took place, or you selectively stripped out parts. The latter never worked for me: the kernel got too complex and has too many options for me to try out. Do I need initramfs? Never heard of it, so I guess not.

Fortunately, a recent option has been added, which would simplify this task. make localmodconfig scans all the modules which are currently loaded on your system and creates a minimal configuration which includes them.

So here is how it goes:

First, pull your favorite branch. For drm-radeon-testing this can be achieved using:

git init linux
cd linux
git fetch --depth=1 git:// \
git checkout drm-radeon-testing

Next, create a configuration file:

make oldconfig
make localmodconfig
# Press lots of ENTER until the command prompt returns.

Now I have a somewhat disappointing news. I know I said that localmodconfig will solve all our problems, but I lied. To tell the truth, there are still some modules which are loaded only when devices are hot-plugged. Which ones? Hard to tell. You will just have to run the kernel for a while and see what is missing. For example, unless you had a USB Stick and a CD-ROM mounted while you localmodconfiged, you might want to do the following:

make menuconfig
# go to "Filesystems -> DOS / FAT / NT" and check MSDOS, VFAT
# go to "Filesystems -> CD-ROM / DVD" and check ISO (including Joliet), UDF
# go to "Filesystems -> NLS" and check all options
# go to "General -> Local version" and write your initials so you can brag about it 😀

Last, but not least:

make -j4

Then install your kernel:

sudo make install
sudo make modules_install
# The next two commands are Ubuntu-specific (tested on Ubuntu 10.04 Lucid)
sudo update-initramfs -u -k all
sudo update-grub

Ready! Before rebooting your system, make sure you have access to the Grub menu (check /etc/default/grub), so that you can boot your old kernel if things don’t go quite as expected.

P.S. Just tested 98e5963f723eab392699896d39eed9ca54750575 from 2010-04-09. I finally have non-crashing KMS + DRI2 + 3D on my ATI Radeon R600.


Simple Python Simulation Module

Filed under: Python — cristiklein @ 11:30

I need to write discrete, event-driven simulators in Python. To simplify this, I want an API to describe multiple processes, which would either do some computations, sleep or wait for a condition to become true.

The first thing I stumbled upon was SimPy. After using it for some time I found out that the idea behind it is very good, but the way it is implemented makes it unpractical for my purposes. It uses Python generators, which makes using nested functions in your model counter-intuitive and very difficult.

This is why I chose to write a simple Python simulation module, which uses a fiber implementation for Python called greenlets. Although, it is not nearly as feature-rich as SimPy, I am quite pleased that I can write clean and easy-to-read simulators.

You can download my simulation module from here. Please look at the example at the end of the file, or use the generated DoxyGen for help. If you have Ubuntu Karmic or Lucid, you can download the python-greenlet package from my PPA.



Filed under: Meta — cristiklein @ 22:30

Now that my first post is ready, it is time to think about the technical details regarding the publishing of my blog. Here is a list of requirements I had in mind:

  1. Long-lived and independent of my current residence / work place: it should not be hosted by my employee, my ISP nor on my home computer. Also, I feel uncomfortable hosting it on Google as I feel it would be too tied to my email account.
  2. Easy to browse: it should have permalinks, categories and RSS feeds.
  3. Comments welcome: it should allow other people both to manifest their opposition and ask for further details, without forcing them to create an account etc.
  4. Code: it should allow easy formatting and friendly display of source code and console commands.
  5. Cool: it should look pleasant to human eyes.

Since it suits all my needs and I did not want to invest too much time in comparing and contrasting, I just gave a shot at



Filed under: Meta — cristiklein @ 01:26

Ceasing under social pressure, the incredible happened today: I opened up my first blog. The knowledge shared by so many other people on the Internet helped me know more, do my work more efficiently, become passionate about computers … now it’s time to give something back to them.

This is my main driving force. I will regularly post here solutions to problems I have found, so as to keep computers a hobby and not just a tool I use at work (thanks to Adi for influencing me in this direction). Here is a small manifesto (or rather a list of things I will laugh about in future):

I will be as neutral as possible and will not launch flame wars. Negative comments, their reasoning and context will be well described. E.g. instead of writing “Git sucks.”, I will rather write “Git does not fit my needs, because …”.)
I will insist more on getting stuff done than status updates. E.g. Instead of a “check out my PPA” post, I will put at the end of a post “Should you want to try the above described solution, save your compile time and use the package from my PPA.” Also, should I not have time for the blog, or should ideas not come to my mind, I will not post “sorry for not posting” posts.

It should be obvious, but just in case you did not notice: if you want to know more about my opinions, personal feelings, fears, doubts etc. … well, I rather discuss that with friends instead of stripping my personality naked in front of the whole world.

Blog at