<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Claus Witt dot Com</title><link>http://clauswitt.com/</link><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ClausWitt" /><language>en</language><managingEditor>noemail@noemail.org (Claus Witt)</managingEditor><lastBuildDate>Tue, 07 May 2013 12:32:35 PDT</lastBuildDate><generator>Octopress http://octopress.org/</generator><feedburner:info uri="clauswitt" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><description>The awesome blog posts of Claus Witt, burned and fed</description><item><title>Fighting Procrastination by Changing Hosts-file with Cron</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/_-5ehv00BnE/fighting-procrastination-by-changing-hosts-file-with-cron.html</link><pubDate>Mon, 18 Mar 2013 12:30:00 PDT</pubDate><guid isPermaLink="false">http://clauswitt.com/fighting-procrastination-by-changing-hosts-file-with-cron</guid><description>&lt;p&gt;Recently &lt;a href="http://sirupsen.com"&gt;Simon Hørup Eskildsen&lt;/a&gt; posted a tweet or two about his new hostfile setup. The tweets were following by him posting &lt;a href="https://gist.github.com/Sirupsen/5150994"&gt;his hosts-file as a gist&lt;/a&gt;. At work &lt;a href="http://jesperrasmussen.com"&gt;Jesper Rasmussen&lt;/a&gt; took the idea and solved it a bit smarter - so that you can have your pie and eat it too. (You can have host-file mappings, without the need to maintain them in two files).&lt;/p&gt;

&lt;p&gt;The solution is quite simple. You have your regular hosts file, containing the usual mapping of domains to (quite possibly) localhost. Then you have one hosts file containing all the remapping of services, that you need to abstain yourself from using. Two small scripts either copy the original hosts file, and concats the focus files to them, or just symlinks the original hosts file. This way, any changes to the hosts file is always included.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;The idea in both Simons and Jespers approach is to have cron switch the hosts files at apropriate times, to ensure that you cannot procrastinate, when you should be working.&lt;/p&gt;

&lt;p&gt;My own solution consists of not two, but three hosts files. And a crontab with a lot of entries. The idea is to have a five minute window every half hour where you can procrastinate all you want, and 25 minutes of uninteruptable focus-work. You might recognize this from the &lt;a href="http://www.pomodorotechnique.com"&gt;Pomodoro Technique&lt;/a&gt;. On top of that there a rule setup so that I can only use my webmail clients half an hour four times a day (at 10, at 13 at 16 and at 21) - in these periods there are no procrastination-allowance - the pomodoro break should be used to get away from the desk!&lt;/p&gt;

&lt;p&gt;My cron looks like this:&lt;/p&gt;

&lt;div&gt;&lt;script src='https://gist.github.com/5186114.js?file='&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;pre&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/noscript&gt;&lt;/div&gt;


&lt;p&gt;And my hosts.focus looks like this:&lt;/p&gt;

&lt;div&gt;&lt;script src='https://gist.github.com/5186116.js?file='&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;pre&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/noscript&gt;&lt;/div&gt;


&lt;p&gt;And finally my hosts.email looks like this:&lt;/p&gt;

&lt;div&gt;&lt;script src='https://gist.github.com/5186120.js?file='&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;pre&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/noscript&gt;&lt;/div&gt;


&lt;p&gt;The scripts called in the crontab can be found (alongside everything else here) &lt;a href="https://github.com/clauswitt/dotfiles/tree/master/hostfiles"&gt;in my dotfiles&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/_-5ehv00BnE" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/fighting-procrastination-by-changing-hosts-file-with-cron.html</feedburner:origLink></item><item><title>Tmux Helper for Copying Settings</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/7y5hilWRa2k/tmux-helper-for-copying-settings.html</link><pubDate>Mon, 28 Jan 2013 13:40:00 PST</pubDate><guid isPermaLink="false">http://clauswitt.com/tmux-helper-for-copying-settings</guid><description>&lt;p&gt;Usually when I code, I use only terminal tools. This usually means that each project has its own tmux-session and that I use vim as my editor there. I manage my projects with tmuxinator, and have previously blogged about how I use &lt;a href="http://clauswitt.com/tmuxinator-zsh-completion.html"&gt;little mapping in zsh to get autocomletion for projects&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The only problem with this setup, is that I very often start new small projects, and I never create the tmuxinator configuration first. This means that I open a new tmux session manually, and change the title, and manually add windows as needed. At some point though, if the project is a keeper, I would like the setup in tmuxinator as well.&lt;/p&gt;

&lt;p&gt;Turns out, this is not easy. In an ideal world, I just want each window created with current dir, and a command. However you cannot (or rather, I cannot) get the current dir for each window. You can get the initial directory of the session, thats it. And you can get the window names, and a initial command of each pane. However since all my windows are created manually, all initial commands are just zsh, not very helpful.&lt;/p&gt;

&lt;p&gt;I decided to write a little tool to do most of the work.&lt;/p&gt;

&lt;script src="https://gist.github.com/clauswitt/5038107.js"&gt;&lt;/script&gt;


&lt;p&gt;This tool will take a tmux session, and save it as a yaml file in tmuxinators configration directory - and include all windows. I then manually have to make sure all directories are correct, and that the correct initial command is correct for each window. But it&amp;#8217;s still better than doing it all from scratch.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/7y5hilWRa2k" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/tmux-helper-for-copying-settings.html</feedburner:origLink></item><item><title>New Stuff in my Dotfiles</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/M9tZd5tEtzQ/new-stuff-in-my-dotfiles.html</link><pubDate>Mon, 28 Jan 2013 13:40:00 PST</pubDate><guid isPermaLink="false">http://clauswitt.com/new-stuff-in-my-dotfiles</guid><description>&lt;p&gt;There has been many many &lt;a href="https://github.com/clauswitt/dotfiles/commits/master"&gt;changes to my dotfiles repo&lt;/a&gt; today. Most of the updates has been related to my vim settings and plugins.&lt;/p&gt;

&lt;p&gt;I have installed a couple of new plugins:&lt;/p&gt;

&lt;h2&gt;UltiSnips&lt;/h2&gt;

&lt;p&gt;I hated SnipMate. I hated it so much, that I never used it (on purpose anyway). But since it was installed, sometimes a snippet expanded when I did not want it. I hated it!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/SirVer/ultisnips"&gt;UltiSnips&lt;/a&gt; is the answer to my snippet prayers in vim. The provided default snippets are good, and it has been made easy to make new snippets. Just call the method UltiSnipsEdit and it opens a snippet file mathcing the filetype of your current file, and then (of course) there is a snippet (called snip) to create a new snippet.&lt;/p&gt;

&lt;p&gt;One very nice thing with UltiSnips is that you can define a snippet to only be used in the beginning of a line, and thus let the normal autocomplete take over on the rest of the line. (I find this very useful)&lt;/p&gt;

&lt;h2&gt;EasyMotion&lt;/h2&gt;

