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;}
</style>

<?

/*
//////////////////////////////////////////////////////
// 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);
            
$cell_count++;
            if (!isset(
$cell_lengths[$key]) || $cell_length > $cell_lengths[$key]) $cell_lengths[$key] = $cell_length;
        }    
    }

    
// Build header bar

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

    foreach (
$cell_lengths AS $fieldname => $length) {
        
$i++;
        
$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";

    return
$output;

}

$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';


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

var_dump($table);

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

echo
draw_text_table ($table);

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

?>