nVidia driver on Ubuntu 12.04

For whatever reason, the “Additional Drivers” tool on Ubuntu refuses to install the binary nVidia driver on my machine. Thus I have to do it manually via the following commands.

sudo apt-get install nvidia-current-updates nvidia-settings-updates



Binary Radeon Driver on Ubuntu 12.04

The “Additional Drivers” tool that ships with Ubuntu has always been unreliable. I’ve never been able to successfully install the binary Radeon drivers, and have had to resort to installing it manually every time!

The instructions are based on what was presented at https://help.ubuntu.com/community/BinaryDriverHowto/ATI

sudo apt-get install libqtgui4 dh-make dh-modaliases execstack lib32gcc1 libc6-i386

sudo sh amd-driver-installer-12-4-x86.x86_64.run –buildpkg Ubuntu/precise

sudo dpkg -i –auto-deconfigure *.deb

sudo aticonfig –initial

Building a Zero MQ application on OS X

I’ve been trying to build a self-contained app bundle that uses Zero MQ on OS X. After spending a day with py2app on OS X, these are the steps I had to take.

  1. Install homebrew. http://mxcl.github.com/homebrew/
  2. Then install the latest version of Python via home brew. This is necessary as py2app doesn’t makes a partially redistributable apps if you’re using the system python.
  3. Install Zero MQ via home brew.
  4. Install pyzmq and py2app, using the easy_install that’s installed via home brew. This is normally located in /usr/local/share/python.

To generate an app bundle, ensure you add the flags –package zmq or else the resulting app bundle will not run. I’m told this is because py2app may occasionally require a helping hand with resolving dependencies.

Python Screen Grab Code

The following code listing is for a cross platform method for grabbing the screen in Python. It uses PIL on Windows, and ImageMagick on other platforms.

import PIL
import os
import platform

def grab_screen(fname):
    if platform.system() == 'Windows':
        PIL.ImageGrab.grab().save(fname, "JPEG")
        cmd = "import -window root %s" % fname

Tightening Up EC2 Security

An EC2 instance is configured with very tight firewall rules out of the box, allowing access only to port 22 (SSH) and forcing you to log-in using your RSA private key. Nevertheless, I discovered that my instance was subject to a brute force attack from someone in the U.A.E.

They didn’t manage to log in, but it make me think of locking down my EC2 instance. The easiest thing to do is to install Fail2Ban

  1. sudo apt-get install fail2ban
  2. Edit /etc/fail2ban/jail.conf and modify the destemail line to point to your email address.
  3. Restart the fail2ban service. sudo service fail2ban restart

You could always tweak the parameters to your liking but I was satisfied with the default fail2ban parameters.

NTFS short file name generation

During the week, I discovered that the product I was working on appeared to slow down dramatically after the dataset reached a certain size (approximately 150,000 items). This was worrying, as we’re aiming to be “enterprise” ready and need to be able to process millions of items. In addition to that, we already had customers far more items than that and yet they had not reported such an issue.

After some in depth investigation involving a profiler, it turned out that our web service was spending >90% of its time on 1 line of code – this line created a file in a directory to store some binary data that was sent from the client. It wasn’t an I/O issue as the disk was hardly thrashing and the next line of code that actually wrote the data to the file was fast, i.e. <0.001% of CPU time.

It turned out that this was due to the way the file system worked. Windows automatically creates a MS-DOS short file name to go with each file. When there are many files in a single directory, the time it takes to generate a unique short file name grows. As we had more than 200,000 files in the directory, it was obvious that the hashing algorithm struggling. This would explain the huge CPU usage and the long file creation time.

To fix this, we disabled short file name generation by bringing up the command prompt and typing in the following command:

fsutil.exe behavior set disable8dot3 1

Microsoft cautions that this could break compatibility with older 16 bit applications that rely on short file names. Given that most machines are 64 bit capable and the days of 32 bit applications are numbered, I think it’s a risk is sufficiently minimal 🙂

Management vs Leadership

“Men, we need to take out that machine gun nest. Jones, you go first.” – Management

“Men, we need to take out that machine gun nest. Follow me.” – Leadership

There is a significant difference between leadership and management.