Installing Guest Additions on Debian

March 1st, 2010

Must have root or sudo access.

  1. apt-update;apt-upgrade;
  2. Install required packages with apt-get install build-essential module-assistant;
  3. Configure your system for building kernel modules by running m-a prepare;
  4. Click on Install Guest Additions… from the Devices menu, then run mount /media/cdrom.
  5. Run sh /media/cdrom/VBoxLinuxAdditions-x86.run, and follow the instructions on screen. Choose 64bit if you have installed a 64bit os.

Convert Letter to Number or Number to Letter in Javascript

January 19th, 2010

Number to letterr:
String.fromCharCode( 96 + num );

Letter to number:
letter.toLowerCase().charCodeAt(0) - 96;

Thanks Jeff for pointing this out to me today.

Backup & Restore Postgis DB

January 18th, 2010

To dump:
pg_dump -Fc dbname > dbname.dmp

To restore:
pg_restore -Fc -d dbname dbname.dmp

Basically we create a pg_dump using a custom format. Custom format is left undefined (not required) and as a bonus the data is gziped. In my use of this a 6.5GB db became a 1.5GB dump file.

Thank goes to David Hancock. I stumbled on his post while googling this problem.

Useful Reg Expressions

January 6th, 2010

I’m always forgetting these:

Strip all but alpha numeric characters:

$string = preg_replace('#\W#', '' $string);

Strip all but numbers:

$string = ereg_replace("[^0-9]", "", $string );

Strip all but letters:

$string = ereg_replace("[^A-Za-z]", "", $string );

Zoom & Pan

November 26th, 2009

When zooming and panning with version 3 of the api today, I made the mistake of panning and then zooming.

It seems when I panned the map to a new position and then zoomed from level 11 to 16 it would set the map position way, way, way off the mark.

this.map.panTo( pos );
this.map.setZoom( 11 );

Reversing the order, zooming first and then panning seems to have fixed the problem.

this.map.setZoom( 16 );
this.map.panTo( pos );

.checkResize()

November 26th, 2009

Google maps version 3 is still in beta so as expected it still has a few kinks to work out. Today while working on a project for work I came across one involving showing a map inside a hidden div.

In version 2 of the maps api this was easily fixed by calling .checkResize() when you show your hidden div. .checkResize() was not ported to version 3 of the api, instead we are to use:

google.maps.event.trigger(this.map, 'resize');
 Read the rest of this entry »

Evolution.

November 22nd, 2009

And the design changes again. This time I’m going to work on the design as I blog. That way it might get done! So if you see broken / strange things, its probably me screwing with the site.

Starting again.

August 29th, 2009

Time to start again. New host. New blog.

Temporary theme until I have the energy / time to put into creating my own.