Posted
on April 7, 2009, 5:17 PM,
by David Craddock,
under
Uncategorized.

Volunteers on the OLPC project have developed a low-cost heart rate monitor that can be plugged into the XO laptop, making steps towards an affordable monitoring system for hospitals in developing countries.
For more information on the development, see the: OLPC Goldenstate project. People in the US can currently buy the sensor here; unfortunately there is no international shipping yet in place.
Posted
on March 30, 2009, 10:45 PM,
by David Craddock,
under
Uncategorized.

A common task when setting up an Apache webserver under Linux, is writing a httpd.conf file. The httpd.conf file is the main configuration file for Apache. One of the main reasons to edit the httpd.conf file is to setup virtual hosts In Apache. A Virtual host configuration allows several different domains to be run off a single instance of Apache, on a single IP. Each host is a ‘Virtual host’, and typically has a different web root, log file, and any number of subdomains aliased to it. The virtualhosts are configured in parts of the httpd.conf file that look like this:
<VirtualHost *:80>
ServerName myserver.co.uk
ServerAlias www.myserver.co.uk
ServerAdmin me@myserver.co.uk
DocumentRoot /var/www/html/myserver.co.uk
ErrorLog logs/myserver.co.uk-error_log
CustomLog logs/myserver.co.uk-access_log common
</VirtualHost>
Now on Ubuntu, virutalhosts are made easy. The httpd.conf is split into several files. Each virutalhost has a different file in /etc/apache2/sites-available. When you want to activate a particular vitualhost, you create a symbolic link from /etc/apache2/sites-enabled/mysiteto /etc/apache2/sites-available/mysite (if you wanted to call your site configuration file ‘mysite’). When apache boots up, it loads all the files it can find in /etc/apache2/sites-available/* and that determines which virutalhosts it loads. If there is not a link from /etc/apache2/sites-available/ to your virutalhost file, it won’t load it. So you can easily remove the links in /etc/apache2/sites-available without deleting the actual virutalhost file. Therefore you can easily toggle which virtualhosts get loaded.
CentOS uses a different structure. Everything is lumped into /etc/apache/httpd.conf. So there is no way to easily toggle virutalhosts on/off, and everything is a bit more chaotic. I’ve just had to setup a new CentOS webserver, and I struggled for a bit after being used to ubuntu-server. Here’s a format you can use if you’re in the same boat, and you have to setup httpd.conf files for CentOS:
NameVirtualHost *:80 # this is eseential for for name-based switching
# an example of a simple VirtualHost that serves data from
# /var/www/html/myserver.co.uk to anyone who types in
# www.myserver.co.uk to the browser
<VirtualHost *:80>
ServerName myserver.co.uk
ServerAlias www.myserver.co.uk
ServerAdmin me@myserver.co.uk
DocumentRoot /var/www/html/myserver.co.uk
ErrorLog logs/myserver.co.uk-error_log
CustomLog logs/myserver.co.uk-access_log common</VirtualHost>
</VirutalHost>
# an example of a VirutalHost with apache overrides allowed, this means you can use
# .htaccess files in the servers web root to change your config dynamically
<VirtualHost *:80>
ServerName bobserver.co.uk
ServerAlias www.bobserver.co.uk
ServerAdmin me@bobserver.co.uk
DocumentRoot /var/www/html/bobserver.co.uk
ErrorLog logs/bobserver.co.uk-error_log
CustomLog logs/bobserver.co.uk-access_log common
<Directory />
AllowOverride All
</Directory>
<Directory /secure>
AllowOverride AuthConfig
Order Allow,Deny
Allow from All
</Directory>
</VirtualHost>
# an example of a VirutalHost with apache overrides allowed, and two subdomains
# (mail and www) that both point to the same web root
<VirtualHost *:80>
ServerName fredserver.co.uk
ServerAlias www.fredserver.co.uk
ServerAlias mail.fredserver.co.uk
ServerAdmin me@fredserver.co.uk
DocumentRoot /var/www/html/fredserver.co.uk
ErrorLog logs/fedserver.co.uk-error_log
CustomLog logs/fredserver.co.uk-access_log common
<Directory />
AllowOverride All
</Directory>
<Directory /secure>
AllowOverride AuthConfig
Order Allow,Deny
Allow from All
</Directory>
</VirtualHost>
# .. etc
With the above structure, you can add as many VirutalHosts to your configuration as you have memory to support (typically dozens). Apache will decide on which to choose based on the ‘ServerName’ specified in each VirtualHost section. Just remember to add that all-important NameVirtualHost: *:80 in the beginning.
Once you’ve got your httpd.conf file the way you like it, be sure to test it before you restart apache. If you restart apache and your httpd.conf file has errors in it, Apache will abort the load process. This means that all the websites on your webserver will fail to load. I always use apachectl -t or apache2ctl -t before I restart. That will parse the httpd.conf file and check the syntax. Once that’s OK, then you can issue a /etc/init.d/httpd restart to restart Apache.
Posted
on March 30, 2009, 12:14 AM,
by David Craddock,
under
Uncategorized.

So, about a month ago I got a second-hand microKORG from Ebay. Fiddling around with the preset patches, and creating new patches is great fun, even though I only know a few chords. Recently I plugged it in to my PC via my M-Audio Uno USB->MIDI interface, and soon was using Ableton Live to program drums in time with the microKORG’s arp.
I thought I’d experiment the music libraries available in python, and see if I could send notes to the synth via MIDI. Turns out that the M-Audio Uno is supported under Ubuntu, all you have to do is install the midisport-firmware package. With the help of pyrtmidi, a set of python wrappers around the C++ audio library rtmidi I was able to recieve MIDI signals in realtime from the microKORG, and send them in realtime also. With the help of this old midi file reader/writer library that I found posted to a python mailing list, I’ve made some progress in writing a simple MIDI file player that sends notes to the ‘KORG.
Posted
on March 27, 2009, 11:47 PM,
by David Craddock,
under
Uncategorized.

So, after saying all that stuff about how vimplugin and EasyEclipse was great, I actually started to use the setup heavily, and it started to annoy me.
For one, EE is not a recent build of eclipse, nor does it come with a full set of recent plugins. This makes it annoyingly difficult to use when you want to use more than the set of plugins it packages for you. As far as vimplugin goes, it does not provide the vim integration I thought it might from embedded vim. Not really even close.
What I use now, after lots of trial and error, and at least 4 reinstalls of Eclipse, is a combination of Eclipse 3.4.2, Eclim, (which is the most mature of the free vi-binding plugins around, and actually includes an improved version of the vimplugin previously mentioned), and the latest pydev, Mylyn and Subeclipse.
I’m using it now to refactor a largeish python project, and I’m really appreciating the help it gives me. Definitely worth trying an Eclipse setup similar to this if you’re writing any python apps that are more than small-scale.
Posted
on March 26, 2009, 6:53 PM,
by David Craddock,
under
Uncategorized.
Up until now, I’ve always used the terminal for programming development on my projects. Because I’m so familiar with the advanced text editor vim, I can get a lot done on the command line, and it doesn’t detract away from what is actually going on behind the scenes, as a lot of IDEs seem to do.
However, in reading the book Foundations of Agile Python Development (which I recommend highly), and through working in software houses using IDEs only, I’ve come to realise that I need to gain at least some familiarity with an IDE.
So I’ve decided to try out Eclipse. I fiddled around with the Eclipse version in the Ubuntu 8.10 repositories for a while, with little success. I wanted to install pydev and vimplugin. Pydev is an eclipse python development environment. Vimplugin allows vim keybindings, and can actually embed the gvim editor within Eclipse. I tried for a few hours, but couldn’t get it all working with the stock Eclipse version in the Ubuntu repositories.
So I thought I’d try out EasyEclipse. EasyEclipse bundles a stable version of Eclipse with pydev in its “Easy Eclipse for Python Development” distribution, and that worked a charm. I then installed vimplugin which worked immediately when enabled, and supported embedded VIM mode within Eclipse. In the screenshot below, you should be able to (just about!) see what I mean, gvim is embedded into Eclipse:
