<?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>nooshu &#187; Interesting Archives </title>
	<atom:link href="http://nooshu.com/category/interesting/feed" rel="self" type="application/rss+xml" />
	<link>http://nooshu.com</link>
	<description>Kneeling on the shoulders of giants</description>
	<lastBuildDate>Sun, 15 Apr 2012 13:42:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>A visualisation experiment using SoundCloud, Backbone.js, three.js and node.js</title>
		<link>http://nooshu.com/a-visualisation-experiment-using-soundcloud-backbone-js-three-js-and-node-js?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-visualisation-experiment-using-soundcloud-backbone-js-three-js-and-node-js</link>
		<comments>http://nooshu.com/a-visualisation-experiment-using-soundcloud-backbone-js-three-js-and-node-js#comments</comments>
		<pubDate>Sun, 15 Apr 2012 13:42:21 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Three.js]]></category>
		<category><![CDATA[backbone]]></category>
		<category><![CDATA[three.js]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=2144</guid>
		<description><![CDATA[A code competition is always a good reason to have an experiment with some new technology.]]></description>
			<content:encoded><![CDATA[<p>Client work, as always, has been busy over the past month or so; so it&#8217;s always refreshing to have a play with something a little different. It&#8217;s even better when you can actually combine the two! <a href="http://www.visualjazz.com.au/">Visual Jazz Isobar</a> decided to have a little code competition open to all the developers in the company. The brief was very simple: build something cool using an external API (bonus points for multiple API&#8217;s). Very open brief don&#8217;t you think? You only have to have a look at the <a href="http://www.programmableweb.com/apis">list of API&#8217;s</a> available on programmable web to see that.</p>
<p>As I&#8217;ve recently been looking at <a href="http://documentcloud.github.com/backbone/">Backbone.js</a> I decided to put what I&#8217;ve learned good use. The experiment evolved over a couple of weeks. I originally planned to use d3.js and last.fm but eventually settled on three.js and SoundCloud. My final submission looked like this:</p>
<div id="attachment_2146" class="wp-caption alignnone" style="width: 528px"><a href="http://nooshu-soundcloud.nodester.com/"><img src="http://nooshu.com/wp-content/uploads/2012/04/soundcloud-backbone-experiment.gif" alt="Visualisation using Backbone.js, Node.js and Three.js" title="soundcloud-backbone-experiment" width="518" height="233" class="size-full wp-image-2146" /></a><p class="wp-caption-text">My little experiment using the SoundCloud API and three.js (with a sprinkling of node.js)</p></div>
<p>To be honest I could have built the experiment easily without using Backbone, but where is the challenge in that! I love the whole Model, View, Router set up. You do seem to be writing a lot of code a first for very little functionality, but once you are over the initial set up you can add features very quickly. I&#8217;ll definitely be using it again for future projects.</p>
<p>The visualisation itself makes use of the <a href="https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html">Web Audio API</a>. The API is still being developed and standardized, because of that it only runs in Chrome at the moment. Three.js itself runs fine in Firefox, but no audio visualisation. </p>
<p>During development I stumbled across <a href="http://code.google.com/p/chromium/issues/detail?id=96136">an issue with Chrome</a> and the way the audio buffer works; for the data to load, the music files need to be on the same server as the application. This was a bit of a problem as I was using the <a href="http://developers.soundcloud.com/">SoundCloud API</a> for music streaming. That&#8217;s where <a href="http://nodejs.org/">node.js</a> and <a href="http://nodester.com/">Nodester</a> came to the rescue. With a little bit of node.js magic it&#8217;s fairly simple to create a proxy server and &#8216;bounce&#8217; the stream from SoundCloud via the server to the visualisation. A big downside to this method is the music stream (mp3) has to be fully downloaded before the visualisation starts. For this reason only tracks under 6 minutes are returned as search results from SoundCloud. It&#8217;s not ideal but it work!</p>
<p>When the competition results came in I was placed second; not first but hey I learnt a lot in the process! You can take a look at my <a href="http://nooshu-soundcloud.nodester.com/">little experiment here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/a-visualisation-experiment-using-soundcloud-backbone-js-three-js-and-node-js/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Writing efficient CSS selectors</title>
		<link>http://nooshu.com/writing-efficient-css-selectors?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=writing-efficient-css-selectors</link>
		<comments>http://nooshu.com/writing-efficient-css-selectors#comments</comments>
		<pubDate>Thu, 08 Dec 2011 06:43:59 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[opera]]></category>
		<category><![CDATA[selector]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=2045</guid>
		<description><![CDATA[With browsers getting faster all the time it's a good idea to remember that not everyone uses them. Writing efficient code is key to maximising device accessibility.]]></description>
			<content:encoded><![CDATA[<p>With modern browsers getting quicker with every new version number it&#8217;s easy to fall into the trap of writing inefficient code. A page will run super quick on the latest version on Chrome or Firefox, but you also have to consider older browsers and mobile devices. That shiny new web application that uses some super fancy CSS selectors may be unusable on certain devices due to its limited hardware. That&#8217;s not to say you shouldn&#8217;t be using super fancy selectors; you just have to be careful to consider your target audience, and use them in the most efficient way possible.</p>
<p>The first thing to note about CSS selectors is they don&#8217;t work in the way you&#8217;d expect. In the west we read a page from left to right. Reading a CSS selector, you&#8217;d expect that&#8217;s what the browser does as well. Wrong! The browser actually reads a selector from right to left (in Mozilla&#8217;s case anyway, and most likely in others too). So take the following CSS as an example:</p>
<div class="codecolorer-container css default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">body <span style="color: #cc00cc;">#wrapper</span> <span style="color: #6666ff;">.article</span> ul<span style="color: #6666ff;">.meta</span> li a <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">700</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Arial<span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
<p>The browser first looks for all the anchor tags (called the &#8220;key&#8221; as it&#8217;s the rightmost selector), then looks at the list items, it evaluates those and throws away the results that don&#8217;t match. Next the browser moves onto elements with a class of &#8220;meta&#8221;, throwing out results that don&#8217;t match and so on&#8230; you get the idea! There&#8217;s so much redundancy in the above selector, it could easily be cut down to:</p>
<div class="codecolorer-container css default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666ff;">.meta</span> a <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">700</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Arial<span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
<p>This example is much more efficient. There are less rules for the browser to evaluate, it&#8217;s much easier to read and if you apply minimal selectors across your whole stylesheet you will notice a big difference in file size. The key to writing efficient selectors is to be as specific as possible. Whatever you do don&#8217;t write this:</p>
<div class="codecolorer-container css default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">body <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
<p>The universal selector(*) is bad (even body isn&#8217;t needed)! You are targeting every single element in the DOM and setting it&#8217;s padding and margin to zero. For a large page that could easily be thousands of elements!</p>
<p>I actually inspected the stylesheet for this website and went over it with a fine tooth comb. I found many additional selectors that just weren&#8217;t needed. The size of my stylesheet went from 18.3kB down to 16.5kB, a saving of 1.8kB. It doesn&#8217;t sound a lot in terms of file size, but that&#8217;s a whole lot of selectors the browser no longer has to evaluate to render the page.</p>
<p>Luckily there are tools available that can help you make your CSS more efficient, as well as many other areas of your website too. The first tool I&#8217;d recommend is called <a href="http://code.google.com/speed/page-speed/docs/overview.html">Page Speed</a>, created by Google. The Page Speed extension is available on both Chrome and Firefox. Once installed you have the option to run it on any page; it will give you an overall score for that page and recommendations on how to <a href="http://code.google.com/speed/page-speed/docs/rules_intro.html">improve it</a>.</p>
<div id="attachment_2047" class="wp-caption alignnone" style="width: 528px"><a href="http://nooshu.com/wp-content/uploads/2011/12/google-page-speed.jpg"><img src="http://nooshu.com/wp-content/uploads/2011/12/google-page-speed-518x279.jpg" alt="Google Page Speed results for Nooshu.com." title="google-page-speed" width="518" height="279" class="size-medium wp-image-2047" /></a><p class="wp-caption-text">Page Speed results for this site. Note the &quot;Use efficient CSS selectors&quot; drop down.</p></div>
<p>The second tool I&#8217;d recommend is Opera&#8217;s <a href="http://www.opera.com/dragonfly/">Dragonfly</a>. Dragonfly (similar to Firebug, in name at least) is Opera&#8217;s developer toolkit, much like Web Inspector for Chrome. An awesome feature that Dragonfly has, that other toolkits don&#8217;t is &#8220;style recalculation&#8221;. <a href="http://my.opera.com/dragonfly/blog/style-profiler-preview">Style recalculation</a> gives you a breakdown of all the selectors that were run on the page, how long they took to evaluate and how many elements they hit along the way (hits).</p>
<div id="attachment_2048" class="wp-caption alignnone" style="width: 528px"><a href="http://nooshu.com/wp-content/uploads/2011/12/dragonfly-debugger.jpg"><img src="http://nooshu.com/wp-content/uploads/2011/12/dragonfly-debugger-518x279.jpg" alt="Opera&#039;s Dragonfly debugger in action on nooshu.com." title="dragonfly-debugger" width="518" height="279" class="size-medium wp-image-2048" /></a><p class="wp-caption-text">Dragonfly gives you an extremely useful breakdown of what selectors were used and how long they took to evaluate.</p></div>
<p>If you look closely at the results in the image above, you will see that the selectors with the most number of hits are the ones involving the universal selector(*), as you would expect. You may also notice that most of the timings say 0.0ms which isn&#8217;t very helpful. This is due to the fact that the size of the DOM being tested is very small, and timing to 1 decimal place isn&#8217;t accurate enough to show the actual time it took to evaluate. If you were to run this test on a huge page, say the <a href="http://dev.w3.org/html5/spec/Overview.html">HTML5 Specification</a> for example, you would really be able see the difference in CSS selector efficiency.</p>
<p>This feature of Dragonfly is very new and is still in testing. There are a few issues still to be ironed out in future releases but it&#8217;s definitely a tool to keep in your bookmarks.</p>
<p>A word of warning when it comes to writing efficient selectors. I found myself trying to make the selectors so efficient it was becoming quite hard to pin-point where exactly on the site they were being used. If you have a very specific area of a site you are trying to target, it is easier to read if you have the selectors starting with an ID reflecting that area. You then know for certain that the changes you make won&#8217;t affect other parts of the site. Also remember that removing &#8220;unused&#8221; selectors will affect the specificity of the rule. You could end up breaking something, as what you thought was an unused selector was actually used in overriding another rule.</p>
<p>Having too many descendent selectors is something that Page Speed frowns upon, but as with all things in life it&#8217;s a case of finding that happy medium. In this case it&#8217;s between efficient selectors and CSS that is easy to read and maintain (for you and other developers).</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/writing-efficient-css-selectors/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Design for Developers</title>
		<link>http://nooshu.com/design-for-developers?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=design-for-developers</link>
		<comments>http://nooshu.com/design-for-developers#comments</comments>
		<pubDate>Wed, 30 Nov 2011 03:10:11 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[slideshow]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1968</guid>
		<description><![CDATA[Design is hard! Well it is for me anyway. Here's a brilliant slideshow for developers to point you in the right direction.]]></description>
			<content:encoded><![CDATA[<p>As a developer I must admit I find design hard! Open up a blank PSD in Photoshop and I come out in a cold sweat. More often than not a developer will quickly construct an application, get it working and dump everything on a page. The application works, but it&#8217;s horrible to look at and is very unintuitive to use. Thankfully, a designer by the name of <a href="http://wolfslittlestore.be/">Johan Ronsse</a> has put together a presentation aimed at developers who are looking to improve their design skills.</p>
<p><iframe src="http://www.slideshare.net/slideshow/embed_code/10323363" width="518" height="428" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>The presentation has some excellent content on what you should (and shouldn&#8217;t) do with an interface design. Basics on fonts, colours, shadows and icons are all explained in a clear and concise way. For those wishing to continue with their new-found design skills, slide number 179 has a long list of links and books to read. My personal favourite is the simple, yet effective <a href="http://www.29digital.net/grid/">Grid Calculator</a> tool. I&#8217;ve read many articles on the grid system, but have never used it. This handy website does all the mundane maths for you, allowing you to get back to making your application look pretty!</p>
<p>Big thank you to Johan for the presentation, every developer should read it at least once (or bookmark it to read later)!</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/design-for-developers/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Embracing Git for version control</title>
		<link>http://nooshu.com/embracing-git-for-version-control?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=embracing-git-for-version-control</link>
		<comments>http://nooshu.com/embracing-git-for-version-control#comments</comments>
		<pubDate>Tue, 29 Nov 2011 07:25:05 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[useful]]></category>
		<category><![CDATA[version-control]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1956</guid>
		<description><![CDATA[Who would have thought version control could be so easy and fun? It can be with Git!]]></description>
			<content:encoded><![CDATA[<p>For many years I&#8217;ve been using Subversion (SVN) as my version control of choice. It&#8217;s been a part of my deployment process, all of my work is in Subversion, even the small demos I&#8217;ve created are in a repository. It&#8217;s a good feeling to know that if your laptop dies (or is stolen), all your work is backed up on a remote server.</p>
<p>Recently I&#8217;ve heard many developers raving about <a href="http://git-scm.com/">Git</a>, and I&#8217;ve looked at libraries and code snippets that are using it, so I thought I&#8217;d check it out and see what all the fuss is about. After a couple of hours reading up and watching a few tutorials I&#8217;m genuinely excited about using it in future projects. It really is that good! So, what&#8217;s so good about it then you may ask? Well here are a few points that stood out for me:</p>
<ul>
<li>Easy to install and start using (Windows has a simple installer)</li>
<li>Distributed version control, so no need for a central server</li>
<li>Runs on your local machine, no need to connected to the internet to commit(!)</li>
<li>Very clean, it only creates one git directory for the whole repository (no hidden .svn&#8217;s everywhere)</li>
<li>Incredibly easy to branch and merge your code (this is a big plus!)</li>
<li>It&#8217;s simple to use Git with SVN, no need to abandon your SVN repositories. Git can pull &#038; push directly into an existing SVN repository!</li>
</ul>
<p>I&#8217;d heard developers saying how easy it was to branch and merge your code using Git, I assumed they were exaggerating. But no, it really is simple:</p>
<div class="codecolorer-container bash default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#create a new branch in my repository</span><br />
<span style="color: #c20cb9; font-weight: bold;">git</span> branch my_new_branch<br />
<br />
<span style="color: #666666; font-style: italic;">#move to the new branch for commits etc</span><br />
<span style="color: #c20cb9; font-weight: bold;">git</span> checkout my_new_branch<br />
<br />
<span style="color: #666666; font-style: italic;">#finished with the branch, so lets merge it back into master</span><br />
<span style="color: #c20cb9; font-weight: bold;">git</span> merge my_new_branch</div></td></tr></tbody></table></div>
<p>One of the most amazing parts of Git that blew me away: when you jump between branches it automatically updates your file structure accordingly! So lets say you have a new set of files in a new branch, and you need to jump back to master (trunk) to make some changes. Simply run &#8216;git checkout master&#8217;, the new branch files will be &#8216;removed&#8217; and stored away until you are back on the new branch where they were added. Amazing!</p>
<p>The feature that really sold Git to me was the stash command. So many times I&#8217;ve been working on a project and got half way through some changes, only to have to fix a bug in the original version. So you copy the modified files somewhere, undo all your changes, fix the bug, copy the files over and start where you left off. Not fun! Git and the stash command come to the rescue:</p>
<div class="codecolorer-container bash default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#store your current changes in a 'clipboard' so they can be seen again later</span><br />
<span style="color: #c20cb9; font-weight: bold;">git</span> stash<br />
<br />
<span style="color: #666666; font-style: italic;">#you are now working on the unmodified version of the branch</span><br />
<span style="color: #666666; font-style: italic;">#after you've fixed the issue, start from where you left off by applying the stash</span><br />
<span style="color: #c20cb9; font-weight: bold;">git</span> stash apply</div></td></tr></tbody></table></div>
<p>Another huge advantage Git has is how simple it is to share code between developers. It only takes a couple of commands to clone another repository. Once you have a local copy (clone), you can change whatever you like. Make the project better (or break it horribly, it&#8217;s up to you). For an example of how powerful social coding is take a look at <a href="https://github.com/">Github</a>. The 3D JavaScript library <a href="https://github.com/mrdoob/three.js/">three.js</a> for example has over 4000 people watching and 400+ people have forked (cloned) the repository. If your version adds a cool new feature or fixes a bug, it can easily be merged back into the original project!</p>
<p>If you are interested in learning how to use Git there are some superb resources available. For people who like screencasts I highly recommend watching the one created by <a href="http://peepcode.com/products/git">Peepcode</a>. It&#8217;s only $9 (US), 1 hour-long and will get you up and running with Git in no time at all! Here are some other resources I found useful:</p>
<ul>
<li><a href="http://git.or.cz/course/svn.html">Git-SVN &#8211; A Crash Course</a></li>
<li><a href="http://nvie.com/posts/a-successful-git-branching-model/">A successful Git branching model</a></li>
<li><a href="http://net.tutsplus.com/tutorials/other/easy-version-control-with-git/">NetTuts &#8211; Easy Version Control with Git</a></li>
<li><a href="http://help.github.com/">Github help documents</a></li>
</ul>
<p>Right, I&#8217;m off to start committing to a repository while travelling on a train to work when I don&#8217;t have an internet connection (warm fuzzy feeling enabled)! </p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/embracing-git-for-version-control/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>dat.gui &#8211; controller library for JavaScript</title>
		<link>http://nooshu.com/dat-gui-controller-library-for-javascript?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=dat-gui-controller-library-for-javascript</link>
		<comments>http://nooshu.com/dat-gui-controller-library-for-javascript#comments</comments>
		<pubDate>Wed, 16 Nov 2011 02:14:45 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Vanilla JavaScript]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[euler]]></category>
		<category><![CDATA[library]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1933</guid>
		<description><![CDATA[Building a demo in JavaScript? Then you really need to start using the dat.gui library. It takes the hassle out of controlling your variables. ]]></description>
			<content:encoded><![CDATA[<p>Very recently I&#8217;ve been looking at some awesome JavaScript experiments and have noticed they are all using the same GUI. Now I fully admit I had a little &#8216;blonde&#8217; moment as I assumed it was just a style everyone had adopted; developers being &#8216;one of the cool kids&#8217;, that type of thing. It turns out I was wrong, and it finally clicked. All the experiments have started using a little controller library called <a href="http://code.google.com/p/dat-gui/">dat.gui</a>.</p>
<p>After it appeared on <a href="http://workshop.chromeexperiments.com/">Google&#8217;s workshop</a> (along with three.js), I thought it was about time I had a play with this neat little library. Luckily there&#8217;s an excellent set of documentation and <a href="http://workshop.chromeexperiments.com/examples/gui/#1--Basic-Usage">working examples</a> available so you can dive right in. Here&#8217;s a code example of how to get started:</p>
<div class="codecolorer-container javascript default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">//Define the controller function</span><br />
<span style="color: #003366; font-weight: bold;">var</span> FresnelControls <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">movingParticles</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">5000</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">seedColor</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;#ff0098&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Create the Dat.gui controls</span><br />
<span style="color: #003366; font-weight: bold;">var</span> fc <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> FresnelControls<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Create the GUI</span><br />
<span style="color: #003366; font-weight: bold;">var</span> gui <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> dat.<span style="color: #660066;">GUI</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Add 2 folders</span><br />
<span style="color: #003366; font-weight: bold;">var</span> f1 <span style="color: #339933;">=</span> gui.<span style="color: #660066;">addFolder</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Particle Dynamics'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> f2 <span style="color: #339933;">=</span> gui.<span style="color: #660066;">addFolder</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Particle Colours'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #006600; font-style: italic;">//Add the moving particles controller to folder 1</span><br />
f1.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>fc<span style="color: #339933;">,</span> <span style="color: #3366CC;">'movingParticles'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5000</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">step</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Add the colour controller, store in a var to attach events</span><br />
<span style="color: #003366; font-weight: bold;">var</span> seedColor <span style="color: #339933;">=</span> f2.<span style="color: #660066;">addColor</span><span style="color: #009900;">&#40;</span>fc<span style="color: #339933;">,</span> <span style="color: #3366CC;">'seedColor'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">//Colour change event</span><br />
seedColor.<span style="color: #660066;">onChange</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Do something on color change...</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>I decided to dig out an <a href="http://nooshu.com/animating-the-euler-spiral">old demo</a> I created last year and adapt it to use dat.gui. Originally I used jQuery + jQuery UI to control the JavaScript variables. It worked well, but it really added page weight (jQuery + UI came to over 90Kb); not great when you are only using it for the sliders. </p>
<p>Following the documentation you start off simple and progressively add more of the dat.gui functionality. You can see my adapted demo <a href="http://dl.dropbox.com/u/7851949/euler-dat/index.html">here</a>. The dat.gui code is highlighted if you want to see how it was set up.</p>
<div id="attachment_1936" class="wp-caption alignnone" style="width: 528px"><a href="http://dl.dropbox.com/u/7851949/euler-dat/index.html"><img src="http://nooshu.com/wp-content/uploads/2011/11/datgui-518x205.jpg" alt="Dat.gui in action on the Euler Spiral demo I created." title="datgui" width="518" height="205" class="size-medium wp-image-1936" /></a><p class="wp-caption-text">You can see dat.gui in action on my modified Euler Spiral demo.</p></div>
<p>Dat.gui really has some excellent features available. I was able to make use of the colour picker, presets and folder functionality; but there&#8217;s a whole host of others I didn&#8217;t, such as the <a href="http://workshop.chromeexperiments.com/examples/gui/#8--Custom-Placement">custom placement</a> and <a href="http://workshop.chromeexperiments.com/examples/gui/#9--Updating-the-Display-Automatically">updating the display automatically</a>. Personally I love the presets functionality; supply the GUI with a little bit of JSON and away you go!</p>
<p>As always, a big thank you goes out to the Data Arts Team in Google’s Creative Lab for creating such a useful little library! One I will be using in every demo I create from now on.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/dat-gui-controller-library-for-javascript/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Back to my desk (down under)</title>
		<link>http://nooshu.com/back-to-my-desk-down-under?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=back-to-my-desk-down-under</link>
		<comments>http://nooshu.com/back-to-my-desk-down-under#comments</comments>
		<pubDate>Sun, 13 Nov 2011 05:50:05 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Interesting]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[catch-up]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1897</guid>
		<description><![CDATA[As anyone who has worked on the web knows, a lot can change in three months. Time to get back to work and catch up with the latest goings on.]]></description>
			<content:encoded><![CDATA[<p>Well that was a quick three months! <a href="http://solostrightnow.com/">Travelling around south-east Asia</a> was incredible! So many memories and stories to take away from the experience. Unfortunately all good things have to come to an end, so back to work it is. Actually I&#8217;ve been looking forward to getting back to work for a couple of weeks, itching to start using the latest technologies the web has to offer.</p>
<p>A lot can change on the web in three months; so in order to get my head around what&#8217;s new, I&#8217;ve compiled a list of exciting developments and changes in the Web Developer community (in no particular order).</p>
<h3>Browsers</h3>
<p>Thankfully the browser war has started again (this time for the better) and it certainly hasn&#8217;t slowed down in the last three months!</p>
<p>Some amazing news first; Has Internet Explorers browser market share finally <a href="http://mashable.com/2010/10/05/ie-50-percent-market-share/">dropped below 50%</a>? Well according to Statcounter it has (oh please let it be true!). As with all statistics you have to be careful how you interpret the data. A more important statistic would be how that 50% is broken down. How many users are still using IE6? If corporations are still sticking with IE6 due to internal tools and upgrade cost, that value won&#8217;t be changing any time soon (boo!).</p>
<p><a href="http://en.wikipedia.org/wiki/WebGL">WebGL</a> is the big thing on the web at the moment. Incredible graphics rendered directly in the browser (no Flash required!). Of course Microsoft being Microsoft, they aren&#8217;t going to support it. To be fair they do give a good excuse; the specification isn&#8217;t 100% set, so they aren&#8217;t going to implement it (but when has that ever stopped them before?). Luckily for developers a small team in Russia have decided to add it themselves by creating a plug-in for IE (for non-commercial use) called <a href="http://iewebgl.com/">IEWebGL</a>. It&#8217;s not ideal but it&#8217;s better than nothing!</p>
<p>There&#8217;s been big changes at Firefox over the past three months. The Firefox team have now adopted a six week release schedule just like Chrome. So while I&#8217;ve been away we&#8217;ve had version 6,7 and <a href="http://www.getfirefox.net/">8</a>. There&#8217;s even talk of Aurora 10 (a.k.a. Firefox 10) on the horizon. Mozilla also seem to have adopted the &#8216;channel&#8217; route for deployment, where by you can join the stable, beta or nightly channel depending on how brave you are. You can receive a new version of Firefox every few days (or sometimes a broken version) if you so wish. I&#8217;m hoping they also adopt the &#8216;delta&#8217; update strategy that Chrome uses; no need to download the whole installer every time, only the parts that have changed. On a side note, Firefox now gets 100% on the <a href="http://www.acid3.org/">Acid3 test</a>, so well done to Mozilla for achieving that (if that type of browser comparison floats your boat).</p>
<p>I love this little addition; in the latest nightly versions of Firefox, Mozilla has added support for the <a href="https://wiki.mozilla.org/JoystickAPI">draft JoystickAPI</a>. What an incredibly simple idea, it never even occurred to me! The API allows a browser to communicate directly with a joystick / gamepad, meaning you can control that snazzy HTML5 game you&#8217;ve written just like you would on a games console. There&#8217;s a breakdown of what is supported on the API page including handy code examples. All you need is a joystick that&#8217;s supported by your PC or Mac. It looks like a standard Xbox360 controller will work, and they&#8217;re fairly cheap to buy. I May just have to add that to my Christmas list this year and give it a whirl!</p>
<p>With the IE browser market share (apparently) going below 50%, it looks like Chrome could be set to take <a href="http://news.slashdot.org/story/11/09/29/1945201/chrome-set-to-take-no-2-spot-from-firefox">number 2 spot from Firefox</a> very soon. I must admit, I&#8217;m not too bothered about who&#8217;s in second place; as long as all browser vendors keep improving their products I&#8217;m a very happy developer. More competition equals better browsers for all. When one of the &#8216;good&#8217; browsers gets to number one, then I will celebrate.</p>
<p>At the start of October Google unveiled their new <a href="http://googlesystem.blogspot.com/2011/10/dart-googles-programming-language-for.html">Dart programming language</a> which is supposed to replace JavaScript as the working language on open web platforms. Dart will compile to ECMAScript 3 on the fly for non-Dart compatible browsers. There&#8217;s even a <a href="http://www.dartlang.org/docs/getting-started/index.html">simple IDE</a> so you can start playing around with a bit of Dart right now. Will it catch on? Who knows, only time will tell.</p>
<p>Last but not least the browser that everyone forgets about (but it&#8217;s actually an excellent browser), Opera. At the start of October they <a href="http://my.opera.com/desktopteam/blog/2011/10/13/introducing-opera-12-alpha">released Opera 12 alpha</a>, which finally supports WebGL! Great news for Opera and WebGL. As it looks like WebGL is here to stay, maybe it&#8217;s time the IE team reconsidered its position? Let&#8217;s hope they do.</p>
<div id="attachment_1911" class="wp-caption alignnone" style="width: 528px"><img src="http://nooshu.com/wp-content/uploads/2011/11/chrome-firefox-stats-518x303.jpg" alt="Chrome is about to replace Firefox at the number 2 spot." title="chrome-firefox-stats" width="518" height="303" class="size-medium wp-image-1911" /><p class="wp-caption-text">Will Chrome overtake Firefox for browser market share in November?</p></div>
<h3>JavaScript</h3>
<p>The big event (in Europe at least) that happened while I was away was <a href="http://jsconf.eu/2011/">JSConf.eu</a>, a 2 day conference dedicated to the JavaScript programming language. This year it was held in Berlin, Germany, somewhere I&#8217;ve never been (but have heard many great things about). I wish I could have been there, a couple of the talks I&#8217;d loved to have seen include &#8220;<a href="http://jsconf.eu/2011/magic_wand_for_surface_generat.html">Magic Wand for surface generation &#8211; Voxels with JS</a>&#8221; and &#8220;<a href="http://jsconf.eu/2011/connecting_the_real_world_to_n.html">Connecting the real world to node</a>&#8220;. Luckily for those of us who couldn&#8217;t be there videos of most of the talks are available <a href="http://blip.tv/jsconfeu">online</a>.</p>
<p>Talking of <a href="http://nodejs.org">Node</a>, the development team has been bug fixing and adding lots of lovely new features to the code base, and it is now up to <a href="https://github.com/joyent/node/wiki/ChangeLog">version 0.6.0</a>. A point that really caught my attention was the work regarding Windows support. Being a Windows user myself it&#8217;s always nice to know the Windows platform is being considered in future development. Looking at the performance statistics in the <a href="http://blog.nodejs.org/2011/11/05/node-v0-6-0/">0.6.0 blog post</a>, the team have made huge improvements by supporting native APIs (rather than through Cygwin).</p>
<p><strong>Note</strong>: As I was writing this blog post <a href="http://blog.nodejs.org/2011/11/11/node-v0-6-1/">Node 0.6.1 was released</a> and it now comes with a Windows installer (MSI).</p>
<div id="attachment_1913" class="wp-caption alignnone" style="width: 528px"><a href="http://jsconf.eu/2011/"><img src="http://nooshu.com/wp-content/uploads/2011/11/JSConf.eu-2011-518x146.png" alt="JSConf.eu took place in Berlin in 2011" title="JSConf.eu - 2011" width="518" height="146" class="size-medium wp-image-1913" /></a><p class="wp-caption-text">Lots of lovely JavaScript geeking out at this years JSConf.eu.</p></div>
<h3>jQuery</h3>
<p>For users of jQuery (myself included) it&#8217;s been a very busy three months. There have been three new versions released (not including betas and RC&#8217;s), <a href="http://blog.jquery.com/2011/09/01/jquery-1-6-3-released/">1.6.3</a>, <a href="http://blog.jquery.com/2011/09/12/jquery-1-6-4-released/">1.6.4</a> and <a href="http://blog.jquery.com/2011/11/03/jquery-1-7-released/">1.7</a>. Here are some of the key features that caught my eye in each version:</p>
<ul>
<li><strong>1.6.3</strong>: requestAnimationFrame API has been removed for animations due to strange goings on when animated tabs are hidden from view. The team plans to re-implement it in a later version.</li>
<li><strong>1.6.4</strong>: Minor bug fix release.</li>
<li><strong>1.7</strong>: Big changes in the way events are bound (and unbound) to elements. There&#8217;s a whole new .on(), .off() event API which aims to unify all the ways of attaching events in jQuery. Also, as mentioned on the jQuery blog they are shorter to type!</li>
</ul>
<p>For version 1.8 the jQuery team is planning on <a href="http://blog.jquery.com/2011/11/08/building-a-slimmer-jquery/">slimming down the library</a> to reduce it&#8217;s overall gzipped file size. They are asking for feedback from the community as to what should be removed and offloaded into a separate plug-in, or maybe even removed all together. There are now <a href="http://api.jquery.com/category/version/1.7/">so many methods available</a> to a developer, a lot of which are probably never used; I can see why they are looking to slim it down. Maintaining rarely used code is never fun. </p>
<p>I personally would like to see the animations offloaded to a separate plug-in, as for most projects I never use them. I&#8217;d happily add the animation plug-in back in if and when needed. Maybe this could be the start of a more modular version of jQuery; by that I mean something along the lines of the <a href="http://mootools.net/core/">MooTools core builder</a>. Creating a custom jQuery build, with only the parts you need really would be a great option. I&#8217;m sure lots of other jQuery developers would be against it, but each to their own.</p>
<p>Last in the jQuery news is the announcement that there will be a <a href="http://blog.jquery.com/2011/11/01/jquery-conference-2012-united-kingdom-announced/">jQuery conference in Oxford</a>, UK in 2012. It&#8217;s the first jQuery conference in the UK, and of course I&#8217;m now in Australia. Typical! Oh well, maybe next time.</p>
<div id="attachment_1916" class="wp-caption alignnone" style="width: 528px"><a href="http://events.jquery.org/2012/uk/"><img src="http://nooshu.com/wp-content/uploads/2011/11/jQuery-UK-Conference-Oxford-2012-518x208.png" alt="jQuery confrence in the UK in 2012." title="jQuery UK Conference   Oxford 2012" width="518" height="208" class="size-medium wp-image-1916" /></a><p class="wp-caption-text">The first jQuery conference in the UK while I&#039;m in Australia. Damn! </p></div>
<h3>Three.js</h3>
<p>The three.js community has been busy beavering away with lots of <a href="http://www.reddit.com/r/three.js/">cool new demos</a>. It&#8217;s incredible how this superb JavaScript library has taken off since mr.doob unleashed it on the web. </p>
<p>I&#8217;ve noticed from the <a href="https://github.com/mrdoob/three.js/">Git repository for three.js</a> that the number of updates has really slowed down. Maybe there are things in the pipe line that have yet to be rolled into the Git repository; or maybe it&#8217;s a sign of the three.js API stabilising.</p>
<p>One of the major problems I found while working on a few personal projects was the lack of documentation. It really was a case of diving into the library and examples and having a play (fun, but not ideal). Stability will allow the documentation to catch up with the current release, and in turn allow the wider community to develop lots more interesting 3D demos.</p>
<p>Speaking of interesting demos, here&#8217;s one that&#8217;s been released by HelloEnjoy called <a href="http://lights.elliegoulding.com/">Lights &#8211; An interactive music experience</a>. I can&#8217;t say I&#8217;ve heard of Ellie Goulding (I know, I&#8217;m old), but it&#8217;s a catchy tune and kudos to her record company for pushing the music video envelope. Is interactivity the future of music videos? I hope so!</p>
<div id="attachment_1901" class="wp-caption alignnone" style="width: 528px"><a href="http://lights.elliegoulding.com/"><img src="http://nooshu.com/wp-content/uploads/2011/11/lights-518x247.jpg" alt="Lights by Ellie Goulding, lovely interactive music video" title="lights" width="518" height="247" class="size-medium wp-image-1901" /></a><p class="wp-caption-text">Music video using the power of three.js.</p></div>
<h3>Demos</h3>
<p>One thing I really missed while I was away was how all this new technology is being applied on the web. It&#8217;s always interesting to see how other developers apply technology to problems they encounter. Creating demos is a fun way to learn something new.</p>
<p>First on the list is a bit of <a href="http://wesbos.com/html5-video-face-detection-canvas-javascript/">face detection using HTML5 and JavaScript</a>. This technique is used in various webcam applications, where you can add things like glasses and masks to your face in real-time. Hours of fun for kids (and developers too). The demo makes use of the <a href="https://github.com/liuliu/ccv">CCV JavaScript Face Detection library</a> and HTML5 canvas element. Awesome stuff by <a href="http://twitter.com/wesbos">@wesbos</a>, and as a bonus there&#8217;s a whole blog post with commented code on how he did it.</p>
<p>What do you get when you combine <a href="http://googleblog.blogspot.com/2011/10/step-inside-map-with-google-mapsgl.html">Google maps and WebGL</a>? That&#8217;s right, you get MapsGL! Google has enabled the option to view its maps complete with 3D buildings, in the browser, no plug-ins required! Superb news for WebGL as there is no bigger name you want behind you to push the technology into the mainstream. It&#8217;s still a little rough around the edges but it looks very promising! You can enable and view a demo <a href="http://maps.google.com/mapsgl">here</a>.</p>
<p>Mozilla developer Michael Bebenita has created and released a JavaScript-based H.264 decoder that will run natively in the browser&#8230; wow! Nicknamed <a href="https://github.com/mbebenita/Broadway">Broadway</a>, it is based on the open-source decoder that Google uses in the Android OS. Yet another example of how powerful the JavaScript programming language is. To test it you will need a nightly version of Firefox, or you can always <a href="http://yfrog.com/nmng0z">view a video</a> from Brendan Eich&#8217;s talk at ACM’s annual OOPSLA conference, where he shows it in action. Amazing!</p>
<p>Do you want to help a computer beat a Grandmaster at chess using JavaScript? Well now you can thanks to the <a href="http://chessathome.org/">Chess@home project</a>. Developers at <a href="http://joshfire.com/">Joshfire</a> created a project prototype at this years 48 hour Node Knockout contest. It utilises lots of cutting edge technologies. Starting with the Web Workers API in the browser, to Socket.io for communication and a Node.js &#8211; MongoDB combination for storing the results. It works by using the spare CPU cycles of browsing users to calculate the best next move. By adding a small Chess@home widget to your website you can help the project defeat a Grandmaster. By making use of the Web Worker API, visitors to your website won&#8217;t even notice the difference (users can disable the widget via a check box if they so wish).</p>
<div id="attachment_1925" class="wp-caption alignnone" style="width: 528px"><img src="http://nooshu.com/wp-content/uploads/2011/11/westminster-518x155.jpg" alt="Combining Google Maps and WebGL" title="westminster" width="518" height="155" class="size-medium wp-image-1925" /><p class="wp-caption-text">Google maps goes 3D with MapsGL - Virtual Westminster Abbey</p></div>
<p>As you can see the Web Development community has been busy over the past few months! Hopefully I picked out most of the important changes. If you think there&#8217;s anything I&#8217;ve missed that&#8217;s a worthy addition, please leave a comment, I&#8217;d love to hear about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/back-to-my-desk-down-under/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>There ain&#8217;t no party like a DemoJS party</title>
		<link>http://nooshu.com/there-aint-no-party-like-a-demojs-party?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=there-aint-no-party-like-a-demojs-party</link>
		<comments>http://nooshu.com/there-aint-no-party-like-a-demojs-party#comments</comments>
		<pubDate>Wed, 06 Jul 2011 10:15:00 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1762</guid>
		<description><![CDATA[What can be more fun than some cutting edge web technology and a bunch of people who love to create interesting demos!]]></description>
			<content:encoded><![CDATA[<p>Another day, another website that makes my jaw drop to my desk. This time it&#8217;s the results from the latest <a href="http://demojs.org/" title="JavaScript fun!">Mozilla Labs DemoJS</a> party. Hosted in Paris, France over the weekend, it had many coders and artists attending hoping to win big prizes by creating interesting demo&#8217;s using the latest web technologies. I may not understand French but I&#8217;d have still attended just to see all the demos on show; some extremely inspiring coding going on.</p>
<p>The competition was split into two sections; 1k and freestyle. I find both interesting but as I&#8217;ve mentioned before in <a href="http://nooshu.com/1kjs-smaller-is-better" title="JS1k: Smaller is Better!">previous blog posts</a> I&#8217;m always amazed at what can be done with 1k of code.</p>
<p><iframe width="518" height="418" src="http://www.youtube.com/embed/B24bLKWIy-o?rel=0" frameborder="0" allowfullscreen></iframe></p>
<p>The video above is of a demo created by <a href="http://www.silexars.com/">Silexars</a> that came in second place. A live demo can be viewed <a href="http://demojs.org/2011/releases/1K/online/Silexars_-_Creation">here</a>. All created with less than 1k of code! WebGL really is starting to come of age. As with any of these demo&#8217;s it&#8217;s so easy to copy / paste, modify and learn from them. View source is a wonderful tool. </p>
<p>Another demo that caught my eye was by <a href="http://www.p01.org">p01</a> (who I&#8217;ve blogged about <a href="http://nooshu.com/p01-org-amazing-experiments-using-javascript" title="p01.org: Amazing Experiments using JavaScript">before</a>). This time he created <a href="http://www.p01.org/releases/gl1k_cotton_candy/">Quaternion Julia Fractal</a> in only 550 bytes of JavaScript and GLSL! It came in third place.</p>
<div id="attachment_1764" class="wp-caption alignnone" style="width: 528px"><a href="http://www.p01.org/releases/gl1k_cotton_candy/1k.htm"><img src="http://nooshu.com/wp-content/uploads/2011/07/p01-julia-518x294.jpg" alt="Quaternion Julia Fractal by p01" title="p01-julia" width="518" height="294" class="size-medium wp-image-1764" /></a><p class="wp-caption-text">All this possible in less that 1k of code.</p></div>
<p>From the freestyle section the <a href="http://demojs.org/2011/releases/Freestyle/online/basecode_-_Particles.js">Particles.js</a> by basecode has completely killed my productivity today! </p>
<p>Nice work guys and gals! If you have a spare few minutes (hours) check out the rest of the <a href="http://demojs.org/" title="JavaScript fun!">DemoJS</a> results, you won&#8217;t be disappointed.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/there-aint-no-party-like-a-demojs-party/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A little bit of MicroJS</title>
		<link>http://nooshu.com/a-little-bit-of-microjs?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-little-bit-of-microjs</link>
		<comments>http://nooshu.com/a-little-bit-of-microjs#comments</comments>
		<pubDate>Sun, 29 May 2011 18:12:10 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Interesting]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Vanilla JavaScript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[small]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1732</guid>
		<description><![CDATA[For some projects you may not need a fully featured JavaScript library. But what are the alternatives?]]></description>
			<content:encoded><![CDATA[<p>Recently there was a flurry of talk around a little something called MicroJS, mainly thanks to a website of the same name created by <a href="http://mir.aculo.us/">Thomas Fuchs</a>, author of the <a href="http://script.aculo.us/">script.aculo.us</a> user interface library. I&#8217;m not sure if Thomas coined the term &#8220;MicroJS&#8221; or if it&#8217;s been in use for a while, but it describes the micro-framework methodology perfectly. So what is a micro-framework? The best way to answer that is to first ask what is a JavaScript framework?</p>
<p>JavaScript frameworks have been around since around 2005 (looking at the Prototype and jQuery history); their purpose is to allow developers to easily add interactivity to a page by creating a JavaScript abstraction layer to build from. The library takes care of any cross browser issues and quirks, allowing developers to focus on the &#8220;cool&#8221; stuff, building websites. As a developer I can&#8217;t thank all the library authors enough; without them my working life would be so much more stressful (and my hair would be even grayer than it is now!).</p>
<p>Once you know what a JavaScript framework is, it doesn&#8217;t take a genius to guess what a micro-framework is. Where as a full framework will have many tools (methods) a developer can use, a micro-framework only focuses on a very specific set of functions. I like the knife analogy: a full-framework like Dojo would be a Swiss Army knife where as a micro-framework could be considered a small pen knife. So which do you use in a project? This completely depends on the project in hand. I&#8217;ve put together a small list of pros and cons for each (let me know if you have any others):</p>
<h3>Full Framework</h3>
<ul>
<li><strong>Pros</strong></li>
<li>Extensive set of features to cater for most eventualities.</li>
<li>Consistent API across features.</li>
<li>Large user base with lots of community support.</li>
<li>Huge number of working examples available.</li>
<li>Many developers to fix bugs and add additional functionality.</li>
<li>Single point of reference of documentation.</li>
</ul>
<ul>
<li><strong>Cons</strong></li>
<li>Large code base could be very daunting to new users.</li>
<li>Large page footprint.</li>
<li>Many features of the library may not be needed.</li>
</ul>
<h3>Micro-Framework</h3>
<ul>
<li><strong>Pros</strong></li>
<li>Small page weight, usually less than 5K.</li>
<li>Small set of features so very quick to pick up and use.</li>
<li>Main focus on a very specific set of functionality.</li>
<li>No feature creep or excess code.</li>
<li>Use the right tool for the right job.</li>
</ul>
<ul>
<li><strong>Cons</strong></li>
<li>Small number of developers, bugs and issues may take a while to be fixed.</li>
<li>Development of the framework may stop completely.</li>
<li>May be very little support from the author and the community.</li>
<li>Fellow developers in your team may not be familiar with the framework.</li>
<li>Mixing micro-frameworks could conflict if badly coded.</li>
<li>Multiple frameworks could mean multiple HTTP requests.</li>
<li>Multiple points of reference for API docs.</li>
<li>Multiple frameworks could lead to an overlap in functionality.</li>
</ul>
<p>Many of the cons for micro-frameworks stem from using more than one at a time, but if you only plan on using one then they can be ignored.</p>
<p>Micro-frameworks caught my eye recently due to a couple of small projects I&#8217;d been working on. The projects all used vanilla JavaScript as there was no need for a helper library. I later realised I needed to attach a few events and manipulate the DOM but I wanted to avoid including jQuery in the project as I only needed a small fraction of its functionality. Luckily the MicroJS website came to the rescue.</p>
<p>The examples below are taken from <a href="https://github.com/ded/qwery">Query</a>, <a href="https://github.com/ded/bonzo">Bonzo</a>, <a href="https://github.com/kbjr/Events.js">Events.js</a> and <a href="https://github.com/fat/bean">Bean</a>. As you can see the usage for each is pretty self-explanatory with lots more functionality is available from each library&#8217;s website. If you&#8217;re a jQuery user the syntax will look <a href="http://www.dustindiaz.com/qwery">very familiar</a>.</p>
<p><strong>CSS selector and DOM utility</strong></p>
<div class="codecolorer-container javascript default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">/*<br />
Query - Dustin Diaz<br />
https://github.com/ded/qwery<br />
CSS selector engine<br />
*/</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#myid&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.myclass&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#myid .myclass div a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a, div, strong&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">/*<br />
Query Paired with Bonzo - Dustin Diaz<br />
https://github.com/ded/bonzo<br />
DOM utility<br />
*/</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#myid&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.myclass&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">offset</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#myid .myclass div a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;anchorClass&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
query<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a, div, strong&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p><strong>Events</strong></p>
<div class="codecolorer-container javascript default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">/*<br />
Events.js - James Brumond<br />
https://github.com/kbjr/Events.js<br />
Event handler library<br />
*/</span><br />
Events.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>window<span style="color: #339933;">,</span> <span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Page loaded, do something</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">//Invoke the page load event</span><br />
Events.<span style="color: #660066;">invoke</span><span style="color: #009900;">&#40;</span>window<span style="color: #339933;">,</span> <span style="color: #3366CC;">'load'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">//Mouse click event</span><br />
Events.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>selectedElements<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Mouse has been clicked</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">//Very handy keystroke event</span><br />
Events.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>document<span style="color: #339933;">,</span> <span style="color: #3366CC;">'keystroke.Ctrl+Shift+Alt+S'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; saveMySlices<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">/*<br />
Bean - Dustin Diaz<br />
https://github.com/fat/bean<br />
Event handler library<br />
*/</span><br />
bean.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>selectedElements<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Mouse has been clicked</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">//DOM has loaded</span><br />
bean.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>document<span style="color: #339933;">,</span> <span style="color: #3366CC;">'DOMContentLoaded'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Page loaded, do something</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">//Invoke an event on an element</span><br />
bean.<span style="color: #660066;">fire</span><span style="color: #009900;">&#40;</span>selectedElement<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #006600; font-style: italic;">//Remove the event from an element</span><br />
bean.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span>selectedElement<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>I&#8217;ll be trying out a few more of these micro-frameworks for my personal projects in the future as the ability to select only the functionality you need really appeals to me. Are there any other micro-frameworks you&#8217;ve used that you&#8217;d recommend? Leave me a comment and I&#8217;ll check them out.</p>
<p><strong>Update</strong>: It just so happens that a handy library website has emerged inspired by the MicroJS website called <a href="http://www.everyjs.com/">EveryJS</a>. The website lists all library&#8217;s rather than just micro versions. Not all are listed but I&#8217;m sure they will be added soon so it&#8217;s one to keep your eye on.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/a-little-bit-of-microjs/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chrome Developer Tools at Google IO 2011</title>
		<link>http://nooshu.com/chrome-developer-tools-at-google-io-2011?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=chrome-developer-tools-at-google-io-2011</link>
		<comments>http://nooshu.com/chrome-developer-tools-at-google-io-2011#comments</comments>
		<pubDate>Wed, 18 May 2011 10:31:05 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1707</guid>
		<description><![CDATA[As a long time user of Firebug for Firefox, Google Chrome's Developer Tools are making me think about changing my debug tool!]]></description>
			<content:encoded><![CDATA[<p><iframe width="518" height="325" src="http://www.youtube.com/embed/N8SS-rUEZPg?rel=0&amp;hd=1&amp;modestbranding=1" frameborder="0" allowfullscreen></iframe></p>
<p>I&#8217;ve been a long time user of Firefox&#8217;s magnificent <a href="http://getfirebug.com/">Firebug extension</a>; I honestly cannot remember how I used to develop websites without it (can you?). Changing web pages on the fly and debugging issues in seconds rather than minutes, we really are spoiled. I thought it would be hard for any other debugging tool to come close to Firebug in terms of ease of use and available tool set. Oh how I was wrong!</p>
<p>Paul Irish and Pavel Feldman hosted a talk at this years Google I/O about Chrome Dev Tools and what&#8217;s new in the world of debugging in Chrome. I must admit, there were a number of jaw dropping moments in the video where it dawned on me how powerful the tools actually are. Here are a few of my favourite points:</p>
<ul>
<li><a href="http://www.youtube.com/watch?v=N8SS-rUEZPg&#038;feature=player_embedded#t=431s">7:11</a>: Chrome monitoring the changes to the style sheets and letting you know what has changed.</li>
<li><a href="http://www.youtube.com/watch?v=N8SS-rUEZPg&#038;feature=player_detailpage#t=475s">7:55</a>: Ability to revert back to different CSS versions. The Dev Tools automatically creates a new version as you change code.</li>
<li><a href="http://www.youtube.com/watch?v=N8SS-rUEZPg&#038;feature=player_detailpage#t=1262s">21:02</a>: A whole host of JavaScript debugging tools. Edit the script in the browser (with code colouring.. nice) rather than edit in IDE, upload, test, repeat&#8230;</li>
<li><a href="http://www.youtube.com/watch?v=N8SS-rUEZPg&#038;feature=player_detailpage#t=1831s">30:31</a>: My favourite part, the remote debugging feature. Chrome can act as a server meaning you can connect too and edit pages remotely. At first you may think &#8220;well, what&#8217;s the point?&#8221;. As this is being done at the WebKit level it will soon be available for all WebKit browsers including mobile devices. Debug mobiles browser directly from your desktop. Wow!</li>
</ul>
<p>I&#8217;m definitely going to have to wean myself off Firebug and give the Chrome Dev Tools a blast. As mentioned in the video, the tools are being developed all the time with new features landing daily (on dev channel). Looks like Firebug has some serious competition! If you&#8217;re a developer with 43 minutes to spare, watch the video, you won&#8217;t regret it.</p>
<p>A few helpful links mentioned in the video:</p>
<ul>
<li><a href="http://leaverou.me/css3patterns/">Lea Verous CSS3 pattern gallery</a></li>
<li><a href="http://code.google.com/chrome/devtools/docs/overview.html">Full documentation for Dev Tools</a></li>
<li><a href="http://goo.gl/IYNuQ">The slides &#8211; Chrome Dev Tools: Reloaded</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/chrome-developer-tools-at-google-io-2011/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Sieve of Eratosthenes</title>
		<link>http://nooshu.com/the-sieve-of-eratosthenes?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-sieve-of-eratosthenes</link>
		<comments>http://nooshu.com/the-sieve-of-eratosthenes#comments</comments>
		<pubDate>Thu, 12 May 2011 15:19:05 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Interesting]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[maths]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1670</guid>
		<description><![CDATA[Having fun with a little bit of prime hunting and JavaScript. Maths geek for the win!]]></description>
			<content:encoded><![CDATA[<p>I recently read <a href="http://www.amazon.co.uk/Prime-Obsession-Bernhard-Greatest-Mathematics/dp/0452285259">Prime Obsession by John Derbyshire</a>; a book all about prime numbers and one of the worlds greatest Mathematicians: <a href="http://en.wikipedia.org/wiki/Bernhard_Riemann">Bernhard Riemann</a>. The books main focus is on the <a href="http://en.wikipedia.org/wiki/Riemann_hypothesis">Riemann Hypothesis</a> which states that:</p>
<blockquote><p>The real part of any non-trivial zero of the Riemann zeta function is 1/2.</p></blockquote>
<p>I&#8217;d love to say that after reading the book I understand the Maths behind it but alas I do not. That&#8217;s not surprising though as it&#8217;s a problem that has yet to be solved, 159 years after Riemann paper on &#8220;On the Number of Primes Less Than a Given Magnitude&#8221;. It doesn&#8217;t look like it&#8217;s going to be solved any time soon either! If you&#8217;re interested it&#8217;s one of the Clay Mathematics Institutes <a href="http://en.wikipedia.org/wiki/Millennium_Prize_Problems">Millennium Prize Problems</a> in which you can earn yourself US$1,000,000.</p>
<p>While reading Prime Obsession it mentioned an interesting method for finding prime numbers called &#8220;Sieve of Eratosthenes&#8221; (pronounced air-a-TAWS-the-nEEss). Eratosthenes was a librarian at the great library of Alexandria around 230 B.C.E. It&#8217;s quite obvious how the method works once you know it, and easy to see why it&#8217;s called a sieve. The method goes like this:</p>
<ol>
<li>Write a list of numbers in which you wish to identify the primes, say 2 &#8211; 100 (exclude 1 as it isn&#8217;t required)</li>
<li>Take the first number 2. Leaving 2 intact, remove every second number.</li>
<li>Move onto the next number 3. Leave 3 intact and remove every third number</li>
<li>Take the next number 5. Leave 5 intact and take away every fifth number</li>
<li>Repeat until you get to the end of your list</li>
</ol>
<p>The end result is the set of prime numbers up to your given number. Essentially all you are doing is removing any number that is divisible by the 1st, 2nd&#8230; Nth number. Clever stuff!</p>
<p>As a little side project I decided to implement this method using JavaScript, displaying the result in the browser. You can view the <a href="http://dl.dropbox.com/u/7851949/sieve/index.html">demo here</a>. For fun I created two implementations, one relying heavily on the DOM, the other only using arrays. As you&#8217;d expect the DOM method is slow; looping through large tables multiple times doesn&#8217;t make for a quick execution time. The second method using a single JavaScript array is much quicker. I&#8217;ve added a stats panel to the right hand side of the page so it&#8217;s possible to compare results from both methods over different input values.</p>
<p>I&#8217;ve added a limit to the number you can enter into the input box (5000), I don&#8217;t want anyone blaming me for crashing their browser by entering 10 million! :) Feel free to copy the demo if you want to see what happens at higher values.</p>
<div id="attachment_1672" class="wp-caption alignnone" style="width: 528px"><a href="http://nooshu.com/wp-content/uploads/2011/05/sieve.gif"><img src="http://nooshu.com/wp-content/uploads/2011/05/sieve-518x255.gif" alt="Sieve of Eratosthenes using JavaScript" title="sieve" width="518" height="255" class="size-medium wp-image-1672" /></a><p class="wp-caption-text">The sieve in action showing prime numbers up to 500.</p></div>
<p>Thanks goes to John Resig for his very handy <a href="http://ejohn.org/blog/javascript-array-remove/">Array Remove method</a>.It made removing non-primes from the numbers array very simple indeed.</p>
<p>Prime Obsession is a superb book but a word of warning, it contains a lot of higher level Mathematics, so may not be to everyone&#8217;s taste. It certainly made my brain hurt at times; not always what you need on that 8am commute to work! <a href="http://dl.dropbox.com/u/7851949/sieve/index.html">View the demo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/the-sieve-of-eratosthenes/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

