Fixing the arrow and delete keys in Vim on OS X

One thing that has frustrated me for the past year and half that I have been a Mac user, is the fact that the arrow keys behave strangely in vim’s insert mode. Instead of moving you around the document, they insert an A,B,C or D character followed by a newline. Further more, the delete key doesn’t work. Anyway, I had finally had enough tonight, and so I searched the web for a solution.

The fix turned out to be incredibly easy….

cp /usr/share/vim/vim62/vimrc_example.vim ~/.vimrc

Querying postfix’s queue size

We use Zabbix to monitor our servers, but recently the monitoring agent has been causing some problems of it’s own.

About once a week we send a fairly large mailshot out to our users. Zabbix monitors the sizeof the postfix mail queue on each of our mail servers, and then stores this in its database so it can draw graphs and send us an alert if the mail queue gets too big. But here’s the problem: the action of counting the mail queue itself is quite intensive, and it seems to be locking up the server when it runs.

After some investigation I found (in /etc/zabbix/zabbix_agentd.conf) that we were using the following command to measure the mailq:

[root@mx1 ~]# time mailq | grep -c '^[0-9A-Z]'
real 0m6.590s
user 0m2.144s
sys 0m0.289s

As you can see it took 6.59 seconds to run on a queue size of about 35,000. You could also run the postqueue command and look at the end of the output:

[root@mx1 ~]# time postqueue -p | tail -5
-- 158346 Kbytes in 34621 Requests.
real 0m5.668s
user 0m0.075s
sys 0m0.225s

But, again this takes over 5 seconds for 35,000 mails. So a much quicker way would be to use:

[root@mx1 ~]# time find /var/spool/postfix/deferred/ /var/spool/postfix/active/ /var/spool/postfix/maildrop/ | wc -l
real 0m0.033s
user 0m0.030s
sys 0m0.022s

Using find is over 100 times faster than the other two methods. Each of those command reports a slightly different size of the mailq, but they are pretty close. If anyone knows of an even quicker way to measure the queue size then please let me know!

UK mobile broadband market – September 2007

The last few months have been pretty exciting for anyone interested in mobile broadband in the UK. Until now, T-mobile has lead the way with their ‘Web N Walk’ unlimited data tariffs, but as of the beginning of this month both Three and Vodafone have launched competitive data products.

I believe now is the first time that mobile broadband can actually rival fixed line broad band in terms of price, speed and bandwidth allowance.

NB: For this study, I’m only interested in data packages that can be used with a computer or laptop (not phone only).

Mobile broadband packages

Network Tarrif Speed Inclusive Data Price
T-mobile Web’n’Walk Plus with Phone contract 1.8 mbps 3 GB / month Normal contact + £12.50 per month
T-mobile Web’n’Walk Plus USB Modem / Data card 1.8 mbps 3 GB / month £29 per month
Vodafone Phone contract standard 7.2 mbps? 15 MB / day £1 per day
Vodafone Phone contract + data pack 7.2 mbps? 120 MB / month £ 7.50 per month
Three USB Modem – Broadband Lite *2.8 mbps 1GB / month £10 per month
Three USB Modem – Broadband Lite *2.8 mbps 3GB / month £15 per month
Three USB Modem – Broadband Max *2.8 mbps 7GB / month £25 per month

* Three’s 2.8 mbps area is being rolled out gradually from September 2007 onwards, with national network coverage expected in 2008.

How to disable touchpad tapping (clicking) with Ubuntu


My original post described how to install the qsynaptic utility to fix this problem, but it turns out that the settings are lost every time you restart your computer, so I have found a much quicker fix to disable touchpad tapping. Just add this line to your /etc/X11/xorg.conf:

Option "TapButton1" "0"

If I get some time I will re-visit this issue to see why the other method doesn’t save.

Broken Method – Doesn’t Save Settings!

One thing that always frustrates me when I install Ubuntu on a laptop, is that the default behaviour for the touchpad is to allow “tapping” as a left button click. Perhaps it’s just me with my fat fingers, but I am constantly clicking by accident. However, thankfully it is easy to fix with 4 simple steps.

  1. Simply edit /etc/X11/xorg.conf, find the labelled “Synaptics Touchpad” and add the following line to the end of that section:
    Option "SHMConfig" "on"
  2. Install the qsnaptics utility with
    sudo apt-get install qsynaptics
  3. Now you need to load these new settings by rebooting x windows. To do this press CTRL + ALT + BACKSPACE simultaneously.
  4. Finally, when you have logged back in, press ALT + F2 to bring up the run window. In this type qsynaptics and then click run. This will load qsynaptics where you can disable tapping on the tapping tab.

Cost of mobile roaming set to fall next week

Thanks to new regulation by the European Commission, the cost of making and receiving a mobile phone call while you are abroad in the EU is set to fall from next week. The following table highlights the new roaming prices that UK operators will charge.

Network Making a call Receiving a call
Three 25p per min 15p per min
T-mobile 38p per min 19p per min
Vodafone 38p per min 19p per min
O2 35p per min 18p per min
Orange 38p per min 19p per min

Historic Farnborough

Historic Farnborough is a new site that has been set up to document the history of Farnborough, with everything from its famous Landmarks to its worst eye soars.

Residents past and present are invited to submit their photos, memories and any other historic facts about Farnborough.

My favourite feature is the Gone but not Forgotten section where they keep track of all the old buildings that are being demolised around the town. In the past 100 years over 40 different locations have been re-developed.

