How to install PIL inside a virtualenv in Ubuntu 11.10

To be able to install the Python Imaging Library (PIL) into a virtualenv in Ubuntu 11.10, you will first need to install the following Ubuntu packages:

$ sudo apt-get install python-dev

The previous command will install the development files needed to be able to compile PIL during installation. It will also install the package necessary for PNG support by PIL (zlib1g-dev), as it is a dependency of python-dev package.

If you need JPEG support (most likely you want this):

$ sudo apt-get install libjpeg8-dev

If you need font support:

$ sudo apt-get install libfreetype6-dev

Then activate your virtualenv and install PIL with:

pip install pillow

Pillow is a fork of PIL, with better packaging.

How-to setup Django bash completion in Ubuntu

Steps to enable Django commands auto-completion in the Ubuntu terminal:

  1. Download the shell script from Django’s source repository and save it in your home directory as a hidden file:

    $ wget -O ~/.django_bash_completion.sh https://raw.github.com/django/django/master/extras/django_bash_completion

  2. Add the following line to the end of your .bashrc file in your home folder:

    source $HOME/.django_bash_completion.sh

Now go to your Django project folder (the folder where the manage.py is located) and type like this to launch the Django development web server:

$ python m[press tab to auto-complete manage.py] runs[press tab to auto-complete runserver]

If you make the manage.py executable with chmod u+x manage.py, you can also run the command like this:

$ ./m[tab] runs[tab]

Saves you a few keystrokes :)

virtualenvwrapper setup in Ubuntu

Here are the steps that I use to setup virtualenv and virtualevnwrapper in Ubuntu. It allows for easier updates and we install just one package system wide.

sudo apt-get install python-setuptools
This will do a system wide installation of distribute. This is needed so that we can install the rest of the packages.

easy_install --user virtualenvwrapper
With the --user option, we are installing virtualenvwrapper (and its dependency virtualenv) in .local/

gedit ~/.bashrc

export PATH=$PATH:$HOME/.local/bin
export PROJECT_HOME=$HOME/Dev
source virtualenvwrapper.sh

Add the above to the very bottom of the .bashrc file. Change the PROJECT_HOME variable to point to the place where you keep your development projects.

source ~/.bashrc
Run this or restart the terminal window.

mkproject myproject
Will create a virtual enviroment called myproject and will also create a myproject folder in your project home folder and will make it your current directory.

If you want just the virtualenv to be created, then run:
mkvirtualevn myproject

Go the virtualenvwrapper and virtualenv documentation for more useful commands.

How to disable the login sound in Ubuntu 11.10