&lt;p&gt;Sometimes navigating with motions in vim is a bit complex. Easymotion helps with that. With easymotion you can do a more advanced version of a simple motion. If you do a simple motion (w,b,f,t and so forth) prefixed with Leader Leader - you will get up to 26 marks that you can jump to. &lt;a href="https://github.com/Lokaltog/vim-easymotion"&gt;Check out the github page for a better explanation&lt;/a&gt; - or even better, try the plugin out.&lt;/p&gt;

&lt;h2&gt;Ruby Refactoring&lt;/h2&gt;

&lt;p&gt;I have seen several of &lt;a href="http://blog.extracheese.org"&gt;Gary Bernhardt&lt;/a&gt;s screencasts at &lt;a href="http://www.destroyallsoftware.com"&gt;http://www.destroyallsoftware.com&lt;/a&gt; the last couple of days. And one of the things I kept thinking he did very very fast in vim was a refactoring where he did inlining of a temporary variable. I found - what I think - he uses for that. And I love the mappings. &lt;a href="https://github.com/ecomba/vim-ruby-refactoring"&gt;Take a look here.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Command-T&lt;/h2&gt;

&lt;p&gt;I have had command-t installed once before - but never knew how much I was missing out, before I saw (yet again) Gary use it in a screencast, where he had several mappings for it, that made the plugin prefilter the output for a given path. Now it was suddenly much much more useful. Take a look at &lt;a href="https://www.destroyallsoftware.com/screencasts/catalog/file-navigation-in-vim"&gt;the screencast here&lt;/a&gt;, and see &lt;a href="https://www.destroyallsoftware.com/file-navigation-in-vim.html"&gt;the mappings he has published here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And I have removed a git plugin (had two installed, and Fugitive seems superior).&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/M9tZd5tEtzQ" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/new-stuff-in-my-dotfiles.html</feedburner:origLink></item><item><title>Testing Backbone Apps with Jasmine</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/trQu6MMMoAI/testing-backbone-apps-with-jasmine.html</link><pubDate>Sun, 02 Dec 2012 02:09:00 PST</pubDate><guid isPermaLink="false">http://clauswitt.com/testing-backbone-apps-with-jasmine</guid><description>&lt;p&gt;At &lt;a href="http://www.arnsbomedia.com/"&gt;Arnsbo Media&lt;/a&gt; we write more and more &lt;a href="http://backbonejs.org"&gt;backbone&lt;/a&gt; based frontend applications for &lt;a href="http://www.voicearchive.com"&gt;various&lt;/a&gt; &lt;a href="http://www.arnsbopropertymedia.com"&gt;parts&lt;/a&gt; of our business. Lately we (or at least I) have become more and more obsessed with test driven development, and we have a need for doing even more testing of our frontend applications.&lt;/p&gt;

&lt;h2&gt;What to test&lt;/h2&gt;

&lt;p&gt;The biggest problem with people who take a deep dive into test driven development is, in my opinion, that they use too much effort on testing obvious working stuff, and to little on testing their brittle assumptions. In other words, they tend to test that a framework method does as documented, instead of focusing on your own code.&lt;/p&gt;

&lt;h2&gt;What not to test&lt;/h2&gt;

&lt;p&gt;In backbone, don&amp;#8217;t test default operations of the classes. Dont test that if your set the url of a collection, and call fetch, that the url will get a GET-request. However if you override the url-function, or the fetch function - that should be tested. Don&amp;#8217;t test that a model.set saves data, and that model.get can retrieve it again. However do test changes to the parse function. In the same vein do not test that a view contains this.el and this.collection when el and collection are sent through the constructor. But do test that your special rendering loop gets executed as you expect, and test that your events are triggered correctly when the view is attached to the dom, and that they are not tested when it is not attached.&lt;/p&gt;

&lt;h2&gt;How to test&lt;/h2&gt;

&lt;p&gt;We use &lt;a href="http://pivotal.github.com/jasmine/"&gt;jasmine&lt;/a&gt;. &lt;!--more--&gt; In most of our projects we also use requirejs and write most frontend code in coffeescript, and in our latest project we use yeoman as a build tool. In this project we use &lt;a href="https://github.com/jasmine-contrib/grunt-jasmine-runner"&gt;grunt-jasmine-runner&lt;/a&gt; to handle the loading of jasmine tests, and running them through yeoman test. This runner runs the tests in a phantomjs instance, and gives us the result on the command line, instead of the need to start a browser, and running the tests there.&lt;/p&gt;

&lt;p&gt;First we add the grunt-jasmine-runner package as a npmTask in the gruntfile.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;grunt.loadNpmTasks('grunt-jasmine-runner');&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Then we configure it.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;span class='line-number'&gt;12&lt;/span&gt;
&lt;span class='line-number'&gt;13&lt;/span&gt;
&lt;span class='line-number'&gt;14&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;jasmine : {
&lt;/span&gt;&lt;span class='line'&gt;  amd: true,
&lt;/span&gt;&lt;span class='line'&gt;  specs : 'app/scripts/specs/**/*Spec.js',
&lt;/span&gt;&lt;span class='line'&gt;  helpers : [
&lt;/span&gt;&lt;span class='line'&gt;    //Place all dependencies here (jquery, backbone and all that)
&lt;/span&gt;&lt;span class='line'&gt;  ],
&lt;/span&gt;&lt;span class='line'&gt;  timeout : 10000,
&lt;/span&gt;&lt;span class='line'&gt;  junit : {
&lt;/span&gt;&lt;span class='line'&gt;    output : 'junit/'
&lt;/span&gt;&lt;span class='line'&gt;  },
&lt;/span&gt;&lt;span class='line'&gt;  phantomjs : {
&lt;/span&gt;&lt;span class='line'&gt;    'ignore-ssl-errors' : true
&lt;/span&gt;&lt;span class='line'&gt;  }
&lt;/span&gt;&lt;span class='line'&gt;},&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Finally we setup the test command to run coffee compiler and then all the tests.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;grunt.registerTask('test', 'coffee jasmine');&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;h2&gt;Jasmine tests using require.js and CoffeeScript&lt;/h2&gt;

&lt;p&gt;In my opinion jasmine tests are much more readable in coffeescript. And by having all parts of our application in amd modules, it is easy for us, to only load the part of the application a specific test needs.&lt;/p&gt;

