<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Max says... &#187; Web Development</title>
	<atom:link href="http://maxmanders.co.uk/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://maxmanders.co.uk</link>
	<description>thoughts of a web developer</description>
	<lastBuildDate>Tue, 31 Aug 2010 07:25:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Revert to PHP 5.2 in Ubuntu 10.04 (Lucid Lynx)</title>
		<link>http://maxmanders.co.uk/web-development/revert-to-php-5-2-in-ubuntu-10-04-lucid-lynx/</link>
		<comments>http://maxmanders.co.uk/web-development/revert-to-php-5-2-in-ubuntu-10-04-lucid-lynx/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 17:32:08 +0000</pubDate>
		<dc:creator>maxmanders</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://maxmanders.co.uk/?p=174</guid>
		<description><![CDATA[Despite suppressing updates of my LAMP stack, the upgrade to Ubuntu 10.04 ignored that, and as such I now have PHP 5.3.X installed.  Ordinarilly this woud be fine, but one of the open source web applications I work with doesn&#8217;t play well with PHP 5.3.X.  I needed a simple way to revert to a previous [...]]]></description>
			<content:encoded><![CDATA[<p>Despite suppressing updates of my LAMP stack, the upgrade to Ubuntu 10.04 ignored that, and as such I now have PHP 5.3.X installed.  Ordinarilly this woud be fine, but one of the open source web applications I work with doesn&#8217;t play well with PHP 5.3.X.  I needed a simple way to revert to a previous 5.2.X version of PHP.  The version in the Ubuntu 9.10 (Karmic) repositories would do the trick, so it was jsut a case of forcing Ubuntu to honour the 9.10 versions of various PHP packages over the 10.04 versions.</p>
<p>First, we get a list of all the currently installed PHP packages:</p>
<pre class="brush:bash">sudo dpkg -l | grep php &gt; /tmp/php.packages
</pre>
<p>Next we remove the currently installed PHP packages:</p>
<pre class="brush:bash">sudo apt-get remove --purge $(dpkg -l | grep php)
</pre>
<p>Now we need to create an alternative sources list:</p>
<pre class="brush:bash">sed s/lucid/karmic/g /etc/apt/sources.list |\
sudo tee /etc/apt/sources.list.d/karmic.list
</pre>
<p>Having done that, we need to generate an aptitude preferences file for PHP:</p>
<pre class="brush:bash">awk '{print "Package: " $0; print "Pin: release a=karmic\nPin-Priority: 991\n"}' /tmp/php.packages |\
sudo tee /etc/apt/preferences.d/php
</pre>
<p>This preferences file tells aptitude that for each listed package, we want to pin down the installation candidate to that from the Karmic repositories.  We can now install the packages that we previously removed, but this time the versions from the Karmic repositories:</p>
<pre class="brush:bash">sudo apt-get install $(cat /tmp/php.packages | tr "\n" " ")
</pre>
<p>A quick restart of Apache and everything seems to be working with the older version of PHP!</p>
]]></content:encoded>
			<wfw:commentRss>http://maxmanders.co.uk/web-development/revert-to-php-5-2-in-ubuntu-10-04-lucid-lynx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UK Geocoding &#8211; Update</title>
		<link>http://maxmanders.co.uk/development/uk-geocoding-update/</link>
		<comments>http://maxmanders.co.uk/development/uk-geocoding-update/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 16:22:51 +0000</pubDate>
		<dc:creator>maxmanders</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[YQL]]></category>

		<guid isPermaLink="false">http://maxmanders.co.uk/?p=171</guid>
		<description><![CDATA[I&#8217;ve updated the UK Geocoding site to provide better documentation, and a UI for geocoding, in addition to the XML API.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve updated the <a href="http://ukgeocode.maxmanders.co.uk/">UK Geocoding site</a> to provide better documentation, and a UI for geocoding, in addition to the XML API.</p>
]]></content:encoded>
			<wfw:commentRss>http://maxmanders.co.uk/development/uk-geocoding-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UK Geocoding</title>
		<link>http://maxmanders.co.uk/development/uk-geocoding/</link>
		<comments>http://maxmanders.co.uk/development/uk-geocoding/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 12:40:05 +0000</pubDate>
		<dc:creator>maxmanders</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[YQL]]></category>

		<guid isPermaLink="false">http://maxmanders.co.uk/?p=166</guid>
		<description><![CDATA[After a little hard work, I&#8217;m releasing my attempt to address the shortfall in accurate UK geocoding services.  Courtesy of open data provided by Ordnance Survey Open Click-Point, some sed, SQLite, PHP and YQL I&#8217;ve produced a REST API, and a YQL datatable.  I&#8217;ve also written a more thorough account of this by way of [...]]]></description>
			<content:encoded><![CDATA[<p>After a little hard work, I&#8217;m releasing my attempt to address the shortfall in accurate UK geocoding services.  Courtesy of open data provided by Ordnance Survey Open Click-Point, some sed, SQLite, PHP and YQL I&#8217;ve produced a REST API, and a YQL datatable.  I&#8217;ve also written <a title="UK Geocoding" href="http://maxmanders.co.uk/uk-geocode/">a more thorough account</a> of this by way of documenation.</p>
]]></content:encoded>
			<wfw:commentRss>http://maxmanders.co.uk/development/uk-geocoding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>YQL Nutritional Data</title>
		<link>http://maxmanders.co.uk/web-development/yql-nutritional-data/</link>
		<comments>http://maxmanders.co.uk/web-development/yql-nutritional-data/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 19:42:40 +0000</pubDate>
		<dc:creator>maxmanders</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://maxmanders.co.uk/?p=156</guid>
		<description><![CDATA[My todo list has been telling me to play with Yahoo&#8217;s YQL for far too long now, so last night I did something about it.  YQL is a Yahoo SQL-like language that allows developers to easily aggregate data from various disparate data sources without having to go through the rigmarole of writing their own API.  [...]]]></description>
			<content:encoded><![CDATA[<p>My todo list has been telling me to play with Yahoo&#8217;s <a title="YQL on YDN" href="http://developer.yahoo.com/yql/">YQL</a> for far too long now, so last night I did something about it.  YQL is a Yahoo SQL-like language that allows developers to easily aggregate data from various disparate data sources without having to go through the rigmarole of writing their own API.  There is a large selection of base tables that allow the developer to work with e.g. <a href="http://www.flickr.com">Flickr</a> or <a href="http://www.upcoming.org">Upcoming</a>.  There is also a community contributed selection of tables (see <a href="http://datatables.org">datatables.org</a>).  You can contribute to the project by forking the GitHub project and sending a pull request once you&#8217;ve committed changed to your tree.</p>
<p>That&#8217;s exactly what I did last night.  I did some digging and found the UK government&#8217;s data source for nutritional information, the <a title="Composition of Foods" href="http://www.food.gov.uk/science/dietarysurveys/dietsurveys/">&#8220;Composition of Foods&#8221; report</a>.  To use the data, I had to apply for a free <a title="OPSI Click Use Licensing" href="http://www.opsi.gov.uk/click-use/index">Click-Use license</a>.  I didn&#8217;t have to specify what data I was using or how I was going to use it; it seemed more the case that I had to have my name added to a list of people who use government data in some way, shape or form.  Once I&#8217;d munged the data a bit, I created a CSV, and corresponding XML file as described by the DataTables documentation.</p>
<p>You can use my DataTable by querying YQL (or in the YQL-console) like this for example:</p>
<pre class="brush:sql">use "http://maxmanders.co.uk/lab/nutritionals/nutritionals.xml";
select * from nutritionals where name = 'banana';</pre>
]]></content:encoded>
			<wfw:commentRss>http://maxmanders.co.uk/web-development/yql-nutritional-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing With Perl Sockets</title>
		<link>http://maxmanders.co.uk/general/playing-with-perl-sockets/</link>
		<comments>http://maxmanders.co.uk/general/playing-with-perl-sockets/#comments</comments>
		<pubDate>Sun, 12 Oct 2008 17:47:08 +0000</pubDate>
		<dc:creator>maxmanders</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://maxmanders.co.uk/?p=99</guid>
		<description><![CDATA[At work, I have a Snom 360 IP phone that is hooked up to our internal Asterisk PBX.  If I&#8217;m listening to music with my headphones in, I&#8217;m not always aware that my phone is ringing &#8211; some Perl and PHP hacking later, I&#8217;ve got a crude (and work-in-progress) solution. The phone has an internal [...]]]></description>
			<content:encoded><![CDATA[<p>At work, I have a <a href="http://www.snom.com/en/products/snom-360-voip-phone/">Snom 360</a> IP phone that is hooked up to our internal <a href="http://www.asterisk.org/">Asterisk</a> PBX.  If I&#8217;m listening to music with my headphones in, I&#8217;m not always aware that my phone is ringing &#8211; some Perl and PHP hacking later, I&#8217;ve got a crude (and work-in-progress) solution.<span id="more-99"></span></p>
<p>The phone has an internal web server that lets the user customise a number of options.  The one I&#8217;m interested in is &#8216;Action URI&#8217;.  When a call comes through to my phone, I can enter a URI that my phone will request.  I can send arbitrary parameters in the query string, e.g. a message or the phone number of the caller.  My solution involves a PHP script that the phone can request, a simple Perl socket server sitting listening on my laptop, and a simpel Perl Tk script that will open a window to alert me to the call.</p>
<p>The PHP script that my phone requests is quite simple:</p>
<pre class="brush:perl">
// Hostname of machine
$host = 'somehost';
// Port to connect to
$port = '7890';
$timeout = 30;
$message = $_GET['message'];

$socket = fsockopen($host, $port, $errnum, $errstr, $timeout);
if (!is_resource($socket))
{
exit("Cannot connect: " . $errnum . " " . $errstr);
}
else
{
fputs($socket, $message);
}
fclose($socket);
</pre>
<p>This script is called from my phone and connects to the socket server listening on my laptop.  The code for the corresponding socket server follows:</p>
<pre class="brush:perl">
use strict;
use IO::Socket;
use Net::hostent;

my $PORT = 7890;
my $IP = '192.168.0.1';

my $serverSocket = IO::Socket::INET-&gt;new(
    Proto =&gt; 'tcp',
    LocalHost =&gt; $IP,
    LocalPort =&gt; $PORT,
    Listen =&gt; SOMAXCONN,
    Reuse =&gt; 1,
) or die("Cannot create socket: $!\n");

while (my $clientSocket = $serverSocket-&gt;accept())
{
    $clientSocket-&gt;autoflush(1);
    while (&lt;$clientSocket&gt;)
    {
        `/path/to/tk/script/showMessage.pl "$_"`;
    }
    close($clientSocket);
}
</pre>
<p>This Perl script listens in the background for incoming connections and passes any data it receives to a Perl TK script that displays this data in the form of a simple window on display 0:0.  Here&#8217;s the code for th Perl Tk srcript:</p>
<pre class="brush:perl">
use strict;
use Tk;
use Tk::Font;

my $message = $ARGV[0];

my $mainWindow = MainWindow-&gt;new();
$mainWindow-&gt;minsize(qw(500 200));
$mainWindow-&gt;title("Incoming Call");
$mainWindow-&gt;configure(-background =&gt; 'white');

my $font = $mainWindow-&gt;Font(
    -family =&gt; 'Arial',
    -size =&gt; '24',
);

my $acceptButton = $mainWindow-&gt;Button(
    -text =&gt; $message,
    -background =&gt; 'red',
    -command =&gt; \&amp;exit,
    -foreground =&gt; 'white',
    -font =&gt; $font,
);

$acceptButton-&gt;pack(
    -side =&gt; 'bottom',
    -expand =&gt; 1,
    -fill =&gt; 'both'
);

$mainWindow-&gt;withdraw();
$mainWindow-&gt;update();
my $winXPos = int(($mainWindow-&gt;screenwidth - $mainWindow-&gt;width) / 2);
my $winYPos = int(($mainWindow-&gt;screenheight - $mainWindow-&gt;height) / 2);
$mainWindow-&gt;geometry("+$winXPos+$winYPos");
$mainWindow-&gt;deiconify();

MainLoop();
</pre>
<p>There&#8217;s no doubt about it, this combination of scripts is crude, insecure, and really more of a proof of concept.  Nonetheless, it serves my purposes and hopefully can tidy it up as time allows.</p>
]]></content:encoded>
			<wfw:commentRss>http://maxmanders.co.uk/general/playing-with-perl-sockets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hardy and Firefox</title>
		<link>http://maxmanders.co.uk/web-development/hardy-and-firefox/</link>
		<comments>http://maxmanders.co.uk/web-development/hardy-and-firefox/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 17:06:26 +0000</pubDate>
		<dc:creator>maxmanders</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://maxmanders.co.uk/?p=94</guid>
		<description><![CDATA[As I mentioned in my last post, I have had issues getting Firebug working in Firefox 3.0b5.  Unfortunately at the moment Firebug isn&#8217;t compatible with the beta release of Firefox 3.  To be honest, I&#8217;m quite happy with Firefox 2.x.  From what I&#8217;ve read, Firefox 3 is more stable and less memory-hungry that its predecessor, [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in my last post, I have had issues getting Firebug working in Firefox 3.0b5.  Unfortunately at the moment Firebug isn&#8217;t compatible with the beta release of Firefox 3.  To be honest, I&#8217;m quite happy with Firefox 2.x.  From what I&#8217;ve read, Firefox 3 is more stable and less memory-hungry that its predecessor, and it does look nice (especially so according to Mac users).  Unfortunately, these benefits are outweighed by my love of the Firebug extension.  It is, in my opinion, the best debug tool for web developers bar none.  To that end, I&#8217;ve chosen to remove Firefox 3 (and all the bits and bobs that come with it) and install Firefox 2.</p>
<p>A few apt-gets later, I had got rid of Firefox-3 and related packages, and installed Firefox-2, symlinked to /usr/bin/firefox.  However, Firefox-2 still used the profile created by Firefox-3 in my home directory.  I started Firefox from the terminal, with the &#8216;-ProfileManager&#8217; switch.  I created a new profile, renamed default, and renamed my new profile to default.  I then copied my bookmarks and related data from the old profile directory to the new one.  Once this was done, I started Firefox with my new default profile,  installed my favourite plugins and all was good &#8211; Firebug now works like a dream!</p>
]]></content:encoded>
			<wfw:commentRss>http://maxmanders.co.uk/web-development/hardy-and-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving To Dreamhost</title>
		<link>http://maxmanders.co.uk/web-development/moving-to-dreamhost/</link>
		<comments>http://maxmanders.co.uk/web-development/moving-to-dreamhost/#comments</comments>
		<pubDate>Sat, 26 Jan 2008 14:42:56 +0000</pubDate>
		<dc:creator>maxmanders</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://maxmanders.co.uk/web-development/moving-to-dreamhost/</guid>
		<description><![CDATA[After some months of being unhappy with the service from Hostgator, I decided yesterday to move to Dreamhost.  While Hostgator are very affordable and for the most part reliable, the ssh connection was always painfully slow; it took me considerable effort in the beginning to even get ssh access (having been required to justify my [...]]]></description>
			<content:encoded><![CDATA[<p>After some months of being unhappy with the service from Hostgator, I decided yesterday to move to Dreamhost.  While Hostgator are very affordable and for the most part reliable, the ssh connection was always painfully slow; it took me considerable effort in the beginning to even get ssh access (having been required to justify my need to them); the control panel they provided (cPanel) made it difficult to get anything done; and as far as I know I could only host a single site with them.</p>
<p>After a recommendation from a colleague at work, I decided to switch to Dreamhost.  I opted to pay for a year in advance, as the monthly direct-debit payments are a little more expensive otherwise, and there is an initial setup fee if you pay monthly.  The control panel is far more intuitive and a lot easier to use.  I can host as many sites and sub-domains as I like with as many users, email accounts and MySQL databases as I like.  Once I had created the account and switched my name servers with my domain registrar everything was underway.  Within half an hour I had shell access, an initial account with which I could create more accounts, an initial email address of my choosing (thus reducing email outage to a minimum) and a general impression that Dreamhost were a lot more professional and experienced.</p>
<p>Obviously it will take up to 48 hours for the new name server settings to propagate to the root name servers, but despite this within about four hours the name server change had been effective for me.  After about 15 minutes work making changes to my local copy of my WordPress installation and MySQL dump, I rsync-ed everything to the new server, got the database up and running, and job done!</p>
]]></content:encoded>
			<wfw:commentRss>http://maxmanders.co.uk/web-development/moving-to-dreamhost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hosting With Hostgator</title>
		<link>http://maxmanders.co.uk/technology/hosting-with-hostgator/</link>
		<comments>http://maxmanders.co.uk/technology/hosting-with-hostgator/#comments</comments>
		<pubDate>Sat, 19 May 2007 23:54:06 +0000</pubDate>
		<dc:creator>maxmanders</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://maxmanders.co.uk/technology/hosting-with-hostgator/</guid>
		<description><![CDATA[Up until recently my hosting was provided by Fasthosts. For reasons that have nothing to do with the experience I have had with Fasthosts I have had to move to an alternative hosting provider. After some research I opted to go with Hostgator&#8217;s Baby plan. The features included with this hosting plan are excellent for [...]]]></description>
			<content:encoded><![CDATA[<p>Up until recently my hosting was provided by Fasthosts.  For reasons that have nothing to do with the experience I have had with Fasthosts I have had to move to an alternative hosting provider.  After some research I opted to go with Hostgator&#8217;s Baby plan. The features included with this hosting plan are excellent for the small fee of Â£5.00 per month.   And the technical support is brilliant.  I initially had problems getting SSH access, but after raising the issue via the ticket system, I had SSH access within a few emails! <span id="more-46"></span></p>
<p>Once I was certain I had everything I needed from the hosting, I changed the domain name servers and within a day or two my domain name was pointing to the Hostgator server and my MX records were altered accordingly.  The next step &#8211; migrating WordPress!</p>
<p>This is the first time I have migrated content between hosts, and I was reasonably confident I could manage it.  Hostgator did offer a migration service but I thought it would be beneficial to have a shot myself.  I have come to expect reliability and robustness from WordPress, and this migration was no exception &#8211; almost.  I migrated the database between servers without any problems; a simple enough task with the help of PHPMyAdmin.  Next I downloaded my wordpress directory from Fasthosts and uploaded it to Hostgator.  The configuration was changed with Vi, and all was almost well.</p>
<p>Unfortunately WordPress stores the records that represent files (uploads, images etc.) as absolute filesystem paths rather than relative URLs.  As such my uploaded images and other files, despite being on the new server, failed to load in the browser.  I had to manually alter all of the records in the database that referred to filesystem paths so that my uploads were correctly referenced by WordPress.  I&#8217;m sure there must be a patch or plugin to do this, but at the time I couldn&#8217;t find one.</p>
<p>I think now that I have done this migration without too much difficulty I&#8217;ll export my database again, and do a clean install of the latest version of WordPress.  Given that we are now in summer, although the ever changing Scottish weather would have you believe otherwise, my autumnal theme should be updated to a give a more summery feel.  So that&#8217;s my next project, a redesigned &#8216;Max says&#8230;&#8217;!</p>
]]></content:encoded>
			<wfw:commentRss>http://maxmanders.co.uk/technology/hosting-with-hostgator/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
