<?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>Connorhd &#187; node.js</title>
	<atom:link href="http://connorhd.co.uk/tag/node-js/feed/" rel="self" type="application/rss+xml" />
	<link>http://connorhd.co.uk</link>
	<description>Interesting stuff.</description>
	<lastBuildDate>Sat, 30 Mar 2013 23:35:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Realtime UK train map</title>
		<link>http://connorhd.co.uk/2013/03/30/realtime-uk-train-map/</link>
		<comments>http://connorhd.co.uk/2013/03/30/realtime-uk-train-map/#comments</comments>
		<pubDate>Sat, 30 Mar 2013 21:18:18 +0000</pubDate>
		<dc:creator>Connorhd</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[d3]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[open data]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[planet compsoc]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[websockets]]></category>

		<guid isPermaLink="false">http://connorhd.co.uk/?p=339</guid>
		<description><![CDATA[A quick project to visualise some of the open data available about the UK train network.
First of all, the result, you should be able to see a map of the UK below, with coloured dots appearing to represent trains as they arrive at stations in realtime.
This requires a browser that supports SVG and websockets, I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p><strong>A quick project to visualise some of the open data available about the UK train network.</strong></p>
<p>First of all, the result, you should be able to see a map of the UK below, with coloured dots appearing to represent trains as they arrive at stations in realtime.</p>
<p><small>This requires a browser that supports SVG and websockets, I&#8217;ve only tested it works in Firefox and Chrome.</small><br />
<iframe src="http://connorhd.co.uk/project/trainmap/" style="border: 0; width: 500px; height: 600px" scrolling="no"></iframe><br />
<a href="http://connorhd.co.uk/project/trainmap/" target="_blank">Click for larger version</a> </p>
<p>So, whats going on here?</p>
<p>It starts with the <a href="http://www.networkrail.co.uk/data-feeds/">network rail operational data feeds</a> one of which  provides a stream of events for train movements (excellently documented by the <a href="http://nrodwiki.rockshore.net/index.php/Train_Movement">Open Rail Data wiki</a>). The interesting fields of data are the timestamp of the event, and the planned timestamp of the event, as well as the STANOX code. These allow me to locate the event, and to calculate the delay between when the event should have happened, and when it actually happened.</p>
<p>To display the events on a map the STANOX code needs to be translated into something more useful, to do that I grabbed one of the reference data files described <a href="http://nrodwiki.rockshore.net/index.php/ReferenceData">here</a>. I then use that to convert STANOX codes to TIPLOC codes (bear with me). Once I have the TIPLOC code I can find the Easting and Northing of stations using the <a href="http://data.gov.uk/dataset/naptan">NaPTAN dataset</a>. This doesn&#8217;t cover the locations of all events as it only has public stations and doesn&#8217;t include depot/switch points that trains also report at, but it turns out it locates about 70% of the events received, which is more than enough for a visualisation.</p>
<p>Unfortunately Eastings and Northings are not a very useful co-ordinate system, what I really want is WGS84 latitude and longitude (GPS co-ordinates), thankfully Chris Veness of <a href="http://www.movable-type.co.uk/">movable-type.co.uk</a> has written <a href="http://www.movable-type.co.uk/scripts/latlong-gridref.html">conversion functions in javascript</a>.</p>
<p>At this point I&#8217;m connecting to the National Rail data feed in node, looking up the location and coverting to the useful lat/long, so I have a realtime stream of train locations and how delayed they are in my console. The next step is to get this into a browser.</p>
<p>I don&#8217;t really have any experience with drawing maps in the browser, but my first guess that <a href="http://d3js.org/">d3</a> will be useful proves correct, and I quickly find this extremely useful tutorial: <a href="http://bost.ocks.org/mike/map/">Let’s Make a Map</a>. I take the <a href="http://bost.ocks.org/mike/map/step-7.html">end result</a> of this tutorial, slightly zoom and recentre the map (the national rail data doesn&#8217;t cover Northern Ireland, and not much goes on in the very north of Scotland). The result is a nice looking SVG UK map that I can draw points on using the d3 projection to convert the lat/long to x/y points.</p>
<p>The last thing to link together is to get the data from node to the browser, I wanted to use websockets given the streaming nature of the data, so I grab <a href="https://github.com/einaros/ws">ws for node</a>. I currently use lighttpd as a webserver, which can&#8217;t handle websocket proxying, so I also setup HAProxy in front of lighttpd to pass the websocket requests directly to node.</p>
<p>At this point it all works, I have dots appearing on my map in the browser as trains arrive at stations. To make things a little more interesting I <a href="https://github.com/mbostock/d3/wiki/Quantitative-Scales">use d3</a> to create a colour gradient for on time to very delayed trains, and I use a radial gradient with some transparency to make trains slightly colour an area of the map.</p>
<p>The result is what you (hopefully) see above, an animated map that shows locations of trains as they arrive, colour coded by how delayed the train is. The source for this is all available <a href="https://github.com/Connorhd/trainmap">on GitHub</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://connorhd.co.uk/2013/03/30/realtime-uk-train-map/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>TabCloud</title>
		<link>http://connorhd.co.uk/2010/10/23/tabcloud/</link>
		<comments>http://connorhd.co.uk/2010/10/23/tabcloud/#comments</comments>
		<pubDate>Sat, 23 Oct 2010 23:12:16 +0000</pubDate>
		<dc:creator>Connorhd</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[google app engine]]></category>
		<category><![CDATA[IBM]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[websockets]]></category>

		<guid isPermaLink="false">http://connorhd.co.uk/?p=241</guid>
		<description><![CDATA[TabCloud is a Chrome extension and Android app which allows you to save open Chrome windows and restore them on another computer or at a later date.
After being thoroughly disappointed by a talk from Mozilla labs about Weave (now called Sync) at last years FOSDEM (they appeared to have made very little progress in the [...]]]></description>
			<content:encoded><![CDATA[<p><strong><a href="https://chrome.google.com/extensions/detail/npecfdijgoblfcgagoijgmgejmcpnhof">TabCloud</a> is a <a href="https://chrome.google.com/extensions/detail/npecfdijgoblfcgagoijgmgejmcpnhof">Chrome extension</a> and <a href="http://www.androidzoom.com/android_applications/tools/tabcloud_miyj.html?nav=googleDownload">Android app</a> which allows you to save open Chrome windows and restore them on another computer or at a later date.</strong></p>
<p>After being thoroughly disappointed by a talk from <a href="https://mozillalabs.com/">Mozilla labs</a> about <a href="https://mozillalabs.com/blog/2007/12/introducing-weave/">Weav</a>e (now called <a href="https://mozillalabs.com/sync/">Sync</a>) at last years <a href="http://archive.fosdem.org/2010/schedule/events/moz_sync_weave">FOSDEM</a> (they appeared to have made very little progress in the last 3 years, and were not even planning to offer any kind of real-time synchronisation). I had decided to attempt to implement the open window/tab synchronisation feature for Google Chrome as an extension. At the time I planned to host the server for this using <a href="http://nodejs.org/">node.js</a> and allow real-time synchronisation with changes automatically affecting any machines you currently had connected. After quickly writing a solution using <a href="http://en.wikipedia.org/wiki/WebSockets">websockets</a> it became obvious this was a harder problem than I anticipated &#8211; synchronisation is hard, mainly when things go wrong, i.e. how do you deal with conflicts when multiple machines have flakey connections, also the <a href="http://code.google.com/chrome/extensions/windows.html">Chrome extension API</a> makes it very difficult to distinguish the difference between closing all a windows tabs, and closing the window &#8211; so the project in that form was abandoned until I could find more time for it.</p>
<p>Fast-forward to the summer and I am working at <a href="http://www.ibm.com/uk/en/">IBM</a> as a technical intern for <a href="http://en.wikipedia.org/wiki/Extreme_Blue">Extreme Blue</a>, I have a work laptop, home computer and my personal laptop, I am still using Chrome as my main browser and I would really like a way of sharing my browser sessions between my machines. I had recently created <a href="http://linkpush.appspot.com">LinkPush</a> (something I intend to blog about shortly), which made me think of using <a href="http://code.google.com/appengine/">Google App Engine</a> to host a simplified session sharing plugin for Chrome using Google Accounts as a means of secure identification. The result &#8211; <a href="https://chrome.google.com/extensions/detail/npecfdijgoblfcgagoijgmgejmcpnhof">TabCloud</a> &#8211; is an extension which allows you to save an open window as a group of tabs, which can be restored on any other computer (or the same computer at a later date) via the extension interface. It also offers some other features such as naming windows, and re-arranging tabs between open windows and saved sessions by dragging and dropping the tab icons. I also released a very simple <a href="http://www.androidzoom.com/android_applications/tools/tabcloud_miyj.html?nav=googleDownload">Android app</a> which allows you to view your saved tabs as a list from your phone and open any individual link.</p>
<p><img src="http://connorhd.co.uk/wp-content/uploads/2010/10/tabcloud.png" alt="TabCloud Screenshot" title="tabcloud" width="477" height="290" class="alignnone size-full wp-image-251" /></p>
<p>The project isn&#8217;t really anything like my original plans, however I find it extremely useful, hopefully at some point I will find the time to make a truely real-time session synchronisation app (unless Google <a href="http://code.google.com/p/chromium/issues/detail?id=30519">beat me to it</a>). Firefox 4 beta comes with the current Mozilla Sync (also available as an extension for older Firefoxes), which periodically saves all your open tabs (as well as other data) to their server, which allows you to view open tabs on one machine from another (or mobile device), however (despite this being more what I originally aimed for) this seems a lot less useful in practice than the simpler functionality I have implemented with TabCloud.</p>
<p>If you are interested the whole project is open source and available on <a href="http://github.com/Connorhd/TabCloud">GitHub</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://connorhd.co.uk/2010/10/23/tabcloud/feed/</wfw:commentRss>
		<slash:comments>59</slash:comments>
		</item>
		<item>
		<title>Pixelatr &#8211; SVG powered pixel drawing demo</title>
		<link>http://connorhd.co.uk/2010/10/19/pixelatr/</link>
		<comments>http://connorhd.co.uk/2010/10/19/pixelatr/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 21:49:38 +0000</pubDate>
		<dc:creator>Connorhd</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[ie9]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[minecraft]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[socket.io]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[websockets]]></category>

		<guid isPermaLink="false">http://connorhd.co.uk/?p=214</guid>
		<description><![CDATA[I&#8217;ve wanted to experiment with some of the various graphics libraries in JavaScript for a while now, and deciding to attempt the ambitious task of a 2D clone of the recently popular game, MineCraft, seemed a worthy reason to play around with some of them.
After deciding (perhaps wrongly) that Raphaël would be a good library [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve wanted to experiment with some of the various graphics libraries in JavaScript for a while now, and deciding to attempt the ambitious task of a 2D clone of the recently popular game, <a href="http://www.minecraft.net/">MineCraft</a>, seemed a worthy reason to play around with some of them.</p>
<p>After deciding (perhaps wrongly) that <a href="http://raphaeljs.com/">Raphaël</a> would be a good library to do this in (or at least one I would like to try out). A quick weekend of implementing and reimplementing various ways of rendering scrolling around a vast 2D block world (in the end using a massive SVG element that is scrolled with blocks being added or removed as they come into and leave the visible area). The results are (not quite 2D MineCraft yet I know) a massive editable grid of &#8220;pixels&#8221; which are actually rounded rectangles of various colours.</p>
<p>As I wasn&#8217;t going to complete 2D MineCraft in a weekend I decided to add in websocket support using <a href="http://socket.io">Socket.IO</a> and make it a multi-user editable canvas that persists between sessions. Its quite fun to play with and there is a small demo below (works best in Chrome, Safari or IE9, should work slowly in Firefox), for a full page version <a href="http://connorhd.co.uk/project/pixelatr/#blog">click here</a>, the last part of the URL defines the &#8220;channel&#8221; you are in if you wish to create a private page to share with friends.</p>
<p><iframe style="width:100%; height: 400px; border: 0" src="http://connorhd.co.uk/project/pixelatr/#blog"></iframe></p>
<p>If you are interested in the source just view the source of that page, I&#8217;ll be uploading the server and client to github shortly (once I&#8217;ve tided up some of the code a bit). If I have some time in the future I hope to take this further and make some kind of user editable platformer type game in the general theme of MineCraft. I would also like to try implementing this using the HTML5 canvas element (especially with the recent hardware rendering developments on Chrome and IE9).</p>
]]></content:encoded>
			<wfw:commentRss>http://connorhd.co.uk/2010/10/19/pixelatr/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How To Node</title>
		<link>http://connorhd.co.uk/2010/02/25/how-to-node/</link>
		<comments>http://connorhd.co.uk/2010/02/25/how-to-node/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 21:18:10 +0000</pubDate>
		<dc:creator>Connorhd</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://connorhd.co.uk/2010/02/25/how-to-node/</guid>
		<description><![CDATA[At the risk of being boring, another node related link. A collection of articles written about node (mainly as tutorials) by the node community.
]]></description>
			<content:encoded><![CDATA[<p>At the risk of being boring, another node related link. A collection of articles written about node (mainly as tutorials) by the node community.</p>
]]></content:encoded>
			<wfw:commentRss>http://connorhd.co.uk/2010/02/25/how-to-node/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MongoDB</title>
		<link>http://connorhd.co.uk/2010/01/31/mongodb/</link>
		<comments>http://connorhd.co.uk/2010/01/31/mongodb/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 01:57:12 +0000</pubDate>
		<dc:creator>Connorhd</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[ircster]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[nosql]]></category>

		<guid isPermaLink="false">http://connorhd.co.uk/?p=71</guid>
		<description><![CDATA[Another nosql project, mongodb provides more than just key-value pair storage. It is a document orientated database (along the lines of relational databases, but without a fixed structure for tables, or relational queries). That is, you can store objects (documents) that contain any combination of fields and data (data being strings, numbers, arrays or objects [...]]]></description>
			<content:encoded><![CDATA[<p>Another nosql project, mongodb provides more than just key-value pair storage. It is a document orientated database (along the lines of relational databases, but without a fixed structure for tables, or relational queries). That is, you can store objects (documents) that contain any combination of fields and data (data being strings, numbers, arrays or objects themselves), and then perform queries on them.</p>
<p>I have been interested in using mongo as a logging system for <a href="http://ircster.com">Ircster</a> for a while now (it supports large sets of data with <a href="http://www.mongodb.org/display/DOCS/Full+Text+Search+in+Mongo">full text search</a> and very fast queries), however until recently there was no reasonable driver for <a href="http://nodejs.org">node</a>. There are now two drivers available <a href="http://github.com/orlandov/node-mongodb">node-mongodb</a> (bindings to the C driver) and <a href="http://github.com/christkv/node-mongodb-native">node-mongodb-native</a> (a JS implementation of the driver). The native driver especially interests me as I can more easily understand and work with the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://connorhd.co.uk/2010/01/31/mongodb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>node_debug &#8211; A debugging console over HTTP</title>
		<link>http://connorhd.co.uk/2010/01/25/node_debug-a-debugging-console-over-http/</link>
		<comments>http://connorhd.co.uk/2010/01/25/node_debug-a-debugging-console-over-http/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 23:40:24 +0000</pubDate>
		<dc:creator>Connorhd</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[planet compsoc]]></category>
		<category><![CDATA[project]]></category>

		<guid isPermaLink="false">http://connorhd.co.uk/?p=43</guid>
		<description><![CDATA[I&#8217;d also like to use my blog to write about a few of my personal projects. Many of these aren&#8217;t very useful and very few actually reach any usable state, however I feel node_debug is actually something quite useful.
Before reading this post you should probably know what node.js is.
node_debug allows you to evaluate statements and view their [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d also like to use my blog to write about a few of my personal projects. Many of these aren&#8217;t very useful and very few actually reach any usable state, however I feel node_debug is actually something quite useful.</p>
<p>Before reading this post you should probably know what <a href="http://nodejs.org">node.js</a> is.</p>
<p><a href="http://github.com/Connorhd/node_debug">node_debug</a> allows you to evaluate statements and view their result (much like a <a href="http://en.wikipedia.org/wiki/Read-eval-print_loop">REPL</a>) from your favourite browser (assuming your favourite browser isn&#8217;t IE). It also allows you to browse objects if the result of your statement is an object, for example the global object in node is <code>process</code> so executing <code>process;</code> will return a browsable tree structure of the global scope.</p>
<p><a href="http://connorhd.co.uk/wp-content/uploads/2010/01/node_debug11.png"><img class="alignnone size-full wp-image-48" title="node_debug screenshot 1" src="http://connorhd.co.uk/wp-content/uploads/2010/01/node_debug11.png" alt="" width="447" height="324" /></a></p>
<p>Additionally it exports a log function that allows you to asynchronously output to any active console, for example <code>setTimeout(function () { debug.log("Hello") }, 5000);</code> will output <strong>Hello</strong> to any open consoles after 5 seconds, allowing useful debug output when using asynchronous functions.</p>
<p><a href="http://connorhd.co.uk/wp-content/uploads/2010/01/node_debug21.png"><img class="alignnone size-full wp-image-49" title="node_debug screenshot 2" src="http://connorhd.co.uk/wp-content/uploads/2010/01/node_debug21.png" alt="" width="448" height="323" /></a></p>
<p>To get started using node_debug you need to have a server running node, and to grab the latest node_debug from github. There is an example.js included to show how you would include it in your own scripts, the idea being you can simply include this in your own project in order to easily debug issues.</p>
<p>Future features I would like to add include:</p>
<ul>
<li>A debug.scope object that allows you to import other objects into the debuggers scope (currently only the global scope is available which can cause confusion due to closures in JavaScript hiding a lot of variables from the debugger).</li>
<li>debug.error/warn/info functions in line with the browser console object provided by firebug.</li>
<li>Detect disconnection from node and attempt reconnection.</li>
<li>Caching of asynchronous messages that can be shown when connecting to the console, in order to log things without having an active browser window all the time.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://connorhd.co.uk/2010/01/25/node_debug-a-debugging-console-over-http/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Node.js</title>
		<link>http://connorhd.co.uk/2010/01/25/node-js/</link>
		<comments>http://connorhd.co.uk/2010/01/25/node-js/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 02:20:48 +0000</pubDate>
		<dc:creator>Connorhd</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[ircster]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[node.js]]></category>

		<guid isPermaLink="false">http://www.connorhd.co.uk/?p=40</guid>
		<description><![CDATA[So, the point of this blog is for me to post about things that interest me, this seems like a pretty obvious start.
Node.js is &#8220;Evented I/O for V8 javascript&#8221; this means you can perform I/O (read files, send across the internet etc) in an extremely efficient way, and write your code in JavaScript (something I find very attractive). [...]]]></description>
			<content:encoded><![CDATA[<p>So, the point of this blog is for me to post about things that interest me, this seems like a pretty obvious start.</p>
<p>Node.js is &#8220;Evented I/O for <a href="http://code.google.com/p/v8/">V8 javascript</a>&#8221; this means you can perform I/O (read files, send across the internet etc) in an extremely efficient way, and write your code in JavaScript (something I find very attractive). I am currently using this for a number of projects including <a href="http://ircster.com">Ircster</a> (more posts on this later).</p>
]]></content:encoded>
			<wfw:commentRss>http://connorhd.co.uk/2010/01/25/node-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