Want to disable the login sound in Ubuntu 11.10? Sadly, there is no obvious way to do it from system settings. But it’s not impossible:

  1. From the terminal (press Ctrl+Alt+T to open one) type:cp /etc/xdg/autostart/*.desktop ~/.config/autostart/This will copy the .desktop files from the system folder to your user autostart folder.
  2. Then run:find ~/.config/autostart/ -name "*.desktop" -exec sed -i "s/NoDisplay=true/NoDisplay=false/g" '{}' \;This will change the NoDisplay option from true to false on all those files. This is needed so that the autostart entries show up in the configuration utility.
  3. Click the power menu icon (top right corner of your screen) and choose "Startup Applications...". You will see a "Gnome Login Sound" entry, that wasn't there before. Uncheck it.

Now every time you login to your account, you will not hear those drums :) You can also uncheck other entries you are sure you don't need, If you know what you are doing.

Ubuntu Unity launcher for Aptana Studio

If you are using Ubuntu 11.04 (comes with the Unity interface) together with the Aptana Studio IDE, here is a way to add a working launcher icon for Unity. Aptana/Eclipse don’t yet support the global menu in Unity. With this launcher, the global menu support is deactivated for the aptana application only.

First open a text editor (ex. gedit) and add the following:

#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
StartupNotify=true
Icon[en_US]=/opt/apps/aptana/icon.xpm
Name[en_US]=Aptana Studio 3
Exec=env UBUNTU_MENUPROXY=0 /opt/apps/aptana/AptanaStudio3 -application com.aptana.commandline.launcher.LauncherApplication "$@" > /dev/null 2>&1 &
Name=Aptana Studio 3
Icon=/opt/apps/aptana/icon.xpm

You first need to change some of the paths to match the location where you have the aptana folder in your system. In my system, I have aptana installed in /opt/apps/aptana. Then, save the file with a name like "aptana3.desktop" into a directory out of your way. Just make sure you don't delete this file later on by accident. I saved it inside my aptana folder. Next open the file browser (nautilus), go to the folder where you saved the .desktop file and drag and drop the file into the Unity bar on the left. That's it!

My dream constructed language

While being frustrated with the difficulty of learning Japanese, I came with a random thought. Looking quickly through the list of constructed languages at wikipedia, I couldn’t help but notice that most of them are based on the latin alphabet. This.. is.. boring.. You could do better than that!

You know what would be REALLY interesting? A language that would have the following features:

a) The pronunciation of the Japanese language. About 110 different sounds only and it sounds so cute ;) Compare that to 8000 sounds of the English language.

Image credit: Human Japanese

b) A writing system using simple/quick to write and needing minimal space syllabary symbols, like the ones in the Korean alphabet or Katakana.

Image credit: Wikipedia

c) A consistent and simple grammar system without all those exceptions to the rules that we hate.

Now, that would be a fun language to create, learn and speak. Is it possible? It might even exist already? I don’t know. I don’t even have any idea what I’m just talking about.. :) I can barely speak my own native language correctly. But it’s an interesting though, don’t you think?

Remove APE tags from a MP3 file

When an MP3 file has both an ID3v2 tag and an APE tag, rhythmbox seems to display information from the APE tags. So no matter what changes you do in Easytag, you won’t be able to change the information that rhythmbox displays. So one way to solve this mess, is to delete the APE tags. After searching around the internets, I came across this script that allows you to delete the APE tag of an individual file. Works as expected. To use it paste it in a text editor save it adn then do:
python scriptname.py test.mp3
You can compare the metatags in the file before and after the deletion with:
strings test.mp3 | tail

Ubuntu demo at work turns bad

The day after the Ubuntu 10.04 LTS release I wanted to present the new release to my coworkers (it’s like a tradition, I do it with every release). But it didn’t turn out as good as I would like.

First I loaded the live CD in the pc of one of my coworkers. Well, that pc must have been the slowest pc in the company. So, there where people asking me why it’s taking so long to load and I was trying to explain that it’s because it’s loading the entire freaking OS from the CD. Then, while waiting for it to boot, the Ubuntu logo in plymouth appeared with some weird green borders around the logo. Damn it. The professional image of the distro was gone after that.

When the desktop loaded, the colleague using the computer was trying to see where is the button that can launch the application list. It was funny watching his actions. After he figured out that the “show desktop” button is not it, he noticed the application menu and Firefox at the top panel. He was actually surprised that he could use Firefox in Ubuntu as well. Mozilla Firefox is a strong brand and distributions should think twice when talking about removing the Firefox branding. He started Firefox and opened the company website. A browser bar pops up telling us that some plug-in is not available. The page he loaded required adobe flash. He clicked the pop up, a wizard opened telling us that it would search for suitable plug-ins, but at the end the wizard came up with nothing. This is not a good impression for a first time user.

Later this day, some other colleague asked me to replace the Xandros installation in his Asus 1101HA netbook with Ubuntu, as he told me that he liked how the desktop looked in the new Ubuntu version. Yeeaa! I loaded Ubuntu on his netbook from my USB stick, everything seemed to work fine, till I tried to open a video. It was really slow. What the hell I said, this is an intel atom based netbook. It should run flawlessly. I went to search online for any problems this netbook model had with Ubuntu and it turns out that the netbook is using the infamous Poulsbo chipset and that for Ubuntu 10.04 there where are no drivers available :(

So the day didn’t go as well as I was expecting and linux will have to wait another year at least to conquer the desktop. Have you had any similar bad days?

The little details…

Just noticed today this cool little feature of the Ubuntu 10.04 beta. When a restart is needed after a system upgrade, the shut down panel icon turns red. Cute.

Red shutdown icon in panel

Superscript logos the new fashion?

Spot the similarity of the new ubuntu logo with the fedora one. ^_^

ubuntu and fedora logos