Code Linux

Undistract v0.2

I have posted a version 0.2 of my attention monitoring software “Undistract”. This release features the following changes:

  • Uses libnotify instead of xosd, which looks a lot better in GNOME
    at least and should work fine cross-desktop.

  • The most drastic action is now to minimize the distracting window
    rather than change virtual desktops, which was quite specific to my
    desktop usage. I have tried to manage the focus with this change too,
    so that the user doesn’t inadvertently send key presses to a different

  • Uses GTK event loop which makes monitoring a lot more efficient.

  • More sophisticated usage of libwnck to determine which windows are
    active at whether they belong to a distracting application.

  • Simplified some of the code and tried to de-jargonize the config file.

You can download it at

Linux Voice Over IP

Wengophone: What’s My SIP Address?

I’ve been using the ever-so-useable WengoPhone VOIP software, and I wanted to see if there was a public SIP address that i could provide to people on other SIP networks. Well, it took me a while to figure out, but there is. Just enter into any SIP phone and you’ll be cooking on gas. I tested this from Ekiga running on another computer and Wengo received the call just like normal.

BTW my Wengo username is ‘werkshy’.

Linux ROOT

Quickfix: libroot-python-dev for Ubuntu Gutsy

Since my last post on building ROOT packages for Ubuntu the resourceful Christian Holm Christensen has got the unofficial Debian/Ubuntu ROOT repository back online. One problem is that due to a dh_python bug in Ubuntu, the libroot-python-dev package (required for PyROOT) is broken for Gutsy (and probably Feisty too), since it depends on python < 2.5. I’ve hacked the ‘control’ file to remove that broken dependency and repacked the .deb file to make a package that is installable and doesn’t break apt.

Download it here:

Steps to create this:

  • Get the libroot-python-dev package from the repository
  • Unpack the .deb
    ar -x libroot-python-dev_5.17.05-3_i386.deb
  • Unpack the control data:
    tar -zxf control.tar.gz
  • Edit the file ‘control’ to fix the dependencies and bump the version number
  • Repack control data:
    tar -zcf control.tar.gz control md5sums postinst prerm
  • Repack the .deb
    ar -r libroot-python-dev_5.17.05-3-quickfix_i386.deb debian-binary control.tar.gz data.tar.gz

I hope to help fix the underlying issue soon but right I’ve got a ton of thesis-related work to plough through so this band-aid will have to do for now.

Update 2007-12-11:
I spent a morning last week tracking down this ROOT Python bug. Turns out there was a file not being deleted during the ‘clean’ stage of the debian package creation which led to a dependency confusion with python versions. New source packages have been uploaded which fix this issue:
deb-src unstable main contrib

Binary packages should be up shortly.

Update 2009-03-02:

Noticed a typo in the re-tarring command, now fixed.

Physics ROOT

Making Pretty ROOT Color Palettes

My friend and colleague (I like him even more since he told me about this!) Segev gave me this information, which he had gleaned from some old posts on ROOTtalk and a lot of experimentation. It’s a technique for setting the color palette of ROOT plots so that, for example, Graph2D with the “COLZ” option doesn’t look like total crap. I have no idea why something like this isn’t used as the default palette in ROOT.

In short, here’s before and after screenshots of the plot.

Default PaletteBefore
New PaletteAfter
Linux Physics ROOT

Building ROOT Packages on Ubuntu Feisty

I read with satisfaction the fact that Cern’s ROOT physics and data analysis framework has finally been integrated into Debian. I assumed that this would lead to easier installation on Ubuntu and in the future, hopefully, ROOT in the Ubuntu repositories. For a brief and happy period there was a third party repository with up-to-date and semi-official ROOT packages.

My hopes were dashed with the news that the Brookhaven machine hosting the repository lost a hard disk and the Ubuntu repository was down. I frequently need access to ROOT packages, so I just recently built .debs from the lastest stable release (5.16.00). Here’s a guide as to how to make it work:


Creating a RedHat 7.2 VMWare Image

Update: I have created a CentOS 2 virtual machine image for
VirtualBox which is available for download

I’ve created a VMWare image of a RedHat 7.2 operating system. I need one for compiling and testing programs since a cluster that I sometimes use runs this aging OS, and programs that I compile on my Ubuntu laptop or the Fedora Core 6 server at the lab don’t work properly on that system.

I would love to redistribute the base image for other people who might require it but unfortunately Red Hat’s trademark protection policy prevents this. I don’t have time to go through the image and remove all the trademark-covered files, so here’s a quick guide to getting a useful system in a short time. By useful, I mean with Subversion, GSL and Boost libraries.

Linux ROOT

Scaling ROOT PostScript Files

I encountered some trouble today printing PostScript files from ROOT at smaller sizes. This is most useful to me because my lab notebook, heretically, is smaller than ‘letter’ size, which I find more convenient for carrying than the huge squared notebooks which seem to be the norm around here. I was looking for a quick way of printing PostScript at 80% scale.


Don’t Define Template Functions In .cpp Files

This is another gotcha from my recent C++ work. When I learned C++ I was taught to put the interface (function declarations) in a header file and the implentation (function definitions) in a .cpp module source file. Some small functions could be written inline in the class declarations, usually just get/set member functions for private data. At one point (or possibly just in C) having if/else statements in a header was not allowed, the compiler complained about branching. I recently realized (about 10 years after everyone else, it seems) that there is actually a very good reason to put implementation of templated functions in the header file.


Mixing Inheritance and Templates in C++

I came across a gotcha today with some C++ code I’m working on. I have an abstract base class for doing interpolation, and when I tried converting it to a template class it stopped working – specifically the derived class could no longer access certain members of the base class.


Slug USB Audio

I use a Linksys NSLU2 (slug) network attached storage device on my home network. The device is great, primarily because it is low power and runs full-fledged Debian GNU/Linux which makes it extremely versatile. I use mine as

  • File server – runs Samba, serves up music, videos and photos to home network
  • Print server – allows wired and wireless PC/Mac/Linux computers to print to the laser printer
  • Backup Server – makes automatic rsync backups of my website
  • Music Server – serves up MP3s from a web interface to play on other computers
  • Music Jukebox – has web interface to play songs through the stereo, using a USB Audio device

All this, and for less than 25W — 14W for the slug, which has no moving parts, and 5W each for 2x320GB USB hard drives.

Update: Tenx chipset USB adapters suck! See the end of the post for more details.