&lt;p&gt;This is an actual test from one of our latest applications.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;span class='line-number'&gt;12&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;define ['helpers/RuntimeFactory'], (RuntimeFactory) -&amp;gt;
&lt;/span&gt;&lt;span class='line'&gt;  describe "Basic operations", -&amp;gt;
&lt;/span&gt;&lt;span class='line'&gt;    factory = new RuntimeFactory
&lt;/span&gt;&lt;span class='line'&gt;    it "returns the runtime instance", -&amp;gt;
&lt;/span&gt;&lt;span class='line'&gt;      require ['helpers/Registry/Runtime'], (runtime) -&amp;gt;
&lt;/span&gt;&lt;span class='line'&gt;        expect(factory.getRuntime()).toEqual(runtime)
&lt;/span&gt;&lt;span class='line'&gt;    it "has set the mainNavigationPanes value", -&amp;gt;
&lt;/span&gt;&lt;span class='line'&gt;      expect(factory.getRuntime().has('mainNavigationPanes')).toBeTruthy()
&lt;/span&gt;&lt;span class='line'&gt;    it "has set the appRouter", -&amp;gt;
&lt;/span&gt;&lt;span class='line'&gt;      expect(factory.getRuntime().has('appRouter')).toBeTruthy()
&lt;/span&gt;&lt;span class='line'&gt;    it "has set the approuter to an instance of Backbone router", -&amp;gt;
&lt;/span&gt;&lt;span class='line'&gt;      expect(factory.getRuntime().get('appRouter') instanceof Backbone.Router).toBeTruthy()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;The runtime factory module creates a runtime, and sets some default data on it. These tests are made to ensure that the runtime factory returns an instance of the correct module, and that the default values needed for our application to work has been set correctly.&lt;/p&gt;

&lt;p&gt;I have three posts about this topic comming in the comming weeks. You could call it my advent calendar. They are &amp;#8220;Testing Backbone Collections&amp;#8221;, &amp;#8220;Testing Backbone Models&amp;#8221;, and &amp;#8220;Testing Backbone Views&amp;#8221;.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/trQu6MMMoAI" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/testing-backbone-apps-with-jasmine.html</feedburner:origLink></item><item><title>High Performance Batch Processing in Javascript</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/G8YQMgeAhZI/high-performance-batch-processing-in-javascript.html</link><pubDate>Mon, 26 Nov 2012 01:03:00 PST</pubDate><guid isPermaLink="false">http://clauswitt.com/high-performance-batch-processing-in-javascript</guid><description>&lt;p&gt;One of my favourite books on Javascript Performance is &lt;a href="http://www.amazon.com/gp/product/059680279X/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=059680279X&amp;linkCode=as2&amp;tag=clawit-20"&gt;High Performance JavaScript (Build Faster Web Application Interfaces)&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=clawit-20&amp;l=as2&amp;o=1&amp;a=059680279X" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt; by &lt;a href="http://www.nczonline.net"&gt;Nicholas Zakas&lt;/a&gt;. The ideas in this post are influenced by that book. Read it!&lt;/p&gt;

&lt;p&gt;When doing expensive operations in javascript, it can block the UI from rendering. The reason behind this is that all code in the browser runs in one thread, and as a result, only one thing can happen at a time. There are several ways to circumvent this - one could be using &lt;a href="http://www.html5rocks.com/en/tutorials/workers/basics/"&gt;WebWorkers&lt;/a&gt;. Another way is to split the expensive task in to smaller chunks, and use setTimeout to ensure that the ui can be updated as well.&lt;/p&gt;

&lt;p&gt;How much you should batch together, and how long you should wait between batches depends on your use case. Both the amount of work to be done, and how dynamic your UI is (e.g. eventhandlers and animations) will influence how you solve this problem.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;I have created a small utility that can be used to batch operations together. I call it &lt;a href="https://github.com/clauswitt/ListProcessor.js"&gt;ListProcessor.js&lt;/a&gt;. The idea is that you create an instance of it, providing a list of input (an array). You may also decide on the timeout (defaults to 100 ms) and items per batch (default to 1).&lt;/p&gt;

&lt;p&gt;Per default the items in the array are shifted of (meaning it changes the original array), by setting the copyInsteadOfReference parameter to true, you can prevent that.&lt;/p&gt;

&lt;p&gt;When you are ready to process the list, you call run. Run takes two arguments, the processor (the function that receives each item, and does something to them), and a callback, that is called when run finishes.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;list = new ListProcessor([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], 1000, 3);
&lt;/span&gt;&lt;span class='line'&gt;list.run(function(item){console.log(item)}, function(){console.log('finished')});&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;This will do three console.log calls every second.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/G8YQMgeAhZI" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/high-performance-batch-processing-in-javascript.html</feedburner:origLink></item><item><title>Code Kata List</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/lz0TnhDhobU/code-kata-list.html</link><pubDate>Sun, 18 Nov 2012 13:12:00 PST</pubDate><guid isPermaLink="false">http://clauswitt.com/code-kata-list</guid><description>&lt;p&gt;In &lt;a href="http://www.amazon.com/gp/product/0137081073/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0137081073&amp;linkCode=as2&amp;tag=clawit-20"&gt;The Clean Coder: A Code of Conduct for Professional Programmers (Robert C. Martin Series)&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=clawit-20&amp;l=as2&amp;o=1&amp;a=0137081073" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt; &lt;a href="http://www.objectmentor.com/omTeam/martin_r.html"&gt;Uncle Bob&lt;/a&gt; writes about the importance of doing deliberate practice. One of his methods is to do a Code Kata in the beginning of the work day, and one at the end.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;I like this idea, and have decided to compile a list of code katas that can be used for this. The list is currently just links to the katas at their sources. Some of the Katas in this list are harder than others. Most are from the Ruby community. I encourage you to try several of them, and try them using different programming languages, different techniques and with different interfaces.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataBankOCR"&gt;Bank OCR&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataFizzBuzz"&gt;Fizz Buzz&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataPotter"&gt;Potter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataRomanCalculator"&gt;Roman Calculator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataArgs"&gt;Args&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataAnagram"&gt;Anagram&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataDepthFirstSearch"&gt;Depth First Search&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataNumberToLCD"&gt;Number to LCD&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataTennis"&gt;Tennis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataBowling"&gt;Bowling&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataTexasHoldEm"&gt;Texas Hold Em&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataPokerHands"&gt;Poker Hands&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataMinesweeper"&gt;Mine Sweeper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataReversi"&gt;Reversi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataGameOfLife"&gt;Game of Life&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataPacMan"&gt;Pacman&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataYahtzee"&gt;Yahtzee&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataDictionaryReplacer"&gt;Dictionary Replacer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataWordWrap"&gt;Word Wrap&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.splatbang.com/rubyquiz/quiz.rhtml?id=157_The_Smallest_Circle"&gt;Smallest Circle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.splatbang.com/rubyquiz/quiz.rhtml?id=159_Word_Search_Generator"&gt;Word Search Generator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.splatbang.com/rubyquiz/quiz.rhtml?id=161_Reverse_Divisible_Numbers"&gt;Reverse Divisable Numbers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.splatbang.com/rubyquiz/quiz.rhtml?id=164_Price_Ranges"&gt;Price Ranges&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.splatbang.com/rubyquiz/quiz.rhtml?id=165_Preferable_Pairs"&gt;Preferable Pairs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.splatbang.com/rubyquiz/quiz.rhtml?id=166_Circle_Drawing"&gt;Circle Drawing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.splatbang.com/rubyquiz/quiz.rhtml?id=171_hexdump"&gt;Hex Dump&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.splatbang.com/rubyquiz/quiz.rhtml?id=173_Not_So_Random"&gt;Not so Random&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.splatbang.com/rubyquiz/quiz.rhtml?id=174_Uptime_Since..."&gt;Up Since&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.splatbang.com/rubyquiz/quiz.rhtml?id=176_Equation_Graphing"&gt;Equation Graphing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.splatbang.com/rubyquiz/quiz.rhtml?id=178_Cookie_Monster"&gt;Cookie Monster&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.splatbang.com/rubyquiz/quiz.rhtml?id=180_Long_Division"&gt;Long Division&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.splatbang.com/rubyquiz/quiz.rhtml?id=183_Unit_Conversion"&gt;Unit Conversion&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.rubyquiz.com/quiz2.html"&gt;Secret Santas&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.rubyquiz.com/quiz9.html"&gt;Banned Words&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.rubyquiz.com/quiz16.html"&gt;Paper, Rock, Scissors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.rubyquiz.com/quiz25.html"&gt;English Numerals&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.rubyquiz.com/quiz42.html"&gt;Scheduling&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.rubyquiz.com/quiz98.html"&gt;A*&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.rubyquiz.com/quiz100.html"&gt;Bytecode Compiler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.rubyquiz.com/quiz121.html"&gt;Morse Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.rubyquiz.com/quiz155.html"&gt;Json Parser&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/lz0TnhDhobU" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/code-kata-list.html</feedburner:origLink></item><item><title>Top Javscript Libraries from Premium Bootstrap Themes</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/MUH058f-ci4/top-javscript-libraries-from-premium-bootstrap-themes.html</link><pubDate>Tue, 06 Nov 2012 02:25:00 PST</pubDate><guid isPermaLink="false">http://clauswitt.com/top-javscript-libraries-from-premium-bootstrap-themes</guid><description>&lt;p&gt;It happened again today. &lt;a href="http://wrapbootstrap.com/preview/WB0PHMG9K"&gt;An awesome theme based on Bootstrap&lt;/a&gt; &lt;a href="http://news.ycombinator.com/item?id=4746456"&gt;landed on hacker news&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The theme looked so nice, that I almost ended up buying the damn thing (for a measly $18) even though I have absolutely nothing use it for at the moment.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;However looking at the source reminded me of some of the other nice themes I have seen earlier this year, based on bootstrap. And a lot of them include a large list of javascript files, primarily in the form of jquery-plugins.&lt;/p&gt;

