Saturday 6 February 2010
Travel time visualisation using google maps
I've written a web-app using the google maps API which for a given point works out how long it will take to get to any other point in a grid. The times are then plotted using an intensity colour map. Unfortunately due to the nature of the google maps API this is only an academic exercise as the plots take an hour or so to create.
Potential uses could be for would-be house buyers to see what things are in a given travel-time radius.
For example. Search grid over London and surrounding area.

Another example, Sheffield.

LAMP hello world
Quick start/refresher cheat-sheet on setup of fresh LAMP test server on Ubuntu 9.10. Intended for local development only, no security concerns addressed.
Installation
apt-get install apache2 libapache2-mod-php5 php5 mysql-server php5-mysql
Login as root user to create a dedicated user and database.
mysql --user root --password mysql> USE mysql; mysql> CREATE DATABASE testdb; mysql> CREATE USER adam@localhost IDENTIFIED BY 'password1234'; mysql> GRANT ALL ON testdb.* TO adam@localhost; mysql> FLUSH PRIVILEGES;
Login in new user and create a table in the database.
mysql --user adam --password
mysql> USE testdb;
mysql> CREATE table test (c CHAR(255));
mysql> INSERT INTO test (c) VALUES ("hello world");
Write some PHP to read the hello world value. Put it at /var/www/hw.php
<?php
$db_username="adam";
$db_password="password1234";
$db_host="localhost";
$db_name="testdb";
$link = mysql_connect($db_host, $db_username, $db_password);
mysql_select_db($db_name, $link);
$result = mysql_query("SELECT * FROM test", $link);
$row = mysql_fetch_assoc($result);
print_r($row);
mysql_close($link);
?>
Visit http://localhost/hw.php. and you should see the output.
Array ( [c] => hello world )
Sunday 31 January 2010
Broadband line quality. FEC, CRC and HRC errors.
Summary of information from debugging broadband connection drop outs on bethere internet, UK.
- FEC error count not to be worried about.
- CRC error count should be low and will increment slowly.
- HEC error count should be low and will increment slowly. Large number indicates line noise.
Bonus fact. Be support admitted large numbers of DSL drop outs will cause the bebox router to crash (locks up, no response to pings on wireless or wired interfaces). In my case this is a SpeedTouch 585.
Support line staff extremely helpful and changed the upped the error tolerance level as temporary solution till BT sort out the line.
Line noise test. Use corded phone, not cordless into master socket without ADSL filter, using test socket if possible. Dial 17070, option 2. Listen to line. Should be quiet, no crackles, etc. If there is noise contact BT. Full details on noise line from BT.
Line faults can be test online but only if you have the luxury of another Internet connection you can use.
Wednesday 30 December 2009
Linux on a Samsung NC10
I thought this would be another build-your-own airline seat mission, but no, ubuntu karmic koala* 9.10 installed flawlessly on a Samsung NC10 netbook.
Bluetooth, webcam, sound, wifi, power management like screen brightness, sleep, the custom function keys for volume etc. all work out of the box. Even connecting to the internet using my mobile phone as bluetooth modem works with zero faffing around.
*Karmic is currently based on a 2.6.31 kernel if you want to check against your favourite distribution.
There were however some shocking omissions in the default ubuntu install.
apt-get install nmap john aircrack-ng amsn sharutils php5-cli imagemagick emacs
Saturday 28 November 2009
Ubuntu VPN server setup
Want to use VPN to circumvent geo-IP detection on channel 4OD, BBC iPlayer etc whilst abroad?
Here's a quick checklist.
Make sure your UK home network isn't using a standard IP subnet (192.168.0.*, 192.168.1.* or 10.0.0.*). This is important as these addresses tend to allocated for hotel/airport wireless networks and home routers and you can't VPN between addresses on the same subnet. I'm using 10.5.1.*.
Make sure your linux machine has a static address. Edit /etc/network/interfaces if necessary.
auto eth0 iface eth0 inet static address 10.5.1.51 netmask 255.255.255.0 gateway 10.5.1.254
Setup port mapping on your router for port 1723 to the static address of your linux machine.
Get a dyndns account or similar and set it up so can find your machine whilst abroad.
Install the VPN server.
apt-get install pptpd
Edit /etc/pptpd.conf, add the following options. localip is the address of your linux machine, and remoteip is the range of address to allocate to VPN clients.
localip 10.5.1.51 remoteip 10.5.1.27-37
Edit /etc/ppp/pptpd-options, set the DNS server to give to clients. This should be the address of your broadband router.
ms-dns 10.5.1.254
Edit /etc/ppp/chap-secrets, add usernames/passwords. * means allow all client IP address which is probably what you want if roaming abroad.
# client server secret IP addresses joebloggs pptpd password123 *
Restart daemon to apply changes
/etc/init.d/pptpd restart
Edit /etc/sysctl.conf, enable forwarding if necessary. You'll need to reboot to apply this change.
# Uncomment the next line to enable packet forwarding for IPv4 net.ipv4.ip_forward=1
Client setup, example with windows XP, other clients probably similar.
- Network connections - New connection
- Connect to the network at my workplace, Next.
- Virtual Private Nework Connection, Next.
- Company Name, enter something random, Next.
- Hostname, enter your dyndns hostname, Next.
- Finish.
- Select new connect, right click menu, connect.
- Properties, Security, Advanced Custom, Settings..., Select "Allow these protocols", un tick MS-CHAP and tick MS-CHAP v2. OK.
- Enter username password, then Press Connect.
BeBox custom subnet config [solved]
Having trouble changing the default subnet on your BeBox (aka SpeedTouch 585 6.1.4.3)?
Can't figure out why the default DHCP pool of DHCP pool of 192.168.1.64 to 192.168.1.253 doesn't have an edit / delete option?
Just un-tick the "Use DHCP server" option, press Apply, and the edit option will become available. FFS!
Full instructions
- Home network - Interfaces - LocalNetwork - Configure
- Add a new IP for the bebox on custom subnet, e.g. 10.5.1.254
- Un-tick "Use DHCP Server", press Apply, edit button will now be available, make your changes, e.g. 10.5.1.80 - 10.5.1.120
- Tick "Use DHCP Server", press Apply
UK DVB-T audio IDs issue [solved]
Symptoms: Some files sourced from freeview DVB re-encoded using mencoder have silent soundtracks.
Analysis: The MPEG-TS stream often contains additional sountracks, for example "audio commentaries" for blind viewers. mencoder incorrectly selects these tracks, even if switch -alang en is given. It seems mencoder will give up trying to find the requested soundtrack and go with the first one it finds.
Solution: Use the -tsprobe <byte position> option to make mencoder search further into the file than it would by default. Also switch -tskeepbroken appears to help deal with broken files.
Example. Set byte offset to half the size of the file
file=1741_20091125102600.mpg size=$(stat -c %s "$file") size=$(( $size / 2 )); mencoder -tskeepbroken -tsprobe $size -alang en <other options....> $file
Saturday 7 November 2009
Karmic upgrade - bizarre mythweb error [solved]
If you get a weird error like this in your browser when trying to access mythweb it's because the username/password in /etc/apache2/sites-available/mythweb.conf have been defaulted. Just edit the file with your actual username/password and all will be well.
Fatal error: require() [function.require]: Failed opening required 'modules/_shared /tmpl/tmpl/header.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/share /mythtv/mythweb/modules/_shared/tmpl/_errors/fatal.php on line 23
Karmic upgrade - Nova T500 issues [solved]
# Change configuration filename (none .conf extension files now deprecated) mv /etc/modprobe.d/options /etc/modprobe.d/options.confAdd the following lines to /etc/modprobe.d/options.conf if you haven't already.
options dvb-usb-dib0700 force_lna_activation=1 options dvb_usb disable_rc_polling=1Rebuild video for linux DVB. Maybe not strictly necessary.
# get deps apt-get install linux-source linux-headers-$(uname -r) build-essential # prepare linux source (ubuntu install is just an archive in /usr/src. WTF cd /usr/src bunzip2 linux-source-2.6.31.tar.bz2 tar xf linux-source-2.6.31.tar # Change link from /lib rm /lib/modules/2.6.31-14-386/build ln -s /usr/src/linux-source-2.6.31 /lib/modules/2.6.31-14-386/build # Merge in headers (avoids full kernel rebuild but provides configuration etc) cp -rv /usr/src/linux-headers-2.6.31-14-386/* /usr/src/linux-source-2.6.31/ # get sources mkdir /tmp/v4l-dvb-build cd /tmp/v4l-dvb-build hg clone http://linuxtv.org/hg/v4l-dvb cd v4l-dvb make installNow COLD-RESTART, that means power off, remove power, power on. This is the only way to ensure new firmware is reset. A simple reboot will not work, trust me I've tried.
Saturday 24 October 2009
/usr/games/fortune => twitter
Not got anything interesting to say? Why not have your twitter account update from /usr/games/fortune
#!/usr/bin/php
<?php
/**
* Broadcast a twitter
* @param username Username, typically email address
* @param password Password in plaintext
* @param message Message to update, warning, might be truncated
*/
function updateTwitter($username, $password, $message) {
$message=urlencode($message);
$rv=0;
// The twitter API address
$url = 'http://twitter.com/statuses/update.xml';
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "$url");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");
curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if (empty($buffer)) {
$rv=0;
} else {
$rv=1;
}
return $rv;
}
/**
* Use fortune to get a fortune suitable for a twitter update
* @return String, no new lines, 140 characters or less
*/
function getTwitterFortune() {
$TWITTER_CHAR_LIMIT=140;
$found = false;
$rv="";
while ($found == false) {
$cmd="/usr/games/fortune";
$fp=popen($cmd, "r");
$fortune="";
if ($fp) {
while (feof($fp) == false) {
$fortune.=fread($fp, 1024);
}
$fortune = twitterize($fortune);
fclose($fp);
if (strlen($fortune) <= $TWITTER_CHAR_LIMIT) {
$rv = $fortune;
break;
}
}
}
return $rv;
}
/**
* Make text suitable for twitter update.
* Single line, no tabs or other crazy characters etc.
* $param input Input line
* @return Twitterized text
*/
function twitterize($input) {
$output="";
for ($i = 0; $i < strlen($input); $i++) {
$c = $input[$i];
if (preg_match("/[A-Za-z0-9\.\-\:\ \'\"]/", $c)) {
$output .= $c;
} else {
$output .= " ";
}
}
return $output;
}
updateTwitter("mrhorse@horse.com", "ilikehorses", getTwitterFortune());
?>
Tuesday 4 August 2009
Disc burn error 0xFFFFFFCA [SOLVED]
I keep getting "Disc burn error 0xFFFFFFCA" on Mac OS 10.5 Leopard.
The cause was that I didn't have read access to all the files that I was trying to burn.
If you need to change this: Ctrl-Click on the file -> get info -> Sharing and permissions.
Monday 27 July 2009
Alphabet according to google
Noticed how google tries to auto-complete your search as you're typing...

