Tuesday, April 29, 2008

Windows Portable Executable (PE) File Format

Great articles by Matt Pietrek that discuss the PE format in-depth:

Bash 'for' loop examples

I can never remember the syntax for bash for loops:

#!/bin/bash
for i in $( ls ); do
echo item: $i
done

#!/bin/bash
for i in `seq 1 10`; do
echo $i
done

#!/bin/bash
for ((i=100;i<=115;i+=1)); do
echo $i
sleep 1
echo $i > /dev/ttyS1
done

PenguinTV broken on Gutsy

I have been using PenguinTV to download the radio shows I subscribe to. The interface is OK, except:

  • The multiple download feature is broken. You can't select muliple files and get it to download. Sucky!
  • It is totally broken on Ubuntu Gutsy (segfaults). The workaround is:

    export LD_LIBRARY_PATH=/usr/lib/firefox
    export MOZILLA_FIVE_HOME=/usr/lib/firefox
    PenguinTV

Monday, April 28, 2008

HOWTO write a firefox plugin

I'm in the process of writing my first firefox plugin and have recorded my experiences here. The HOWTOs and links I used were:


The most important firefox extensions are:

  • Console2
  • Extension developer's extension. The 'reload all chrome' is useful for stuff that is otherwise cached.

To create the xpi file for publishing you need to change your chrome.manifest to point to the jar file (I keep another chrome.manifest for packaging in the repository so I can just copy it over). The ordinary manifest looks like this:

content myextensionname chrome/content/
skin myextensionname classic chrome/skin/
overlay chrome://browser/content/browser.xul chrome://myextensionname/content/browser_overlay.xul
locale myextensionname en chrome/locale/en/myextensionname/
and the packaging one looks like this:

content myextensionname jar:chrome/myextensionname.jar!/content/
skin myextensionname classic jar:chrome/myextensionname.jar!/skin/
overlay chrome://browser/content/browser.xul chrome://myextensionname/content/browser_overlay.xul
locale myextensionname en jar:chrome/myextensionname.jar!/locale/en/myextensionname/

I use these commands to create the jar and xpi:

cd chrome
zip -r myext.jar * -x \*.svn\*
cd ..
zip myext.xpi install.rdf chrome.manifest chrome/myext.jar

Monday, April 7, 2008

Python memcached

Installing the python bindings for the C libmemcached:
  1. Patch libmemcache

  2. It's been a while since I used patch, so I thought I'd record the command I used. This was a multifile patch, and it applies the patches to all the right files. How cool is that! The -p1 prunes off one slash of the path since my directory was different to the guys who made the patch.

    patch -b -p1 -i libmemcache-1.4.0.rc2.patch

  3. Compile and install libmemcache

  4. sudo apt-get install python-dev

  5. sudo python setup.py install

  6. Download the actual memcached, compile and install

  7. Use it (StringClient for strings, Client uses pickle for other types):


  8. import cmemcache
    a=cmemcache.StringClient(["127.0.0.1:11211"])
    a.set('key', 'value')
    a.get('key')

Sunday, March 30, 2008

Port forwarding to a VMWare NAT-ed OS

I had the need to forward ports to a VMWare machine behind a VMWare NAT. VMware has some good instructions on how to do this. For a linux host you need to edit
/etc/vmware/vmnet8/nat/nat.conf
which is pretty self explanatory.

Friday, March 28, 2008

Openchange: Open source exchange server

I just heard about Openchange, which is a GPL version of MS Exchange server. I think it is awesome people are working on this. Samba, openchange, soon we will be able to replace the entire windows backend with linux without impacting user desktops :)