<?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>Jamie Thompson</title>
	<atom:link href="http://jamiethompson.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://jamiethompson.co.uk</link>
	<description>Web Developer</description>
	<lastBuildDate>Sun, 30 May 2010 21:33:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Code-Point Open &#8211; Northern Ireland Addendum</title>
		<link>http://jamiethompson.co.uk/web/2010/05/30/code-point-open-northern-ireland-addendum/</link>
		<comments>http://jamiethompson.co.uk/web/2010/05/30/code-point-open-northern-ireland-addendum/#comments</comments>
		<pubDate>Sun, 30 May 2010 21:19:47 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[geocoding]]></category>
		<category><![CDATA[postcode]]></category>

		<guid isPermaLink="false">http://jamiethompson.co.uk/?p=548</guid>
		<description><![CDATA[
In April 2010 Ordnance Survey released The Code-Point Open dataset under a licence compatible with the Creative Commons Attribution Licence. The dataset locates, by OSGB grid reference every postcode unit in England, Scotland and Wales. Northern Ireland is missing. You can read more about the limitations of the Code-Point Open dataset in my previous post
All [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://jamiethompson.co.uk/wp-content/uploads/2010/05/cpo_ni.jpg" alt="Code-Point Open Northern Ireland" title="Code-Point Open Northern Ireland" width="530" height="190" class="alignnone size-full wp-image-559" /></p>
<p>In April 2010 Ordnance Survey released The Code-Point Open dataset under a licence compatible with the Creative Commons Attribution Licence. The dataset locates, by OSGB grid reference every postcode unit in England, Scotland and Wales. Northern Ireland is missing. You can read more about the limitations of the Code-Point Open dataset in <a href="http://jamiethompson.co.uk/web/2010/05/29/the-problem-with-code-point-open-from-ordnance-survey/">my previous post</a></p>
<p>All is not lost though. The Northern Ireland Statistics and Research Agency (NISRA) provide the necessary data. As far as I can tell this is freely reusable under the terms of the <a href="http://www.nationalarchives.gov.uk/information-management/our-services/click-use.htm">Click-Use PSI Licence</a>.</p>
<p>NISRA provide the data in MapInfo or ESRI Shapefile format. The coordinates are in <a href="http://en.wikipedia.org/wiki/Irish_grid_reference_system">Irish Grid Reference</a> format. For ease of use I have re-exported the data as a single CSV file.</p>
<table>
<thead>
<tr>
<th>Column</th>
<th>Length</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>7-8</td>
<td>Postcode</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td>Active</td>
</tr>
<tr>
<td>3</td>
<td>6</td>
<td>OSI Easting (X)</td>
</tr>
<tr>
<td>4</td>
<td>6</td>
<td>OSI Northing (Y)</td>
</tr>
</tbody>
</table>
<p><a href="http://geo.jamiethompson.co.uk/download/nisra_cpd_points_may08.csv.zip">Download the CSV</a></p>
<p>Reproduced under the terms of the Click-Use PSI Licence.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2010/05/30/code-point-open-northern-ireland-addendum/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>The Problem With Code-Point Open From Ordnance Survey</title>
		<link>http://jamiethompson.co.uk/web/2010/05/29/the-problem-with-code-point-open-from-ordnance-survey/</link>
		<comments>http://jamiethompson.co.uk/web/2010/05/29/the-problem-with-code-point-open-from-ordnance-survey/#comments</comments>
		<pubDate>Fri, 28 May 2010 23:17:43 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[geocoding]]></category>
		<category><![CDATA[postcode]]></category>

		<guid isPermaLink="false">http://jamiethompson.co.uk/?p=512</guid>
		<description><![CDATA[
Before I begin, let me just say that decision of Ordnance Survey to release a whole bunch of their data into the public domain is a massive leap in the right direction.  The number of freely available datasets is vast, but what I&#8217;m most interested in is the Code-Point Open dataset.
Code-Point Open purports to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://jamiethompson.co.uk/wp-content/uploads/2010/05/os_opendata.jpg" alt="OS Code-Point Open Data" title="OS Code-Point Open Data" width="530" height="190" class="alignnone size-full wp-image-524" /></p>
<p>Before I begin, let me just say that decision of Ordnance Survey to release a whole bunch of their data into the public domain is a massive leap in the right direction.  The number of <a href="https://www.ordnancesurvey.co.uk/opendatadownload/products.html">freely available datasets</a> is vast, but what I&#8217;m most interested in is the <a href="http://www.ordnancesurvey.co.uk/oswebsite/products/code-point-open/index.html">Code-Point Open</a> dataset.</p>
<p>Code-Point Open purports to be a dataset containing the geographical location of every postcode unit in the United Kingdom. Released into the public domain under a licence compatible with the Creative Commons Attribution 3.0 Licence, it sounds like exactly what we&#8217;ve all been waiting/campaigning for since literally forever. Postcode geodata without the Royal Mail PAF file price tag.</p>
<h2>Too Good to be True?</h2>
<p>Unfortunately yes. The Code-Point Open dataset is advertised with the bold statement that <a href="http://www.ordnancesurvey.co.uk/oswebsite/products/code-point-open/index.html">&#8220;Code-Point Open locates every postcode unit in the UK with precision&#8221;</a>. Unfortunately this is simply untrue, and as much as it pains me to point this out, they&#8217;ve fallen at the first hurdle. The reason? Northern Ireland, The Channel Islands and The Isle of Man are all missing.</p>
<p>They immediately go on to state:</p>
<blockquote><p>There are approximately 1.7 million postcode units in England, Scotland and Wales. Each postcode unit, such as KY12 8UP or PO14 2RS, contains an average of fifteen adjoining addresses.</p>
<p>Northern Ireland postcodes are not available with Code-Point Open.</p></blockquote>
<p>The omission of Channel Islands and The Isle of Man is forgiveable. Technically they&#8217;re not a part of the UK even though they&#8217;re covered by Royal Mail&#8217;s postcode system. There is absolutely no way however that Code-Point Open can be deemed a full &#8220;UK&#8221; dataset with Northern Ireland (BT postcodes) missing.</p>
<p>For those of you for whom geography is not a strong-point, let me clarify (political correctness aside). England + Scotland + Wales == Great Britain. Great Britain + Northern Ireland == The United Kingdom.</p>
<p>Let&#8217;s take a look at how the Open offering stacks up against the commercial product</p>
<table>
<thead>
<tr>
<th>Data element</th>
<th>Code-Point Open</th>
<th>Code-Point</th>
</tr>
</thead>
<tbody>
<tr>
<td>Coverage</td>
<td align="center">GB</td>
<td align="center">UK</td>
</tr>
<tr>
<td>Cost</td>
<td align="center">Free</td>
<td align="center">£5,852.75*</td>
</tr>
<tr>
<td  >Postcode unit</td>
<td align="center">√</td>
<td align="center">√</td>
</tr>
<tr>
<td  >Eastings</td>
<td align="center">√</td>
<td align="center">√</td>
</tr>
<tr>
<td  >Northings</td>
<td align="center">√</td>
<td align="center">√</td>
</tr>
<tr>
<td  >Positional quality indicator</td>
<td align="center">√</td>
<td align="center">√</td>
</tr>
<tr>
<td  >PO box indicator</td>
<td align="center">&nbsp;</td>
<td align="center">√</td>
</tr>
<tr>
<td  >Total number of delivery points</td>
<td align="center">&nbsp;</td>
<td align="center">√</td>
</tr>
<tr>
<td  >Delivery points</td>
<td align="center">&nbsp;</td>
<td align="center">√</td>
</tr>
<tr>
<td  >Domestic delivery points</td>
<td align="center">&nbsp;</td>
<td align="center">√</td>
</tr>
<tr>
<td  >Non-domestic delivery points</td>
<td align="center">&nbsp;</td>
<td align="center">√</td>
</tr>
<tr>
<td  >PO box delivery points</td>
<td align="center">&nbsp;</td>
<td align="center">√</td>
</tr>
<tr>
<td  >Matched address premises</td>
<td align="center">&nbsp;</td>
<td align="center">√</td>
</tr>
<tr>
<td  >Unmatched delivery points</td>
<td align="center">&nbsp;</td>
<td align="center">√</td>
</tr>
<tr>
<td  >NHS regional health authority code</td>
<td align="center">√</td>
<td align="center">√</td>
</tr>
<tr>
<td  >NHS health authority code</td>
<td align="center">√</td>
<td align="center">√</td>
</tr>
<tr>
<td  >Country code</td>
<td align="center">√</td>
<td align="center">√</td>
</tr>
<tr>
<td  >Administrative county code</td>
<td align="center">√</td>
<td align="center">√</td>
</tr>
<tr>
<td  >Administrative district code</td>
<td align="center">√</td>
<td align="center">√</td>
</tr>
<tr>
<td  >Administrative ward code</td>
<td align="center">√</td>
<td align="center">√</td>
</tr>
<tr>
<td  >Postcode type</td>
<td align="center">&nbsp;</td>
<td align="center">√</td>
</tr>
</tbody>
</table>
<p>* £5,852.75 is based on the 101+ terminal licence (which would be the licence required for web use and comes without a discount for non-commercial use)</p>
<h2>In Conclusion</h2>
<p>In my opinion Code-Point Open is little more than a token effort. Code-Point Open <em>can</em> be used to freely and legally locate postcodes in England, Scotland and Wales. Channel Islands (JE and GY), Isle of Man (IM) and Northern Ireland (BT) postcodes are all entirely missing from the dataset, and for this reason It is not a viable option for commercial use or any application where you don&#8217;t want to exclude a sizeable portion of the UK population (just over 2 million people according by my Wikipedia based caclulations)</p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2010/05/29/the-problem-with-code-point-open-from-ordnance-survey/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Creating MySQL Dates From Integer day, month and year columns</title>
		<link>http://jamiethompson.co.uk/web/2010/05/21/creating-mysql-dates-from-integer-day-month-and-year-columns/</link>
		<comments>http://jamiethompson.co.uk/web/2010/05/21/creating-mysql-dates-from-integer-day-month-and-year-columns/#comments</comments>
		<pubDate>Fri, 21 May 2010 19:00:17 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://jamiethompson.co.uk/?p=467</guid>
		<description><![CDATA[Granted, this is hardly a common occurrence, but recently I&#8217;ve had need to work with a database table that for historical reasons stores dates in three separate integer columns, one each for day, month and year. The need for special intervention here depends very much on your data, and I&#8217;m assuming that if you&#8217;re reading [...]]]></description>
			<content:encoded><![CDATA[<p>Granted, this is hardly a common occurrence, but recently I&#8217;ve had need to work with a database table that for historical reasons stores dates in three separate integer columns, one each for day, month and year. The need for special intervention here depends very much on your data, and I&#8217;m assuming that if you&#8217;re reading this your powerless the change the actual data structure, otherwise you would. And that&#8217;s okay.</p>
<p>If your year columns are YYYY and your month and day columns are zero padded then your solution is an easy one. Simply concatenate the values together using MySQL&#8217;s CONCAT_WS function (concatenate with separator).</p>
<pre class="brush: sql">
SELECT CONCAT_WS('-', '2001', '01','31')
--> '2001-01-31'
</pre>
<p>If this isn&#8217;t the case you could deal with the problem in code, using PHPs famously forgiving strtotime function for example, but my <abbr title="Obsessive Compulsive Disorder">OCD</abbr> got the better of me and I decided to revisit MySQL&#8217;s built in <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html">date and time functions</a></p>
<h2>An Elegant Solution</h2>
<p>The solution I found is to use the STR_TO_DATE function with the CONCAT_WS function. That way, even if the date parts aren&#8217;t correctly formatted as in the following example (2 digit year, 1 digit month), STR_TO_DATE will correctly interpret the string &#8216;1-1-31&#8242; and return a datetime value of &#8216;2001-01-31&#8242;. This also has the advantage of being an actual DATETIME value rather than a string.</p>
<pre class="brush: sql">
SELECT STR_TO_DATE(CONCAT_WS('-',1,1,31),'%Y-%m-%d') AS date
--> '2001-01-31'
</pre>
<p>Obviously, this is a solution to a problem that shouldn&#8217;t exist, but that&#8217;s just how we roll.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2010/05/21/creating-mysql-dates-from-integer-day-month-and-year-columns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yoda Syntax &#8211; A Backwards Design Pattern for If Statements</title>
		<link>http://jamiethompson.co.uk/web/2010/05/20/yoda-syntax-a-php-design-pattern-for-if-statements/</link>
		<comments>http://jamiethompson.co.uk/web/2010/05/20/yoda-syntax-a-php-design-pattern-for-if-statements/#comments</comments>
		<pubDate>Thu, 20 May 2010 15:00:58 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jamiethompson.co.uk/?p=483</guid>
		<description><![CDATA[
Sometimes the penny drops and you realise there&#8217;s a childishly simple solution to a problem that&#8217;s been bugging you for years. And no, I&#8217;m not talking about my wife, I&#8217;m talking about Yoda Syntax.
Have you ever spent far too long hunting down an impossible bug in your PHP only to eventually track it down to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://jamiethompson.co.uk/wp-content/uploads/2010/05/yoda_syntax.jpg" alt="Yoda Syntax" title="Yoda Syntax" width="530" height="190" class="alignnone size-full wp-image-486" /></p>
<p>Sometimes the penny drops and you realise there&#8217;s a childishly simple solution to a problem that&#8217;s been bugging you for years. And no, I&#8217;m not talking about my wife, I&#8217;m talking about Yoda Syntax.</p>
<p>Have you ever spent far too long hunting down an impossible bug in your PHP only to eventually track it down to a typo in an if statement. Chances are it was a misplaced &#8216;=&#8217;.</p>
<h2>Named must your fail be before banish it you can</h2>
<p>We all do it, and more often than we&#8217;d probably like to admit. Unless you don&#8217;t, in which case go pat yourself on the back, you&#8217;re a PHP rockstar. But as a simplified example say you wanted to write the following rather pointless function:</p>
<pre class="brush: php">
function is_it_red($colour) {
    if ($colour == 'red') {
         return true;
    }
}
</pre>
<p>but what you ended up writing was</p>
<pre class="brush: php">
function is_it_red($colour) {
    if ($colour = 'red') {
         return true;
    }
}
</pre>
<p>And as you know, whatever you pass into the second function (because you&#8217;re accidentally performing a variable assignment rather than testing for equality) it will return true.<br />
Obviously this is an oversimplified example, but typos like this nestled inside large classes can prove hair-removingly difficult to track down.</p>
<h2>Help you I can, yes</h2>
<p>The solution to this is simply to alter the way you write if statements:</p>
<pre class="brush: php">
function is_it_red($colour) {
    if ('red' == $colour) {
         return true;
    }
}
</pre>
<p>It looks odd, yeah, and you might have seen other people writing their if statements backwards in the past and wondered why. But the benefit of this is striking, and so simple that I&#8217;m left wondering why I never thought of it before.</p>
<p>Quite simply, if you make a typo and write the following:</p>
<pre class="brush: php">
function is_it_red($colour) {
    if ('red' = $colour) {
         return true;
    }
}
</pre>
<p>You will cause a big nasty syntax error that you simply cannot fail to notice.</p>
<p><strong>Parse error: syntax error, unexpected &#8216;=&#8217; in /var/www/vhosts/example.com/httpdocs/what_colour_is_it.php</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2010/05/20/yoda-syntax-a-php-design-pattern-for-if-statements/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Streetview Postcode Thumbnails</title>
		<link>http://jamiethompson.co.uk/web/2010/05/19/google-streetview-postcode-thumbnails/</link>
		<comments>http://jamiethompson.co.uk/web/2010/05/19/google-streetview-postcode-thumbnails/#comments</comments>
		<pubDate>Wed, 19 May 2010 19:35:23 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[geocoding]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[postcode]]></category>
		<category><![CDATA[Streetview]]></category>

		<guid isPermaLink="false">http://jamiethompson.co.uk/?p=457</guid>
		<description><![CDATA[Following my explorations of Google&#8217;s undisclosed Street View Images API, I&#8217;ve put together a handy little webservice that mashes up postcode geodata with the Streetview Images API.
It&#8217;s handy in that it let&#8217;s you directly request a streetview thumbnail with nothing more than a postcode. The format of the request looks like this:

http://geo.jamiethompson.co.uk/streetview/[POSTCODE]_[WIDTH]x[HEIGHT].jpg

As far as the [...]]]></description>
			<content:encoded><![CDATA[<p>Following my explorations of Google&#8217;s undisclosed <a href="/web/2010/05/15/google-streetview-static-api/">Street View Images API,</a> I&#8217;ve put together a handy little webservice that mashes up <a href="/projects/2010/04/30/an-open-free-uk-postcode-geocoding-web-service/">postcode geodata</a> with the Streetview Images API.</p>
<p>It&#8217;s handy in that it let&#8217;s you directly request a streetview thumbnail with nothing more than a postcode. The format of the request looks like this:</p>
<p><code></p>
<p>http://geo.jamiethompson.co.uk/streetview/[POSTCODE]_[WIDTH]x[HEIGHT].jpg</p>
<p></code></p>
<p>As far as the postcode goes either strip out the space or escape it. The maximum dimensions are 416 x 208 pixels.</p>
<p><strong>Example:</strong><br />
<a href="http://geo.jamiethompson.co.uk/streetview/SW1W9TQ_416x208.jpg">http://geo.jamiethompson.co.uk/streetview/SW1W9TQ_416&#215;208.jpg</a><br />
<img src="http://geo.jamiethompson.co.uk/streetview/SW1W9TQ_416x208.jpg" /></p>
<p>As you reduce the thumbnail dimensions the image gets centre cropped accordingy. For the least distortion it&#8217;s best to use a very small portion cropped out of the center as Google do with the streetview thumbnails on Google Maps.</p>
<p>I&#8217;m interested in possibly taking this further with canvas and JavaScript. I&#8217;m fairly sure that if  the maths behind it were figured out you could, via cylindrical projection, un-distort the panorama to provide a natural 360 degree panorama.</p>
<p>That&#8217;s one for the todo list though.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2010/05/19/google-streetview-postcode-thumbnails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Expanding Short URLs with PHP: expand_url PHP function</title>
		<link>http://jamiethompson.co.uk/web/2010/05/18/expanding-short-urls-with-php-expand_url-php-function/</link>
		<comments>http://jamiethompson.co.uk/web/2010/05/18/expanding-short-urls-with-php-expand_url-php-function/#comments</comments>
		<pubDate>Tue, 18 May 2010 01:59:31 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jamiethompson.co.uk/?p=430</guid>
		<description><![CDATA[
URL shortening services work by redirecting a users browser from the shortened URL to the actual target URL. Some of these services provide means of reversing the shortening process. Some provide API methods for this.
The following function will take a shortened URL, from any service, and return the original URL. As it works by inspecting [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://jamiethompson.co.uk/wp-content/uploads/2010/05/301.jpg" alt="PHP Short URL Expander Function" title="PHP Short URL Expander Function" width="530" height="190" class="alignnone size-full wp-image-433" /></p>
<p>URL shortening services work by redirecting a users browser from the shortened URL to the actual target URL. Some of these services provide means of reversing the shortening process. <a href="http://code.google.com/p/bitly-api/wiki/ApiDocumentation#/v3/expand">Some</a> provide API methods for this.</p>
<p>The following function will take a shortened URL, from <strong>any</strong> service, and return the original URL. As it works by inspecting the HTTP redirect headers it is 100% service independent, and does away with the need to query the API of services like bit.ly for url expansion.</p>
<pre class="brush: php">
function expand_url($url) {

	// Use curl to fetch the HTTP Headers
	$ch = curl_init($url);
	curl_setopt($ch, CURLOPT_HEADER, 1); // just the header
	curl_setopt($ch, CURLOPT_NOBODY, 1); // not the body
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$output = curl_exec($ch);
	preg_match('/Location: (.*)\n/', $output, $matches);

	// if no redirect header then return the original url
	return isset($matches[1]) ? $matches[1] : $url;

}
</pre>
<h2>A Simpler PHP 5 Version</h2>
<p>I&#8217;ve used curl for portability. PHP 5 has a built in get_headers function which you could use to simplify the function a little. It would look something like this:</p>
<pre class="brush: php">
function expand_url($url) {

	$h = get_headers($url);

	// if no redirect header then return the original url
	return isset($h['Location']) ? $h['Location'] : $url;

}
</pre>
<div class="pullout">
<h2>Creating Short URLs With PHP</h2>
<p>For creating short urls on the fly with PHP see: <a href="http://tinyurl.com/php-shorten-url">PHP shorten_url function</a> </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2010/05/18/expanding-short-urls-with-php-expand_url-php-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Short URLs with PHP: shorten_url PHP Function</title>
		<link>http://jamiethompson.co.uk/web/2010/05/18/create-short-urls-with-php-shorten_url-php-function/</link>
		<comments>http://jamiethompson.co.uk/web/2010/05/18/create-short-urls-with-php-shorten_url-php-function/#comments</comments>
		<pubDate>Tue, 18 May 2010 00:45:31 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jamiethompson.co.uk/?p=416</guid>
		<description><![CDATA[
Do you want to create short urls from within your own PHP application? Most url shortening services provide an API, it&#8217;s how apps like twitter clients provide built-in url shortening. I wrote a small PHP function to provide url shortening from two of the most popular services, is.gd and tinyurl.com. Where&#8217;s bit.ly I hear you [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://jamiethompson.co.uk/wp-content/uploads/2010/05/tape_measure.jpg" alt="Create Short URLs with PHP" title="tape_measure" width="530" height="190" class="size-full wp-image-425" /></p>
<p>Do you want to create short urls from within your own PHP application? Most url shortening services provide an API, it&#8217;s how apps like twitter clients provide built-in url shortening. I wrote a small PHP function to provide url shortening from two of the most popular services, <a href="http://is.gd">is.gd</a> and <a href="http://tinyurl.com">tinyurl.com</a>. Where&#8217;s <a href="http://bit.ly">bit.ly</a> I hear you ask. Well yeah, sure, that&#8217;s what all the cool kids are using these days, but bit.ly <a href="http://code.google.com/p/bitly-api/wiki/ApiDocumentation#Authentication_and_Shared_Parameters">requires an API key</a>. That&#8217;s not a huge issue, it&#8217;s free. It just doesn&#8217;t sit well with creating a nice portable, drop in a go PHP function. So bit.ly didn&#8217;t get an invite to my super mega PHP function party.</p>
<p>If you want to get some bit.ly action on the go then feel free to modify the code below accordingly. I might update this at some point. I keep thinking I should, but meh.</p>
<pre class="brush: php">
function shorten_url($url,$service='tinyurl.com') {

	// create the request url based on the selected shortening service
	switch ($service) {
	    case 'tinyurl.com':
	       $service_url = 'http://tinyurl.com/api-create.php?url='.urlencode($url);
		   break;
	    case 'is.gd':
	        $service_url = 'http://is.gd/api.php?longurl='.urlencode($url);
	}

	/*
	 * use cURL to fetch the respons
	 * Feel free to swap this out for
	 * $output = file_get_contents($service_url)
	 * if you have fopen wrappers enabled
	 */
	$ch = curl_init($service_url);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$output = curl_exec($ch);
	curl_close($ch);

	// return false on error
	return strtolower(substr($output,0,5))=='error' ? false : $output;

}
</pre>
<p>The function defaults to tinyurl. Yeah. Interesting choice you&#8217;re thinking, but I&#8217;m old school and that&#8217;s how I roll. I&#8217;ve used curl to make the HTTP requests for the simple fact that when it comes to hosting curl support is enabled more ofthen than fopen wrappers is on (and you need fopen wrappers on to be able to do a file_get_contents on an url). Either way the result is the same. Use whichever method you like.</p>
<div class="pullout">
<h2>Expanding Short URLs With PHP</h2>
<p>For expanding short urls on the fly with PHP see: <a href="http://tinyurl.com/php-expand-url">PHP expand_url function</a> </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2010/05/18/create-short-urls-with-php-shorten_url-php-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Streetview Static API</title>
		<link>http://jamiethompson.co.uk/web/2010/05/15/google-streetview-static-api/</link>
		<comments>http://jamiethompson.co.uk/web/2010/05/15/google-streetview-static-api/#comments</comments>
		<pubDate>Sat, 15 May 2010 21:19:37 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[geocoding]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[postcode]]></category>
		<category><![CDATA[Streetview]]></category>

		<guid isPermaLink="false">http://jamiethompson.co.uk/?p=317</guid>
		<description><![CDATA[It is possible to extract both thumbnails and higher resolution images (tiles) from the Google Streetview service through an unpublished, undocumented API which I will document below. Google have not publicly released this API, but nor have they sought to secure or even obfuscate it in any way. To me, this is about as open [...]]]></description>
			<content:encoded><![CDATA[<p>It is possible to extract both thumbnails and higher resolution images (tiles) from the Google Streetview service through an unpublished, undocumented API which I will document below. Google have not publicly released this API, but nor have they sought to secure or even obfuscate it in any way. To me, this is about as open an invitation as it gets.</p>
<h2>Thumbnails (The Easy Bit)</h2>
<p>You might have noticed that more often than not, when viewing a location on Google Maps nowadays you get a little Streetview thumbnail linking to the appropriate location on Google Streetview. If you&#8217;ve ever wondered if you could get static streetview imaging out Google for your own use then read on.</p>
<p><a href="http://jamiethompson.co.uk/wp-content/uploads/2010/05/maps_sm_thumbnail1.png"><img src="http://jamiethompson.co.uk/wp-content/uploads/2010/05/maps_sm_thumbnail1.png" alt="Google Maps Showing Streetview Thumbnail" title="Google Maps Showing Streetview Thumbnail" width="530" height="340" class="alignnone size-full wp-image-320" /></a></p>
<p>Inspection of the image source reveals something quite surprising:<br />
<a href="http://cbk0.google.com/cbk?output=thumbnail&#038;w=90&#038;h=68&#038;ll=51.494966,-0.146674">http://cbk0.google.com/cbk?output=thumbnail&#038;w=90&#038;h=68&#038;ll=51.494966,-0.146674</a></p>
<p><code>http://cbk0.google.com/cbk?output=thumbnail&#038;w=[WIDTH]&#038;h=[HEIGHT]&#038;ll=[LAT,LNG]</code></p>
<p>Not exactly cryptic is it. We have a width, a height and a lat/lng pair. Playing with the values of width and height you will find the maximum dimensions available are 416&#215;208 pixels, giving you a full, albeit small, 360 degree panorama of your desired location. You can play with the coordinates too but specifying a location without a streetview panorama will result in a 404 error.</p>
<p><img src="http://cbk0.google.com/cbk?output=thumbnail&#038;w=416&#038;h=208&#038;ll=51.494966,-0.146674" /></p>
<h2>I think I&#8217;m panoid&#8230;</h2>
<p>Each Streetview panorama is uniquely identified by an panoid. I&#8217;m pretty sure this is a timecode hash but I haven&#8217;t looked into it any further. For the purposes of fetching Streetview images the only important thing to consider is that these are unique ids.</p>
<p>If you&#8217;re like me, you&#8217;ve been looking at the example above and wondering what other output types there are besides &#8216;thumbnail&#8217;. One of the other options is &#8216;xml&#8217;, which returns some handy metadata for a given location. You can use this data to determine if there is a streetview panorama available at your chosen location.</p>
<p><code>http://cbk0.google.com/cbk?output=xml&#038;ll=[LAT,LNG]</code></p>
<p><strong>Example:</strong><br />
<a href="http://cbk0.google.com/cbk?output=xml&#038;ll=51.494966,-0.146674">http://cbk0.google.com/cbk?output=xml&#038;ll=51.494966,-0.146674</a></p>
<pre class="brush: xml">
&lt;panorama&gt;
&lt;data_properties image_width=&quot;13312&quot; image_height=&quot;6656&quot; tile_width=&quot;512&quot; tile_height=&quot;512&quot; pano_id=&quot;sLaiF6Jex7mJmNol7tdOoA&quot; num_zoom_levels=&quot;3&quot; lat=&quot;51.495090&quot; lng=&quot;-0.146971&quot; original_lat=&quot;51.495098&quot; original_lng=&quot;-0.147000&quot;&gt;
&lt;copyright&gt;&#169; 2010 Google&lt;/copyright&gt;
&lt;text&gt;Eccleston Pl&lt;/text&gt;
&lt;region&gt;London, England&lt;/region&gt;
&lt;country&gt;United Kingdom&lt;/country&gt;
&lt;data_flag&gt;1&lt;/data_flag&gt;
&lt;/data_properties&gt;
&lt;projection_properties projection_type=&quot;spherical&quot; pano_yaw_deg=&quot;201.78&quot; tilt_yaw_deg=&quot;92.06&quot; tilt_pitch_deg=&quot;1.75&quot;/&gt;
&lt;annotation_properties&gt;
&lt;link yaw_deg=&quot;204.7&quot; pano_id=&quot;CeutxcyB2V74lfN_fJwRww&quot; road_argb=&quot;0x80ffffff&quot;&gt;
&lt;link_text&gt;Eccleston Pl&lt;/link_text&gt;
&lt;/link&gt;
&lt;link yaw_deg=&quot;24.7&quot; pano_id=&quot;t_mnKSugTLrQTEnJplXQ3A&quot; road_argb=&quot;0x80ffffff&quot;&gt;
&lt;link_text&gt;Eccleston Pl&lt;/link_text&gt;
&lt;/link&gt;
&lt;/annotation_properties&gt;
&lt;/panorama&gt;
</pre>
<p>This returns a lot of data, but for now we&#8217;ll simply concentrate on the <strong>panoid</strong> values. Generally there will be three panoids. One as an attribute of the <strong>data_properties</strong> element and two as the attributes of the two <strong>link</strong> elements of the <strong>annotation_properties</strong> element. As far as I can tell the supplemental two panoids relate to the previous and next panorama on the route.</p>
<p>So in this example we end up with a main panoid of <strong>&#8220;sLaiF6Jex7mJmNol7tdOoA&#8221;</strong></p>
<p>Finally we can plug this value into the thumbnail url as follows:</p>
<p><code>http://cbk0.google.com/cbk?output=thumbnail&#038;w=[WIDTH]&#038;h=[HEIGHT]&#038;panoid=[PID]</code></p>
<p><a href="http://cbk0.google.com/cbk?output=thumbnail&#038;w=416&#038;h=208&#038;panoid=sLaiF6Jex7mJmNol7tdOoA">http://cbk0.google.com/cbk?output=thumbnail&#038;w=416&#038;h=208&#038;panoid=sLaiF6Jex7mJmNol7tdOoA</a></p>
<p><img src="http://cbk0.google.com/cbk?output=thumbnail&#038;w=416&#038;h=208&#038;panoid=sLaiF6Jex7mJmNol7tdOoA" /></p>
<p>Notice how we end up with exactly the same panorama, but at a different offset.</p>
<p>With a little extra work, tying this into the <a href="/projects/2010/04/30/an-open-free-uk-postcode-geocoding-web-service/">Open Postcode Geocoding API</a>, I came up with a nice little wrapper around this accepting a UK postcode and directly returning the corresponding panorama thumbnail. I&#8217;ve added this to my geo webservice and it is callable as follows:</p>
<p><code>http://geo.jamiethompson.co.uk/streetview/[POSTCODE]_[WIDTH]x[HEIGHT].jpg</code></p>
<p><strong>Example</strong><br />
<a href="http://geo.jamiethompson.co.uk/streetview/SW1W9TQ_416x208.jpg">http://geo.jamiethompson.co.uk/streetview/SW1W9TQ_416&#215;208.jpg</a></p>
<h2>The high detail tiles</h2>
<p>So, you probably noticed some info relating to tiles in the xml data in the previous example. It&#8217;s possible to fetch a set of 512 pixel square tiles at various zoom levels for a given panorama using the following request.</p>
<p><code>http://cbk0.google.com/cbk?output=tile&#038;panoid=[PID]&#038;zoom=[ZOOM]&#038;x=[X]&#038;y=[Y]</code></p>
<p>[X] and [Y] relate to the horizontal and vertical tile positions, while [ZOOM] relates to the zoom level. If the XML data is to be believed there are 3 zoom levels, but I have found there to be 5. The number of X and Y positions increases with each zoom level. These are zero based.</p>
<p><strong>Zoom Level 0:</strong><br />
<img src="http://jamiethompson.co.uk/wp-content/uploads/2010/05/zoom0.png" alt="Example of Streetview Tile Zoom Level 0" title="Example of Streetview Tile Zoom Level 0" width="263" height="263" class="alignnone size-full wp-image-366" /><br />
<a href="http://cbk0.google.com/cbk?output=tile&#038;panoid=sLaiF6Jex7mJmNol7tdOoA&#038;zoom=0&#038;x=0&#038;y=0">Single Tile &#8211; X=0, Y=0</a></p>
<p><strong>Zoom Level 1:</strong><br />
<img src="http://jamiethompson.co.uk/wp-content/uploads/2010/05/zoom1.png" alt="Example of Streetview Tile Zoom Level 1" title="Example of Streetview Tile Zoom Level 1" width="530" height="263" class="alignnone size-full wp-image-367" /><br />
<a href="http://cbk0.google.com/cbk?output=tile&#038;panoid=sLaiF6Jex7mJmNol7tdOoA&#038;zoom=1&#038;x=0&#038;y=0">Tile 1 &#8211; X=0, Y=0</a> <a href="http://cbk0.google.com/cbk?output=tile&#038;panoid=sLaiF6Jex7mJmNol7tdOoA&#038;zoom=1&#038;x=1&#038;y=0">Tile 2 &#8211; X=1, Y=0</a></p>
<p><strong>Zoom Level 2</strong><br />
<img src="http://jamiethompson.co.uk/wp-content/uploads/2010/05/zoom2.png" alt="Example of Streetview Tile Zoom Level 2" title="Example of Streetview Tile Zoom Level 2" width="530" height="263" class="alignnone size-full wp-image-369" /><br />
4 X positions (0-3), 2 Y positions (0-1)</p>
<p><strong>Zoom Level 3</strong><br />
<img src="http://jamiethompson.co.uk/wp-content/uploads/2010/05/zoom3.png" alt="Example of Streetview Tile Zoom Level 3" title="Example of Streetview Tile Zoom Level 3" width="530" height="264" class="alignnone size-full wp-image-370" /><br />
6 X positions (0-5), 3 Y positions (0-2)</p>
<p><strong>Zoom Level 4</strong><br />
<img src="http://jamiethompson.co.uk/wp-content/uploads/2010/05/zoom4.png" alt="Example of Streetview Tile Zoom Level 4" title="Example of Streetview Tile Zoom Level 4" width="530" height="288" class="alignnone size-full wp-image-371" /><br />
13 X positions (0-12), 7 Y positions (0-6)</p>
<p><strong>Zoom Level 5</strong><br />
<img src="http://jamiethompson.co.uk/wp-content/uploads/2010/05/zoom5.png" alt="Example of Streetview Tile Zoom Level 5" title="Example of Streetview Tile Zoom Level 5" width="530" height="268" class="alignnone size-full wp-image-372" /><br />
26 X positions (0-25), 13 Y positions (0-12)</p>
<h2>Demo</h2>
<p>I&#8217;ve put together a very quick and dirty demo page that displays the  tiles re-assembled for any given UK postcode. Be warned, at zoom level 5 this will download 338 512&#215;512 pixel tiles, roughly 7-8MB.</p>
<p><a href="http://geo.jamiethompson.co.uk/streetview_tiles.php?postcode=SW1W+9TQ&#038;zoom=3"><br />
<img src="http://jamiethompson.co.uk/wp-content/uploads/2010/05/tile_viewer_demo.jpg" alt="Google Streetview Tile Viewer Demo" title="Google Streetview Tile Viewer Demo" width="530" height="264" class="alignnone size-full wp-image-364" /><br />
</a></p>
<p><a href="http://geo.jamiethompson.co.uk/streetview_tiles.php?postcode=SW1W+9TQ&#038;zoom=3">View the demo here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2010/05/15/google-streetview-static-api/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>An Open Postcode Geocoding API</title>
		<link>http://jamiethompson.co.uk/projects/2010/04/30/an-open-free-uk-postcode-geocoding-web-service/</link>
		<comments>http://jamiethompson.co.uk/projects/2010/04/30/an-open-free-uk-postcode-geocoding-web-service/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 18:38:25 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[geocoding]]></category>
		<category><![CDATA[postcode]]></category>

		<guid isPermaLink="false">http://jamiethompson.co.uk/?p=276</guid>
		<description><![CDATA[
Because I needed one for various (non-profit) projects of my own, I&#8217;ve put together a small Postcode geocoding web service which collates partial data from various sources into what aims to be a full geocoder / reverse geocoder for UK postcodes.
Now, the term &#8216;geocoding&#8217; can mean several very subtly different things depending on who you [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://jamiethompson.co.uk/wp-content/uploads/2010/04/geocoding.png" alt="" title="geocoding" width="530" height="190" class="alignnone size-full wp-image-291" /></p>
<p>Because I needed one for various (non-profit) projects of my own, I&#8217;ve put together a small Postcode geocoding web service which collates partial data from various sources into what aims to be a full geocoder / reverse geocoder for UK postcodes.</p>
<p>Now, the term &#8216;geocoding&#8217; can mean several very subtly different things depending on who you talk to. So to clarify, this is what the web service does.</p>
<ol>
<li>It takes a full UK postcode</li>
<li>It returns a geographical location (lat/lng and optionally os/landranger grid references)</li>
<li>It also attempts to reverse geocode the street address via the Google Maps API (experimental)</li>
</ol>
<h2>Isn&#8217;t that Illegal?</h2>
<p>Not anymore. <a href="http://www.ordnancesurvey.co.uk/oswebsite/opendata/">Ordnance Survey have open sourced</a> huge chunks of their data. This includes their CodePoint file which contains the coordinates of every single UK postcode.</p>
<h2>Usage</h2>
<p>There&#8217;s nothing complicated involved in calling the service. Simply make an HTTP request in the following format, where SW1A 2AA is your postcode; or more accurately that of 10 Downing Street.</p>
<p>Get the data in XML format<br />
<a href="http://geo.jamiethompson.co.uk/SW1A2AA.xml">http://geo.jamiethompson.co.uk/SW1A2AA.xml</a></p>
<pre class="brush: xml">&lt;result&gt;
  &lt;status&gt;200&lt;/status&gt;
  &lt;postcode&gt;SW1A 2AA&lt;/postcode&gt;
  &lt;geo&gt;
    &lt;os_x&gt;530047&lt;/os_x&gt;
    &lt;os_y&gt;179951&lt;/os_y&gt;
    &lt;lat&gt;51.50354&lt;/lat&gt;
    &lt;lng&gt;-0.127696&lt;/lng&gt;
    &lt;landranger&gt;TQ300799&lt;/landranger&gt;
    &lt;accuracy&gt;1&lt;/accuracy&gt;
  &lt;/geo&gt;
  &lt;address&gt;
    &lt;street&gt;Downing St&lt;/street&gt;
    &lt;locality&gt;London&lt;/locality&gt;
    &lt;district&gt;Westminster&lt;/district&gt;
    &lt;county&gt;Greater London&lt;/county&gt;
  &lt;/address&gt;
&lt;/result&gt;
</pre>
<p>The data is also available as JSON<br />
<a href="http://geo.jamiethompson.co.uk/SW1A2AA.json">http://geo.jamiethompson.co.uk/SW1A2AA.json</a></p>
<pre class="brush: js">{
   "status":200,
   "postcode":"SW1A 2AA",
   "geo":{
      "os_x":"530047",
      "os_y":"179951",
      "lat":"51.50354",
      "lng":"-0.127696",
      "landranger":"TQ300799",
      "accuracy":"1"
   },
   "address":{
      "street":"Downing St",
      "locality":"London",
      "district":"Westminster",
      "county":"Greater London"
   }
}</pre>
<p>and additionally as JSONP by specifying a callback<br />
<a href="http://geo.jamiethompson.co.uk/SW1A2AA.json?callback=doStuff">http://geo.jamiethompson.co.uk/SW1A2AA.json?callback=doStuff</a></p>
<h2>Things You Should be Aware of</h2>
<p>The data returned should be pretty self documenting but there&#8217;s a few things you should be aware of.</p>
<p>Although, more often than not you will receive a full dataset. The only guaranteed values are lat and lng. All other values of geo are optional. Additionally to this, if the accuracy level of a result is 2 then the coordinates relate to the broader postcode area rather than the postcode itself. An accuracy 2 result for the postcode <strong>JE3 8FA*</strong> will return the centre point of the <strong>JE3 8</strong> area.</p>
<p><em>* All channel island postcodes are returned at accuracy level 2</em></p>
<p>Northern Ireland (<strong>BTXX XXX</strong>) postcodes don&#8217;t return ordnance survey osgrid coords. Lat/lng values however are accurate to level 1.</p>
<h2>A final word</h2>
<p>This is an experimental web service. Please don&#8217;t hammer it for anything humongous or commercial. The reverse geocoding is experimental and cannot be relied upon for anything super-serious at the moment. If you need this data commercially please do yourself (and me) a favour and check out the reasonably priced services offered by the likes of <a href="http://www.afd.co.uk/">AFD</a> (which I can personally recommend) or <a href="http://www.postcodeanywhere.co.uk/">PostcodeAnywhere</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/projects/2010/04/30/an-open-free-uk-postcode-geocoding-web-service/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>jQuery Document Meta Plugin</title>
		<link>http://jamiethompson.co.uk/web/2010/04/09/jquery-document-meta-plugin/</link>
		<comments>http://jamiethompson.co.uk/web/2010/04/09/jquery-document-meta-plugin/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 18:30:03 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[meta]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://jamiethompson.co.uk/?p=247</guid>
		<description><![CDATA[Got some persistent variables you want to pass from the server-side into your jQuery application? If you&#8217;ve got lots of complex data then you probably want to pull it in as JSON data, but for a handful of scalar variables it can be nice to just output them in the document head as meta tags.

&#60;meta [...]]]></description>
			<content:encoded><![CDATA[<p>Got some persistent variables you want to pass from the server-side into your jQuery application? If you&#8217;ve got lots of complex data then you probably want to pull it in as JSON data, but for a handful of scalar variables it can be nice to just output them in the document head as meta tags.</p>
<pre class="brush: html">
&lt;meta name="user_id" content="1337" /&gt;
&lt;meta name="user_name" content="Gary Barlow" /&gt;
</pre>
<p>I&#8217;m thinking core stuff like user ids which never change and get used again and again in ajax calls. Yes, you could achieve the same thing with cookie data, but if like me you like to keep the amount of data stored in cookies to the bare minimum, then this can be a nice little solution.</p>
<p>You can easily access these values like this:</p>
<pre class="brush:js">var user_id = $("meta[name='user_id']").attr('content')</pre>
<p>But eww, it&#8217;s pretty ugly, and ugly code makes Jamie a sad developer.</p>
<p>The following plugin simply provides a neat shorthand for accessing those variables. And I do like to keep things neat. It also caches by means of lazy-loading each meta contents into an internal object, so that the DOM is only traversed once. This is possibly overkill, and probably doesn&#8217;t save a single millisecond in any real-life scenario, but I like to optimise as I go and you can&#8217;t stop me.</p>
<pre class="brush:js">(function($) {
$.meta = function(name) {
    if (typeof($.meta.cache[name])=='undefined'){
        $.meta.cache[name] = $("meta[name='"+name+"']").attr('content');
    }
    return $.meta.cache[name];
};
$.meta.cache = new Object;
})(jQuery);</pre>
<p>You&#8217;re then free to access your variables neatly and concisely throughout your application using your new $.meta function.</p>
<pre class="brush: js">$.post('path/to/someAjaxController', {method: 'doStuff', id: $.meta('user_id')}, function(r){
    alert('Thanks for doing stuff ' + $.meta('user_name'));
})</pre>
<p>This isn&#8217;t to be confused with the existing and widely used <a href="http://docs.jquery.com/Plugins/Metadata">jQuery Metadata Plugin</a> which extracts meta data from DOM Elements. I should perhaps call this plugin something different, but to be honest I can&#8217;t think of a better name.</p>
<p>So to sum up. Ground-breaking? Not really. Useful? Yes.<code></code></p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2010/04/09/jquery-document-meta-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
