<?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>Ed&#039;s World &#187; twitter</title>
	<atom:link href="http://www.jellard.co.uk/tag/twitter/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jellard.co.uk</link>
	<description>Bringing data into real life in a meaningful way</description>
	<lastBuildDate>Fri, 14 May 2010 15:00:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MythTweet &#8211; Twitter MythTV recordings</title>
		<link>http://www.jellard.co.uk/2010/03/mythtweet-twitter-mythtv-recordings/</link>
		<comments>http://www.jellard.co.uk/2010/03/mythtweet-twitter-mythtv-recordings/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 21:32:39 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[mythtv]]></category>
		<category><![CDATA[mythTweet]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.jellard.co.uk/?p=164</guid>
		<description><![CDATA[In the move to put as much of my house onto twitter as possible, MythTV was the next victim.  I&#8217;d previously made a PHP script that sent MSN alerts, but now I don&#8217;t use MSN, it needed a revamp.

I knocked up a small PHP script that grabs the backend status, finds what is being [...]]]></description>
			<content:encoded><![CDATA[<p>In the move to put as much of my house onto twitter as possible, MythTV was the next victim.  I&#8217;d previously made a PHP script that sent MSN alerts, but now I don&#8217;t use MSN, it needed a revamp.</p>
<p><img src="http://www.jellard.co.uk/wp-content/uploads/2010/03/Screenshot-1.png" alt="MythTweet" /></p>
<p>I knocked up a small PHP script that grabs the backend status, finds what is being recorded or watched, compares with the previous run, and sends a message to twitter using wget.</p>
<p>To use it, grab the <a href="http://www.jellard.co.uk/wp-content/uploads/2010/03/mythTweet.phps">script</a>, change the username/password variables, chmod +x it, and then add it to your &#8220;Startup Applications&#8221; or equivalent if you&#8217;re not using Ubuntu.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jellard.co.uk/2010/03/mythtweet-twitter-mythtv-recordings/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hampshire Twittering Traffic-Jams &#8211; SMS alerts &#8211; @hants_motorway</title>
		<link>http://www.jellard.co.uk/2010/01/hampshire-twittering-traffic-jams/</link>
		<comments>http://www.jellard.co.uk/2010/01/hampshire-twittering-traffic-jams/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 09:17:54 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[hants_motorway]]></category>
		<category><![CDATA[traffic]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.jellard.co.uk/?p=130</guid>
		<description><![CDATA[Something that drives me nuts is every so often there&#8217;ll be an accident on the M3 or M27 and the entire surrounding area will be flooded with people trying to avoid the deadlock, only to find they&#8217;re on a tiny road with thousands of other people.  Yes, I could check the traffic websites each [...]]]></description>
			<content:encoded><![CDATA[<p>Something that drives me nuts is every so often there&#8217;ll be an accident on the M3 or M27 and the entire surrounding area will be flooded with people trying to avoid the deadlock, only to find they&#8217;re on a tiny road with thousands of other people.  Yes, I could check the traffic websites each morning, or do some intelligent parsing of traffic RSS feeds, but the first option requires effort before 9am (not going to happen), and the second option is never going to be reliable enough &#8211; it&#8217;d be too hard to programmatically determine how bad the conditions on the road really are.</p>
<p><a href="http://twitter.com/hants_motorway"><img src="http://www.jellard.co.uk/wp-content/uploads/2010/01/hants_motorway1.png" alt="Twitter feed" /></a></p>
<p><span id="more-130"></span></p>
<p>What I really want is a text message telling me which junctions on the M27 and M3 are delayed and roughly what their speed are.  While I don&#8217;t actually use the motorways to get to work, if they&#8217;re gridlocked, the surrounding country-roads tend to also be gridlocked, so this should work.  My house already texts me thanks to twitter, so that part of the system is easy, and has the bonus of other people can use it.</p>
<p>After discovering a site that gives average speeds between junctions, cogs started to whir.  Unfortunately the site doesn&#8217;t provide a nice feed, but that wasn&#8217;t going to stop me.</p>
<p>A few hours of Java hacking later, <a href="http://twitter.com/hants_motorway">@hants_motorway</a> was born.</p>
<p>Every 20 minutes, between 7am-10am and 4pm-7pm, the speeds of each junction between J2-J12 on M27 and J4-J14 on M3 are recorded in a database, and compared against the speed of that junction at that time in the previous month.  If it is less than 45%, it assumes there&#8217;s a delay and puts a message on Twitter.  When the list of junctions delayed change, or the delays end, another message is put on Twitter.</p>
<p>I&#8217;ve setup my personal account (<a href="http://twitter.com/ejellard">@ejellard</a>) to follow @hants_motorway and to text me each update.</p>
<p>I&#8217;m hoping that this means that those driving from the Southampton area to some location near Winchester won&#8217;t have to sit in stupid amounts of traffic.  I obviously can&#8217;t guarantee it&#8217;s accuracy, and no doubt my house will have a power-cut or network outage the one day it would be useful, but it shouldn&#8217;t give false-positives (or negatives, depending which way you look at it).  Let me know what you think, and if there are any better ways of doing this.</p>
<p><a name="graph"></a><br />
And purely because I can, here&#8217;s an &#8220;interesting&#8221; graph of road speeds of different junctions along the M3:<br />
<img src="http://chart.apis.google.com/chart?cht=r&#038;chs=400x400&#038;chdl=J1|J10|J11|J12|J2|J3|J4|J4A|J5|J6|J7|J8|J9&#038;chd=t:64,66,69,60,60,69,68,65,68,69,69,68,68,69,69,69,69,66,68,68,67,70,67,68,64|63,63,62,61,62,65,65,54,34,34,46,65,67,67,68,68,68,66,67,68,68,67,66,65,63|63,62,61,60,62,65,64,49,35,38,51,65,66,66,67,67,65,63,65,67,66,66,65,65,63|64,62,61,63,63,66,65,48,38,44,61,66,67,66,66,66,66,63,65,67,66,67,66,66,64|67,70,70,68,68,68,68,61,49,41,51,67,69,69,68,66,68,63,63,63,68,70,70,69,67|62,62,62,64,66,67,66,47,41,43,61,68,68,69,69,69,68,65,66,69,69,68,67,65,62|62,62,62,64,66,67,66,46,41,43,62,69,68,69,69,69,68,66,67,69,69,68,67,65,62|69,67,69,68,69,70,69,55,44,49,66,69,70,70,70,70,69,67,68,70,70,69,69,69,69|68,67,64,66,68,69,70,69,68,69,70,69,70,70,70,70,70,69,69,70,69,69,69,69,68|68,67,64,66,68,69,70,69,69,70,70,69,70,70,70,70,70,69,69,70,69,69,69,69,68|66,64,64,63,64,66,67,65,67,69,69,69,69,69,70,69,69,69,69,70,69,69,67,68,66|64,62,62,63,65,66,67,64,67,68,68,69,69,69,69,69,69,68,69,69,69,69,68,67,64|64,62,63,63,65,67,67,64,66,67,67,68,69,69,69,69,69,68,69,69,69,68,68,67,64&#038;chco=0000FF,00FF00,00FFFF,FF0000,FF00FF,FFFF00,000088,008800,008888,880000,880088&#038;chxt=x&#038;chxl=0:|0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23" alt="M3 Roadspeeds" /></p>
<p>And the M27:<br />
<img src="http://chart.apis.google.com/chart?cht=r&#038;chs=400x400&#038;chdl=J10|J11|J12|J2|J3|J4|J5|J7|J8|J9&#038;chd=t:67,64,65,64,61,62,66,61,42,59,67,66,68,68,68,68,68,63,65,68,67,67,68,68,67|65,64,62,61,60,62,66,58,49,62,67,67,68,68,68,68,68,64,65,68,67,67,67,66,65|64,64,62,61,62,63,64,60,58,61,63,64,64,64,65,65,64,59,61,65,64,64,65,63,64|65,64,63,63,65,67,68,67,68,69,69,69,69,69,69,69,69,68,69,69,69,68,67,67,65|65,62,62,62,64,66,68,66,62,64,68,68,68,69,69,69,69,68,69,68,68,68,66,66,65|63,60,59,59,60,63,66,63,56,58,66,66,67,67,67,68,67,65,66,67,65,65,64,63,63|67,65,62,63,61,62,65,64,58,61,69,67,68,66,67,68,64,56,65,69,68,68,68,67,67|67,65,62,63,61,62,65,64,58,61,69,67,68,66,67,68,64,56,65,69,68,68,68,67,67|66,66,63,62,62,63,65,64,58,58,69,69,69,69,69,69,67,59,63,69,69,68,68,68,66|67,66,64,64,63,64,67,65,59,61,68,69,69,69,69,69,67,62,64,69,68,68,68,68,67&#038;chco=0000FF,00FF00,00FFFF,FF0000,FF00FF,FFFF00,000088,008800,008888,880000,880088&#038;chxt=x&#038;chxl=0:|0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23" alt="M27" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jellard.co.uk/2010/01/hampshire-twittering-traffic-jams/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Ambient Light and Arduino boxed up and ready to rumble</title>
		<link>http://www.jellard.co.uk/2009/11/ambient-light-and-arduino-boxed-up-and-ready-to-rumble/</link>
		<comments>http://www.jellard.co.uk/2009/11/ambient-light-and-arduino-boxed-up-and-ready-to-rumble/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 21:30:30 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Home automation]]></category>
		<category><![CDATA[AM comms]]></category>
		<category><![CDATA[ambient light]]></category>
		<category><![CDATA[BlinkM]]></category>
		<category><![CDATA[central heating ctrl]]></category>
		<category><![CDATA[current cost]]></category>
		<category><![CDATA[home easy]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.jellard.co.uk/?p=99</guid>
		<description><![CDATA[One bitsbox order and a trip to buy some deodorant later, and my arduino is boxed up, and ambient light has a stand!

The cap off an addidas deoderant can makes a nice enough base for the orb from a B&#38;Q disco lamp (no link as can&#8217;t find it online).  I soldered the ends of some [...]]]></description>
			<content:encoded><![CDATA[<p>One bitsbox order and a trip to buy some deodorant later, and my arduino is boxed up, and ambient light has a stand!</p>
<p><a href="http://www.jellard.co.uk/wp-content/uploads/2009/11/IMG_4495.JPG"><img class="attachment-medium" title="Ambient Light and Box" src="http://www.jellard.co.uk/wp-content/uploads/2009/11/IMG_4495-300x199.jpg" alt="" width="300" height="199" /></a></p>
<p>The cap off an addidas deoderant can makes a nice enough base for the orb from a B&amp;Q disco lamp (no link as can&#8217;t find it online).  I soldered the ends of some CAT5 to the BlinkM, and left the other ends loose to be shoved into the arduino.</p>
<p><a href="http://www.jellard.co.uk/wp-content/uploads/2009/11/IMG_4500.JPG"><img class="attachment-medium" title="The insides" src="http://www.jellard.co.uk/wp-content/uploads/2009/11/IMG_4500-300x199.jpg" alt="" width="300" height="199" /></a></p>
<p>As I&#8217;ve got an arduino and ethernet shield, I went for the second <a href="http://www.bitsbox.co.uk/boxes.html">largest ABS box</a> and even then, I had to break off the screw connectors on one side so that the plugs could stick through the outside.  I soldered the AM receiver and transmitter onto a small piece of stripboard (also from bitsbox), added a couple of wires for aerials (with a knot in each to prevent someone pulling it out the circuit).  So that&#8217;s pretty much the finished product, what a shame!  I will add a thermometer to it so it can become a thermostat in another room &#8211; eventually this&#8217;ll go in the sitting room, so will have the current cost meter producing one temperature reading from the kitchen, this one in the sitting room, and have just ordered another arduino for my bedroom&#8217;s ambient light/thermometer/development board.</p>
<p>The java code has been working nicely, turning the heating on and off via the hacked home-easy plug!  I sent a text from my phone to turn the heating on, very proud of actually finding a use for it as I was stuck in traffic but had friends coming round so the heating would have cut out at 5.30 (it heats up til 5.30, then waits for movement) &#8211; only to find there was a street power cut that has lasted 3 days (intermittently)!  So, if the power holds up a little longer, I should get a tweet tomorrow telling me how long the central heating was on for, fingers crossed!</p>
<p>So, time to write the web interface, pretty dull <img src='http://www.jellard.co.uk/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.jellard.co.uk/2009/11/ambient-light-and-arduino-boxed-up-and-ready-to-rumble/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to tweet from your website with your own tinyurl URL shortening service</title>
		<link>http://www.jellard.co.uk/2009/10/how-to-tweet-from-your-website-with-your-own-tinyurl-url-shortening-service/</link>
		<comments>http://www.jellard.co.uk/2009/10/how-to-tweet-from-your-website-with-your-own-tinyurl-url-shortening-service/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 19:51:39 +0000</pubDate>
		<dc:creator>Ed</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tinyurl]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.jellard.co.uk/?p=55</guid>
		<description><![CDATA[As this is my first post about Magic Hat, a little introduction.  Magic Hat is a site for magicians to learn magic, with over 50 thousand users.  I started it in 2004, and since then have gradually (or not so gradually) being changing it.  We&#8217;re now at the 8th major redesign.  [...]]]></description>
			<content:encoded><![CDATA[<p>As this is my first post about Magic Hat, a little introduction.  Magic Hat is a site for magicians to learn magic, with over 50 thousand users.  I started it in 2004, and since then have gradually (or not so gradually) being changing it.  We&#8217;re now at the 8th major redesign.  It started as a good way to learn PHP/MySQL/HTML, so I didn&#8217;t touch any content management systems, and wrote the entire first 3 versions with linux&#8217;s best text editor, vim!  I then treated myself to using Eclipse, which saves a lot of work &#8211; Ctrl + Space and your website&#8217;s done (I wish!).  Then I chucked in a phpBB forum, modified it and my site so that they&#8217;re nicely integrated.  Finally, I changed to using smarty templates, which has made changing the look of the site in the last few versions significantly easier &#8211; would highly recommend it.</p>
<p>So, you&#8217;ve probably gathered that I&#8217;ll happily reinvent the wheel many times over, but hopefully for a good result.  Magic Hat is very dynamic and has lots of complicated features that I don&#8217;t think would have been feasible to get working in something like WordPress without having to learn and change most of WP.</p>
<p>I&#8217;ve setup the Magic Hat forums to tweet every time someone posts, but I didn&#8217;t really want to use tinyurl/bit.ly as I&#8217;d like to keep magichat.co.uk in the links.  So, here&#8217;s some code that creates the smallest possible hash.</p>
<p><span id="more-55"></span></p>
<pre><code style="font-size: 9px;">$letters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
function getHash($i) {
        $string = "";
        while ($i &gt;= strlen($letters)) {
                $string = substr($letters, $i % strlen($letters), 1) . $string;
                $i = floor($i / strlen($letters));
        }
        $string = substr($letters, $i, 1) . $string;
        return $string;
}
function getNumFromHash($string) {
        $letters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $k = 0;
        $count = 0;
        for ($j = strlen($string) - 1; $j &gt;= 0; $j--) {
                $letter = substr($string, $j, 1);
                $indexOfLetter = strpos($letters, $letter);
                $k += $indexOfLetter * pow(strlen($letters), $count);
                $count++;
        }
        return $k;
}
</code></pre>
<p>So, whenever I want to twitter something, I stick an entry in a database table with the URL and text contents.  I grab the auto incrementing ID from the primary key, and pass it into getHash().  Then I run this:</p>
<pre><code style="font-size: 9px;">$twitters = sql_array("SELECT id, message, link FROM twitter WHERE sent = 0 ORDER BY id");
if (count($twitters[0]) &gt; 0) {
        foreach ($twitters as $t) {
                $linkLength = 0;
                $link = "";
                $message = $t['message'];
                if (strlen($t['link']) &gt; 0) {
                        $link = "http://magichat.co.uk/w/".function_getHash($t['id']);
                        $linkLength = strlen($link) + 1;
                        $message = substr($message, 0, 140 - $linkLength);
                        $message .= " ".$link;
                }
                $message = urlencode($message);
                $ch = curl_init('http://twitter.com/statuses/update.json');
                curl_setopt ($ch, CURLOPT_POST, true);
                curl_setopt ($ch, CURLOPT_POSTFIELDS, 'status='.$message);
                curl_setopt($ch, CURLOPT_USERPWD, 'magichatuk:PASSWORD');
                curl_setopt($ch, CURLOPT_VERBOSE, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
                $response = curl_exec($ch);
                curl_close($ch);
                sql_update("twitter", "sent = 1", "id = ".$t['id']);
        }
}</code></pre>
<p>sql_array and sql_update are a couple of functions that I&#8217;ve written to do stuff with the database, and cache results etc.</p>
<p>The code ensures the full URL is present by shrinking the text if need be.</p>
<p>This line in my .htaccess file directs everything starting /w/ to tinyurl.php</p>
<pre><code style="font-size: 9px;">RewriteRule ^w/(.+)    /tinyurl.php?hash=$1</code></pre>
<p>tinyurl.php:</p>
<pre><code style="font-size: 9px;">
$string = $_GET['hash'];
$k = getNumFromHash($string);
$url = sql_result("link", "ma_twitter", "id = $k");
sql_update("ma_twitter", "hits = hits + 1", "id = $k");
header("Location:http://www.magichat.co.uk".$url);
</code></pre>
<p>And the job&#8217;s done!  Doing it this way (without using tinyurl) means that you can jump to #anchors on the page.</p>
<p>See it in action at <a href="http://twitter.com/magichatuk">http://twitter.com/magichatuk</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jellard.co.uk/2009/10/how-to-tweet-from-your-website-with-your-own-tinyurl-url-shortening-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