Here are the most popular words by letter and number.
| a | 718,000,000 | ask |
| b | 163,000,000 | bt |
| c | 102,000,000 | channel 4 |
| d | 483,000,000 | dell |
| e | 485,000,000 | ebay |
| f | 718,000,000 | |
| g | 1240,000,000 | games |
| h | 364,000,000 | hotmail |
| I | 998,000,000 | images |
| j | 846,000,000 | jobs |
| k | 245,000,000 | kiss |
| l | 134,000,000 | last minute |
| m | 955,000,000 | msn |
| n | 3,190,000,000 | news |
| o | 1,130,000,000 | office |
| p | 413,000,000 | paypal |
| q | 227,000,000 | quotes |
| r | 192,000,000 | radio 1 |
| s | 269,000,000 | sky |
| t | 218,000,000 | |
| u | 232,000,000 | ups |
| v | 120,000,000 | virgin |
| w | 415,000,000 | weather |
| x | 258,000,000 | xbox |
| y | 2,160,000,000 | yahoo |
| z | 22,500,000 | zara |
| 0 | 5,030,000,000 | 2 |
| 1 | 386,000,000 | 118 |
| 2 | 7,050,000,000 | 24 |
| 3 | 1,060,000,000 | 300 |
| 4 | 559,000,000 | 4 music |
| 5 | 1,320,000,000 | 5 music |
| 6 | 349,000,000 | 6 music |
| 7 | 8,3200,000 | 7 pounds |
| 8 | 148,000,000 | 888 |
| 9 | 410,000,000 | 9 11 |
Sunday 12 July 2009
Enabling PHP system calls
If you're struggling to enable any of the functions (system, exec, popen etc) by disabling safe mode, then you're going down the wrong path. You need to change the disabled_functions key in php.ini instead.
; This directive allows you to disable certain functions for security reasons. ; It receives a comma-delimited list of function names. This directive is ; *NOT* affected by whether Safe Mode is turned On or Off. disable_functions = system,dl,passthru,chown,popen,proc_open
Friday 15 May 2009
Underworld series of films
Underworld (2003)
Underworld: Evolution (2006)
Underworld: Rise of the Lycans (2009)

Tuesday 5 May 2009
nuvexport in ubuntu jaunty 9.04
# Sources / dependencies svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg apt-get install libgsm1-dev libvorbis-dev libxvidcore4-dev libfaac-dev libmp3lame-dev libx264-dev libfaad-dev libtheora-dev libsdl1.2-dev # Configure/build ./configure --enable-gpl --enable-postproc --enable-pthreads --enable-x11grab --enable-libdc1394 --enable-libfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree make # Install checkinstall --fstrans=no --install=yes --pkgname=ffmpeg --pkgversion "3:0.svn`date +%Y%m%d`-12ubuntu3" --default Nuvexport changes required in /usr/share/nuvexport/export/ffmpeg/MP4.pm * remove -slice option * remove -chroma option * remove -title option