﻿<?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>Bassett-Jones.com</title>
	<atom:link href="http://www.bassett-jones.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bassett-jones.com</link>
	<description>The web site of Hugh Bassett-Jones</description>
	<lastBuildDate>Tue, 04 May 2010 12:15:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Music mashing with YouTube, YQL and Open Data Tables</title>
		<link>http://www.bassett-jones.com/music-mashing-with-youtube-yql-and-open-data-tables/</link>
		<comments>http://www.bassett-jones.com/music-mashing-with-youtube-yql-and-open-data-tables/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 07:42:53 +0000</pubDate>
		<dc:creator>Hugh</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[addbass]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[open data table]]></category>
		<category><![CDATA[top20]]></category>
		<category><![CDATA[youtube]]></category>
		<category><![CDATA[yql]]></category>

		<guid isPermaLink="false">http://www.bassett-jones.com/?p=479</guid>
		<description><![CDATA[BBC's top 20 chart + YouTube's music videos + YQL = AddBass top 20 excellence!]]></description>
			<content:encoded><![CDATA[<p>BBC&#8217;s <a href="http://www.bbc.co.uk/radio1/chart/singles/">top 20 chart</a> + YouTube&#8217;s <a href="http://www.youtube.com/channels?c=10">music videos</a> + <a href="http://developer.yahoo.com/yql/">YQL</a> = <a href="http://addbass.com/top20/">AddBass top 20</a> excellence!</p>
<p><a class="aligncenter" href="http://addbass.com/top20/"><img class="alignnone size-full wp-image-486" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/addbass-top20.jpg" alt="" width="600" height="486" /></a></p>
<h2>The plan</h2>
<p>Grab the top 20 chart singles from the BBC web site, look up each song on YouTube and get the most popular matching videos. Show them in the chromeless player and set it so that they play automatically and users can skip ones they don&#8217;t like.</p>
<p><img class="aligncenter size-full wp-image-704" title="diagram" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/diagram.png" alt="" width="528" height="720" /></p>
<p><span id="more-479"></span><br />
<h2>Make it so</h2>
<h3>BBC chart data</h3>
<p>The BBC publish chart data at <a href="http://www.bbc.co.uk/radio1/chart/singles/">www.bbc.co.uk/radio1/chart/singles/</a> but this is not available in a raw data format such as XML or JSON. Luckily, Yahoo have introduced Yahoo! Query Language (YQL) that can <a href="http://www.wait-till-i.com/2009/11/16/using-yql-to-read-html-from-a-document-that-requires-post-data/">extract data from HTML</a> pages using an XPath expression. I needed the song title and artist and the BBC has these in the image <code>alt</code> attribute.</p>
<p><img class="alignnone size-full wp-image-686" title="bbc-chart-alt" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/bbc-chart-alt.png" alt="" width="601" height="256" /></p>
<p>The following YQL extracts the top 20 from the chart page:</p>
<div class="sql" style="font-family:monospace;"><ol><li class="li1"><pre class="de1"><span class="kw1">SELECT</span> alt <span class="kw1">FROM</span> html <span class="kw1">WHERE</span></pre></li><li class="li1"><pre class="de1">url<span class="sy0">=</span><span class="st0">&quot;http://www.bbc.co.uk/radio1/chart/singles/&quot;</span> <span class="kw1">AND</span> xpath<span class="sy0">=</span><span class="st0">&quot;//li/img&quot;</span> <span class="kw1">LIMIT</span> <span class="nu0">20</span></pre></li></ol></div>
<p>The result from <a href="http://developer.yahoo.com/yql/console/?q=SELECT%20alt%20FROM%20html%20WHERE%0Aurl%3D%22http%3A%2F%2Fwww.bbc.co.uk%2Fradio1%2Fchart%2Fsingles%2F%22%20AND%20xpath%3D%22%2F%2Fli%2Fimg%22%20LIMIT%2020">trying it in the console</a>:</p>
<p><a href="http://developer.yahoo.com/yql/console/?q=SELECT%20alt%20FROM%20html%20WHERE%0Aurl%3D%22http%3A%2F%2Fwww.bbc.co.uk%2Fradio1%2Fchart%2Fsingles%2F%22%20AND%20xpath%3D%22%2F%2Fli%2Fimg%22%20LIMIT%2020"><img class="alignnone size-full wp-image-687" title="yql-bbc" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/yql-bbc.png" alt="" width="589" height="474" /></a></p>
<h3>YouTube data</h3>
<p>Now that I had the chart data, an option would be for the web browser to query YouTube for each song title and show the video. This would be a slow process and a bit of a pain as each request would be asynchronous and be returned in a different order to the one sent.</p>
<p>YQL supports the <a href="http://www.w3schools.com/sql/sql_in.asp">IN operator</a> and sub-queries for <a href="http://datatables.org/">Open Data Tables</a>. If I used a YouTube table, I could have all the processing done on Yahoo&#8217;s servers in one YQL query. There wasn&#8217;t a YouTube <a href="http://github.com/yql/yql-tables">community table</a> so I created an Open Table at <a href="http://addbass.com/youtube.xml">http://addbass.com/youtube.xml</a> with the following definition:</p>
<div class="xml" style="font-family:monospace;"><ol><li class="li1"><pre class="de1"><span class="sc3"><span class="re1">&lt;table<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1">  <span class="sc3"><span class="re1">&lt;meta<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1">    <span class="sc3"><span class="re1">&lt;author<span class="re2">&gt;</span></span></span>Hugh Bassett-Jones<span class="sc3"><span class="re1">&lt;/author<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1">    <span class="sc3"><span class="re1">&lt;documentationURL<span class="re2">&gt;</span></span></span>http://code.google.com/apis/youtube/2.0/reference.html<span class="sc3"><span class="re1">&lt;/documentationURL<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1">    <span class="sc3"><span class="re1">&lt;sampleQuery<span class="re2">&gt;</span></span></span>select entry where q=&quot;jackson&quot;<span class="sc3"><span class="re1">&lt;/sampleQuery<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1">  <span class="sc3"><span class="re1">&lt;/meta<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1">  <span class="sc3"><span class="re1">&lt;bindings<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1">    <span class="sc3"><span class="re1">&lt;select</span> <span class="re0">itemPath</span>=<span class="st0">&quot;feed.entry&quot;</span> <span class="re0">produces</span>=<span class="st0">&quot;XML&quot;</span><span class="re2">&gt;</span></span></pre></li><li class="li1"><pre class="de1">      <span class="sc3"><span class="re1">&lt;urls<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1">        <span class="sc3"><span class="re1">&lt;url</span> <span class="re0">env</span>=<span class="st0">&quot;all&quot;</span><span class="re2">&gt;</span></span>http://gdata.youtube.com/feeds/api/videos<span class="sc3"><span class="re1">&lt;/url<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1">      <span class="sc3"><span class="re1">&lt;/urls<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1">      <span class="sc3"><span class="re1">&lt;inputs<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1">        <span class="sc3"><span class="re1">&lt;key</span> <span class="re0">id</span>=<span class="st0">&quot;q&quot;</span> <span class="re0">type</span>=<span class="st0">&quot;xs:string&quot;</span> <span class="re0">paramType</span>=<span class="st0">&quot;query&quot;</span> <span class="re0">required</span>=<span class="st0">&quot;true&quot;</span><span class="re2">/&gt;</span></span></pre></li><li class="li1"><pre class="de1">        <span class="sc3"><span class="re1">&lt;key</span> <span class="re0">id</span>=<span class="st0">&quot;format&quot;</span> <span class="re0">type</span>=<span class="st0">&quot;xs:string&quot;</span> <span class="re0">paramType</span>=<span class="st0">&quot;query&quot;</span> <span class="re0">default</span>=<span class="st0">&quot;5&quot;</span><span class="re2">/&gt;</span></span></pre></li><li class="li1"><pre class="de1">        <span class="sc3"><span class="re1">&lt;key</span> <span class="re0">id</span>=<span class="st0">&quot;max-results&quot;</span> <span class="re0">type</span>=<span class="st0">&quot;xs:string&quot;</span> <span class="re0">paramType</span>=<span class="st0">&quot;query&quot;</span> <span class="re0">default</span>=<span class="st0">&quot;1&quot;</span><span class="re2">/&gt;</span></span></pre></li><li class="li1"><pre class="de1">        <span class="sc3"><span class="re1">&lt;key</span> <span class="re0">id</span>=<span class="st0">&quot;start-index&quot;</span> <span class="re0">type</span>=<span class="st0">&quot;xs:string&quot;</span> <span class="re0">paramType</span>=<span class="st0">&quot;query&quot;</span> <span class="re0">default</span>=<span class="st0">&quot;1&quot;</span><span class="re2">/&gt;</span></span></pre></li><li class="li1"><pre class="de1">        <span class="sc3"><span class="re1">&lt;key</span> <span class="re0">id</span>=<span class="st0">&quot;orderby&quot;</span> <span class="re0">as</span>=<span class="st0">&quot;order&quot;</span> <span class="re0">type</span>=<span class="st0">&quot;xs:string&quot;</span> <span class="re0">paramType</span>=<span class="st0">&quot;query&quot;</span> <span class="re0">default</span>=<span class="st0">&quot;relevance&quot;</span><span class="re2">/&gt;</span></span></pre></li><li class="li1"><pre class="de1">      <span class="sc3"><span class="re1">&lt;/inputs<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1">    <span class="sc3"><span class="re1">&lt;/select<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1">  <span class="sc3"><span class="re1">&lt;/bindings<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1"><span class="sc3"><span class="re1">&lt;/table<span class="re2">&gt;</span></span></span></pre></li></ol></div>
<p>This data table is used in the YQL query</p>
<div class="sql" style="font-family:monospace;"><ol><li class="li1"><pre class="de1"><span class="kw1">USE</span> <span class="st0">&quot;http://addbass.com/youtube.xml&quot;</span> <span class="kw1">AS</span> vids;</pre></li><li class="li1"><pre class="de1"><span class="kw1">SELECT</span> id<span class="sy0">,</span> title <span class="kw1">FROM</span> vids <span class="kw1">WHERE</span> <span class="kw1">ORDER</span><span class="sy0">=</span><span class="st0">&quot;viewCount&quot;</span> <span class="kw1">AND</span> q <span class="kw1">IN</span> <span class="br0">&#40;</span></pre></li><li class="li1"><pre class="de1">  <span class="kw1">SELECT</span> alt <span class="kw1">FROM</span> html <span class="kw1">WHERE</span> url<span class="sy0">=</span><span class="st0">&quot;http://www.bbc.co.uk/radio1/chart/singles/&quot;</span> <span class="kw1">AND</span> xpath<span class="sy0">=</span><span class="st0">&quot;//li/img&quot;</span> <span class="kw1">LIMIT</span> <span class="nu0">20</span><span class="br0">&#41;</span></pre></li></ol></div>
<p>The result from <a href="http://developer.yahoo.com/yql/console/?q=USE%20%22http%3A%2F%2Faddbass.com%2Fyoutube.xml%22%20AS%20vids%3B%0ASELECT%20id%2C%20title%20FROM%20vids%20WHERE%20order%3D%22viewCount%22%20AND%20q%20IN%20(%0A%20%20SELECT%20alt%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.bbc.co.uk%2Fradio1%2Fchart%2Fsingles%2F%22%20and%20xpath%3D%22%2F%2Fli%2Fimg%22%20LIMIT%2020)">trying it in the console</a>:</p>
<p><a href="http://developer.yahoo.com/yql/console/?q=USE%20%22http%3A%2F%2Faddbass.com%2Fyoutube.xml%22%20AS%20vids%3B%0ASELECT%20id%2C%20title%20FROM%20vids%20WHERE%20order%3D%22viewCount%22%20AND%20q%20IN%20(%0A%20%20SELECT%20alt%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.bbc.co.uk%2Fradio1%2Fchart%2Fsingles%2F%22%20and%20xpath%3D%22%2F%2Fli%2Fimg%22%20LIMIT%2020)"><img class="alignnone size-full wp-image-693" title="ytopen" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/ytopen.png" alt="" width="599" height="413" /></a></p>
<h3>Putting it all together with javascript: the breakdown</h3>
<p>Link to the latest versions of <a href="http://jquery.com/">jQuery</a> and <a href="http://code.google.com/p/swfobject/">swfobject</a> on <a href="http://code.google.com/apis/ajaxlibs/documentation/">Google&#8217;s CDN</a> and the <a href="http://addbass.com/top20/top.js">local js file</a> in the document <code>head</code>:</p>
<div class="xml" style="font-family:monospace;"><ol><li class="li1"><pre class="de1"><span class="sc3"><span class="re1">&lt;script</span> <span class="re0">src</span>=<span class="st0">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js&quot;</span><span class="re2">&gt;</span><span class="re1">&lt;/script<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1"><span class="sc3"><span class="re1">&lt;script</span> <span class="re0">src</span>=<span class="st0">&quot;http://ajax.googleapis.com/ajax/libs/swfobject/2/swfobject.js&quot;</span><span class="re2">&gt;</span><span class="re1">&lt;/script<span class="re2">&gt;</span></span></span></pre></li><li class="li1"><pre class="de1"><span class="sc3"><span class="re1">&lt;script</span> <span class="re0">src</span>=<span class="st0">&quot;top.js&quot;</span><span class="re2">&gt;</span><span class="re1">&lt;/script<span class="re2">&gt;</span></span></span></pre></li></ol></div>
<p>Load the YouTube chromeless player before the closing document <code>body</code>:</p>
<div class="xml" style="font-family:monospace;"><ol><li class="li1"><pre class="de1"><span class="sc3"><span class="re1">&lt;script</span> <span class="re0">type</span>=<span class="st0">&quot;text/javascript&quot;</span><span class="re2">&gt;</span></span></pre></li><li class="li1"><pre class="de1">  swfobject.embedSWF('http://www.youtube.com/apiplayer?enablejsapi=1<span class="sc1">&amp;playerapiid=player', 'video', '400', '300', '8', null, null, { allowScriptAccess: 'always', bgcolor: '#000000', wmode: 'transparent' }, { id: 'myplayer' });</span></pre></li><li class="li1"><pre class="de1"><span class="sc3"><span class="re1">&lt;/script<span class="re2">&gt;</span></span></span>;</pre></li></ol></div>
<p>In <code>top.js</code>, declare a global variable to hold video player details:</p>
<div class="javascript" style="font-family:monospace;"><ol><li class="li1"><pre class="de1"><span class="kw2">var</span> player<span class="sy0">;</span></pre></li></ol></div>
<p><code>onYouTubePlayerReady</code> is called when the player has loaded:</p>
<div class="javascript" style="font-family:monospace;"><ol start="3"><li class="li1"><pre class="de1"><span class="kw2">function</span> onYouTubePlayerReady<span class="br0">&#40;</span>playerId<span class="br0">&#41;</span> <span class="br0">&#123;</span></pre></li><li class="li1"><pre class="de1">&nbsp;</pre></li><li class="li1"><pre class="de1">  <span class="co1">// youtube player</span></pre></li><li class="li1"><pre class="de1">  player <span class="sy0">=</span> document.<span class="me1">getElementById</span><span class="br0">&#40;</span><span class="st0">'myplayer'</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">  player.<span class="me1">addEventListener</span><span class="br0">&#40;</span><span class="st0">'onStateChange'</span><span class="sy0">,</span> <span class="st0">'onPlayerStateChange'</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">  player.<span class="me1">userEnded</span> <span class="sy0">=</span> <span class="kw2">false</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">  player.<span class="me1">currentVideoID</span> <span class="sy0">=</span> undefined<span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">  player.<span class="me1">playvideo</span> <span class="sy0">=</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></pre></li><li class="li1"><pre class="de1">    <span class="kw1">if</span><span class="br0">&#40;</span>player.<span class="me1">currentVideoID</span> <span class="sy0">==</span> undefined<span class="br0">&#41;</span></pre></li><li class="li1"><pre class="de1">      player.<span class="me1">currentVideoID</span> <span class="sy0">=</span> $<span class="br0">&#40;</span><span class="st0">'#tracks li:first'</span><span class="br0">&#41;</span>.<span class="me1">attr</span><span class="br0">&#40;</span><span class="st0">'id'</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">&nbsp;</pre></li><li class="li1"><pre class="de1">    $<span class="br0">&#40;</span><span class="st0">'#tracks li'</span><span class="br0">&#41;</span>.<span class="me1">removeClass</span><span class="br0">&#40;</span><span class="st0">'selected'</span><span class="br0">&#41;</span>.<span class="me1">find</span><span class="br0">&#40;</span><span class="st0">'span'</span><span class="br0">&#41;</span>.<span class="me1">remove</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">    $<span class="br0">&#40;</span><span class="st0">'#'</span> <span class="sy0">+</span> player.<span class="me1">currentVideoID</span><span class="br0">&#41;</span>.<span class="me1">addClass</span><span class="br0">&#40;</span><span class="st0">'selected'</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">    player.<span class="me1">loadVideoById</span><span class="br0">&#40;</span>player.<span class="me1">currentVideoID</span><span class="sy0">,</span> 0<span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">&nbsp;</pre></li><li class="li1"><pre class="de1">    player.<span class="me1">userEnded</span> <span class="sy0">=</span> <span class="kw2">false</span><span class="sy0">;</span> <span class="co1">// reset</span></pre></li><li class="li1"><pre class="de1">    $<span class="br0">&#40;</span><span class="st0">'#loading'</span><span class="br0">&#41;</span>.<span class="me1">fadeOut</span><span class="br0">&#40;</span><span class="st0">'slow'</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">  <span class="br0">&#125;</span><span class="sy0">;</span></pre></li></ol></div>
<p><code>player.updateRemaining()</code> gets the total number of seconds remaining and converts it to minutes and seconds. This function is called once a second.</p>
<div class="javascript" style="font-family:monospace;"><ol start="21"><li class="li1"><pre class="de1">player.<span class="me1">updateRemaining</span> <span class="sy0">=</span> <span class="kw2">function</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></pre></li><li class="li1"><pre class="de1">    <span class="kw2">var</span> mins <span class="sy0">=</span> Math.<span class="me1">floor</span><span class="br0">&#40;</span><span class="br0">&#40;</span>player.<span class="me1">getDuration</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">-</span> player.<span class="me1">getCurrentTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">/</span> 60<span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">    <span class="kw2">var</span> secs <span class="sy0">=</span> Math.<span class="me1">floor</span><span class="br0">&#40;</span><span class="br0">&#40;</span>player.<span class="me1">getDuration</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">-</span> player.<span class="me1">getCurrentTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">%</span> 60<span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">    secs <span class="sy0">=</span> <span class="br0">&#40;</span><span class="st0">'00'</span> <span class="sy0">+</span> secs<span class="br0">&#41;</span>.<span class="me1">slice</span><span class="br0">&#40;</span><span class="sy0">-</span>2<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// leading zero</span></pre></li><li class="li1"><pre class="de1">    $<span class="br0">&#40;</span><span class="st0">'#'</span> <span class="sy0">+</span> player.<span class="me1">currentVideoID</span><span class="br0">&#41;</span>.<span class="me1">find</span><span class="br0">&#40;</span><span class="st0">'span'</span><span class="br0">&#41;</span>.<span class="me1">remove</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">    $<span class="br0">&#40;</span><span class="st0">'#'</span> <span class="sy0">+</span> player.<span class="me1">currentVideoID</span><span class="br0">&#41;</span>.<span class="me1">append</span><span class="br0">&#40;</span><span class="st0">'&lt;span&gt;'</span><span class="sy0">+</span> mins <span class="sy0">+</span> <span class="st0">':'</span> <span class="sy0">+</span> secs <span class="sy0">+</span> <span class="st0">'&lt;/span&gt;'</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">  <span class="br0">&#125;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">&nbsp;</pre></li><li class="li1"><pre class="de1">  setInterval<span class="br0">&#40;</span>player.<span class="me1">updateRemaining</span><span class="sy0">,</span> 1000<span class="br0">&#41;</span><span class="sy0">;</span></pre></li></ol></div>
<p>The control click events are wired up:</p>
<div class="javascript" style="font-family:monospace;"><ol start="31"><li class="li1"><pre class="de1"><span class="co1">// wire up controls</span></pre></li><li class="li1"><pre class="de1">    $<span class="br0">&#40;</span><span class="st0">'#previous'</span><span class="br0">&#41;</span>.<span class="me1">click</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> player.<span class="me1">userEnded</span> <span class="sy0">=</span> <span class="kw2">true</span><span class="sy0">;</span> player.<span class="me1">currentVideoID</span> <span class="sy0">=</span> $<span class="br0">&#40;</span><span class="st0">'#'</span> <span class="sy0">+</span> player.<span class="me1">currentVideoID</span><span class="br0">&#41;</span>.<span class="me1">prev</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">attr</span><span class="br0">&#40;</span><span class="st0">'id'</span><span class="br0">&#41;</span><span class="sy0">;</span> player.<span class="me1">playvideo</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">    $<span class="br0">&#40;</span><span class="st0">'#back'</span><span class="br0">&#41;</span>.<span class="me1">click</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> player.<span class="me1">seekTo</span><span class="br0">&#40;</span>player.<span class="me1">getCurrentTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">-</span> 30<span class="sy0">,</span> <span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">    $<span class="br0">&#40;</span><span class="st0">'#play'</span><span class="br0">&#41;</span>.<span class="me1">click</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> player.<span class="me1">userEnded</span> <span class="sy0">=</span> <span class="kw2">true</span><span class="sy0">;</span> player.<span class="me1">currentVideoID</span> <span class="sy0">=</span> player.<span class="me1">currentVideoID</span><span class="sy0">;</span> player.<span class="me1">playvideo</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">    $<span class="br0">&#40;</span><span class="st0">'#stop'</span><span class="br0">&#41;</span>.<span class="me1">click</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> player.<span class="me1">userEnded</span> <span class="sy0">=</span> <span class="kw2">true</span><span class="sy0">;</span> player.<span class="me1">stopVideo</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">    $<span class="br0">&#40;</span><span class="st0">'#forward'</span><span class="br0">&#41;</span>.<span class="me1">click</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> player.<span class="me1">seekTo</span><span class="br0">&#40;</span>player.<span class="me1">getCurrentTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">+</span> 30<span class="sy0">,</span> <span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">    $<span class="br0">&#40;</span><span class="st0">'#next'</span><span class="br0">&#41;</span>.<span class="me1">click</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> player.<span class="me1">userEnded</span> <span class="sy0">=</span> <span class="kw2">true</span><span class="sy0">;</span> player.<span class="me1">currentVideoID</span> <span class="sy0">=</span> $<span class="br0">&#40;</span><span class="st0">'#'</span> <span class="sy0">+</span> player.<span class="me1">currentVideoID</span><span class="br0">&#41;</span>.<span class="me1">next</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">attr</span><span class="br0">&#40;</span><span class="st0">'id'</span><span class="br0">&#41;</span><span class="sy0">;</span> player.<span class="me1">playvideo</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li></ol></div>
<p><a href="http://api.jquery.com/jQuery.ajax/">jQuery&#8217;s ajax method</a> is used to get the YouTube chart data through <a href="http://developer.yahoo.com/yql/console/?q=USE%20%22http%3A%2F%2Faddbass.com%2Fyoutube.xml%22%20AS%20vids%3B%0ASELECT%20id%2C%20title%20FROM%20vids%20WHERE%20order%3D%22viewCount%22%20AND%20q%20IN%20(%0A%20%20SELECT%20alt%20FROM%20html%20WHERE%20url%3D%22http%3A%2F%2Fwww.bbc.co.uk%2Fradio1%2Fchart%2Fsingles%2F%22%20and%20xpath%3D%22%2F%2Fli%2Fimg%22%20LIMIT%2020)">the YQL query</a>. This allows the response to be cached on the browser making it speedy the next time the data is requested. As the data does not change often, <code>_maxage=86400</code> is specified to allow Yahoo to cache the results for 24 hours on their servers:</p>
<div class="javascript" style="font-family:monospace;"><ol start="39"><li class="li1"><pre class="de1"><span class="co1">// go go go!</span></pre></li><li class="li1"><pre class="de1">  $.<span class="me1">ajax</span><span class="br0">&#40;</span><span class="br0">&#123;</span></pre></li><li class="li1"><pre class="de1">    url<span class="sy0">:</span> <span class="st0">'http://query.yahooapis.com/v1/public/yql?q=USE%20%22http%3A%2F%2Faddbass.com%2Fyoutube.xml%22%20AS%20vids%3B%20SELECT%20id%2C%20title%20FROM%20vids%20WHERE%20order%3D%22viewCount%22%20AND%20q%20IN%20(SELECT%20alt%20FROM%20html%20WHERE%20%0Aurl%3D%22http%3A%2F%2Fwww.bbc.co.uk%2Fradio1%2Fchart%2Fsingles%2F%22%20and%20xpath%3D%22%2F%2Fli%2Fimg%22%20LIMIT%2020)%20%7C%20sanitize()&amp;format=json&amp;diagnostics=false&amp;_maxage=86400'</span><span class="sy0">,</span></pre></li><li class="li1"><pre class="de1">    cache<span class="sy0">:</span> <span class="kw2">true</span><span class="sy0">,</span></pre></li><li class="li1"><pre class="de1">    dataType<span class="sy0">:</span> <span class="st0">'jsonp'</span><span class="sy0">,</span></pre></li><li class="li1"><pre class="de1">    jsonp<span class="sy0">:</span> <span class="st0">'callback'</span><span class="sy0">,</span></pre></li><li class="li1"><pre class="de1">    jsonpCallback<span class="sy0">:</span> <span class="st0">'yqlSuccess'</span><span class="sy0">,</span></pre></li><li class="li1"><pre class="de1">    success<span class="sy0">:</span> <span class="kw2">function</span><span class="br0">&#40;</span>data<span class="sy0">,</span> text<span class="sy0">,</span> request<span class="br0">&#41;</span> <span class="br0">&#123;</span> yqlSuccess<span class="br0">&#40;</span>data<span class="br0">&#41;</span><span class="sy0">;</span> <span class="br0">&#125;</span><span class="sy0">,</span></pre></li><li class="li1"><pre class="de1">    error<span class="sy0">:</span> <span class="kw2">function</span><span class="br0">&#40;</span>request<span class="sy0">,</span><span class="kw3">status</span><span class="sy0">,</span>errorThown<span class="br0">&#41;</span> <span class="br0">&#123;</span> yqlFail<span class="br0">&#40;</span><span class="kw3">status</span><span class="br0">&#41;</span><span class="sy0">;</span><span class="br0">&#125;</span></pre></li><li class="li1"><pre class="de1">  <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li></ol></div>
<p>If the request fails, show an error message instead of the loading text:</p>
<div class="javascript" style="font-family:monospace;"><ol start="50"><li class="li1"><pre class="de1"><span class="kw2">function</span> yqlFail<span class="br0">&#40;</span><span class="kw3">status</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></pre></li><li class="li1"><pre class="de1">    $<span class="br0">&#40;</span><span class="st0">'#loading'</span><span class="br0">&#41;</span>.<span class="me1">addClass</span><span class="br0">&#40;</span><span class="st0">'fail'</span><span class="br0">&#41;</span>.<span class="me1">html</span><span class="br0">&#40;</span><span class="st0">'Oh noes! '</span> <span class="sy0">+</span> <span class="kw3">status</span> <span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">  <span class="br0">&#125;</span></pre></li></ol></div>
<p>If the request is successful, build a list where each list item has the same ID as the music video on YouTube:</p>
<div class="javascript" style="font-family:monospace;"><ol start="54"><li class="li1"><pre class="de1"><span class="kw2">function</span> yqlSuccess<span class="br0">&#40;</span>data<span class="br0">&#41;</span> <span class="br0">&#123;</span></pre></li><li class="li1"><pre class="de1">&nbsp;</pre></li><li class="li1"><pre class="de1">    $<span class="br0">&#40;</span><span class="st0">'#tracks'</span><span class="br0">&#41;</span>.<span class="me1">empty</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">&nbsp;</pre></li><li class="li1"><pre class="de1">    $.<span class="me1">each</span><span class="br0">&#40;</span>data.<span class="me1">query</span>.<span class="me1">results</span>.<span class="me1">entry</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span>i<span class="sy0">,</span><span class="kw1">item</span><span class="br0">&#41;</span><span class="br0">&#123;</span></pre></li><li class="li1"><pre class="de1">      <span class="kw2">var</span> id <span class="sy0">=</span> <span class="kw1">item</span>.<span class="me1">id</span>.<span class="me1">replace</span><span class="br0">&#40;</span><span class="st0">'http://gdata.youtube.com/feeds/api/videos/'</span><span class="sy0">,</span><span class="st0">''</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">      <span class="kw2">var</span> title <span class="sy0">=</span> <span class="kw1">item</span>.<span class="me1">title</span>.<span class="me1">content</span>.<span class="me1">indexOf</span><span class="br0">&#40;</span><span class="st0">&quot; - &quot;</span><span class="br0">&#41;</span> <span class="sy0">==</span> <span class="sy0">-</span><span class="nu0">1</span> <span class="sy0">?</span> <span class="st0">'&lt;b&gt;'</span> <span class="sy0">+</span> <span class="kw1">item</span>.<span class="me1">title</span>.<span class="me1">content</span> <span class="sy0">+</span> <span class="st0">'&lt;/b&gt;'</span> <span class="sy0">:</span> <span class="st0">'&lt;b&gt;'</span> <span class="sy0">+</span>     <span class="kw1">item</span>.<span class="me1">title</span>.<span class="me1">content</span>.<span class="me1">substring</span><span class="br0">&#40;</span>0<span class="sy0">,</span><span class="kw1">item</span>.<span class="me1">title</span>.<span class="me1">content</span>.<span class="me1">indexOf</span><span class="br0">&#40;</span><span class="st0">&quot; - &quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">'&lt;/b&gt; '</span><span class="sy0">+</span> <span class="kw1">item</span>.<span class="me1">title</span>.<span class="me1">content</span>.<span class="me1">substring</span><span class="br0">&#40;</span><span class="kw1">item</span>.<span class="me1">title</span>.<span class="me1">content</span>.<span class="me1">indexOf</span><span class="br0">&#40;</span><span class="st0">&quot; - &quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">      <span class="kw2">var</span> $li <span class="sy0">=</span> $<span class="br0">&#40;</span><span class="st0">'&lt;li id=&quot;'</span> <span class="sy0">+</span> id <span class="sy0">+</span> <span class="st0">'&quot; &gt;&lt;a title=&quot;Play '</span> <span class="sy0">+</span> <span class="kw1">item</span>.<span class="me1">title</span>.<span class="me1">content</span> <span class="sy0">+</span> <span class="st0">'&quot; href=&quot;http://www.youtube.com/watch#!v='</span> <span class="sy0">+</span> id <span class="sy0">+</span> <span class="st0">'&quot;&gt;'</span> <span class="sy0">+</span> title <span class="sy0">+</span> <span class="st0">' &lt;/li&gt;&lt;/a&gt;'</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">      $li.<span class="me1">click</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> player.<span class="me1">userEnded</span> <span class="sy0">=</span> <span class="kw2">true</span><span class="sy0">;</span> player.<span class="me1">currentVideoID</span> <span class="sy0">=</span> <span class="kw1">this</span>.<span class="me1">id</span><span class="sy0">;</span> player.<span class="me1">playvideo</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span>  <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">      $<span class="br0">&#40;</span><span class="st0">'#tracks'</span><span class="br0">&#41;</span>.<span class="me1">append</span><span class="br0">&#40;</span>$li<span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">    <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">&nbsp;</pre></li><li class="li1"><pre class="de1">    player.<span class="me1">playvideo</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">  <span class="br0">&#125;</span></pre></li><li class="li1"><pre class="de1">&nbsp;</pre></li><li class="li1"><pre class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></pre></li></ol></div>
<p><code>onPlayerStateChang</code>e has been wired up on line 7 to fire every time there&#8217;s a change in state. This could be from the music video starting, ending, or a user skipping a track.</p>
<div class="javascript" style="font-family:monospace;"><ol start="70"><li class="li1"><pre class="de1"><span class="kw2">function</span> onPlayerStateChange<span class="br0">&#40;</span>newState<span class="br0">&#41;</span> <span class="br0">&#123;</span></pre></li><li class="li1"><pre class="de1">&nbsp;</pre></li><li class="li1"><pre class="de1">  <span class="kw1">if</span> <span class="br0">&#40;</span>newState <span class="sy0">==</span> <span class="nu0">0</span> <span class="sy0">&amp;&amp;</span> <span class="sy0">!</span>player.<span class="me1">userEnded</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="co1">// track finished</span></pre></li><li class="li1"><pre class="de1">    player.<span class="me1">currentVideoID</span> <span class="sy0">=</span> $<span class="br0">&#40;</span><span class="st0">'#'</span> <span class="sy0">+</span> player.<span class="me1">currentVideoID</span><span class="br0">&#41;</span>.<span class="me1">next</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">attr</span><span class="br0">&#40;</span><span class="st0">'id'</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">    player.<span class="me1">playvideo</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">  <span class="br0">&#125;</span></pre></li><li class="li1"><pre class="de1">&nbsp;</pre></li><li class="li1"><pre class="de1"><span class="br0">&#125;</span><span class="sy0">;</span></pre></li></ol></div>
<p>View the complete listing at <a href="http://addbass.com/top20/top.js">http://addbass.com/top20/top.js</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bassett-jones.com/music-mashing-with-youtube-yql-and-open-data-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Category Clouds WordPress widget</title>
		<link>http://www.bassett-jones.com/category-clouds-wordpress-widget/</link>
		<comments>http://www.bassett-jones.com/category-clouds-wordpress-widget/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 17:10:47 +0000</pubDate>
		<dc:creator>Hugh</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[wordpress plugin]]></category>

		<guid isPermaLink="false">http://www.bassett-jones.com/?p=628</guid>
		<description><![CDATA[A WordPress widget that displays selected categories as a tag cloud]]></description>
			<content:encoded><![CDATA[<p>Tag clouds are an effective way of conveying information about the popularity of key words where the size of the word corresponds to the importance of the word. It is also visually more interesting than a standard list and attracts attention.</p>
<p><a href="http://www.superfundaysout.com"><img class="alignnone size-full wp-image-652" title="example category cloud" src="http://www.bassett-jones.com/wp-content/uploads/2010/03/example-category-cloud.png" alt="" width="588" height="173" /></a></p>
<p>On Super Fun Days Out we needed something similar to WordPress&#8217;s built in tag cloud using categories instead of tags. Fortunately WordPress has an active plugin community and developer Lee Kelleher had already written a <a href="http://leekelleher.com/wordpress/plugins/category-cloud-widget/">Category Cloud widget</a>. A couple of changes were needed to update it for multiple sidebars and to include or exclude specific categories.</p>
<p>Now hosted at WordPress.org at <a href="http://wordpress.org/extend/plugins/category-clouds-widget/stats/">http://wordpress.org/extend/plugins/category-clouds-widget/stats/</a>.</p>
<ul class="download">
<li class="zip"><span>Download widget</span><a href="http://downloads.wordpress.org/plugin/category-clouds-widget.zip">3k zip file for WordPress 1.8+</a></li>
<li class="source"><span>View source</span><a href="/wp-content/uploads/2010/03/category_clouds.php.txt">8k text file of PHP</a></li>
</ul>
<p><span id="more-628"></span></p>
<h2>How to use</h2>
<ol>
<li>Download <a href="http://downloads.wordpress.org/plugin/category-clouds-widget.zip">Category Clouds</a> and unzip</li>
<li>Upload category_clouds folder to the /wp-content/plugins/ directory</li>
<li>Activate the plugin through the &#8216;Plugins&#8217; menu in WordPress</li>
<li>Add the widget to your sidebar through the &#8216;Appearance &gt; Widgets&#8217; menu</li>
</ol>
<h3>Widget options</h3>
<p><img class="alignleft size-full wp-image-631" style="margin-right: 20px;" src="http://www.bassett-jones.com/wp-content/uploads/2010/03/category-clouds-admin.png" alt="Category Clouds plugin widget page" width="260" height="386" /></p>
<h4>Title</h4>
<p>This is the usual widget title that will appear in your theme&#8217;s sidebar.</p>
<h4>Category font size</h4>
<p>The minimum and maximum font sizes you want the cloud to show and their unit of measurement. For example, <code>min: 50 max: 200 unit: %</code> would show the smallest category at half your normal text size and the largest at double.</p>
<h4>Order by</h4>
<p>Choose between ordering by number of posts in a category, or alphabetically by category name.</p>
<h4>Show by</h4>
<p>Either the category with the most posts first or the category with the fewest posts first if using <code>Order by: count</code>, or A-Z or Z-A if <code>Order by: name</code>.</p>
<h4>Minimum number of posts</h4>
<p>Categories where the total number of posts is less than this number will not be shown. Set to <code>1</code> to hide empty categories.</p>
<h4>Comma separated category IDs</h4>
<p>If you only want to include specific categories, enter their IDs in a list. If you want to <em>exclude</em> a category, enter its ID as a negative number. Leave blank for all categories.</p>
<p>Example: <code>1,4,9,36,37,38</code><br />
This will create a category cloud with only categories <code>1,4,9,36,37,38</code> in it.</p>
<p>Example: <code>-1,-3</code><br />
This will create a category cloud hiding categories <code>1</code> and <code>3</code>.</p>
<h2>Code breakdown</h2>
<p>This section isn&#8217;t required to use Category Clouds, but discusses how it works.</p>
<p>The plugin comprises three main sections: using the widget class, getting the data from the database, and setting the font size.</p>
<h4>Using the <code>WP_Widget</code> class</h4>
<p>Category Clouds extends the <a href="http://codex.wordpress.org/Widgets_API"><code>WP_Widget</code></a> widget class which already has the plumbing to work with multiple sidebars, display configuration options and save those options to the database. Justin Tadlock has a useful <a href="http://justintadlock.com/archives/2009/05/26/the-complete-guide-to-creating-widgets-in-wordpress-28">introduction guide</a> on how to develop a basic widget using WordPress 2.8+.</p>
<h4>Getting the data from the database</h4>
<p>All the heavy lifting for database access for this widget is by using the WordPress query <code><a href="http://codex.wordpress.org/Function_Reference/get_categories">get_categories</a></code>, which means most of the work is performed on the database server, not on the PHP server. This accepts a number of parameters and returns a collection of categories. Category Clouds conditionally builds the query parameters based on the saved options:</p>
<div class="php" style="font-family:monospace;"><ol><li class="li1"><pre class="de1"><span class="kw2">&lt;?php</span></pre></li><li class="li1"><pre class="de1"><span class="co1">// build query</span></pre></li><li class="li1"><pre class="de1"><span class="re0">$query</span> <span class="sy0">=</span> <span class="st_h">'show_option_all=1&amp;style=cloud&amp;show_count=1&amp;use_desc_for_title=0&amp;hierarchical=0'</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"><span class="re0">$query</span> <span class="sy0">.=</span> <span class="st_h">'&amp;order='</span> <span class="sy0">.</span> <span class="re0">$instance</span><span class="br0">&#91;</span><span class="st_h">'order'</span><span class="br0">&#93;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"><span class="re0">$query</span> <span class="sy0">.=</span> <span class="st_h">'&amp;orderby='</span> <span class="sy0">.</span> <span class="re0">$instance</span><span class="br0">&#91;</span><span class="st_h">'orderby'</span><span class="br0">&#93;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"><span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$instance</span><span class="br0">&#91;</span><span class="st_h">'min_count'</span><span class="br0">&#93;</span> <span class="sy0">&gt;</span> 0<span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$query</span> <span class="sy0">.=</span> <span class="st_h">'&amp;hide_empty=1'</span><span class="sy0">;</span><span class="br0">&#125;</span></pre></li><li class="li1"><pre class="de1"><span class="sy1">?&gt;</span></pre></li></ol></div>
<p>Specific categories to include or exclude are added to the query as needed by checking the saved comma separated list of ID numbers:</p>
<div class="php" style="font-family:monospace;"><ol><li class="li1"><pre class="de1"><span class="kw2">&lt;?php</span></pre></li><li class="li1"><pre class="de1"><span class="co1">// specified categories</span></pre></li><li class="li1"><pre class="de1"><span class="re0">$inc_cats</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$exc_cats</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"><span class="kw1">foreach</span> <span class="br0">&#40;</span><a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;,&quot;</span> <span class="sy0">,</span><span class="re0">$instance</span><span class="br0">&#91;</span><span class="st_h">'cats_inc_exc'</span><span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="kw1">as</span> <span class="re0">$spec_cat</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></pre></li><li class="li1"><pre class="de1">  <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$spec_cat</span> <span class="sy0">&lt;</span> 0<span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$exc_cats</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <a href="http://www.php.net/abs"><span class="kw3">abs</span></a><span class="br0">&#40;</span><span class="re0">$spec_cat</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="br0">&#125;</span></pre></li><li class="li1"><pre class="de1">  <span class="kw1">elseif</span> <span class="br0">&#40;</span> <span class="re0">$spec_cat</span> <span class="sy0">&gt;</span> 0<span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$inc_cats</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <a href="http://www.php.net/abs"><span class="kw3">abs</span></a><span class="br0">&#40;</span><span class="re0">$spec_cat</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="br0">&#125;</span></pre></li><li class="li1"><pre class="de1"><span class="br0">&#125;</span></pre></li><li class="li1"><pre class="de1"><span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/count"><span class="kw3">count</span></a><span class="br0">&#40;</span><span class="re0">$inc_cats</span><span class="br0">&#41;</span> <span class="sy0">&gt;</span> 0<span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$query</span> <span class="sy0">.=</span> <span class="st_h">'&amp;include='</span> <span class="sy0">.</span> <a href="http://www.php.net/implode"><span class="kw3">implode</span></a><span class="br0">&#40;</span><span class="st0">&quot;,&quot;</span><span class="sy0">,</span> <span class="re0">$inc_cats</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="br0">&#125;</span></pre></li><li class="li1"><pre class="de1"><span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/count"><span class="kw3">count</span></a><span class="br0">&#40;</span><span class="re0">$exc_cats</span><span class="br0">&#41;</span> <span class="sy0">&gt;</span> 0<span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$query</span> <span class="sy0">.=</span> <span class="st_h">'&amp;exclude='</span> <span class="sy0">.</span> <a href="http://www.php.net/implode"><span class="kw3">implode</span></a><span class="br0">&#40;</span><span class="st0">&quot;,&quot;</span><span class="sy0">,</span> <span class="re0">$exc_cats</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="br0">&#125;</span></pre></li><li class="li1"><pre class="de1"><span class="sy1">?&gt;</span></pre></li></ol></div>
<p>Finally, each category is checked to make sure it has the required number of posts:</p>
<div class="php" style="font-family:monospace;"><ol><li class="li1"><pre class="de1"><span class="kw2">&lt;?php</span></pre></li><li class="li1"><pre class="de1"><span class="co1">// ensure minimum post count</span></pre></li><li class="li1"><pre class="de1"><span class="re0">$cats</span> <span class="sy0">=</span> get_categories<span class="br0">&#40;</span><span class="re0">$query</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"><span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re0">$cats</span> <span class="kw1">as</span> <span class="re0">$cat</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></pre></li><li class="li1"><pre class="de1">  <span class="re0">$catlink</span> <span class="sy0">=</span> get_category_link<span class="br0">&#40;</span> <span class="re0">$cat</span><span class="sy0">-&gt;</span><span class="me1">cat_ID</span> <span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">  <span class="re0">$catname</span> <span class="sy0">=</span> <span class="re0">$cat</span><span class="sy0">-&gt;</span><span class="me1">cat_name</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">  <span class="re0">$count</span> <span class="sy0">=</span> <span class="re0">$cat</span><span class="sy0">-&gt;</span><span class="me1">category_count</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">  <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$count</span> <span class="sy0">&gt;=</span> <span class="re0">$instance</span><span class="br0">&#91;</span><span class="st_h">'min_count'</span><span class="br0">&#93;</span><span class="br0">&#41;</span>  <span class="br0">&#123;</span></pre></li><li class="li1"><pre class="de1">    <span class="re0">$counts</span><span class="br0">&#123;</span><span class="re0">$catname</span><span class="br0">&#125;</span> <span class="sy0">=</span> <span class="re0">$count</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">    <span class="re0">$catlinks</span><span class="br0">&#123;</span><span class="re0">$catname</span><span class="br0">&#125;</span> <span class="sy0">=</span> <span class="re0">$catlink</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">  <span class="br0">&#125;</span></pre></li><li class="li1"><pre class="de1"><span class="br0">&#125;</span></pre></li><li class="li1"><pre class="de1"><span class="sy1">?&gt;</span></pre></li></ol></div>
<h4>Outputting the cloud</h4>
<div class="php" style="font-family:monospace;"><ol><li class="li1"><pre class="de1"><span class="kw2">&lt;?php</span></pre></li><li class="li1"><pre class="de1"><span class="co1">// font size calculation</span></pre></li><li class="li1"><pre class="de1"><span class="re0">$spread</span> <span class="sy0">=</span> <a href="http://www.php.net/max"><span class="kw3">max</span></a><span class="br0">&#40;</span><span class="re0">$counts</span><span class="br0">&#41;</span> <span class="sy0">-</span> <a href="http://www.php.net/min"><span class="kw3">min</span></a><span class="br0">&#40;</span><span class="re0">$counts</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$spread</span> <span class="sy0">&lt;=</span> 0<span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$spread</span> <span class="sy0">=</span> <span class="nu0">1</span><span class="sy0">;</span> <span class="br0">&#125;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"><span class="re0">$fontspread</span> <span class="sy0">=</span> <span class="re0">$instance</span><span class="br0">&#91;</span><span class="st_h">'max_size'</span><span class="br0">&#93;</span> <span class="sy0">-</span> <span class="re0">$instance</span><span class="br0">&#91;</span><span class="st_h">'min_size'</span><span class="br0">&#93;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"><span class="re0">$fontstep</span> <span class="sy0">=</span> <span class="re0">$spread</span> <span class="sy0">/</span> <span class="re0">$fontspread</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$fontspread</span> <span class="sy0">&lt;=</span> 0<span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$fontspread</span> <span class="sy0">=</span> <span class="nu0">1</span><span class="sy0">;</span> <span class="br0">&#125;</span></pre></li><li class="li1"><pre class="de1">&nbsp;</pre></li><li class="li1"><pre class="de1"><span class="kw1">echo</span> <span class="st_h">'&lt;p class=&quot;catcloud&quot;&gt;'</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">&nbsp;</pre></li><li class="li1"><pre class="de1"><span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re0">$counts</span> <span class="kw1">as</span> <span class="re0">$catname</span> <span class="sy0">=&gt;</span> <span class="re0">$count</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></pre></li><li class="li1"><pre class="de1">  <span class="re0">$catlink</span> <span class="sy0">=</span> <span class="re0">$catlinks</span><span class="br0">&#123;</span><span class="re0">$catname</span><span class="br0">&#125;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1">  <span class="kw1">echo</span> <span class="st0">&quot;<span class="es1">\n</span>&lt;a href=<span class="es1">\&quot;</span><span class="es4">$catlink</span><span class="es1">\&quot;</span> title=<span class="es1">\&quot;</span>view <span class="es4">$count</span> posts for <span class="es4">$catname</span><span class="es1">\&quot;</span> style=<span class="es1">\&quot;</span>font-size:&quot;</span><span class="sy0">.</span></pre></li><li class="li1"><pre class="de1">    <span class="br0">&#40;</span><span class="re0">$instance</span><span class="br0">&#91;</span><span class="st_h">'min_size'</span><span class="br0">&#93;</span> <span class="sy0">+</span> <a href="http://www.php.net/ceil"><span class="kw3">ceil</span></a><span class="br0">&#40;</span><span class="re0">$count</span><span class="sy0">/</span><span class="re0">$fontstep</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="re0">$instance</span><span class="br0">&#91;</span><span class="st_h">'unit'</span><span class="br0">&#93;</span><span class="sy0">.</span><span class="st0">&quot;<span class="es1">\&quot;</span>&gt;<span class="es4">$catname</span>&lt;/a&gt; &quot;</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"><span class="br0">&#125;</span></pre></li><li class="li1"><pre class="de1">&nbsp;</pre></li><li class="li1"><pre class="de1"><span class="kw1">echo</span> <span class="st_h">'&lt;/p&gt;'</span> <span class="sy0">.</span> <span class="re0">$after_widget</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"><span class="sy1">?&gt;</span></pre></li></ol></div>
]]></content:encoded>
			<wfw:commentRss>http://www.bassett-jones.com/category-clouds-wordpress-widget/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>BBC Micro Chuckie Egg Level 4 Guide</title>
		<link>http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-4-guide/</link>
		<comments>http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-4-guide/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 15:00:02 +0000</pubDate>
		<dc:creator>Hugh</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[bbc micro]]></category>
		<category><![CDATA[chuckie egg]]></category>
		<category><![CDATA[level 4]]></category>

		<guid isPermaLink="false">http://www.bassett-jones.com/?p=599</guid>
		<description><![CDATA[Chuckie Egg level 4: lift, gaps and eggs.]]></description>
			<content:encoded><![CDATA[<p>This is my guide to each Chuckie Egg level:</p>
<ol>
<li><a href="http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-1-guide">Level 1</a></li>
<li><a href="http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-2-guide">Level 2</a></li>
<li><a href="http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-3-guide">Level 3</a></li>
<li><a href="http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-4-guide">Level 4</a></li>
</ol>
<h2>Level 4</h2>
<ul>
<li>Difficulty: <img class="two-star" src="/wp-content/themes/hugh/images/stars.png" alt="Two star out of five difficulty" /></li>
<li>Best time remaining: <strong>826</strong></li>
<li>Number of hens: <strong>4</strong></li>
<li>Speed of hens: <strong>slow</strong></li>
</ul>
<h3>Level 4 strategy</h3>
<p>With a lift and a gap in the bottom platform, this level combines the features introduced in <a href="http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-2-guide">level 2</a> and <a href="http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-3-guide">level 3</a> and adds some tricky jumps to the mix. In particular, the top left jump nearest the caged bird can cause you to fall through if you jump from the nearest platform.</p>
<p>Avoiding hens is still fairly easy where the central ladder can be used to escape.</p>
<p><a href="http://www.bassett-jones.com/wp-content/uploads/2010/03/chuckie-egg-level-4.png"><img class="alignnone size-full wp-image-600" title="chuckie-egg-level-4" src="http://www.bassett-jones.com/wp-content/uploads/2010/03/chuckie-egg-level-4.png" alt="" width="600" height="481" /></a></p>
<p><span id="more-599"></span></p>
<h3>Level 4 video play through</h3>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="473" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube-nocookie.com/v/v5IEyJgawbg&amp;hl=en_GB&amp;fs=1&amp;rel=0" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="600" height="473" src="http://www.youtube-nocookie.com/v/v5IEyJgawbg&amp;hl=en_GB&amp;fs=1&amp;rel=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-4-guide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BBC Micro Chuckie Egg Level 3 Guide</title>
		<link>http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-3-guide/</link>
		<comments>http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-3-guide/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 14:29:36 +0000</pubDate>
		<dc:creator>Hugh</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[bbc micro]]></category>
		<category><![CDATA[chuckie egg]]></category>
		<category><![CDATA[level 3]]></category>

		<guid isPermaLink="false">http://www.bassett-jones.com/?p=595</guid>
		<description><![CDATA[Chuckie Egg level 3 introduces the lift!]]></description>
			<content:encoded><![CDATA[<p>This is my guide to each Chuckie Egg level:</p>
<ol>
<li><a href="http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-1-guide">Level 1</a></li>
<li><a href="http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-2-guide">Level 2</a></li>
<li><a href="http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-3-guide">Level 3</a></li>
</ol>
<h2>Level 3</h2>
<ul>
<li>Difficulty: <img class="two-star" src="/wp-content/themes/hugh/images/stars.png" alt="Two star out of five difficulty" /></li>
<li>Best time remaining: <strong>888</strong></li>
<li>Number of hens: <strong>3</strong></li>
<li>Speed of hens: <strong>slow</strong></li>
</ul>
<h3>Level 3 strategy</h3>
<p>This level introduces the lift. This is three moving platforms, moving vertically up the screen. The platforms are not evenly spaced, with two appearing closer together. Missing the lift and falling down the gap between the lift and the platform will result in a life lost.</p>
<p>The level design makes it easy to avoid the hens, but good timing is needed to complete it quickly.</p>
<p><a href="http://www.bassett-jones.com/wp-content/uploads/2010/03/chuckie-egg-level-3.png"><img class="alignnone size-full wp-image-596" title="chuckie-egg-level-3" src="http://www.bassett-jones.com/wp-content/uploads/2010/03/chuckie-egg-level-3.png" alt="" width="600" height="480" /></a></p>
<p><span id="more-595"></span></p>
<h3>Level 3 video play through</h3>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="473" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube-nocookie.com/v/82lHfmCc-vk&amp;hl=en_GB&amp;fs=1&amp;rel=0" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="600" height="473" src="http://www.youtube-nocookie.com/v/82lHfmCc-vk&amp;hl=en_GB&amp;fs=1&amp;rel=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-3-guide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BBC Micro Chuckie Egg Level 2 Guide</title>
		<link>http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-2-guide/</link>
		<comments>http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-2-guide/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 11:46:10 +0000</pubDate>
		<dc:creator>Hugh</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[bbc micro]]></category>
		<category><![CDATA[chuckie egg]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[playthough]]></category>

		<guid isPermaLink="false">http://www.bassett-jones.com/?p=590</guid>
		<description><![CDATA[Level 2 complete guide to BBC Micro Chuckie Egg with video play through]]></description>
			<content:encoded><![CDATA[<p>This is my guide to each Chuckie Egg level:</p>
<ol>
<li><a href="http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-1-guide">Level 1</a></li>
<li><a href="http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-2-guide">Level 2</a></li>
</ol>
<h2>Level 2</h2>
<ul>
<li>Difficulty: <img class="one-star" src="/wp-content/themes/hugh/images/stars.png" alt="One star out of five difficulty" /></li>
<li>Best time remaining: <strong>831</strong></li>
<li>Number of hens: <strong>3</strong></li>
<li>Speed of hens: <strong>slow</strong><strong> </strong></li>
</ul>
<h3>Level 2 strategy</h3>
<p>The second level has a large number of ladders connecting the platforms. Although there is one more hen compared to level one, there are many jump-able gaps to aid escape and turn back hens.</p>
<p>The single gap on the bottom platform has a gap and falling through results in an instant life lost.</p>
<p><a href="http://www.bassett-jones.com/wp-content/uploads/2010/03/chuckie-egg-level-2.png"><img class="alignnone size-full wp-image-591" title="chuckie-egg-level-2" src="http://www.bassett-jones.com/wp-content/uploads/2010/03/chuckie-egg-level-2.png" alt="" width="600" height="479" /></a></p>
<p><span id="more-590"></span></p>
<h3>Level 2 video play through</h3>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="473" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube-nocookie.com/v/d0nJBY71wEY&amp;hl=en_GB&amp;fs=1&amp;rel=0" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="600" height="473" src="http://www.youtube-nocookie.com/v/d0nJBY71wEY&amp;hl=en_GB&amp;fs=1&amp;rel=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-2-guide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BBC Micro Chuckie Egg Level 1 Guide</title>
		<link>http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-1-guide/</link>
		<comments>http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-1-guide/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 22:39:27 +0000</pubDate>
		<dc:creator>Hugh</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[bbc micro]]></category>
		<category><![CDATA[chuckie egg]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[playthough]]></category>

		<guid isPermaLink="false">http://www.bassett-jones.com/?p=536</guid>
		<description><![CDATA[Level 1 Complete guide to BBC Micro Chuckie Egg with video playthrough]]></description>
			<content:encoded><![CDATA[<p>I was a massive fan of <a href="http://en.wikipedia.org/wiki/Chuckie_Eg">Chuckie Egg</a> on the BBC Micro when I was about 10 years old. There have been a <a href="http://www.gameheads.co.uk/games/retro/chuckie-egg-flash/579">couple</a> <a href="http://www.twinbee.org/hob/play.php?snap=chuckie">of</a> <a href="http://marklomas.net/ch-egg/dhtmlch-egg/playch-egg.htm">ports</a>, but it wasn&#8217;t until 2009 that Mark Lomas released the <a href="http://www.marklomas.net/ch-egg/native/native.htm">ultimate version</a> built on an BBC emulator for the PC.</p>
<p>This is my guide to each Chuckie Egg level:</p>
<ol>
<li><a href="http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-1-guide">Level 1</a></li>
</ol>
<h2>Level 1</h2>
<ul>
<li>Difficulty: <img class="one-star" src="/wp-content/themes/hugh/images/stars.png" alt="One star out of five difficulty" /></li>
<li>Best score: <strong>2,260</strong></li>
<li>Number of hens: <strong>2</strong></li>
<li>Speed of hens: <strong>slow</strong><strong> </strong></li>
</ul>
<h3>Level 1 strategy</h3>
<p>The first level is dominated by a central ladder running through all five platforms. Two hens start in the top left of the level, moving slowly towards the bottom. They can sometimes get in the way on the central ladder, but several nearby platforms can be used to wait them out.</p>
<p>The bottom two platforms have plenty of ladders to avoid getting trapped and to practice running and jumping.</p>
<p><img class="alignnone size-full wp-image-542" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/chuckie-egg-level-1.png" alt="Strategy path for completing level 1 of Chuckie Egg" width="600" /><br />
<br/><br />
<span id="more-536"></span></p>
<h3>Level 1 video play through</h3>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="473" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube-nocookie.com/v/rEiY2HBihTI&amp;hl=en_GB&amp;fs=1&amp;rel=0" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="600" height="473" src="http://www.youtube-nocookie.com/v/rEiY2HBihTI&amp;hl=en_GB&amp;fs=1&amp;rel=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bassett-jones.com/bbc-micro-chuckie-egg-level-1-guide/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Logging laptop battery life</title>
		<link>http://www.bassett-jones.com/logging-laptop-battery-life/</link>
		<comments>http://www.bassett-jones.com/logging-laptop-battery-life/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 11:35:28 +0000</pubDate>
		<dc:creator>Hugh</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[battery life]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[scheduled tasks]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">http://www.bassett-jones.com/?p=461</guid>
		<description><![CDATA[Checking out netbook battery life on Windows 7 with a bit of C#]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-488 noborder" title="1005 ha netbook in shiny white" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/1005ha.jpg" alt="1005 ha netbook in shiny white" width="125" height="125" />I bought an <a href="http://eeepc.asus.com/global/product1005ha.html">Asus EeePC 1005HA Seashell</a> net book for Christmas with Windows 7 and have been very impressed with battery life and lightness. Still… I wasn&#8217;t sure if <a href="http://en.wikipedia.org/wiki/Sleep_mode">Sleep mode</a> was working as expected, so I logged the battery life for a couple of days under normal use.</p>
<p>I didn&#8217;t use any rigorous scientific testing — &#8216;normal use&#8217; for me was watching a bit of YouTube or iPlayer, checking my email, using Facebook and that kind of thing. If power <em>was</em> still being consumed in Sleep mode, then I would expect big falls in power levels as the net book logged the level after coming out of Sleep.</p>
<h2>Results</h2>
<p>Download <a href="http://www.bassett-jones.com/wp-content/uploads/2010/01/BatteryStatusData.zip">BatteryStatusData</a> for CSV data file of this graph.<br />
<img class="aligncenter noborder size-full wp-image-504" title="netbook-battery-graph" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/netbook-battery-graph.gif" alt="line graph of battery life of my network in percentage remaining and calculated number of hours left" width="570" height="290" /><br />
<span id="more-461"></span>The gaps in the <em>hours remaining</em> green line are where I&#8217;ve removed data that reported -1 hours remaining.</p>
<p><em>Hours remaining</em> appears to be calculated depending on the current task when the log was taken. For example, if I was watching a video, the projected hours remaining if I kept just watching videos is less than if I closed the video and browsed the web.</p>
<p><em>Percentage remaining</em> shows a steady decline. Logging only takes place when the laptop is open, so this is as expected if sleep mode is working as expected. Looks like everything is working as it should be.</p>
<h2>Logging battery life</h2>
<p>Download <a href="http://www.bassett-jones.com/wp-content/uploads/2010/01/BatteryLogger.zip">BatteryLogging.exe</a> and <a href="http://www.bassett-jones.com/wp-content/uploads/2010/01/BatteryLoggerTask.zip">Windows 7 scheduled task</a>.</p>
<p>The battery logger is a scheduled task that runs a simple C# console application regularly. It requires at least version 2.0 of the .net framework due to the PowerStatus class.</p>
<pre>1.  string logFile = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop), "BatteryStatus.csv");
2.
3.  if (!System.IO.File.Exists(logFile))
4.    System.IO.File.WriteAllText(logFile, "Date,Life in seconds,Life in percentage" + System.Environment.NewLine);
5.
6.  string CSV = string.Join(",", new string[] {
7.    System.DateTime.Now.ToString("s"),
8.    System.Windows.Forms.SystemInformation.PowerStatus.BatteryLifeRemaining.ToString(),
9.    System.Windows.Forms.SystemInformation.PowerStatus.BatteryLifePercent.ToString(),
10.   System.Environment.NewLine});
11.
12. System.IO.File.AppendAllText(logFile, CSV);</pre>
<h3>Code breakdown</h3>
<p>1. <code>logFile</code> uses the <code>SpecialFolder</code> enum to create a file path to the user&#8217;s desktop<br />
3. Checks whether the file already exists.<br />
4. <code>WriteAllText</code> will create the file and add the headings of the columns. <code>Environment.NewLine</code> is used to avoid hard-coding in line breaks.<br />
6. <code>CSV</code> will hold line of data to add to the CSV file. <code>string.Join</code> creates the comma separated list.<br />
7. <code>"s"</code> is the <a title="see on msdn" href="http://msdn.microsoft.com/en-us/library/az4se3k1.aspx">standard date and time format</a> for the sortable date time pattern e.g. 2010-01-17T13:45:30.<br />
8. <code>BatteryLifeRemaining</code> gets the approximate number of seconds of battery time remaining using the <a title="see on msdn" href="http://msdn.microsoft.com/en-us/library/system.windows.forms.powerstatus">PowerStatus</a> class.<br />
9. <code>BatteryLifeRemaining</code> gets the approximate percentage of full battery time remaining and appears to be a bit more accurate sometimes for my netbook than BatteryLifeRemaining.<br />
12. <code>AppendAllText</code> open, adds the line of data and closes the file.</p>
<h3>Creating a Window 7 scheduled task</h3>
<p>Press the Windows key and enter &#8216;task scheduler&#8217; into the search box. Select <em>Task Scheduler</em> from the <em>Programs</em> section.</p>
<p><img class="aligncenter size-full wp-image-509" title="launch-task-scheduler" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/launch-task-scheduler.png" alt="screen shot of task scheduler" width="410" height="291" /></p>
<p>Select <em>Create Task&#8230;</em> from the <em>Actions</em> menu.</p>
<p><img class="aligncenter size-full wp-image-511" title="create-task" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/create-task.png" alt="screen shot of creating a new scheduled task" width="600" height="300" /></p>
<p>Complete the fields <em>Name</em> and <em>Description</em> in the General tab. Leave the other options as default.</p>
<p><img class="size-full wp-image-510" title="create-task-1" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/create-task-1.png" alt="screen shot of creating a scheduled task" width="600" height="451" /></p>
<p>From the <em>Triggers</em> tab, select <em>New&#8230; </em>Under advanced settings, make sure <em>Repeat task</em> and <em>Enabled</em> are set.</p>
<p><a href="http://www.bassett-jones.com/wp-content/uploads/2010/01/task-trigger.png"><img class="aligncenter size-full wp-image-523" title="task-trigger" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/task-trigger.png" alt="screen shot of setting a scheduled task trigger" width="600" /></a></p>
<p>When the task trigger has been hit, we want the <em>BatteryLogger</em> program to run.</p>
<p><a href="http://www.bassett-jones.com/wp-content/uploads/2010/01/task-actions.png"><img class="aligncenter size-full wp-image-520" title="task-actions" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/task-actions.png" alt="screen shot of scheduled task actions" width="600" /></a></p>
<p>By default, scheduled tasks are only run when the computer is plugged into the power socket.</p>
<p><a href="http://www.bassett-jones.com/wp-content/uploads/2010/01/task-conditions.png"><img class="aligncenter size-full wp-image-524" title="task-conditions" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/task-conditions.png" alt="screen shot of scheduled task conditions" width="600" /></a></p>
<p>The new task is ready to run.</p>
<p><a href="http://www.bassett-jones.com/wp-content/uploads/2010/01/task-status.png"><img class="aligncenter size-full wp-image-522" title="task-status" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/task-status.png" alt="screen shot of completed scheduled task" width="600" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bassett-jones.com/logging-laptop-battery-life/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extract a web site&#8217;s colour palette</title>
		<link>http://www.bassett-jones.com/extract-a-web-sites-colour-palette/</link>
		<comments>http://www.bassett-jones.com/extract-a-web-sites-colour-palette/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 19:06:19 +0000</pubDate>
		<dc:creator>Hugh</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jslint]]></category>

		<guid isPermaLink="false">http://www.bassett-jones.com/?p=433</guid>
		<description><![CDATA[How to build a bookmarklet that shows the colour palette of a web site]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.bassett-jones.com/wp-content/uploads/2010/01/example-colour-schema.png"><img class="alignright size-full wp-image-447" title="example-colour-schema" src="http://www.bassett-jones.com/wp-content/uploads/2010/01/example-colour-schema.png" alt="" width="251" height="200" /></a><a href="http://www.hextractor.com/">Hextractor </a>is an awesome tool. From their website:</p>
<blockquote><p>Hextractor will extract the colors from your stylesheet — whether they're hex codes, RGB, or named colors — and generate a color palette from them showing you exactly what you've got, displayed in the formats you prefer.</p></blockquote>
<p>However, extracting the colours does rely on a server-side php script and I thought it would make an ideal javascript bookmarklet. An example of the result is shown on the right.</p>
<p>This page also helps me to documents some common javascript examples and links for reference.</p>
<h3>How to install the colour palette bookmarklet</h3>
<p>Try it now! Click <a href="javascript:'use strict';(function(){var g=document.getElementsByTagName('*'),c=g.length,b=['color','borderTopColor','borderRightColor','borderBottomColor','borderLeftColor','backgroundColor'],h={},d,a='',e,f;do{d=g[c-1].currentStyle?g[c-1].currentStyle:window.getComputedStyle(g[c-1],null);for(e=0;e<b.length;e+=1){h[d[b[e]]]=h[d[b[e]]]===undefined?1:h[d[b[e]]]+1}}while(--c);for(f in h){if(h.hasOwnProperty(f)){a+='
<li style=%22margin:3px;padding-left:3px;border-left:solid 50px '+f+'%22>'+f+' ('+h[f]+')</li>
<p>'}}document.getElementsByTagName('body')[0].innerHTML='
<ol style=%22color:#111;margin:5px;padding:5px;width:250px;border:solid 1px goldenrod;background:#fff;opacity:0.9;%22>
<li style=%22padding:0 0 5px 0;font-weight:bold;color:#111;%22>Colours used on this page</li>
<p>'+a+'<br><a href=%22http://www.bassett-jones.com/extract-a-web-sites-colour-palette%22>About this bookmarklet</a> | <a href=%22http://hugh.bassett-jones.com%22>By Hugh</a></ol>
<p>'+document.getElementsByTagName('body')[0].innerHTML}());">this link</a> to view the colours on this site.</p>
<p>To use on other web sites, click and drag this <a href="javascript:'use strict';(function(){var g=document.getElementsByTagName('*'),c=g.length,b=['color','borderTopColor','borderRightColor','borderBottomColor','borderLeftColor','backgroundColor'],h={},d,a='',e,f;do{d=g[c-1].currentStyle?g[c-1].currentStyle:window.getComputedStyle(g[c-1],null);for(e=0;e<b.length;e+=1){h[d[b[e]]]=h[d[b[e]]]===undefined?1:h[d[b[e]]]+1}}while(--c);for(f in h){if(h.hasOwnProperty(f)){a+='
<li style=%22margin:3px;padding-left:3px;border-left:solid 50px '+f+'%22>'+f+' ('+h[f]+')</li>
<p>'}}document.getElementsByTagName('body')[0].innerHTML='
<ol style=%22color:#111;margin:5px;padding:5px;width:250px;border:solid 1px goldenrod;background:#fff;opacity:0.9;%22>
<li style=%22padding:0 0 5px 0;font-weight:bold;color:#111;%22>Colours used on this page</li>
<p>'+a+'<br><a href=%22http://www.bassett-jones.com/extract-a-web-sites-colour-palette%22>About this bookmarklet</a> | <a href=%22http://hugh.bassett-jones.com%22>By Hugh</a></ol>
<p>'+document.getElementsByTagName('body')[0].innerHTML}());">show page colours</a> link to add it to your favorites or bookmarks bar. Visit the web site you would like to see the colour palette of and click on the bookmark or favorite. It will then show the 'Colours used on this page' table.</p>
<ol>
<li><a href="/extract-a-web-sites-colour-palette/#whatis">What is a bookmarklet?</a></li>
<li><a href="/extract-a-web-sites-colour-palette/#outline">Outline of the colour palette bookmarklet</a></li>
<li><a href="/extract-a-web-sites-colour-palette/#code">Code deconstruction</a></li>
<li><a href="/extract-a-web-sites-colour-palette/#jslint">Using JSLint for best practice javascript</a></li>
<li><a href="/extract-a-web-sites-colour-palette/#compressing">Compressing the bookmarklet</a></li>
</ol>
<p><span id="more-433"></span></p>
<h2 id="whatis">What is a bookmarklet?</h2>
<p>A <a href="http://en.wikipedia.org/wiki/Bookmarklet">bookmarklet</a>, or <a href="http://tantek.com/favelets/">favelet</a> is usually a small piece of javascript that can modify a page in a particular way. By adding the bookmarklet to a user's bookmarks, it can be executed on any web page. Examples of bookmarklets include:</p>
<ul>
<li><a href="javascript:void(window.resizeTo(640,480))">changing the window size to 1024 x 768 pixels</a></li>
<li><a href="javascript:void(document.location='http://validator.w3.org/check?uri='+escape(document.location))">validating the current page with the W3C validator</a></li>
<li><a href="javascript:(function(){var i,x; for (i=0;x=document.links[i];++i)x.style.color=[%22blue%22,%22red%22,%22orange%22][sim(x,location)]; function sim(a,b) { if (a.hostname!=b.hostname) return 0; if (fixPath(a.pathname)!=fixPath(b.pathname) || a.search!=b.search) return 1; return 2; } function fixPath(p){ p = (p.charAt(0)==%22/%22 ? %22%22 : %22/%22) + p;/*many browsers*/ p=p.split(%22?%22)[0];/*opera*/ return p; } })()">highlighting links in a page</a></li>
</ul>
<h2 id="outline">Outline of the colour palette bookmarklet</h2>
<p>The bookmarklet can be broken down into the following steps:</p>
<ol>
<li>Get all the html tags that make up the web page</li>
<li>Examine each tag to see its text colour, border colour and background colour.</li>
<li>Add each colour to a holding array</li>
<li>Show a list of distinct colours and their values</li>
</ol>
<h2 id="code">Code deconstruction</h2>
<p>Full listing with line numbers:</p>
<pre><a href="#line1">1</a>  'use strict';
<a href="#line2">2</a>  /*global window: false */
3
<a href="#line4">4</a>  (function () {
<a href="#line5">5</a>    var elements = document.getElementsByTagName('*'),
<a href="#line5">6</a>    elementsLength = elements.length,
<a href="#line5">7</a>    attributes = ['color', 'borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor', 'backgroundColor'],
<a href="#line5">8</a>    colours = {},
<a href="#line5">9</a>    style,
<a href="#line5">10</a>   output = '',
<a href="#line5">11</a>   count,
<a href="#line5">12</a>   property;
13
<a href="#line14">14</a>   do {
<a href="#line15">15</a>     style = elements[elementsLength - 1].currentStyle ? elements[elementsLength - 1].currentStyle : window.getComputedStyle(elements[elementsLength - 1], null);
<a href="#line16">16</a>     for (count = 0; count &lt; attributes.length; count += 1) {
<a href="#line17">17</a>       colours[style[attributes[count]]] = colours[style[attributes[count]]] === undefined ? 1 : colours[style[attributes[count]]] + 1;
<a href="#line16">18</a>     }
<a href="#line14">19</a>   } while (--elementsLength);
20
<a href="#line21">21</a>   for (property in colours) {
<a href="#line22">22</a>     if (colours.hasOwnProperty(property)) {
<a href="#line23">23</a>       output += '&lt;li style=%22margin:3px;padding-left:3px;border-left:solid 50px ' + property + '%22&gt;' + property + ' (' + colours[property] + ')&lt;/li&gt;';
<a href="#line22">24</a>     }
<a href="#line21">25</a>   }
26
<a href="#line27">27</a>   document.getElementsByTagName('body')[0].innerHTML = '&lt;ol style=%22color:#111;margin:5px;padding:5px;width:250px;border:solid 1px goldenrod;background:#fff;opacity:0.9;%22&gt;&lt;li style=%22padding:0 0 5px 0;font-weight:bold;color:#111;%22&gt;Colours used on this page&lt;/li&gt;' + output + '&lt;br&gt;&lt;a href=%22http://www.bassett-jones.com/page-colours-bookmarklet%22&gt;About this bookmarklet&lt;/a&gt; | &lt;a href=%22http://hugh.bassett-jones.com%22&gt;By Hugh&lt;/a&gt;&lt;/ol&gt;' + document.getElementsByTagName('body')[0].innerHTML;
28
<a href="#line4">29</a> }());</pre>
<p><em>Line 1</em> is a way of reporting errors when using poor javascript practice. John Resig covers it in more detail in <a href="http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more">ECMAScript 5 Strict Mode</a>.</p>
<p><em>Line 2</em> comment used for the <a href="#jslint">JSLint checker</a>.</p>
<p><em>Line 4</em> encapsulates the javascript to avoid conflicts and global scope of variables. <a href="http://stackoverflow.com/questions/1634268/explain-javascripts-encapsulated-anonymous-function-syntax">Stack Overflow</a> has a great explanation.</p>
<p><em>Lines 5-12</em> declare and initial all variables used in the script.</p>
<p><em>Lines 14 + 19</em> efficiently loop backwards through all the elements in the page.</p>
<p><em>Line 15</em> get the <a href="https://developer.mozilla.org/en/DOM/window.getComputedStyle">computedStyle</a> for non-IE browsers or the <a href="http://msdn.microsoft.com/en-us/library/ms535231(VS.85).aspx">currentStyle</a> for Internet Explorer.</p>
<p><em>Line 16</em> loop through the list of previously declared style attributes such as background colour and border colour.</p>
<p><em>Line 17</em> check whether the holding colour list already contains the style colour. If so, add to the count, otherwise add it to the list.</p>
<p><em>Line 21</em> loop through the properties of the colour holding list.</p>
<p><em>Line 22</em> <a href="https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference:Global_Objects:Object:hasOwnProperty">hasOwnProperty</a> removes properties inherited through the prototype chain.</p>
<p><em>Line 23</em> adds a html list item to the output string. %22 is the <a href="http://www.w3schools.com/jsref/jsref_escape.asp">escaped value</a> of ", as the raw quote symbol will eventually be used in the href link.</p>
<p><em>Line 27</em> inserts the output string at the top of the &lt;body&gt; tag.</p>
<h2 id="jslint">Using JSLint for best practice javascript</h2>
<p>Once the javascript is written and tested in a couple of browsers to make sure it works, it can be a good idea to run it though <a href="http://jslint.com">JSLint</a> to test for code quality. The colour palette bookmarklet was run through with 'The Good Parts' and 'Assume a browser' checked, which results in the options list of:</p>
<pre>/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, strict: true, newcap: true, immed: true */</pre>
<h2 id="compressing">Compressing the bookmarklet</h2>
<p>Internet Explorer supports a <a href="http://support.microsoft.com/kb/208427">maximum URL length of 1,083</a>, with other modern browsers having no effective limit. This means that the javascript needs to be under 1,083 characters in total to work in IE. Luckily, there are a number of <a href="http://compressorrater.thruhere.net/">javascript compressors available online</a> which can crunch variable names to single characters, remove unnecessary comments and delete white space.</p>
<p>Using the <a href="http://developer.yahoo.com/yui/compressor/">YUI compressor</a> results in 1,010 characters for the colour bookmarklet</p>
<pre>javascript:'use strict';(function(){var g=document.getElementsByTagName('*'),c=g.length,b=['color','borderTopColor','borderRightColor','borderBottomColor','borderLeftColor','backgroundColor'],h={},d,a='',e,f;do{d=g[c-1].currentStyle?g[c-1].currentStyle:window.getComputedStyle(g[c-1],null);for(e=0;e&lt;b.length;e+=1){h[d[b[e]]]=h[d[b[e]]]===undefined?1:h[d[b[e]]]+1}}while(--c);for(f in h){if(h.hasOwnProperty(f)){a+='&lt;li style=%22margin:3px;padding-left:3px;border-left:solid 50px '+f+'%22&gt;'+f+' ('+h[f]+')&lt;/li&gt;'}}document.getElementsByTagName('body')[0].innerHTML='&lt;ol style=%22color:#111;margin:5px;padding:5px;width:250px;border:solid 1px goldenrod;background:#fff;opacity:0.9;%22&gt;&lt;li style=%22padding:0 0 5px 0;font-weight:bold;color:#111;%22&gt;Colours used on this page&lt;/li&gt;'+a+'&lt;br&gt;&lt;a href=%22http://www.bassett-jones.com/extract-a-web-sites-colour-palette%22&gt;About this bookmarklet&lt;/a&gt; | &lt;a href=%22http://hugh.bassett-jones.com%22&gt;By Hugh&lt;/a&gt;&lt;/ol&gt;'+document.getElementsByTagName('body')[0].innerHTML}());</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bassett-jones.com/extract-a-web-sites-colour-palette/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Making a magic dragon</title>
		<link>http://www.bassett-jones.com/making-a-magic-dragon/</link>
		<comments>http://www.bassett-jones.com/making-a-magic-dragon/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 13:10:56 +0000</pubDate>
		<dc:creator>Hugh</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[cat illusion]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[magic dragon]]></category>
		<category><![CDATA[optical illusion]]></category>
		<category><![CDATA[super robot dog]]></category>

		<guid isPermaLink="false">http://www.bassett-jones.com/?p=379</guid>
		<description><![CDATA[Step by step instructions on how to cut out and assemble a dragon that stares at you as you walk around the room]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="480" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube-nocookie.com/v/vhttv0jiHd0&amp;hl=en_GB&amp;fs=1&amp;rel=0" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="600" height="480" src="http://www.youtube-nocookie.com/v/vhttv0jiHd0&amp;hl=en_GB&amp;fs=1&amp;rel=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p style="text-align: center;"><a href="http://www.youtube.com/watch?v=vhttv0jiHd0"> TROGDOR the BURNINATOR Magic Dragon on YouTube</a></p>
<h2>You will need</h2>
<ol>
<li><a href="http://www.bassett-jones.com/making-a-magic-dragon/#templates">Template print out</a></li>
<li>Scissors</li>
<li>A tiny bit of sticky tape</li>
<li>Socks to be knocked off</li>
</ol>
<h3 id="templates">Templates</h3>
<table border="0">
<tbody>
<tr>
<td>
<h4 style="text-align: center;">Cat Illusion</h4>
<p><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/Cat-Illusion.jpg"><img class="alignleft size-thumbnail wp-image-382" title="cat illusion template" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/Cat-Illusion-150x150.jpg" alt="Cat Illusion template" width="150" height="150" /></a></p>
<p style="text-align: center;"><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/Cat-Illusion.jpg">download</a> | <a href="http://papercraft.wikidot.com/papercraft:cat-illusion">source</a></p>
</td>
<td>
<h4 style="text-align: center;">Dragon Illusion</h4>
<p><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/green-dragon.jpg"><img class="alignleft size-thumbnail wp-image-390" title="dragon illusion template" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/green-dragon-150x150.jpg" alt="green dragon illusion template" width="150" height="150" /></a></p>
<p style="text-align: center;"><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/green-dragon.jpg">download</a> | <a href="http://www.grand-illusions.com/opticalillusions/dragon_illusion/">source</a></p>
</td>
<td>
<h4 style="text-align: center;">Super Robot Dog</h4>
<p><a href="http://www.bymanstudio.com/blog/SuperRobot_Dog.pdf"> <img class="alignleft size-thumbnail wp-image-396" title="super robot dog illusion template" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/SuperRobot_Dog_pat-150x150.jpg" alt="SuperRobot illusion template" width="150" height="150" /></a></p>
<p style="text-align: center;"><a href="http://www.bymanstudio.com/blog/SuperRobot_Dog.pdf">download</a> | <a href="http://pekko.exteen.com/20081118/superrobot-dog-version">source</a></p>
</td>
</tr>
</tbody>
</table>
<p><span id="more-379"></span></p>
<h2>Cut out the template</h2>
<p>Cut around the black line of the template, just leaving the part in the middle. Don&#8217;t forget to cut the slits at the bottom for the tabs to go into.</p>
<p><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/cutout1.jpg"><img class="alignleft size-thumbnail wp-image-406" title="cutting round the template" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/cutout1-150x150.jpg" alt="" width="150" height="150" /></a><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/cutout2.jpg"><img class="alignleft size-thumbnail wp-image-407" title="cutting round the cat template" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/cutout2-150x150.jpg" alt="" width="150" height="150" /></a><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/cutout3.jpg"><img class="alignleft size-thumbnail wp-image-408" title="cutting round the cat template" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/cutout3-150x150.jpg" alt="" width="150" height="150" /></a><br />
<a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/cutout4.jpg"><img class="alignleft size-thumbnail wp-image-409" title="cutting out the cat template" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/cutout4-150x150.jpg" alt="cutout 4" width="150" height="150" /></a><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/cutout5.jpg"><img class="alignleft size-thumbnail wp-image-410" title="cat template cut out" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/cutout5-150x150.jpg" alt="" width="150" height="150" /></a><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/cutout6.jpg"><img class="alignleft size-thumbnail wp-image-405" title="cat template cutout" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/cutout6-150x150.jpg" alt="" width="150" height="150" /></a></p>
<h2>Assemble the template</h2>
<p>Score, fold and tape the template together. Scoring by running the scissor edge along the fold line helps crease the paper in the correct place. The only tricky part of this is to make sure you fold the head part <em>in</em>. This is shown in <a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/fold4.jpg">this angle</a> and the <a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/tape2.jpg">head close up</a>. If this goes wrong, you can always re-fold it the correct way.</p>
<p><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/score1.jpg"><img class="alignleft size-thumbnail wp-image-420" title="scoring along the fold line" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/score1-150x150.jpg" alt="" width="150" height="150" /></a><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/score2.jpg"><img class="alignleft size-thumbnail wp-image-421" title="scoring along the fold line" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/score2-150x150.jpg" alt="" width="150" height="150" /></a><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/score3.jpg"><img class="alignleft size-thumbnail wp-image-422" title="scoring along the fold line" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/score3-150x150.jpg" alt="" width="150" height="150" /></a><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/fold1.jpg"><img class="alignleft size-thumbnail wp-image-416" title="folding the base" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/fold1-150x150.jpg" alt="" width="150" height="150" /></a><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/fold2.jpg"><img class="alignleft size-thumbnail wp-image-417" title="base folded and tucked" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/fold2-150x150.jpg" alt="" width="150" height="150" /></a><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/fold3.jpg"><img class="alignleft size-thumbnail wp-image-418" title="base folded and tucked" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/fold3-150x150.jpg" alt="" width="150" height="150" /></a><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/fold4.jpg"><img class="alignleft size-thumbnail wp-image-419" title="demonstration of head fold" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/fold4-150x150.jpg" alt="" width="150" height="150" /></a><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/tape1.jpg"><img class="alignleft size-thumbnail wp-image-423" title="taping the head from behind" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/tape1-150x150.jpg" alt="" width="150" height="150" /></a><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/tape2.jpg"><img class="alignleft size-thumbnail wp-image-415" title="close up of taping the head" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/tape2-150x150.jpg" alt="" width="150" height="150" /></a></p>
<h2>Be amazed</h2>
<p><a href="http://www.bassett-jones.com/wp-content/uploads/2009/12/complete.jpg"><img class="alignnone size-full wp-image-414" title="completed and assembled cat illusion" src="http://www.bassett-jones.com/wp-content/uploads/2009/12/complete.jpg" alt="" width="600" height="450" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bassett-jones.com/making-a-magic-dragon/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>My development toolbox</title>
		<link>http://www.bassett-jones.com/my-development-toolbox/</link>
		<comments>http://www.bassett-jones.com/my-development-toolbox/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 22:40:24 +0000</pubDate>
		<dc:creator>Hugh</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[balsamiq mockups]]></category>
		<category><![CDATA[fiddler]]></category>
		<category><![CDATA[filezilla]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[notepad++]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.bassett-jones.com/?p=164</guid>
		<description><![CDATA[My top software tools for building stuff]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a core list of software tools that I find indispensable for development in the office and at home. This list helps me keep track of the tools I need when re-building a computer.</p>
<h3>1. <a href="http://msdn.microsoft.com/en-gb/vstudio/">Visual Studio</a></h3>
<p>As a .net developer, VS 2008 is a fantastic Integrated Developer Environment. From code snippets to Intellisense, debugging to stack traces, Visual Studio helps me develop swiftly while concentrating on the code.</p>
<h3>2. <a href="http://www.mozilla.com/firefox/ ">Firefox</a> + <a href="http://getfirebug.com/ ">Firebug extension</a> + <a href="http://chrispederick.com/work/web-developer/">Web Developer extension</a></h3>
<p>I recently had a problem running Firefox on my new PC and boy, did I miss Firebug and the Web Developer extension. Although some of the features overlap, the simplicity of Web Developer means that it is very quick and easy to disable CSS, view all images or check page size.</p>
<p>Firebug is indispensable to hunt down CSS inheritance irritations, preview quick style modifications or unravel client-side javascript complexities.</p>
<p>Special mention to <a href="https://addons.mozilla.org/en-US/firefox/addon/271">ColorZilla</a>, <a href="https://addons.mozilla.org/en-US/firefox/addon/59">User Agent Switcher</a> and <a href="https://addons.mozilla.org/en-US/firefox/addon/5648">FireShot</a>.</p>
<p><span id="more-164"></span></p>
<h3>3. <a href="http://www.fiddlertool.com/">Fiddler</a></h3>
<p>A comprehensive HTTP debugging  proxy, Fiddler allows you to examine the raw HTTP traffic between the browser and server. Works well with HTTPS too.</p>
<h3>4. <a href="http://notepad-plus.sourceforge.net/ ">Notepad++</a></h3>
<p>Notepad++ is a text editor hitting all my major requirements: colour coding, quick to load, and excellent FTP integration.</p>
<h3>5. <a href="http://www.balsamiq.com/products/mockups">Balsamiq Mockups</a></h3>
<p>Useful, quick and easy wire framing for web applications and iphone designs.</p>
<h3>6. <a href="http://www.adobe.com/products/photoshop">Photoshop</a></h3>
<p>The granddaddy of image manipulation software, I probably only use 5% of all its features. Once I got over it&#8217;s irritating non-standard menus, I really appreciated the way tools such as spot healing work so well.</p>
<h3>7. <a href="http://filezilla-project.org/">FileZilla</a></h3>
<p>A bit under-rated, FileZilla is a top-notch FTP client that is small, light and regularly updated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bassett-jones.com/my-development-toolbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