&lt;p&gt;I decided to list a few of the ones that I have found in one or more of the themes out there.&lt;/p&gt;

&lt;h2&gt;Beautiful forms with Uniformjs&lt;/h2&gt;

&lt;p&gt;Uniform masks form elements with custom controls, that are easily stylable. This ensures that your forms look the same in every browser. Take a look at &lt;a href="http://uniformjs.com"&gt;http://uniformjs.com&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Growl like notifications with Gritter&lt;/h2&gt;

&lt;p&gt;If you&amp;#8217;re making web applications for users that are used to desktop applications, you will eventually find yourself in need of a notification widget that looks good. &lt;a href="http://boedesign.com/blog/2009/07/11/growl-for-jquery-gritter/"&gt;Gritter looks and behaves exactly like Growl&lt;/a&gt; on the mac.&lt;/p&gt;

&lt;h2&gt;Star ratings with Raty&lt;/h2&gt;

&lt;p&gt;If a Web 2.0 site/app does not have up/down votes, it will almost always have star ratings. The easiest way to get that integrated in your app, is using &lt;a href="http://www.wbotelhos.com/raty/"&gt;raty&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Inline graphs with Sparklines&lt;/h2&gt;

&lt;p&gt;Some times you dont want a large graph to show you a snapshot of some metric. For some information having the graph inline in the text to which it relates is preferable. &lt;a href="http://omnipotent.net/jquery.sparkline/"&gt;Sparklines&lt;/a&gt; will let you embed charts within the text. Oh, and the charts can be updated in realtime, if needed.&lt;/p&gt;

&lt;h2&gt;Knobs with jQuery.Knob&lt;/h2&gt;

&lt;p&gt;These &lt;a href="http://anthonyterrien.com/knob/"&gt;knobs are just beautiful&lt;/a&gt;. They are awesome for showing (or allow editing of) a range.&lt;/p&gt;

&lt;h2&gt;Full sized calendar with FullCalendar&lt;/h2&gt;

&lt;p&gt;If your app does integrates with calendars in anyway, showing calendar like data in an actually calendar widget instead if in a list, is always best. The &lt;a href="http://arshaw.com/fullcalendar/"&gt;Fullcalendar jQuery plugin&lt;/a&gt; does exactly that. It has built in month, week and day view, as well as handling events from external datasources.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/MUH058f-ci4" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/top-javscript-libraries-from-premium-bootstrap-themes.html</feedburner:origLink></item><item><title>Zsh Helpers for Rebasing and Merging</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/kABAqL9gnbg/zsh-helpers-for-rebasing-and-merging.html</link><pubDate>Wed, 24 Oct 2012 11:09:00 PDT</pubDate><guid isPermaLink="false">http://clauswitt.com/zsh-helpers-for-rebasing-and-merging</guid><description>&lt;p&gt;I while back I posted &lt;a href="http://clauswitt.com/zsh-aliases-and-functions-for-my-git-workflow.html"&gt;a couple of my zsh snippets for working with git&lt;/a&gt;. Today however I read about a post about how to keep your feature branch up to date. I liked the little snippet, however we do not always use the master branch as the basis for feature branches. And we do not always use origin as the name for our remote. And on top of that, we do not always merge from the main branch, sometimes we rebase it - so that our feature branch is placed on the head of the branch it was based on.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;This means we need a more flexible helper. I decided creating two though. One for rebasing, and one for merging.&lt;/p&gt;

&lt;p&gt;There are a couple of steps to creating these snippets.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Save the current branch&lt;/li&gt;
&lt;li&gt;Handle (optional) user input&lt;/li&gt;
&lt;li&gt;Checkout main branch&lt;/li&gt;
&lt;li&gt;Pull from the remote&lt;/li&gt;
&lt;li&gt;Checkout the saved (current) branch&lt;/li&gt;
&lt;li&gt;Merge (or rebase) with the main branch.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The only difference in the commands are the subcommand for git in the last step.&lt;/p&gt;