Transferring contacts from an N95 to OS X

I needed to transfer my contacts tonight from my old phone (Sony Ericsson K800i) to my new phone (Nokia N95) and since I had no desire to type them in one at a time, I was determined to find a software tool to do it for me. As ever, Apple came to my rescue.

OS X includes a fantastic little utility called iSync, which allows you to keep your phone book synchronised between your Mac and a number of other devices. I had to install a plugin from Nokia in order to get it to recognise the N95, but it picked up the older K800i without any problems.

So, the steps required to sync your phones are as follows:

  1. Enable bluetooth on your mac, and each of your phones.
  2. Pair the devices in the bluetooth settings in system preferences
  3. Install the latest iSync plugin from Nokia for the N95.
  4. Load iSync and go to Devices > Add Device.
  5. It should detect both your phones, so just double click to add them.
  6. Click Sync Devices.

And that’s it!

Connecting OS X to GPRS/3G via T-mobile

I have just got a new Nokia N95 on T-Mobile’s excellent Web N Walk package, which allows you to use your mobile as a modem to provide Internet Access on your laptop.

In order to do this you must first pair you phone with your laptop.

  1. Enable bluetooth on the N95 in Menu > Tools > Bluetooth
  2. Enable bluetooth in OS X: System Preferences > Bluetooth > Settings
  3. Tick “Show bluetooth on the status bar”.
  4. From the bluetooth status menu, select browse device
  5. Click “search” to search for your N95.
  6. Follow the on screen instructions to pair your laptop and phone (you will need to give a passcode which can be anything you like, e.g. 1234)
  7. You may wish to set the laptop as an authorised device in your N95. If so, go to Menu > Tools > Bluetooth > Paired Devices then click “set as authorised”. This will save having to select “allow” everytime you wish to connect your laptop to your phone.

Then you need to setup a dial-up networking connection

  1. Open System Preferences > Bluetooth > Devices
  2. Select your N95 and click configure
  3. Go through the wizard and tick “Access the Internet through your phone’s data connection” followed by “Use a direct, higher speed connection to reach your Internet Service Provider (e.g. GPRS). Then click continue.
  4. Give the following settings. Username: user – Password: one2one – GPRS CID string: *99# – Modem Script: Nokia Infrared

Creating a GPRS/3G Internet Connection on OS X to a Nokia 95 on T-mobile

PHP Array to Text Table Function

Have you ever wanted to display the contents of an array as a table in a command line script? If so, you will have no doubt realised that it takes somewhat longer than it’s html equivalent.

I needed to output some data in a tabular format from a PHP CLI script this week. MySQL does a good job of this with it’s own command line interface, so my first hope was that someone may have replicated this in a PHP function. After a fair bit of searching on Google, I still couldn’t find a suitable tool, so I decided to write my own.

Please note that it is not perfect; e.g. it will break with unpredictable results if the array you pass to it is not correctly formed. However, if you want a quick function that converts an array to a table, then this will certainly help:

<style type="text/css">

* {font-family:courier new;}


// FUNCTION: draw_text_table ($table)
// Accepts an array ($table) and returns a text table
// Array must be of the form:

$table[1]['id']       = '1';
$table[1]['make']     = 'Citroen';
$table[1]['model']    = 'Saxo';
$table[1]['version']  = '1.4 West Coast';

$table[2]['id']       = '2';
$table[2]['make']     = 'Honda';
$table[2]['model']    = 'Civic';
$table[2]['version']  = '1.6 VTi';

$table[3]['id']       = '3';
$table[3]['make']     = 'BMW';
$table[3]['model']    = '3 Series';
$table[3]['version']  = '328 Ci';


function draw_text_table ($table) {
// Work out max lengths of each cell
foreach ($table AS $row) {
$cell_count = 0;
        foreach (
$row AS $key=>$cell) {
$cell_length = strlen($cell);
            if (!isset(
$cell_lengths[$key]) || $cell_length > $cell_lengths[$key]) $cell_lengths[$key] = $cell_length;

// Build header bar

$bar = '+';
$header = '|';

    foreach (
$cell_lengths AS $fieldname => $length) {
$bar .= str_pad('', $length+2, '-')."+";
$name = $i.") ".$fieldname;
        if (
strlen($name) > $length) {
// crop long headings
$name = substr($name, 0, $length-1);
$header .= ' '.str_pad($name, $length, ' ', STR_PAD_RIGHT) . " |";

$output = '';

$output .= $bar."\n";
$output .= $header."\n";
$output .= $bar."\n";

// Draw rows

foreach ($table AS $row) {
$output .= "|";
        foreach (
$row AS $key=>$cell) {
$output .= ' '.str_pad($cell, $cell_lengths[$key], ' ', STR_PAD_RIGHT) . " |";
$output .= "\n";

$output .= $bar."\n";



$table[1]['id']       = '1';
$table[1]['make']     = 'Citroen';
$table[1]['model']    = 'Saxo';
$table[1]['version']  = '1.4 West Coast';

$table[2]['id']          = '2';
$table[2]['make']     = 'Honda';
$table[2]['model']    = 'Civic';
$table[2]['version']  = '1.6 VTi';

$table[3]['id']          = '3';
$table[3]['make']     = 'BMW';
$table[3]['model']    = '3 Series';
$table[3]['version']  = '328 Ci';

'This function takes an array like this:<br /><pre>';


'</pre>And converts it into a text table like this:<br /><pre>';

draw_text_table ($table);

'</pre>Handy for command line output!';