<?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>planet-nifty.co.uk &#187; Daily Grind</title>
	<atom:link href="http://www.planet-nifty.co.uk/nifty/daily-grind/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.planet-nifty.co.uk</link>
	<description>Home of Russ Wilde&#039;s weird rants and technical experiments...</description>
	<lastBuildDate>Mon, 06 Feb 2012 22:03:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Traffic Light: A Chrome extension to watch for specific URLs&#8230;</title>
		<link>http://www.planet-nifty.co.uk/traffic-light-chrome-extension/</link>
		<comments>http://www.planet-nifty.co.uk/traffic-light-chrome-extension/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 21:47:49 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Daily Grind]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://www.planet-nifty.co.uk/?p=342</guid>
		<description><![CDATA[As a web developer I often find myself working with multiple servers that show identical websites on different URLs. Typically this is a case of test servers and live servers for particular websites  - but this can get confusing. The website on a test server is pretty much identical to a live server in every [...]]]></description>
			<content:encoded><![CDATA[<p>As a web developer I often find myself working with multiple servers that show identical websites on different URLs. Typically this is a case of test servers and live servers for particular websites  - but this can get confusing. The website on a test server is pretty much identical to a live server in every way but if you get confused about which server you&#8217;re looking at you can make mistakes like changing the config of the live server and looking at the test server for changes. Which is not good.</p>
<p>So I&#8217;ve knocked up a little chrome extension that watches which URLs I&#8217;m visiting in each tab and shows a little warning icon depending on which URL I&#8217;m visiting. It&#8217;s hardly a work of art, but it is a neat little introduction to the very basics of creating a google chrome browser extension using page actions and background pages.</p>
<p><strong>So lets take a look at it shall we?<span id="more-342"></span></strong></p>
<p><strong></strong>For the sake of testing, the job for this extension will be to show a different coloured icon in the browser address bar when I visit any of three different web URLs and show nothing if the URL isn&#8217;t already configured.</p>
<p>The URLs I&#8217;m testing with are these;</p>
<p>http://www.planet-nifty.co.uk/</p>
<p>http://if-host.co.uk/</p>
<p>http://www.RussWilde.com/</p>
<p>But you&#8217;ll be able to substitute in your own URLs or other tests as you go through the code.</p>
<h2>Google Chrome Extensions 101</h2>
<p>To begin with, lets look at creating an extension that Chrome will install. There&#8217;s some good examples in the official <a title="Google Code Chrome Extensions - Getting Started Tutorial" href="http://code.google.com/chrome/extensions/getstarted.html">getting started tutorial</a>, so do give that a look too.</p>
<p><strong>To make a chrome extension that will install you need some very simple things;</strong></p>
<ol>
<li>A folder containing all of your extension&#8217;s files.</li>
<li>A file called &#8216;manifest.json&#8217; in the root of that folder.</li>
</ol>
<p>I&#8217;m going to assume you know how to create a folder on your computer and look at the <strong>manifest.json</strong> file instead. If you&#8217;re not familiar with the <a title="JSON - JavaScript Object Notation" href="http://www.json.org/">JSON</a> format, it is a lightweight data-interchange format designed to be easy for humans to read and write and easy for computers to read and generate. It&#8217;s a handy format to write in and very easy to learn.</p>
<p>Here&#8217;s the JSON file for the extension we&#8217;re making&#8230;</p>
<pre class="brush:javascript">{
  "name": "Traffic Lights",
  "version": "1.0",
  "description": "Watch the URL for specific servers.",
  "background_page":"background.html",
  "page_action": {
    "default_icon": "icon-green.png",
    "default_title":"Unwatched server",
    "default_popup":"popup.html"
  },
  "permissions": [
    "tabs", "http://*/*"
  ]
}</pre>
<p>In a nutshell this manifest file instructs Chrome that this plugin is called Traffic Lights, it is version 1.0 and provides a description &#8211; this is the data that is shown to the user when they visit the Wrench Menu &gt; Tools &gt; Extensions page. Like this:</p>
<p><a href="http://www.planet-nifty.co.uk/wp-content/uploads/2012/01/Screen-shot-2012-01-28-at-18.19.33.png"><img class="aligncenter size-medium wp-image-346" title="manifest information displayed to the user on the extensions mapge" src="http://www.planet-nifty.co.uk/wp-content/uploads/2012/01/Screen-shot-2012-01-28-at-18.19.33-300x46.png" alt="manifest information displayed to the user on the extensions mapge" width="300" height="46" /></a></p>
<p>After those details, we include a background_page definition, a page_action definition and set up some very loose permissions on tabs. We&#8217;ll look at these items next&#8230;</p>
<p><strong>The page_action</strong></p>
<p><strong> <img class="alignright" title="Page Actions add additional icons inside the Chrome browser address bar" src="http://www.planet-nifty.co.uk/wp-content/uploads/2012/01/Screen-shot-2012-01-28-at-18.30.01.png" alt="Page Actions add additional icons inside the Chrome browser address bar" width="111" height="75" /></strong>The page action is a particular type of object that Chrome uses to display a small icon <strong>inside</strong> the browser address bar, right next to the &#8216;bookmark&#8217; star. These are fixed in size at 19px x 19px and can be pretty much any type of graphic that Chrom is capable of displaying in a web page. We can change the icons programatically as well, which we&#8217;ll look at later on.</p>
<p>In our page action definition, we define the default icon for our extension (icon-green.png), set a default title for the icon (this is displayed in a tooltip that pops up when the user hovers their mouse over the icon) and  we define the contents of a popup to display when the icon is clicked &#8211; popup.html. These file urls are relative to the folder in which your extension lives by the way, so we need to create a popup.html and an icon-green.png in our folder along side the manifest.json file. I&#8217;ll leave it up to your creativity to manage that. Here&#8217;s the code for my popup.html &#8211; this could do some fancy stuff for configuring the extension, but for now we will just display some boring information:</p>
<pre class="brush:html">&lt;!doctype html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Traffic Lights Popup&lt;/title&gt;
    &lt;style&gt;
      body {
        min-width:357px;
        overflow-x:hidden;
      }
    &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;Traffic Lights&lt;/h1&gt;
    &lt;p&gt;This plugin watches for specific URL patterns and shows a coloured icon on the address bar. Currently the following URLs are matched...&lt;/p&gt;
    &lt;ul&gt;
      &lt;li&gt;*.planet-nifty.co.uk (coloured red)&lt;/li&gt;
      &lt;li&gt;*.if-host.co.uk (coloured amber)&lt;/li&gt;
      &lt;li&gt;*.russwilde.com (coloured green)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre>
<p>Here&#8217;s how it looks when the popup is displayed:<br />
<a href="http://www.planet-nifty.co.uk/wp-content/uploads/2012/01/Screen-shot-2012-01-28-at-20.44.41.png"><img class="aligncenter size-medium wp-image-351" title="The popup displayed after clicking on the icon" src="http://www.planet-nifty.co.uk/wp-content/uploads/2012/01/Screen-shot-2012-01-28-at-20.44.41-300x206.png" alt="The popup displayed after clicking on the icon" width="300" height="206" /></a> That&#8217;s our somewhat rudimentary orange icon there as well. Notice that the popup content is entirely HTML and can be styled up with CSS and made to look lovely &#8211; even though that&#8217;s not what I&#8217;ve done here.</p>
<p>Thanks to the configuration in our manifest.json file, we don&#8217;t have to do anything else to make that popup work once our extension is installed (we&#8217;ll look at installing it later on).</p>
<p><strong>The background_page</strong></p>
<p>The background_page is an html page that is opened in the background when your extension is running. It doesn&#8217;t get displayed to the user, but it has the same functionality as an HTML page in every other sense. This is most commonly used for running javascript for your extension which performs essential background work to make things operate correctly. The background_page in our project &#8211; background.html &#8211; runs some javascript to observe the updating of browser tabs and act on the update where necessary.</p>
<p>In our case, we want to watch when tabs in Chrome are updated, check the URL against our list of URLs to show an icon on and, where necessary, display the icon. Here&#8217;s the code &#8211; it&#8217;s not exactly brilliant, but it fits our basic requirements:</p>
<pre class="brush:html">&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Background operation for Traffic Lights&lt;/title&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;script type="text/javascript"&gt;
        chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {

          if (tab.url.indexOf('.planet-nifty.co.uk/') &gt; -1) {
            //show the red tab
            chrome.pageAction.setIcon({"tabId":tabId, "path":"icon-amber.png"});
            chrome.pageAction.setTitle({"tabId":tabId, "title":"This is a planet-nifty.co.uk url" + "\n" + tab.url});
            chrome.pageAction.show(tabId);
          } else if (tab.url.indexOf('/if-host.co.uk/') &gt; -1 || tab.url.indexOf('.if-host.co.uk/') &gt; -1) {
            chrome.pageAction.setIcon({"tabId":tabId, "path":"icon-red.png"});
            chrome.pageAction.setTitle({"tabId":tabId, "title":"This is an if-host.co.uk url" + "\n" + tab.url});
            chrome.pageAction.show(tabId);
          } else if (tab.url.indexOf('.russwilde.com/') &gt; -1) {
            chrome.pageAction.setIcon({"tabId":tabId, "path":"icon-green.png"});
            chrome.pageAction.setTitle({"tabId":tabId, "title":"This is a russwilde.com url" + "\n" + tab.url});
            chrome.pageAction.show(tabId);
          }
        });
    &lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre>
<p>&#8230; Like I said, not brilliant, but it will do the simple job we&#8217;re trying to achieve.</p>
<p>Let&#8217;s take a quick look at what we&#8217;re doing here:<br />
As you can see, the html page is just a carrier for a short section of JavaScript which does all the work. The first command <em>chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {&#8230;}) </em>attaches a callback function to the Chrome Tab Updated event &#8211; this gets called at a various points during the tab lifecycle, including when the URL changes for whatever reason. The function accepts a few parameters; we&#8217;re particularly interested in the tabId &#8211; which is used to identify which tab was updated (and later which tabs will display the icon), the changeInfo which contains the tab URL when it changes and finally a handle to the tab object itself which always has the URL available.</p>
<p>I must confess to being lazy in creating my code here; I think I could interrogate the changeInfo object each time the tab gets updated, check to see if the URL has changed, and only update the icon if necessary, but I&#8217;ll leave that to you to change at your leisure.</p>
<p>The callback function performs some pretty rudimentary checks on the URL to match against our list and, when the URL is a match, sets the icon graphic to the appropriate colour, sets the tooltip text and sets the icon to show for the given tabId &#8211; note that the icon will not display by default on other tabs, so we don&#8217;t have to include a clause to hide the icon when it isn&#8217;t necessary.</p>
<p><strong>That&#8217;s It!</strong></p>
<p>That&#8217;s all there is to our extension, add a few icon graphics and we&#8217;re set. Let&#8217;s install that bad boy and see it in action!!</p>
<p><strong>Installing your extension is easy&#8230;<br />
</strong>Let&#8217;s just check that we&#8217;ve got everything &#8211; you should have a folder on your computer containing manifest.json, background.html, popup.html and three 19px x 19px images named icon-red.png, icon-amber.png and icon-green.png &#8211; ideally containing some kind of graphic of the named colour. Right? Good! You&#8217;ve got Chrome too right? Okay.</p>
<p>Open Google Chrome, click on the wrench menu button and select Tools &gt; Extensions and the extensions manager opens in a  new tab. If you&#8217;ve not got the &#8216;developer mode&#8217; checkbox ticked, now is the time to tick it. Next click &#8220;Load unpacked extension&#8221; and Chrome will prompt you for a folder location of your extension. Browse to the folder that contains your manifest.json file and click open. Your extension will be installed into Chrome and activated. It should look like this:<br />
<a href="http://www.planet-nifty.co.uk/wp-content/uploads/2012/01/Screen-shot-2012-01-28-at-21.31.06.png"><img class="aligncenter size-medium wp-image-353" title="The extension is installed and activated" src="http://www.planet-nifty.co.uk/wp-content/uploads/2012/01/Screen-shot-2012-01-28-at-21.31.06-300x49.png" alt="The extension is installed and activated" width="300" height="49" /></a></p>
<p>Now just visit some of our special URLs to see the icon appear in the address bar.</p>
<ul>
<li><a href="http://www.planet-nifty.co.uk/">http://www.planet-nifty.co.uk/</a></li>
<li><a href="http://if-host.co.uk/">http://if-host.co.uk/</a></li>
<li><a href="http://www.russwilde.com/">http://www.russwilde.com/</a></li>
</ul>
<p>Hooray!</p>
<p>If you&#8217;ve been reading without following along at home, you can download the sources for this project here:</p>
<p><a href="http://www.planet-nifty.co.uk/wp-content/uploads/2012/01/Planet-Nifty-traffic-light-chrome-extension.zip">Planet-Nifty-traffic-light-chrome-extension<br />
</a>(You&#8217;ll also find a netbeans nbproject folder in there which you can ignore and/or delete if you so wish).</p>
<p>So there you go; We&#8217;ve assembled a simple extension for google chrome that does something which could be useful and installed it into google chrome. I&#8217;d welcome your feedback, complaints etc. in the comments below.</p>
<p><strong>Russ</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.planet-nifty.co.uk/traffic-light-chrome-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zero.</title>
		<link>http://www.planet-nifty.co.uk/zero/</link>
		<comments>http://www.planet-nifty.co.uk/zero/#comments</comments>
		<pubDate>Sat, 05 Nov 2011 19:27:56 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Daily Grind]]></category>
		<category><![CDATA[Invisalign Braces]]></category>

		<guid isPermaLink="false">http://www.planet-nifty.co.uk/?p=331</guid>
		<description><![CDATA[Well, it happened. After months and months &#8211; actually a couple of years. My countdown has hit zero and I&#8217;ve reached the end of my invisalign treatment&#8230; Or so I thought. Right now, I&#8217;m at the end of my first round of &#8216;refinements&#8217; and I&#8217;m allowed a few more if I want to make further [...]]]></description>
			<content:encoded><![CDATA[<p>Well, it happened. After months and months &#8211; actually a couple of years. My countdown has hit zero and I&#8217;ve reached the end of my invisalign treatment&#8230; Or so I thought.</p>
<p>Right now, I&#8217;m at the end of my first round of &#8216;refinements&#8217; and I&#8217;m allowed a few more if I want to make further changes. I&#8217;m actually pretty happy with the result. Looking back at <a title="Good lord. Did my teeth actually look like that?!?" href="http://www.planet-nifty.co.uk/ooo-me-teeth/">how my teeth were at the start of this thing</a>, I can definitely see a real improvement.</p>
<p><strong>Am I finished?<span id="more-331"></span><br />
</strong>I&#8217;m not sure, to be honest. I&#8217;m very interested in not having to wear these things in my mouth anymore and the idea of saying &#8220;Yes, that&#8217;s it. They&#8217;re done.&#8221; is very appealing. But I&#8217;m still not 100% sure that one final tooth has positioned itself perfectly or not. I&#8217;ve discussed it with my dentist and he&#8217;s pretty confident that it&#8217;s as good as it is going to get. He even showed me the arch of my teeth from above with a clever little camera and, if you happen to be inside of my mouth, you&#8217;ll agree the alignment is perfect. From the front, on the other hand, it does look just a little bit out of alignment. My dentist thinks it is because the tops of the teeth are now a little zig-zagged because they&#8217;ve all been repositioned. Which he will fix when we&#8217;re done with aligners by levelling them all off for me.</p>
<p>You know what?! I&#8217;m going to call them done. If I stop now, I&#8217;ll still have a smile two million percent better than it was and that is a massive improvement. If I go through another load of refinements, I will still be wearing aligners in the New Year and there&#8217;s no guarantee that they will actually make any difference whatsoever. I&#8217;ll see if I can get a lovely smiley face picture that matches the one from my original starting post, to show you some before and after shots. You&#8217;ll be shocked at how far I&#8217;ve come. In the meantime here&#8217;s a crappy webcam picture to tide you over:</p>
<p style="text-align: center;"><a href="http://www.planet-nifty.co.uk/wp-content/uploads/2011/11/smilin-teeth-on-2011-11-05.jpg"><img class="size-full wp-image-332 aligncenter" title="smilin teeth on 2011-11-05" src="http://www.planet-nifty.co.uk/wp-content/uploads/2011/11/smilin-teeth-on-2011-11-05.jpg" alt="My new smiley face." width="152" height="106" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.planet-nifty.co.uk/zero/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An Open Letter To The National Lottery</title>
		<link>http://www.planet-nifty.co.uk/an-open-letter-to-the-national-lottery/</link>
		<comments>http://www.planet-nifty.co.uk/an-open-letter-to-the-national-lottery/#comments</comments>
		<pubDate>Sat, 06 Aug 2011 10:35:23 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Daily Grind]]></category>

		<guid isPermaLink="false">http://www.planet-nifty.co.uk/?p=324</guid>
		<description><![CDATA[Russ Wilde complaining in depth about a relatively trivial matter of the National Lottery sending service announcement e-mails which, to some eyes, are nothing more than thinly disguised SPAM. Goodness, he doesn't half go on about it does he?!? He brings up definitions of advertising, the advertising standards agency, complex scalable server farming and the handling of the so called 'slashdot effect' and rounds things up with a dig at Camelot and the national lottery for their profits in 2010 and their sale to the Canadian Teachers pension fund.]]></description>
			<content:encoded><![CDATA[<p>Dear National Lottery,</p>
<p>I just wanted to draw your attention to a little problem I&#8217;ve run across as a subscriber to your online services; Over the past week I have received at least three e-mails from yourselves which were identical except for the date. The e-mail reads something like this;</p>
<blockquote><p>This is a service message to advise you that we expect to see an increasingly high volume of traffic to the National Lottery website in the hours leading up to the close of the EuroMillions draw at 7.30pm tonight.</p>
<p>If it is your intention to purchase a ticket for any draw-based game today, we would recommend that you do so as early as possible in order to avoid any disappointment.</p>
<p>Yours sincerely,</p>
<p>National Lottery Customer Care Team</p>
<p><strong>www.national-lottery.co.uk</strong></p></blockquote>
<p>Seem familiar? I&#8217;m sure you&#8217;ve seen it around.</p>
<p>Since I work for an online retailer, I do appreciate the benefits of sending out e-mails to remind customers of your existence and I&#8217;m sure a campaign like this is quite profitable.</p>
<p>However, I can&#8217;t help but see this as an exploitation of your own terms and conditions. I know that you are bound by UK law regarding customer privacy, which means that, when I tell you I don&#8217;t want to receive advertising or marketing e-mails from you, your company or its affiliates, I know you&#8217;re not allowed to send any of that stuff to me or pass on my details without my consent. This e-mail however is thinly disguised as a &#8220;service message&#8221; which, in your own terms constitutes part of the service I am subscribed to and not direct marketing. Your web server is going to be busy, you say? I might not be able to use the service later, you say? So I should get all my gambling done early and avoid the rush, you think? Well, aren&#8217;t you considerate for warning me?</p>
<p>My problem is this;</p>
<blockquote><p>&#8220;Advertising is a form of communication intended to persuade an audience (viewers, readers or listeners) to purchase or take some action upon products, ideals, or services&#8221; &#8211; <a title="Advertising - Wikipedia" href="http://en.wikipedia.org/wiki/Advertising">Advertising &#8211; Wikipedia</a></p></blockquote>
<p>I think your call to action in the above e-mail fits neatly into this definition of <strong>advertising</strong>, despite being qualified with &#8220;If it is your intention to&#8230; [blah blah blah]&#8220;. I know, the <a href="http://www.asa.org.uk/Regulation-Explained/Online-remit.aspx">Advertising Standards Agency&#8217;s new online remit</a> wouldn&#8217;t agree with me on this, but I still feel like my trust in you to not bother me with &#8220;come and gamble today&#8221; messages has been violated.</p>
<p>If you&#8217;re genuinely worried that a run of last minute gambling will bring down your website on these big lottery draw days then I humbly suggest you <a title="One research paper from Microsoft, which might set you on the right track for dealing with massive spikes in website traffic. (PDF - opens in a new window / tab)" href="http://research.microsoft.com/pubs/75287/flashcrowds-camera-ready.pdf" target="_blank">do something about it</a> rather than waste time and resources on broadcasting about how unprepared you are for the coming onslaught.</p>
<p>I&#8217;m sure a company who, last year, banked over £31 million in profits and paid dividends of over £33 million to it&#8217;s shareholders &#8211; funded by the 70% of UK adults who regularly play National Lottery games - can afford to invest in some more scalable server technology.<a href="#footnote1">¹</a></p>
<p>I know you&#8217;re basically a <a title="BBC News: National Lottery owner Camelot sold to Canada teachers (opens in a new window / tab)" href="http://news.bbc.co.uk/1/hi/business/8588321.stm" target="_blank">Canadian Teacher&#8217;s union pension scheme in disguise</a> nowadays, but come on. Buy some more servers and quit spamming me.</p>
<p>Sincerely Yours</p>
<p>Russ Wilde</p>
<p><a id="footnote1">¹</a><em> Statistics taken from the <a title="Camelot Stakeholder Report 2010 (PDF - opens in a new window / tab)" href="http://www.camelotgroup.co.uk/stakeholderreport2010/assets/d/CSR2010FulReport.pdf" target="_blank">Camelot Stakeholder Report 2010</a>.</em></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.planet-nifty.co.uk/an-open-letter-to-the-national-lottery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>So I wrote this URL shortener&#8230;</title>
		<link>http://www.planet-nifty.co.uk/so-i-wrote-this-url-shortener/</link>
		<comments>http://www.planet-nifty.co.uk/so-i-wrote-this-url-shortener/#comments</comments>
		<pubDate>Tue, 07 Jun 2011 22:28:57 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Daily Grind]]></category>

		<guid isPermaLink="false">http://www.planet-nifty.co.uk/?p=317</guid>
		<description><![CDATA[So there I was, procrastinating over a very important job that I have still to finish and I got to wondering about the short codes used for URL shortening services &#8211; you know, these ones; http://abc.com/1a4c So I decided to make on of my own&#8230; As is so often the case when you start researching [...]]]></description>
			<content:encoded><![CDATA[<p>So there I was, procrastinating over a very important job that I have still to finish and I got to wondering about the short codes used for URL shortening services &#8211; you know, these ones; http://abc.com/<strong>1a4c</strong></p>
<p><strong>So I decided to make on of my own&#8230;<span id="more-317"></span></strong></p>
<p>As is so often the case when you start researching cool mathematical stuff for a neat function, it turns out that someone&#8217;s already done all the work. In this case, I learned about the PHP base_convert function which can neatly convert boring base 10 numbers to lovely  base 35 numbers (actually, it will convert from any base number to any other base up to base 35), which is marvellous. I had originally started drafting another function to generate short-codes of a larger collection of symbols, but the codes might not always be reliable when passed through various internet chanels &#8211; I don&#8217;t think it is safe to rely on case-sensitivity for example, which would have massively extend the code range &#8211; So I decided to use the base_convert function which uses letters and numbers to represent base35 numbers.</p>
<p>I figure, if I use short-codes from 1 to 5 digits in base 35, that still gives me <span style="color: blue;" title="52,521,875 to be precise">over 52.5 million</span> codes before I have to figure a way for extending the code-base. I&#8217;ll probably run out of database before then anyway.</p>
<p>Once you&#8217;ve got short codes from decimal numbers sorted out the rest is a walk in the park really;</p>
<ol>
<li>Collect Urls to be shortened</li>
<li>Store them in a database with a numerical index</li>
<li>Use the index number for each url to generate a shortcode</li>
<li><del>Do some fancy url rewriting to redirect each shortcode to it&#8217;s destination url</del></li>
</ol>
<p><strong>Since my Url rewriter is for me and not for insane &#8220;SEO specialists&#8221;. I&#8217;ve made some concessions in the way it works;</strong></p>
<p>Urls aren&#8217;t redirected with a 301 http code. In fact each url in the shortener presents a page with a javascript redirect that bounces the user to their destination after a short delay. The waiting page shows the precise page that the user is about to visit, giving them a chance to change their mind and hammer the back button. After all, these short codes could be leading you anywhere.</p>
<p>Not redirecting with a 301 also means that I can collect more accurate analytics from each link as I can see every visit to that &#8216;bounce page&#8217; before the user is passed on to their final destination. A 301 redirect is designed to be cached by browsers and subsequent visits would then bypass our page altogether, meaning we wouldn&#8217;t count all visits to our shortened urls.</p>
<p>The other concession I had to make was this &#8211; my url shortener doesn&#8217;t produce very short urls &#8211; regrettably the very short domain names are really damned expensive. So, for the time being, I&#8217;ve plugged it up at a short subdomain of an existing short-ish URL from my collection:</p>
<p><a title="Free URL Shortening Service" href="http://u.if-host.co.uk/">http://u.if-host.co.uk/</a></p>
<p>It currently has no stylesheet &#8217;cause I wrote it in an afternoon, but please do try it out. Feedback will be gratefully received in the comments on this post.<br />
Also if anybody has a cool short URL they&#8217;re not using, I would be happy to host this service on that url for you.</p>
<p>Incidentally, it&#8217;s my Birthday on Friday. There&#8217;s going to be cake, one way or another (and probably both &#8211; oh man I love de cake!).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.planet-nifty.co.uk/so-i-wrote-this-url-shortener/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New Hosting&#8230;</title>
		<link>http://www.planet-nifty.co.uk/new-hosting/</link>
		<comments>http://www.planet-nifty.co.uk/new-hosting/#comments</comments>
		<pubDate>Tue, 24 May 2011 18:56:45 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Daily Grind]]></category>

		<guid isPermaLink="false">http://www.planet-nifty.co.uk/?p=312</guid>
		<description><![CDATA[Just a little note to say that we&#8217;re currently migrating to some new hosting. There won&#8217;t be any down-time &#8211; not that it matters I suppose, but if you&#8217;re reading this version of this post, you&#8217;re talking to the NEW server.]]></description>
			<content:encoded><![CDATA[<p>Just a little note to say that we&#8217;re currently migrating to some new hosting. There won&#8217;t be any down-time &#8211; not that it matters I suppose, but if you&#8217;re reading this version of this post, you&#8217;re talking to the <strong>NEW</strong> server.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.planet-nifty.co.uk/new-hosting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Three Excellent Reasons to Smash Your TV</title>
		<link>http://www.planet-nifty.co.uk/three-excellent-reasons-to-smash-your-tv/</link>
		<comments>http://www.planet-nifty.co.uk/three-excellent-reasons-to-smash-your-tv/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 20:50:07 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Daily Grind]]></category>
		<category><![CDATA[Yet Another Rant]]></category>

		<guid isPermaLink="false">http://www.planet-nifty.co.uk/?p=288</guid>
		<description><![CDATA[Three excellent and compelling reasons to smash your TV - You can admit that you want to. Some days you luck at it, sitting there, collecting dust with it's smug little standby LED and you just want to see what would happen if you smashed it with some kind of bat...]]></description>
			<content:encoded><![CDATA[<p>Being somewhat sick of TV and television advertising, I no longer watch TV at all. Actually it&#8217;s been a couple years since I last watched a show on TV and I thought that I would share with you three good reasons to try going without yourself&#8230;<span id="more-288"></span></p>
<h2>1. Adverts warp your mind</h2>
<p>For over 100 years, advertising executives have been telling you and your forebears what to buy and, in their time, they have evolved the black art of advertising a long long way. From <a title="Wikipedia Article: Albert Lasker" href="http://en.wikipedia.org/wiki/Albert_Lasker">Albert Lasker</a>&#8216;s salesmanship in print to hugely expensive internet viral campaigns these people are constantly working to find new ways to get products into your mind and money out of your wallet.</p>
<p>I think <a title="XKCD" href="http://xkcd.com/">XKCD</a> put it perfectly:</p>
<blockquote><p>&#8220;If someone has paid $X to have the word &#8220;free&#8221; typeset for you and N other people to read, their expected value for the money that will move from you to them is at least $ X / N + 1&#8243;</p>
<p>&#8211; <a title="XKCD Comic: Advertising" href="http://xkcd.com/870/">XKCD Comic: Advertising</a></p></blockquote>
<p>I must assume the same is true of GBP and TV advertising too. I&#8217;ve noticed a correlation between products I&#8217;ve purchased after seeing advertising for the product and products I regret buying:</p>
<p><a href="http://www.planet-nifty.co.uk/wp-content/uploads/2011/03/Ads-vs-Regret-2.png"><img class="size-medium wp-image-302 aligncenter" title="Ads-vs-Regret (2)" src="http://www.planet-nifty.co.uk/wp-content/uploads/2011/03/Ads-vs-Regret-2-300x225.png" alt="" width="300" height="225" /></a></p>
<p>In fact, I&#8217;m so aware of this correlation that I often actively choose not to buy products I see in TV advertisements simply because I expect to be so brutally disappointed by the product. On one occasion I went out of my way to buy a product that was a direct competitor to the one in the advert (that&#8217;s how I got into Android mobiles).</p>
<h2>2. You&#8217;ll still hear about 90% of what happens from people who do watch TV</h2>
<p>Being one of (approximately) fifty-six UK citizens who are lucky enough to actually have a job, I work with an office full of people. One of the most common conversations I overhear between my colleagues is along the linkes of &#8220;Did you see [Popular Reality Show] last night?&#8221;. I may be an <a title="Homestar Runner Strongbad Email: Office Dullard" href="http://www.homestarrunner.com/sbemail37.html">office dullard</a>, but I know that I can get enough information on what&#8217;s going on in the world of popular entertainment by forcing my way into these conversations.</p>
<h2>3. The most memorable, controversial and enjoyable moments are already on the Internet</h2>
<p>Especially in the UK, almost anything worth seeing on TV is either;</p>
<ul>
<li>On the internet roughly three months <strong>before</strong> it is aired on TV &#8211; OR</li>
<li>On the internet within thirty seconds after it has been aired.</li>
</ul>
<p>Considering that any TV station that wants to succeed these days has to offer some kind of &#8216;watch online&#8217; service. I think it&#8217;s not unreasonable to expect that anything seen on TV should be available online from one web service or <a title="YouTube - Shows (TV content on YouTube)" href="http://www.youtube.com/shows?feature=mh">another</a>.</p>
<p><strong>So there you have it, Smash your TV today and you will no longer wonder why you bought things that you didn&#8217;t really want. You&#8217;ll still be able to catch up on what is going on in <a title="Popular Reality Show" href="http://www.hrwiki.org/wiki/dullard#Method_3">popular reality show</a>. You can even watch the occasional good show online and, best of all, You can have the immense satisfaction of smashing a valuable and fragile piece of electrical trickery&#8230; Not to mention the three-plus hours of time you will recover every evening from not-watching.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.planet-nifty.co.uk/three-excellent-reasons-to-smash-your-tv/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft diskpart, your friend in times of need.</title>
		<link>http://www.planet-nifty.co.uk/microsoft-diskpart-your-friend-in-times-of-need/</link>
		<comments>http://www.planet-nifty.co.uk/microsoft-diskpart-your-friend-in-times-of-need/#comments</comments>
		<pubDate>Sun, 14 Nov 2010 21:56:38 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Daily Grind]]></category>

		<guid isPermaLink="false">http://www.planet-nifty.co.uk/?p=279</guid>
		<description><![CDATA[Once again I find myself regretting having purchased an Apple mac. For the third time now, my mac book has wrapped the partition of my usb backup drive (a Maxtor 500 gig usb external drive) in an &#8216;unknown partition&#8217; rendering the drive inaccessible to just about any computer I plug it into. So here&#8217;s how [...]]]></description>
			<content:encoded><![CDATA[<p>Once again I find myself regretting having purchased an Apple mac. For the third time now, my mac book has wrapped the partition of my usb backup drive (a Maxtor 500 gig usb external drive) in an &#8216;unknown partition&#8217; rendering the drive inaccessible to just about any computer I plug it into. So here&#8217;s how I got the drive working again&#8230;</p>
<p><span id="more-279"></span></p>
<p>In my usual Google trawling i found that a lot of people are having similar problems with external drives connected by usb. The problem seems to revolve around mac OS wrapping the partitions on the external drive in some kind of protective partition. After using the and ejecting the drive, the hardware can&#8217;t seem to un-mount for some reason. No amount of waiting or repeated &#8216;ejecting&#8217; of the drive will successfully demount it.  So, naturally, I shut the computer down &#8212; surely the drive must be safely demounted and parked when the machine shuts itself down right?</p>
<p>Apparently not, the drive is now inaccessible to Mac OS, Windows and Ubuntu machines as the partitions are apparently locked inside an unknown partition occupying the entire drive.  It&#8217;s nice to know my backups are safe with Time Machine doing the driving(!).</p>
<p>After the first time this happened, I now know my data on the dive is lost for good. To get the drive working again &#8211; to get rid of that protective partition &#8211; requires some low-level cleaning of the drive which isn&#8217;t always doable for external drives. I have read that some people have had success recovering the drive by connecting it via firewire, on drives where firewire facilities exist. Sadly, I don&#8217;t have a firewire drive. Another option is to split open the USB enclosure, stick the drive into a computer and perform a low level partition and format using manufacturers software,  I didn&#8217;t want to break my pretty little seamless enclosure and I don&#8217;t own a working desktop computer to put the drive in nowadays anyway. So I&#8217;m screwed. Right?</p>
<p>My last-ditch attempts at getting my drive working came down to this: Microsoft DiskPart.</p>
<p>Leave it to Microsoft to create a utility that can fix a problem created by Apple.</p>
<h3>Here&#8217;s how I get my drive working again;</h3>
<p>I plugged the drive into my Windows XP laptop (I don&#8217;t have windows 7 yet, so I couldn&#8217;t say whether this will work in 7, it probably will).</p>
<p>I opened up a command prompt and entered the command to launch the Microsoft diskpart utility.</p>
<p><code>diskpart</code></p>
<p>I should probably mention that diskpart is a destructive utility that should be used with great care as you can pretty easily break your working drives and partitions with little or no warning.</p>
<p>Diskpart is a terminal style application that works interactively to fix or break your hard drives. The first command you should try is the help command (or just type a question mark).</p>
<p><code>help</code></p>
<p>The help lists out the collection of commands that can be used. My facourites are list, select, clean and create.</p>
<p><strong>List<br />
</strong>The list command will list out drives, partitions and volumes depending on which you want, it takes one parameter which can be, you guessed it; disk, partition or volume. you&#8217;ll need to tell diskpart which drive you want to work with before doing anything interesting, so first up I used</p>
<p><code>list disk</code></p>
<p>to get a list of drives. Each one is named disk 0, disk 1 etc. My internal harddrive was disk 0 and the usb drive was disk 1 (I could tell by the capacity). So the next thing to do is tell diskpart that we want to work with the external drive</p>
<p><code>select disk 1</code></p>
<p>Then annihilate any partitions on there including that pesky and immovable partition using the &#8216;clean&#8217; command.</p>
<p><code>clean</code></p>
<p>Clean doesn&#8217;t take any parameters, which is why it&#8217;s important to make sure you&#8217;ve selected the correct drive first.</p>
<p>All that remained was to create a new partition ready for formatting using the</p>
<p><code>create</code></p>
<p>command. Create takes one parameter; which type of partition you want to create, which I leave to your judgement. After the partition is created, the drive is suddenly available in the windows computer management / disk management snap in and can be formatted and managed normally. It&#8217;s worth getting a full format and a scan for bad sectors in before sticking any valuable data on there of course.</p>
<p>Oh and never plug it into mac os again. Ever.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.planet-nifty.co.uk/microsoft-diskpart-your-friend-in-times-of-need/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>You are spammer number 1,000 congratulations</title>
		<link>http://www.planet-nifty.co.uk/you-are-spammer-number-1000-congratulations/</link>
		<comments>http://www.planet-nifty.co.uk/you-are-spammer-number-1000-congratulations/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 07:15:19 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Daily Grind]]></category>
		<category><![CDATA[websites]]></category>

		<guid isPermaLink="false">http://www.planet-nifty.co.uk/?p=262</guid>
		<description><![CDATA[This post was originally scheduled for Tue 15th but it seems to be raining spam out there in internet land. By my estimates, today will see our 1,000th spam comment on this glorious website, so I thought I&#8217;d share a few words to mark the occasion&#8230; Ahem&#8230; Kindly f*ck off! Sorry folks, I have very [...]]]></description>
			<content:encoded><![CDATA[<p><strong>This post was originally scheduled for Tue 15th but it seems to be raining spam out there in internet land.</strong></p>
<p>By my estimates, today will see our 1,000th spam comment on this glorious website, so I thought I&#8217;d share a few words to mark the occasion&#8230;</p>
<p>Ahem&#8230;</p>
<p><span id="more-262"></span></p>
<p>Kindly f*ck off!</p>
<p>Sorry folks, I have very short patience for even commercial advertising, but comment spam is possibly the most annoying thing I&#8217;ve ever encountered (except Quentin Tarantino of course). So I want to finally set the record straight&#8230;</p>
<p>I don&#8217;t want to rent SEO services from a company who don&#8217;t have real email addresses, I don&#8217;t want to buy cheap pharmaceuticals online, I&#8217;m quite happy with the size of my penis, the quotes from books would be marginally interesting if I didn&#8217;t get each one three times, I&#8217;m not interested in seeing 40 links to spammy and virus infested sites, I don&#8217;t want to confirm my bank account details with you, I can&#8217;t help you transfer international funds, I don&#8217;t want a job receiving money, I&#8217;m not going to email you for pictures of naked celebrities and that massive post in Russian doesn&#8217;t even make sense in Russian.</p>
<p>&#8230; phew, did I miss anyone? Oh well.</p>
<p>I wonder if spammers get this much spam.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.planet-nifty.co.uk/you-are-spammer-number-1000-congratulations/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Definition: The Breakfast of Champions</title>
		<link>http://www.planet-nifty.co.uk/definition-the-breakfast-of-champions/</link>
		<comments>http://www.planet-nifty.co.uk/definition-the-breakfast-of-champions/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 20:06:38 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Daily Grind]]></category>
		<category><![CDATA[Fictional Dictionary]]></category>
		<category><![CDATA[dictionary]]></category>
		<category><![CDATA[silly stuff]]></category>

		<guid isPermaLink="false">http://www.planet-nifty.co.uk/definition-the-breakfast-of-champions/</guid>
		<description><![CDATA[The Breakfast of Champions &#8211; a term originally used to describe any potentially nutritious breakfast cereal endorsed by a sporting hero, is now used to describe a completely ridiculous breakfast containing at least 2000 calories and boasting no nutritional value. For example, ricycles and doughnuts cereal. Dee-lish!]]></description>
			<content:encoded><![CDATA[<p><img style="display:block;margin-right:auto;margin-left:auto;" alt="image" src="http://www.planet-nifty.co.uk/wp-content/uploads/2010/07/wpid-breakfast-of-champions.jpg" /></p>
<p>The Breakfast of Champions &#8211; a term originally used to describe any potentially nutritious breakfast cereal endorsed by a sporting hero, is now used to describe a completely ridiculous breakfast containing at least 2000 calories and boasting no nutritional value. </p>
<p>For example, ricycles and doughnuts cereal. </p>
<p>Dee-lish!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.planet-nifty.co.uk/definition-the-breakfast-of-champions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Jumping off the Apple bandwagon</title>
		<link>http://www.planet-nifty.co.uk/jumping-off-the-apple-bandwagon/</link>
		<comments>http://www.planet-nifty.co.uk/jumping-off-the-apple-bandwagon/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 17:47:54 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Daily Grind]]></category>

		<guid isPermaLink="false">http://www.planet-nifty.co.uk/jumping-off-the-apple-bandwagon/</guid>
		<description><![CDATA[Because of my commitment to try every smartphone ever made, and because yet another apple problem had left me rubbing my sore and abused wallet. I have officially jumped off the Apple bandwagon and bought myself an HTC desire. My iPhone is off to be recycled somewhere, may it rest in pieces.]]></description>
			<content:encoded><![CDATA[<p>Because of my commitment to try every smartphone ever made, and because yet another apple problem had left me rubbing my sore and abused wallet. I have officially jumped off the Apple bandwagon and bought myself an HTC desire. </p>
<p>My iPhone is off to be recycled somewhere, may it rest in pieces. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.planet-nifty.co.uk/jumping-off-the-apple-bandwagon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