&lt;div&gt;&lt;script src='https://gist.github.com/3947814.js?file='&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;pre&gt;&lt;code&gt;remain() {
  CURRENTBRANCH=$(git symbolic-ref HEAD | cut -d'/' -f3)
  if (( $# == 0 )) then
    REMOTE='origin'
    BRANCH='master'
  fi
  if (( $# == 1 )) then
    REMOTE='origin'
    BRANCH=$1
  fi
  if (( $# &amp;gt; 1 )) then
    REMOTE=$1
    BRANCH=$2
  fi
  git checkout $BRANCH &amp;amp;&amp;amp; git pull $REMOTE $BRANCH &amp;amp;&amp;amp; git checkout $CURRENTBRANCH &amp;amp;&amp;amp; git rebase $BRANCH
}

memain() {
  CURRENTBRANCH=$(git symbolic-ref HEAD | cut -d'/' -f3)
  if (( $# == 0 )) then
    REMOTE='origin'
    BRANCH='master'
  fi
  if (( $# == 1 )) then
    REMOTE='origin'
    BRANCH=$1
  fi
  if (( $# &amp;gt; 1 )) then
    REMOTE=$1
    BRANCH=$2
  fi
  git checkout $BRANCH &amp;amp;&amp;amp; git pull $REMOTE $BRANCH &amp;amp;&amp;amp; git checkout $CURRENTBRANCH &amp;amp;&amp;amp; git merge $BRANCH
}&lt;/code&gt;&lt;/pre&gt;&lt;/noscript&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/kABAqL9gnbg" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/zsh-helpers-for-rebasing-and-merging.html</feedburner:origLink></item><item><title>Canvas Demo of Game of Life</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/ZG_KDJRPUzY/canvas-demo-of-game-of-life.html</link><pubDate>Sun, 14 Oct 2012 15:00:00 PDT</pubDate><guid isPermaLink="false">http://clauswitt.com/canvas-demo-of-game-of-life</guid><description>&lt;p&gt;Last wednesday we held &lt;a href="http://www.aarhusjs.com/events/javascript-mvc-frameworks-oktober-meetup/"&gt;a meetup at AarhusJs&lt;/a&gt; and one of the talks were about the lessons the team behind &lt;a href="http://www.virtualmanager.com"&gt;Virtual Manager&lt;/a&gt; had learned while creating their new (yet to be released) football visualiser.&lt;/p&gt;

&lt;p&gt;Their solution based on canvas, and I was intrigued. I have not looked into canvas (or any other browser based graphics/animation) in quite some while, and wondered how the state of were at the moment.&lt;/p&gt;

&lt;p&gt;And I must say, a lot have changed in the last few years. To challenge my self to do something &amp;#8220;real&amp;#8221; with the canvas tag, I decided to take &lt;a href="http://www.createjs.com/#!/CreateJS"&gt;CreateJs&lt;/a&gt; for a spin. I quickly decided that the project should be very small, and that I would have to complete it in about an hour.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;I created a very naïve implementation of &lt;a href="http://en.wikipedia.org/wiki/Conway's_Game_of_Life"&gt;Conways Game of Life&lt;/a&gt;. The demo is located at &lt;a href="http://clauswitt.com/demos/code/gameoflife/gameOfLife.html"&gt;http://clauswitt.com/demos/code/gameoflife/gameOfLife.html&lt;/a&gt;. The two main parts of the &amp;#8220;game&amp;#8221; are the &amp;#8220;business rules&amp;#8221; of the game i.e. which positions should light up and which should not, based on the previous generation, and the rendering part of the game.&lt;/p&gt;

&lt;div&gt;&lt;script src='https://gist.github.com/3892795.js?file='&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;pre&gt;&lt;code&gt;window.GameOfLife = function(rows, cols, generations, timeout) {
  rows = rows || 10;
  cols = cols || 10;
  generations = generations || -1;
  timeout = timeout || 100;


  var setupBoard = function() {
    arr = [];
    for(var rowId=0;rowId&amp;lt;rows;rowId++) {
      arr[rowId] = [];
      for(var colId=0;colId&amp;lt;cols;colId++) {
        arr[rowId][colId] = Math.round(Math.random());
      }
    }
    return arr;
  };

  var getNeighbours = function(board, rowId, colId) {
    var neighbours = [];
    //row above
    if(rowId &amp;gt; 0) {
      if(colId &amp;gt; 0) {
        neighbours.push(board[rowId-1][colId-1]);
      }
      neighbours.push(board[rowId-1][colId]);
      if(colId &amp;lt; board[rowId].length - 2) {
        neighbours.push(board[rowId-1][colId]);
      }
    }
    //same row
    if(colId &amp;gt; 0) {
      neighbours.push(board[rowId][colId-1]);
    }
    if(colId &amp;lt; board[rowId].length - 2) {
      neighbours.push(board[rowId][colId+1]);
    }
    //row below
    if(rowId &amp;lt; board.length - 1) {
      if(colId &amp;gt; 0) {
        neighbours.push(board[rowId+1][colId-1]);
      }
      neighbours.push(board[rowId+1][colId]);
      if(colId &amp;lt; board[rowId].length - 2) {
        neighbours.push(board[rowId+1][colId+1]);
      }
    }

    return neighbours;
  };

  
  var checkAliveNeighboursInRange = function(board, rowId, colId, min, max) {
    var neighbours = getNeighbours(board, rowId, colId);
    var count = neighbours.reduce(function(prev, cur) {return prev+cur}, 0);

    return (count &amp;gt;= min &amp;amp;&amp;amp; count &amp;lt;= max);
  };

  var checkDeadValue = function(board, rowId, colId) {
    return checkAliveNeighboursInRange(board, rowId, colId, 3, 3) ? 1 : 0;
  };

  var checkAliveValue = function(board, rowId, colId) {
    return checkAliveNeighboursInRange(board, rowId, colId, 2, 3) ? 1 : 0;
  };

  var getPositionValue = function(board, rowId, colId) {
    if(board[rowId][colId] === 0) {
        //Position is dead
        return checkDeadValue(board, rowId, colId);
      } else {
        //Position is alive
        return checkAliveValue(board, rowId, colId);
      }
  };

  var evaluateBoard = function(board) {
    nextBoard = [];
    for(var rowId = 0;rowId &amp;lt; board.length; rowId++) {
      nextBoard[rowId] = [];
      for(var colId=0; colId &amp;lt; board[rowId].length; colId++) {
        nextBoard[rowId][colId] = getPositionValue(board, rowId, colId);
      }
    }
    return nextBoard;
  };  

  var board = setupBoard();
  var timeRun = 0;
  var callback = null;
  var runner = function() {
    board = evaluateBoard(board);
    callback(board);
    if(generations&amp;gt;-1) timeRun++;
    if((timeRun &amp;lt; generations || generations === -1)) setTimeout(runner, timeout);
  };
  this.run = function(c) {
    callback = c;
    runner.call();
  };
  
  this.getBoard = function() {
    return board;
  };
  this.evaluateBoard = evaluateBoard;
  return this;
};




&lt;/code&gt;&lt;/pre&gt;&lt;/noscript&gt;&lt;/div&gt;




&lt;div&gt;&lt;script src='https://gist.github.com/3892801.js?file='&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;
 &amp;lt;script src=&amp;quot;gameOfLife.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src=&amp;quot;components/EaselJS/lib/easeljs-0.5.0.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;script&amp;gt;

var stageWidth = 640;
var stageHeight = 480;
var sizeDivision = 10;
var stage;
var gol;

function init() {
  canvas = document.getElementById(&amp;quot;canvas&amp;quot;);
  canvas.width = stageWidth = document.width;
  canvas.height = stageHeight = document.height;
  //new stage
  stage = new createjs.Stage(canvas);
  gol = new GameOfLife(stageWidth/sizeDivision, stageHeight/sizeDivision, 100, 100);
  var board = gol.getBoard();
  var color = 0;
  for(var i=0;i&amp;lt;stageWidth/sizeDivision;i++) {
    for(var j=0;j&amp;lt;stageHeight/sizeDivision;j++) {
      if(board[i][j]==0) continue;
      shape1 = new createjs.Shape();
      shape1.graphics.beginFill(&amp;quot;#f00&amp;quot;);
      shape1.graphics.drawRect(i*sizeDivision,j*sizeDivision,sizeDivision,sizeDivision);
      stage.addChild(shape1);
    }
  }
  //draw to the canvas
  stage.update(); 
  var cb = function(board) {
    stage.clear();
    stage.removeAllChildren();
    for(var i=0;i&amp;lt;stageWidth/sizeDivision;i++) {
      for(var j=0;j&amp;lt;stageHeight/sizeDivision;j++) {
        if(board[i][j]==0) continue;
        shape1 = new createjs.Shape();
  
        shape1.graphics.beginFill(&amp;quot;#f00&amp;quot;);
        shape1.graphics.drawRect(i*sizeDivision,j*sizeDivision,sizeDivision,sizeDivision);
        stage.addChild(shape1);
      }
    }
    stage.update();
  };
  gol.run(cb);
   
}
&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body onload=&amp;quot;init()&amp;quot;&amp;gt;  
 &amp;lt;canvas id=&amp;quot;canvas&amp;quot; width=&amp;quot;640&amp;quot; height=&amp;quot;480&amp;quot;&amp;gt;&amp;lt;/canvas&amp;gt; 

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt; &lt;/code&gt;&lt;/pre&gt;&lt;/noscript&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/ZG_KDJRPUzY" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/canvas-demo-of-game-of-life.html</feedburner:origLink></item><item><title>Tmuxinator Zsh Completion</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/m6HjukNZWMg/tmuxinator-zsh-completion.html</link><pubDate>Tue, 02 Oct 2012 15:00:00 PDT</pubDate><guid isPermaLink="false">http://clauswitt.com/tmuxinator-zsh-completion</guid><description>&lt;p&gt;I am a bit weird with my editor choice. I use three different text/code editors. I usually use PhpStorm for large projects in PHP, since the more intelligent code completion is a time saver for large changes in PHP, when the codebase is 248753 lines of PHP code. But for everything else including minor bugfixes and features I use either Sublime Text 2 or vim.&lt;/p&gt;

&lt;p&gt;When writing code in vim, I usually open a complete project in tmux and have a lot of panes, one with vim, one with a terminal, one watching changes (through either grunt or yeoman for instance), one logged in to the db, one starting a server, and perhaps several panes connected to the production environment via ssh.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;Earlier I managed these settings with my own &lt;a href="https://npmjs.org/package/jtmux"&gt;quickly hacked tool called jtmux&lt;/a&gt;, which I wrote because I couldn&amp;#8217;t find a tool that matched my needs. (I know what you think, my search skills are lacking). Well, I eventually found &lt;a href="https://github.com/aziz/tmuxinator"&gt;tmuxinator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I needed some completion of the mux command however. This was of course (yet again) quite easy with the awesome zsh plugin structure.&lt;/p&gt;

&lt;script src="https://gist.github.com/3826089.js"&gt; &lt;/script&gt;


&lt;p&gt;This will autocomplete tmuxinator settings from the files in ~/.tmuxinator&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/m6HjukNZWMg" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/tmuxinator-zsh-completion.html</feedburner:origLink></item><item><title>A zsh Function to Automate Issue id in Commit Messages</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/m2bVTDx4Rek/a-zsh-function-to-automate-issue-id-in-commit-messages.html</link><pubDate>Thu, 27 Sep 2012 15:00:00 PDT</pubDate><guid isPermaLink="false">http://clauswitt.com/a-zsh-function-to-automate-issue-id-in-commit-messages</guid><description>&lt;p&gt;At Arnsbo Media we usually create a new branch when working on an issue from Jira. And we name the branch after the issue id, meaning that the branch, is always prefixed with the issue id from Jira, and then some meaningful name after that.&lt;/p&gt;

&lt;p&gt;This makes it easy to identify which issue a branch relates to. However to make issues auto update with code changes, and to make our automatic deploy mail a meaningful message to Product Owners with a link to the deployed issue, we need to make all relevant commits reference the issue id as well.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;We do this by adding &amp;#8220;#Refs PROJECT-123&amp;#8221; in the commit message.&lt;/p&gt;

&lt;p&gt;However since the issue id is already part of the branch name - in a predictable way - and since we all use zsh as our shell. We created a little zsh function to prefix commit messages with the issue id.&lt;/p&gt;

&lt;script src="https://gist.github.com/3799235.js"&gt; &lt;/script&gt;


&lt;p&gt;The function is called ci for commit issue.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/m2bVTDx4Rek" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/a-zsh-function-to-automate-issue-id-in-commit-messages.html</feedburner:origLink></item><item><title>Using New Relic with FLOW3</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/zbNA1HhJQP0/using-new-relic-with-flow3.html</link><pubDate>Tue, 25 Sep 2012 15:00:00 PDT</pubDate><guid isPermaLink="false">http://clauswitt.com/using-new-relic-with-flow3</guid><description>&lt;p&gt;At &lt;a href="http://www.arnsbomedia.com"&gt;Arnsbo Media&lt;/a&gt; we use &lt;a href="http://flow3.typo3.org"&gt;FLOW3&lt;/a&gt; for several projects. For most of those we use &lt;a href="https://newrelic.com"&gt;New Relic&lt;/a&gt; for application monitoring. This enables gives us great introspection in to the performance and errors on each application.&lt;/p&gt;

&lt;p&gt;However using this with a PHP Framework that is not natively supported all requests show up in New Relic as index.php - which is not very convenient for performance tuning or bug squashing.&lt;/p&gt;

&lt;p&gt;I have created a quick little implementation of a package with an aspect that weaves into each controllers processRequest method. This method has access to the request object, and thus will be able to extract relevant information about either the url used, or the combination of controller and action name.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;We decided to make the transaction name configurable where a template can be set for the name can be set for both web- and cli-requests.&lt;/p&gt;

&lt;p&gt;At the time of writing this we use urls as transaction name for web requests, but may change this to controllername:actionname as per &lt;a href="https://newrelic.com/docs/php/framework-developers-integrated-support-for-new-relic"&gt;recommandations from New Relic&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ArnsboMedia/Flow3-NewRelic"&gt;The new relic package for flow3 can be found here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/zbNA1HhJQP0" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/using-new-relic-with-flow3.html</feedburner:origLink></item><item><title>Defensive Programming using Assertions in JavaScript</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/bjMYFDZXHS4/defensive-programming-using-assertions-in-javascript.html</link><pubDate>Tue, 04 Sep 2012 15:00:00 PDT</pubDate><guid isPermaLink="false">http://clauswitt.com/defensive-programming-using-assertions-in-javascript</guid><description>&lt;p&gt;Several years ago I read Steve McConnell&amp;#8217;s awesome book &lt;a href="http://www.amazon.com/gp/product/0735619670/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0735619670&amp;linkCode=as2&amp;tag=clawit-20"&gt;Code Complete: A Practical Handbook of Software Construction, Second Edition&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=clawit-20&amp;l=as2&amp;o=1&amp;a=0735619670" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt;. Chapter 8 of the book is about defensive programming strategies, and one of those is to use assertions to ensure that variables and parameters match the assumptions we have about the input, and to throw an exception (or fail in some other way) when that is not the case.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;Assertions are mostly just input checks. However consider these two snippets of Javascript testing the same conditions for a functions parameters.&lt;/p&gt;

&lt;script src="https://gist.github.com/3631381.js"&gt; &lt;/script&gt;




&lt;script src="https://gist.github.com/3631390.js"&gt; &lt;/script&gt;


&lt;p&gt;Even though the code is almost just as long, the second version is much easier to read, since the checks are named in a way that shows why they are there.&lt;/p&gt;

&lt;p&gt;I have created a &lt;a href="https://npmjs.org/package/affirm"&gt;npm package called affirm&lt;/a&gt; - &lt;a href="https://github.com/clauswitt/affirm"&gt;find it on github&lt;/a&gt; to see how it is implemented.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/bjMYFDZXHS4" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/defensive-programming-using-assertions-in-javascript.html</feedburner:origLink></item><item><title>Quick Prototyping with Berliner in Node</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/iLwfI4Umpls/quick-prototyping-with-berliner-in-node.html</link><pubDate>Sun, 26 Aug 2012 15:00:00 PDT</pubDate><guid isPermaLink="false">http://clauswitt.com/quick-prototyping-with-berliner-in-node</guid><description>&lt;p&gt;About an hour ago I found a like (probably on hacker news or twitter) to &lt;a href="http://berliner.jcoglan.com"&gt;yet another Sinatra like node library called Berliner&lt;/a&gt;. I have played around with it since then, and I find it awesome. It is very easy to understand, easy to use, and has all the best features from Sinatra, without copying each and every feature.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;I have created a &lt;a href="https://github.com/clauswitt/testBerliner"&gt;quick little demo app&lt;/a&gt;, which shows how to easily put your routes in separate files, and have a central settings file. When cloning the project, remember to call npm install, and then run the app by running&lt;/p&gt;

&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;coffee app.coffee&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Create routes in the routes folder, and this code will automatically pick up the routes on application startup.&lt;/p&gt;

&lt;script src="https://gist.github.com/3491384.js"&gt; &lt;/script&gt;


&lt;p&gt;Routes are defined in a modules initialize method which receives app (the berliner app) and db (the orm connection). An example route - a get request for / - is included, it just redirects to the index.html file which is located in the public folder.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/iLwfI4Umpls" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/quick-prototyping-with-berliner-in-node.html</feedburner:origLink></item><item><title>Kill All Processes Matching a Pattern</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/wQXFnJIpYQM/kill-all-processes-matching-a-pattern.html</link><pubDate>Thu, 02 Aug 2012 15:00:00 PDT</pubDate><guid isPermaLink="false">http://clauswitt.com/kill-all-processes-matching-a-pattern</guid><description>&lt;p&gt;Sometimes you just have to kill something. Today I needed to kill several (about 20) hanging ruby processes. But since I am too lazy to go through a list from&lt;/p&gt;

&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;  ps -A |grep ruby &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;and kill everything manually. I used some (probably just as much) time to create a simple little command to the same thing.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class=''&gt;&lt;span class='line'&gt;  kill -9 `ps -A |grep ruby |grep -v "grep" | awk  -F" " '{ print $1 }'`&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;The command kills all processes that contain the word ruby, except ones that contain the word grep (to ensure that this process will run). Then it pipes that through awk to get only the characters until the first space, since ps -A gives us a list which starts with the process-id which is what we need to feed to the kill command.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/wQXFnJIpYQM" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/kill-all-processes-matching-a-pattern.html</feedburner:origLink></item><item><title>Quick zsh Alias for Opening a Project in Sublime Text</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/gpMw-18Lv0A/quick-zsh-alias-for-opening-a-project-in-sublime-text.html</link><pubDate>Tue, 31 Jul 2012 15:00:00 PDT</pubDate><guid isPermaLink="false">http://clauswitt.com/quick-zsh-alias-for-opening-a-project-in-sublime-text</guid><description>&lt;p&gt;I use both vim and Sublime Text (with vintage mode). For most projects I have a sublime-project file.&lt;!--more--&gt; E.g. this one is my standard project file for rails apps with ember frontend:&lt;/p&gt;

&lt;script src="https://gist.github.com/3224558.js"&gt; &lt;/script&gt;


&lt;p&gt;Since I am a console-aholic, I created a quick alias to open current directory as a project in Sublime Text. The alias is quite simple:&lt;/p&gt;

&lt;script src="https://gist.github.com/3224572.js"&gt; &lt;/script&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/gpMw-18Lv0A" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/quick-zsh-alias-for-opening-a-project-in-sublime-text.html</feedburner:origLink></item><item><title>Getting Recommandations in CoffeeScript</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/AxQybZTlgnU/getting-recommandations-in-coffeescript.html</link><pubDate>Sun, 29 Jul 2012 15:00:00 PDT</pubDate><guid isPermaLink="false">http://clauswitt.com/getting-recommandations-in-coffeescript</guid><description>&lt;p&gt;Having read the awesome book &lt;a target="_blank" href="http://www.amazon.com/mn/search/?_encoding=UTF8&amp;*Version*=1&amp;*entries*=0&amp;camp=1789&amp;creative=390957&amp;linkCode=ur2&amp;tag=clawit-20"&gt;Programming Collective Intelligence&lt;/a&gt;&lt;img src="https://www.assoc-amazon.com/e/ir?t=clawit-20&amp;l=ur2&amp;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt; some time ago, a wondered today how easy it would be to implement the two recommendation algorithms - &lt;a href="http://en.wikipedia.org/wiki/Euclidean_distance"&gt;Eucledian Distance&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Correlation_and_dependence#Pearson.27s_product-moment_coefficient"&gt;Pearson Correlation Score&lt;/a&gt; - in CoffeeScript.&lt;!--more--&gt; Since it is mostly rather simple math - using some simple Math.pow and Math.sqrt - CoffeeScript seemed simple for the job.&lt;/p&gt;

&lt;p&gt;I have created a quick class to show how to create some simple recommendations. It is in a gist at github.&lt;/p&gt;

&lt;script src="https://gist.github.com/3209824.js"&gt; &lt;/script&gt;


&lt;p&gt;&lt;strong&gt;Example of use: &lt;/strong&gt;&lt;/p&gt;

&lt;script src="https://gist.github.com/3209841.js"&gt; &lt;/script&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/AxQybZTlgnU" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/getting-recommandations-in-coffeescript.html</feedburner:origLink></item><item><title>Creating Scoped Keybindings for Snippets in Sublime Text</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/0ifwkM2dL2Y/creating-scoped-keybindings-for-snippets-in-sublime-text.html</link><pubDate>Sun, 22 Jul 2012 15:00:00 PDT</pubDate><guid isPermaLink="false">http://clauswitt.com/creating-scoped-keybindings-for-snippets-in-sublime-text</guid><description>&lt;p&gt;If you want to learn how to do very advanced stuff in sublime text, you should take a look at the settings files for it, and try to learn something new from that.&lt;/p&gt;

&lt;p&gt;One very awesome thing that I use a lot, is to create scoped keybindings that insert a specific snippet, or do some specific action depending on the current file.&lt;/p&gt;

&lt;p&gt;One example is that I want ctrl+command+L to insert a link in a file, however how that link is inserted differs on file type, and context (is something currently selected or not).&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;As an example of scoped keybindings, take a look at the following snippet, directly from the default keybindings in Sublime Text.&lt;/p&gt;

&lt;script src="https://gist.github.com/3163372.js"&gt; &lt;/script&gt;


&lt;p&gt;This snippets surrounds a selected text with quotes, if the following criteria are met:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Auto Match setting is set to true&lt;/li&gt;
&lt;li&gt;Selection is empty&lt;/li&gt;
&lt;li&gt;Following text is a tab, a space, a ), a ] a } a &amp;gt; or the end of the line.&lt;/li&gt;
&lt;li&gt;Preceding text is a non-alphanumeric character&lt;/li&gt;
&lt;li&gt;and the eol_selector is not equal to a string.quoted.double&amp;#8230; Whatever that means&amp;#8230;?&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;There exists a snippet almost identical to this one, whose scope is that selection is non empty.&lt;/p&gt;

&lt;p&gt;The problem I want solved is that I want all my prettyfy commands (currently I have a pretty print json, and pretty print html command installed) to have the same keybinding, and then let the scope decide which command to run.&lt;/p&gt;

&lt;script src="https://gist.github.com/3186775.js"&gt; &lt;/script&gt;


&lt;p&gt;In this extract from my personal sublime-keymap you can see two keybindings with the exact same keys, however each has it&amp;#8217;s own specific context in which it works. One works in text.html (and thus in all html subtypes), and one works with source.json. Now it will be easy for me to add new prettifiers at a later stage, to the same keybinding, and just change the context/scope of the binding.&lt;/p&gt;

&lt;p&gt;And finally we get to the snippets. Here we are using the command insert_snippet, and sending it the snippet as the only parameter, and using ${0:$SELECTION} as insert point for the selection (if any).&lt;/p&gt;

&lt;script src="https://gist.github.com/3186825.js"&gt; &lt;/script&gt;


&lt;p&gt;Now I get the correct link in both scopes.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/0ifwkM2dL2Y" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/creating-scoped-keybindings-for-snippets-in-sublime-text.html</feedburner:origLink></item><item><title>Managing Flow3 Project Packages with flopro</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/HXPtHJYcBIA/managing-flow3-project-packages-with-flopro.html</link><pubDate>Thu, 19 Jul 2012 15:00:00 PDT</pubDate><guid isPermaLink="false">http://clauswitt.com/managing-flow3-project-packages-with-flopro</guid><description>&lt;p&gt;At work we currently have two &lt;a href="http://flow3.org"&gt;FLOW3&lt;/a&gt; based projects, and both of them have a lot of packages. I have been in need of a sort of package management like &lt;a href="http://getcomposer.org/"&gt;Composer&lt;/a&gt; or &lt;a href="http://npmjs.org/"&gt;npm&lt;/a&gt; for FLOW3 - but it seems not to be ready yet. I needed something easy to implement, and easy to manage - with as few dependencies as possible.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;At work we also use javascript, node and npm extensively. And I have found that having a simple json file in the root of a given flow based project, and having that file under version control, could be a basis of a simple tool to either clone or update a package from version control based on wether it exists or not.&lt;/p&gt;

&lt;p&gt;I have created such a tool and called it &lt;a href="https://github.com/clauswitt/flopro"&gt;flopro&lt;/a&gt; (FLOw3 PROject). The tools needs a file called .flow3.json in the root of the flow3 installation, and this json file has an array of packages with their names, their repo location, and their type (Framework or Application). Then you can call flopro from anywhere in the flow3 tree structure, and get the latest version of all packages, that should be in the install.&lt;/p&gt;

&lt;p&gt;On top of that I have created a flopro-generate command (installed automatically when installing flopro). This command can generate the configuration file in the correct location, based on your currently cloned packages. Beware though, that no error checking exists at the moment - and the Packages/Application folder needs to be hold only FLOW3 packages - that have a git remote called origin.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/HXPtHJYcBIA" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/managing-flow3-project-packages-with-flopro.html</feedburner:origLink></item><item><title>Using JSON.parse and JSON.stringify to Clone Objects</title><link>http://feedproxy.google.com/~r/ClausWitt/~3/kIHHdSq2emo/using-json.parse-and-json.stringify-to-clone-objects.html</link><pubDate>Tue, 17 Jul 2012 15:00:00 PDT</pubDate><guid isPermaLink="false">http://clauswitt.com/using-json.parse-and-json.stringify-to-clone-objects</guid><description>&lt;p&gt;Yesterday I read &lt;a href="http://davidwalsh.name/javascript-clone"&gt;David Walsh&amp;#8217;s post about object cloning in javascript&lt;/a&gt;. The method he showed was pretty much the one that is in Dojo Toolkit.&lt;/p&gt;

&lt;p&gt;However one of the commenters mentioned that you could use JSON.parse and JSON.stringify in combination to clone an object. And indeed that works just fine.&lt;/p&gt;

&lt;!--more--&gt;


&lt;p&gt;I decided to &lt;a href="http://jsperf.com/dojo-clone-or-json-cloning"&gt;test the two solutions on jsperf&lt;/a&gt;. The results are, for my very limited number of tests in the latest versions of Firefox, Chrome and Safari, that the JSON version is about 2 times faster than the Dojo way.&lt;/p&gt;

&lt;p&gt;Beware though. This solution is only valid for modern browsers with native JSON support. (Internet Explorer 8+, Firefox 3.1+, Safari 4+, Chrome 3+, and Opera 10.5+ support native JSON parsing.)&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/ClausWitt/~4/kIHHdSq2emo" height="1" width="1"/&gt;</description><feedburner:origLink>http://clauswitt.com/using-json.parse-and-json.stringify-to-clone-objects.html</feedburner:origLink></item></channel></rss>
