Compiling PIL on Ubuntu Natty

Again, I just lost a precious hour trying to install the Python Imaging Library in a virtual environment on Ubuntu. Even though I had installed the required dependencies, the install script did not detect that freetype and zlib were installed… The culprit: Ubuntu installs the libraries in a very weird directory and you need to set these directories in the PIL setup.py script.

First, install the required dependencies:

apt-get install python-dev \
libfreetype6-dev zlib1g-dev libjpeg8-dev

tar -xvzf Imaging-1.1.7.tar.gz
cd Imaging-1.1.7.tar.gz
vim setup.py

Then, in the setup.py file, set these two variables

ZLIB_ROOT = ("/usr/lib/i386-linux-gnu", "/usr/include")
FREETYPE_ROOT = ("/usr/lib/i386-linux-gnu",
    "/usr/include/freetype2/freetype")

Then just run python setup.py install when in your virtual environment.

Interrogation marks and keyboard layouts

I recently switched from KDE to XFCE because I could not stand KDE bugs anymore. The upside is that XFCE is super simple, fast, and minimalist. The downside is that everything looks “blocky” (as in “lego blocks”).

Anyway, two issues have been bugging me these past few days and I finally got around them today.

Accented characters displayed as interrogation marks in terminal

I write in French and English so I sometimes need to type accented characters on the command line. Unfortunately, after installing XFCE on archlinux, I found that every time I typed an accented character in the terminal, it was replaced by an interrogation mark.

After messing around with my configuration files for three days, I finally found the solution on the archlinux wiki:

# in ~/.bashrc
export LC_ALL=
export LC_COLLATE="C"
export LANG=en_US.utf8

# in /etc/environment
LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"

I believe that only the /etc/environment is necessary, but setting your language in your bash file is considered to be a good practice and other programs might use these variables to determine your locale. Obviously, this is in complement of configuring your /etc/locale.gen file properly.

Keyboard layouts and xfce4-xkb-plugin

This was an extremely annoying bug that probably cost me a few years of my life expectancy in stress. After installing the xfce4-xkb-plugin, I added an extra keyboard layout (English Canada) and I set the layout switch key combination to alt-shift. Unfortunately, the plugin, as other users have reported, has a tendency to “forget” the layout and/or the key combination every once in a while.

The plugin seems to be patched in various distributions, but since archlinux rarely patch programs (which is a generally a good thing), I was stuck with a buggy version.

After some research, I uninstalled the plugin and added this script in /etc/X11/xinit/xinitrc.d/50-keyboard-bart

#!/usr/bin/bash

# Reset keyboard options
setxkbmap -option ""
# Set layout
setxkbmap -layout "us,ca"
# Set international keyboard
setxkbmap -model "pc105"
# Use alt-shift to switch layout
setxkbmap -option "grp:alt_shift_toggle"

If you go down that path, don’t forget to make the script executable. You also need to restart your X session (or you can just execute the script in the current session). The downside is that you do not see your current layout on your panel, but I see this as less cutter :–)

HelloWorld moving to Posterous

After evaluating blogging, micro-blogging, and sort-of-in-the-middle blogging platforms, I decided to leave my self-managed wordpress tech blog and transfer all my posts to posterous.

Although my tech blog started well (they all do), I never found the motivation to post regularly. It is surprising how logging to your own website/blog can be a deterrent. I must say that fighting with the editor was not pleasant and left some scars: publishing code is a pain and line breaks seem to be interpreted randomly in wordpress post editor (it is slightly better in blogger’s post editor, but not perfect).

Still, there are many small things I would like to post regularly so I tried to find a blogging platform that would suit my need. After a big two hours of research, I selected Posterous because:

  1. You can post by email and they seem to be good at it. Talk about a low-barrier to publish :–)

  2. You can import your Facebook posts, but you will still need to edit them if you used fancy html or square tags (e.g., [cc])

  3. You can automatically cross-post to Facebook and Twitter, something that I had to manually perform each time I published a new post.

  4. After signing up, I discovered that it is ridiculously easy to customize your theme… You can select one of their theme, then select “advanced editing” and you get a nice html+css page that you can edit. For example, I increased the font size and changed the syntax highlighting font of the default theme.

Only time will tell if this is enough to vanquish my general apathy when it comes to blogging!