<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title type="text" xml:lang="en">Float Left</title>
  <link type="application/atom+xml" href="http://floatleft.com/feed" rel="self"/>
  <link type="text/html" href="http://floatleft.com" rel="alternate"/>
  <updated>2014-12-21T20:06:41+00:00</updated>
  <id>http://floatleft.com/</id>
  <author>
    <name>Andy Appleton</name>
    <email>hello@floatleft.com</email>
  </author>

  
    
      <entry>
        <title>Learning to type like a grown up</title>
        <link href="http://floatleft.com/notebook/learning-to-type-like-a-grown-up"/>
        <updated>2014-02-03T00:00:00+00:00</updated>
        <id>http://floatleft.com/notebook/learning-to-type-like-a-grown-up</id>
        <content type="html">
          &lt;p&gt;Over the last year I’ve slowly developed hand and wrist pain from long stints at the keyboard. I recently decided that enough is enough and I need to take it seriously if I want to be able to do the job I love for the rest of my career. My first naive attempt at a fix was to purchase an ergonomic split keyboard. I went for the &lt;a href=&quot;http://www.microsoft.com/hardware/en-gb/p/sculpt-ergonomic-desktop&quot;&gt;Microsoft Sculpt ergonomic&lt;/a&gt; after reading some good reviews, particularly &lt;a href=&quot;http://www.marco.org/2013/08/30/sculpt-ergonomic-keyboard-review&quot;&gt;Marco Arment’s&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This actually made things worse and it didn’t take me long to figure out that the problem was my typing technique. Like many people of my generation I was not taught touch typing and have never felt the motivation to learn independently. I was using two fingers per hand and making some weird shapes as I reached for different key combos. The rotated hand position on the split keyboard accentuated these movements which led to more pain. On top of that I realised that I needed to look at the keyboard out of the bottom of my eyes as I typed – the split layout hid the keys from view which led to a lot of missed keys.&lt;/p&gt;

&lt;h2 id=&quot;doing-it-properly&quot;&gt;Doing it properly&lt;/h2&gt;

&lt;p&gt;It was Christmas and I had a few days off work so I decided to stop making excuses and learn to touch type. I went cold turkey on my old technique and started following the course on &lt;a href=&quot;http://www.typingclub.com/&quot;&gt;typingclub.com&lt;/a&gt;. It was hugely frustrating for about two days until I had worked through the lessons for all of the main characters but I was able to become reasonably productive within half a week, albeit at a glacial 20 words per minute.&lt;/p&gt;

&lt;p&gt;I’m now a month in and am able to type fluently without looking the keyboard and often without consciously thinking about the location of individual keys. My speed is up in the 35-40 WPM range and I’m more accurate too. I’ve pretty much completed the typing club course but I keep revisiting the speed test lessons to try and edge up my speed and accuracy. I now absolutely love my ergonomic keyboard – it keeps my wrists at a neutral angle and is really comfortable. If you secretly know that your typing technique sucks you owe it to yourself to learn touch typing. You will be frustrated for a few days at worst and will be faster and more comfortable within a month.&lt;/p&gt;

&lt;h2 id=&quot;what-about-the-wrist-pain&quot;&gt;What about the wrist pain?&lt;/h2&gt;
&lt;p&gt;Touch typing is just one helpful factor in trying to
eliminate the pain I’ve been experiencing this last month I’ve also done a lot of reading and have visited a doctor. A big change is that I’ve started using &lt;a href=&quot;http://breaktimeapp.com/&quot;&gt;BreakTime app&lt;/a&gt; to force me to take a 2 minute break every 20 minutes &lt;a href=&quot;#footnote-1&quot; id=&quot;footnote-link-1&quot;&gt;[1]&lt;/a&gt;. This lets me stretch out my hands regularly to make sure they’re not cramped in the same position for long periods. I’ve also made a conscious effort to not use a keyboard unless it’s really necessary, I’m trying to keep away from the computer at the weekend and in the evening to give my hands time to rest and recover.&lt;/p&gt;

&lt;p&gt;The doctor tells me that I can expect it to take 6-8 months to fully recover but I’m starting to feel a bit better already. If you’re dealing with hand or wrist pain I would strongly recommend doing some reading (&lt;a href=&quot;http://web.eecs.umich.edu/~cscott/rsi.html&quot;&gt;this page from Clay Scott&lt;/a&gt; is very thorough) and making some changes to your work setup. Mine is not too bad and hopefully I’ve made good changes early enough that it won’t become a longterm problem, I strongly encourage you to do the same.&lt;/p&gt;

&lt;ol class=&quot;footnotes&quot;&gt;
  &lt;li id=&quot;footnote-1&quot;&gt;
    I was expecting this to kill productivity but as a programmer I actually find it a good opportunity to think about whether what I'm doing is really correct. It's easy to blindly dive down the rabbit hole of a suboptimal solution and the breaks are a great way to counter that. &lt;a href=&quot;#footnote-link-1&quot;&gt;↩&lt;/a&gt;
  &lt;/li&gt;
&lt;/ol&gt;

          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Taking Ember for a spin</title>
        <link href="http://floatleft.com/notebook/taking-ember-for-a-spin"/>
        <updated>2013-10-25T00:00:00+01:00</updated>
        <id>http://floatleft.com/notebook/taking-ember-for-a-spin</id>
        <content type="html">
          &lt;p&gt;After &lt;a href=&quot;http://emberjs.com&quot;&gt;Ember.js&lt;/a&gt; hit 1.0 recently I decided to give it a fair shot and try it out for a week in the context of an app I’m working on. The app actually uses &lt;a href=&quot;http://angularjs.org/&quot;&gt;Angular&lt;/a&gt;, which I’m very comfortable with but it’s always good to evaluate alternatives and be able to pick a tool based on experience.&lt;/p&gt;

&lt;p&gt;I’m building a little recipe/shopping list app. The idea is that you can generate a shopping list by selecting recipes you’d like to cook and how many people it should serve. The ingredients are summed up to create a list which you can take to the shops.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/img/posts/meel.png&quot; alt=&quot;List page with crossed items and with completed screen&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This list page has a few interesting features:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Tapping/clicking a single item will strike a line through it. The state of checked and unchecked items is persisted in &lt;code&gt;localStorage&lt;/code&gt; only.&lt;/li&gt;
  &lt;li&gt;There is a toggle to show and hide already checked items.&lt;/li&gt;
  &lt;li&gt;When all items are checked and the toggle is set to hide checked items, a complete screen shows.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I already had this page implemented in Angular so I knew how it should work and I figured it would be a good comparison. I created a new git branch, deleted all of the Angular code and jumped into reimplementing it with Ember. Here’s a loose collection of my conclusions.&lt;/p&gt;

&lt;h2 id=&quot;ember-data&quot;&gt;ember-data&lt;/h2&gt;

&lt;p&gt;I found a lot to like about Ember. In Ember data it has a very solid model and persistence abstraction which I really appreciated coming from Angular which has next to nothing.&lt;/p&gt;

&lt;p&gt;It provides a store object in the browser which you make queries against. Either it already contains the data you requested or it makes a round trip to the server to retrieve it, caching for next time. Either way it returns a promise so the interface is consistent. Over the life of a long running single page app I can see this saving a lot of needless requests.&lt;/p&gt;

&lt;p&gt;Models declare associations to other models and attribute types are declared upfront. I much prefer this to the Angular way of just parsing server JSON into a plain JavaScript object regardless of content. In the past I’ve encountered bugs where server JSON changed subtly and broke some front end functionality in a way I didn’t spot until it was too late. Ember expects attributes to be present and of the correct type and throws helpful errors when they’re not.&lt;/p&gt;

&lt;h2 id=&quot;embercomponent&quot;&gt;Ember.Component&lt;/h2&gt;

&lt;p&gt;Ember’s answer to Angular directives and an attempt to forward patch &lt;a href=&quot;http://www.w3.org/TR/components-intro/&quot;&gt;web component&lt;/a&gt; support. Ember.Component does a lot less than Angular’s directive, but I think it is a great example of providing 80% of the power with much less learning overhead.&lt;/p&gt;

&lt;p&gt;All Ember components get a new controller and there is only one way of scoping the controller. Contrast with Angular where you must learn about isolate and inherit scopes, transclusion and linking/compile functions before you can be productive — directives are seen as an advanced topic in Angular, components are not in Ember and I think that is to its immense credit.&lt;/p&gt;

&lt;p&gt;I implemented each list item as component and handled the &lt;code&gt;localStorage&lt;/code&gt; persistence inside the individual controllers — it was easy to get started with, especially having some prior knowledge of web components and Angular directives.&lt;/p&gt;

&lt;h2 id=&quot;naming-conventions&quot;&gt;Naming Conventions&lt;/h2&gt;

&lt;p&gt;Ember relies heavily on naming conventions. Your controllers and templates must be named just so to be constructed and rendered correctly and all objects must be placed into a single app namespace object.&lt;/p&gt;

&lt;p&gt;I prefer the flexibility of a module system for declaring dependencies and would prefer not to rely on naming conventions, which can be easily typoed. The flip side is that module systems (particularly Angular’s) add a lot of boilerplate code to a file which Ember just doesn’t need.&lt;/p&gt;

&lt;h2 id=&quot;testing&quot;&gt;Testing&lt;/h2&gt;

&lt;p&gt;The Ember docs are excellent in almost all ways, but there is no information about testing which I found quite disappointing. The information I was able to find seemed more focused on integration level tests so I’d love to see a post or some docs on unit test best practices. This is one area where Angular really shines and it gives a lot of confidence putting an app into production knowing that it it well tested.&lt;/p&gt;

&lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;

&lt;p&gt;Overall I’ve really enjoyed working with Ember. I’m far more productive with Angular, but then I’m also far more experienced. I’m going to finish building my shopping list app with Angular but for my next project I’ll seriously consider Ember as an alternative. I think Ember will really shine with a more data-rich application and I’m looking forward to what they can do with server side pre-rendering.&lt;/p&gt;

&lt;p&gt;If you’re looking to get started with Ember, here’s some resources which helped me out:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://youtu.be/1QHrlFlaXdI&quot;&gt;Ember introduction screencast&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://emberjs.com/guides/&quot;&gt;Ember guides&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://emberjs.com/api&quot;&gt;Ember API reference&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/discourse/discourse&quot;&gt;Discourse&lt;/a&gt; (a large open source Ember app) source code&lt;/li&gt;
&lt;/ul&gt;


          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Diving into AngularJS</title>
        <link href="http://floatleft.com/notebook/diving-into-angularjs"/>
        <updated>2013-04-21T00:00:00+01:00</updated>
        <id>http://floatleft.com/notebook/diving-into-angularjs</id>
        <content type="html">
          &lt;p&gt;This weekend I’ve had some spare time and I’ve used it to take a proper look at &lt;a href=&quot;http://angularjs.org/&quot;&gt;AngularJS&lt;/a&gt;. I’ve used &lt;a href=&quot;http://backbonejs.org/&quot;&gt;Backbone&lt;/a&gt; a lot and find myself defaulting to it as soon as a JavaScript application gets complicated. I realised that I was ignoring everything else because I already know Backbone and that’s not a good place to be. Time to jump into something new.&lt;/p&gt;

&lt;h2 id=&quot;when-all-you-have-is-a-hammer&quot;&gt;When all you have is a hammer…&lt;/h2&gt;

&lt;p&gt;Initially I downloaded the Angular source and launched into trying to build something simple with it but I found this a really frustrating experience. I consider myself a pretty competent JS developer but nothing really worked and the concepts didn’t click. Making me feel stupid is a quick way to turn me off of something.&lt;/p&gt;

&lt;p&gt;I took a step back and realised that I was trying so hard to shoehorn what I knew about MVC from Rails and Backbone into the app that I wasn’t letting myself see the bigger picture. I spent an hour watching and coding along with a tutorial &lt;a href=&quot;http://weblogs.asp.net/dwahlin/archive/2013/04/12/video-tutorial-angularjs-fundamentals-in-60-ish-minutes.aspx&quot;&gt;video&lt;/a&gt; and by the end felt I really understood the basics. Just by investing a small amount of time into learning the fundamentals I’m now &lt;em&gt;really productive&lt;/em&gt; with Angular. Making me feel smart is a great way to keep me interested in something!&lt;/p&gt;

&lt;p&gt;In less than a day I’ve come to love the declarative nature of the code I’m writing. Everything is so terse and I’m spending zero time writing what I would now consider boilerplate DOM manipulation or event binding code. This is really exciting coming from a world of manual template rendering and zombie events and I love not having to think about that stuff.&lt;/p&gt;

&lt;h2 id=&quot;conventions&quot;&gt;Conventions&lt;/h2&gt;

&lt;p&gt;I listened to an &lt;a href=&quot;http://learn.thoughtbot.com/podcast/44&quot;&gt;interview with Chad Fowler&lt;/a&gt; this week. He spoke about how Rails is not necessarily the best web framework but it offers such a strong set of conventions and has such a strong community that it really allows you to forget about hooking an app together and just focus on the product you’re trying to build.&lt;/p&gt;

&lt;p&gt;I feel like Angular offers the same level of convention and I’m really looking forward to getting stuck into a bigger project with it. I don’t want to spend my time writing glue code, clearing up old views, manually re-rendering templates on data change or writing form input handlers. I know there are libraries to handle these things in Backbone, but I also don’t want to be depending on 20 plugins just to get a functioning app.&lt;/p&gt;

&lt;h2 id=&quot;step-back&quot;&gt;Step back&lt;/h2&gt;

&lt;p&gt;These are just my initial thoughts after playing with the framework for a day and maybe I’ll change my mind after I’ve used it more extensively but right now I’m loving Angular and can’t see myself choosing Backbone the next time I start a big front end JS project.&lt;/p&gt;

&lt;p&gt;If you’re looking to get started with Angular I’d recommend you check out the following resources:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Dan Whalin’s &lt;a href=&quot;http://weblogs.asp.net/dwahlin/archive/2013/04/12/video-tutorial-angularjs-fundamentals-in-60-ish-minutes.aspx&quot;&gt;video tutorial&lt;/a&gt; really helped me to get the fundamentals of Angular.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.egghead.io/&quot;&gt;egghead.io&lt;/a&gt; is a great collection of screencasts covering some more specific cases.&lt;/li&gt;
  &lt;li&gt;The AngularJS &lt;a href=&quot;http://angularjs.org/&quot;&gt;project homepage&lt;/a&gt; (although the docs are not that beginner friendly).&lt;/li&gt;
&lt;/ul&gt;


          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Responsive Web Design is not a war</title>
        <link href="http://floatleft.com/notebook/responsive-web-design-is-not-a-war"/>
        <updated>2013-03-07T00:00:00+00:00</updated>
        <id>http://floatleft.com/notebook/responsive-web-design-is-not-a-war</id>
        <content type="html">
          &lt;p&gt;Recently there’s been a bit of a furore around a &lt;a href=&quot;https://gocardless.com/blog/unresponsive-design/&quot;&gt;post&lt;/a&gt; written after we at GoCardless launched our &lt;a href=&quot;https://gocardless.com/&quot;&gt;redesigned homepages&lt;/a&gt;. I wanted to make a few points – to be clear these are my thoughts, and they’re not necessarily shared by my colleagues.&lt;/p&gt;

&lt;h2 id=&quot;responsive-web-design-is-not-always-appropriate&quot;&gt;Responsive Web Design is not always appropriate&lt;/h2&gt;

&lt;p&gt;Elliot Jay Stocks says “&lt;q&gt;&lt;a href=&quot;http://elliotjaystocks.com/blog/responsive-web-design-the-war-has-not-yet-been-won/&quot;&gt;the war has not yet been won&lt;/a&gt;&lt;/q&gt;”. I think that’s a rather black and white way to look at a much more nuanced issue and that painting it as a war is not especially helpful. As with everything on the web there’s degrees of appropriateness.&lt;/p&gt;

&lt;p&gt;In a lot of cases, a well thought out responsive site is awesome. A great example would be a blog (go on, resize the window on this page). In other cases though it’s totally ill-suited.&lt;/p&gt;

&lt;p&gt;Take the example of the &lt;a href=&quot;https://gocardless.com/&quot;&gt;GoCardless homepage&lt;/a&gt;. There’s a fair amount of information here and not everyone wants to see all of it. By setting a small screen’s zoom level to 100% and inlining all of the content we’re forcing the user to scroll (and scroll and scroll) through potentially useless information. In my opinion it’s much better to provide a high level overview and let the user zoom into the interesting sections.&lt;/p&gt;

&lt;p&gt;I appreciate that Elliot is arguing that it’s not all about mobile but honestly which device are you using that has a very narrow screen but can’t zoom and pan?&lt;/p&gt;

&lt;p&gt;Let’s look at GoCardless on an iPhone as an example:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/img/posts/rwd-image.png&quot; alt=&quot;RWD comparison&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Which is a better experience? Which gives the user a quicker understanding of what’s happening?&lt;/p&gt;

&lt;p&gt;I think online maps are a good analogy. You wouldn’t open Google Maps, zoom in as far as possible and then start panning around to find the area you want to look at. Instead you look at the overview, pan around until you’re in broadly the right place and then start to focus in.&lt;/p&gt;

&lt;p&gt;In many cases, especially marketing and homepages, this is how I would like to use websites on a mobile device and I bet I’m not alone.&lt;/p&gt;

&lt;h2 id=&quot;obviously-its-not-all-bad&quot;&gt;Obviously it’s not all bad&lt;/h2&gt;

&lt;p&gt;That said, there’s clearly a place for responsive design. &lt;em&gt;I’m &lt;strong&gt;not&lt;/strong&gt; saying that it’s a fad and should be ignored&lt;/em&gt;. Blogs look great as a phone-width column of text, I wouldn’t want to be zooming and panning around GMail on my phone and that’s just two examples off the top of my head.&lt;/p&gt;

&lt;p&gt;All I’m saying is that as with everything there’s a time and a place and that I often find myself wishing I could see the full site rather than the scaled down responsive version I’m presented with. Let’s not go off the deep end with talk of wars and treat this as the nuanced issue that it is.&lt;/p&gt;


          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Prefilling Backbone model data</title>
        <link href="http://floatleft.com/notebook/prefilling-backbone-model-data"/>
        <updated>2012-12-31T00:00:00+00:00</updated>
        <id>http://floatleft.com/notebook/prefilling-backbone-model-data</id>
        <content type="html">
          &lt;p&gt;The &lt;a href=&quot;http://backbonejs.org/#FAQ-bootstrap&quot;&gt;Backbone docs&lt;/a&gt; suggest that you should bootstrap data into your page on load. This allows the application to be responsive and ready to use as soon as the JavaScript is loaded. This is not always possible though – for example if the app does not have any kind of server side templating or if it interacts with an external API. (DailyJS has &lt;a href=&quot;http://dailyjs.com/tags.html#backgoog&quot;&gt;a good example&lt;/a&gt; of this kind of application).&lt;/p&gt;

&lt;p&gt;In this case the application can seem slow to start as it first loads the JavaScript and then makes one or many API calls to populate the interface with data. Caching can help to a degree but this does not allow for new data to be fetched.&lt;/p&gt;

&lt;h2 id=&quot;cache-prefilling&quot;&gt;Cache Prefilling&lt;/h2&gt;

&lt;p&gt;I have a plugin called &lt;a href=&quot;https://github.com/mrappleton/backbone-fetch-cache&quot;&gt;Backbone fetch cache&lt;/a&gt; which provides an in-memory and &lt;code&gt;localStorage&lt;/code&gt; cache for Backbone’s fetch method. I’ve recently added a &lt;code&gt;prefill&lt;/code&gt; option which will return cached data immediately (where available) but still make the background API request.&lt;/p&gt;

&lt;p&gt;This is really nice because it allows us to present the user with a working interface immediately and then update the data in place as the AJAX requests complete. If you’ve ever used the &lt;a href=&quot;http://instagram.com/&quot;&gt;Instagram&lt;/a&gt; iPhone app you might notice that it does something similar, presenting an interface with the last available data whilst it makes background API calls to get the latest.&lt;/p&gt;

&lt;h2 id=&quot;use&quot;&gt;Use&lt;/h2&gt;

&lt;p&gt;The initial cache hit triggers all of the same events (&lt;code&gt;add&lt;/code&gt;, &lt;code&gt;reset&lt;/code&gt;, &lt;code&gt;change&lt;/code&gt; etc) as an actual call to &lt;code&gt;fetch&lt;/code&gt;, but the success callback is not fired until the AJAX call completes. Instead a new callback is available, &lt;code&gt;prefillSuccess&lt;/code&gt;:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;myModel.fetch({
  &lt;span style=&quot;color:#606&quot;&gt;prefill&lt;/span&gt;: &lt;span style=&quot;color:#069&quot;&gt;true&lt;/span&gt;,
  &lt;span style=&quot;color:#606&quot;&gt;prefillSuccess&lt;/span&gt;: someCallback, &lt;span style=&quot;color:#777&quot;&gt;// Fires when the cache hit happens&lt;/span&gt;
  &lt;span style=&quot;color:#606&quot;&gt;success&lt;/span&gt;: anotherCallback &lt;span style=&quot;color:#777&quot;&gt;// Fires after the AJAX call&lt;/span&gt;
});
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;If you prefer working with promises, the call to &lt;code&gt;fetch&lt;/code&gt; also returns an instance of &lt;a href=&quot;http://api.jquery.com/category/deferred-object/&quot;&gt;jQuery’s&lt;/a&gt; &lt;code&gt;$.Deferred&lt;/code&gt;. A progress event is triggered when the cache hit occurs and the promise is resolved when the AJAX call completes:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;var&lt;/span&gt; modelPromise = myModel.fetch({ &lt;span style=&quot;color:#606&quot;&gt;prefill&lt;/span&gt;: &lt;span style=&quot;color:#069&quot;&gt;true&lt;/span&gt; });
modelPromise.progress(someCallback); &lt;span style=&quot;color:#777&quot;&gt;// Fires when the cache hit happens&lt;/span&gt;
modelPromise.done(anotherCallback); &lt;span style=&quot;color:#777&quot;&gt;// Fires after the AJAX call&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;All in all I think this is a pretty nice solution to the problem of a slow initial page load for a single page JS application. As always the code and tests are available on &lt;a href=&quot;https://github.com/mrappleton/backbone-fetch-cache&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;


          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Backbone fetch cache</title>
        <link href="http://floatleft.com/notebook/backbone-fetch-cache"/>
        <updated>2012-12-17T00:00:00+00:00</updated>
        <id>http://floatleft.com/notebook/backbone-fetch-cache</id>
        <content type="html">
          &lt;p&gt;Building a Backbone application which interacts with an external API means a lot of calls to &lt;code&gt;model.fetch()&lt;/code&gt; and &lt;code&gt;collection.fetch()&lt;/code&gt;. This can be pretty inefficient especially if the API does not set cache headers on responses.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/mrappleton/backbone-fetch-cache&quot;&gt;Backbone fetch cache&lt;/a&gt; is a Backbone plugin which overrides the fetch method on Backbone models and collections to implement caching. Just include the script on your page and start calling fetch with &lt;code&gt;cache: true&lt;/code&gt; in the options:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;color:#777&quot;&gt;// Return cached data if available, otherwise make an AJAX request&lt;/span&gt;
myModel.fetch({ &lt;span style=&quot;color:#606&quot;&gt;cache&lt;/span&gt;: &lt;span style=&quot;color:#069&quot;&gt;true&lt;/span&gt; });
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;By default responses are cached in memory under &lt;code&gt;Backbone.fetchCache._cache&lt;/code&gt; and also persisted to &lt;code&gt;localStorage&lt;/code&gt; if available. This can be disabled by setting:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;color:#777&quot;&gt;// Cache in memory but not localStorage&lt;/span&gt;
Backbone.fetchCache.localStorage = &lt;span style=&quot;color:#069&quot;&gt;false&lt;/span&gt;;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Cached items are saved for 5 minutes by default, but this is also configurable by passing an expires option with a value in seconds to the fetch call:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;color:#777&quot;&gt;// Expire this value in 1 minute&lt;/span&gt;
myModel.fetch({ &lt;span style=&quot;color:#606&quot;&gt;cache&lt;/span&gt;: &lt;span style=&quot;color:#069&quot;&gt;true&lt;/span&gt;, &lt;span style=&quot;color:#606&quot;&gt;expires&lt;/span&gt;: &lt;span style=&quot;color:#00D&quot;&gt;60&lt;/span&gt; })
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;All options are passed through to the actual fetch call so you can still register &lt;code&gt;success&lt;/code&gt; and &lt;code&gt;error&lt;/code&gt; callbacks for actual AJAX requests. A promise is returned from the fake fetch method so the method signature should be identical whether the data comes from a cache hit or miss.&lt;/p&gt;

&lt;p&gt;The code is all &lt;a href=&quot;https://github.com/mrappleton/backbone-fetch-cache&quot;&gt;available on GitHub&lt;/a&gt; along with a &lt;a href=&quot;https://travis-ci.org/mrappleton/backbone-fetch-cache&quot;&gt;full set of tests&lt;/a&gt;.&lt;/p&gt;


          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Moving on</title>
        <link href="http://floatleft.com/notebook/moving-on"/>
        <updated>2012-12-15T00:00:00+00:00</updated>
        <id>http://floatleft.com/notebook/moving-on</id>
        <content type="html">
          &lt;p&gt;A quick personal announcement. I’m leaving my job at &lt;a href=&quot;http://mintdigital.com&quot;&gt;Mint Digital&lt;/a&gt; on the 19th December and starting as a developer at &lt;a href=&quot;http://gocardless.com&quot;&gt;GoCardless&lt;/a&gt; on the 7th January.&lt;/p&gt;

&lt;p&gt;I’ve had a blast working with the talented folks at Mint and I’ll be extremely sad to leave but I’m also really excited about the challenge at GoCardless and can’t wait to get started.&lt;/p&gt;


          
        </content>
      </entry>
    
  
    
      <entry>
        <title>CoffeeScript is just JavaScript</title>
        <link href="http://floatleft.com/notebook/coffeescript-is-just-javascript"/>
        <updated>2012-12-03T00:00:00+00:00</updated>
        <id>http://floatleft.com/notebook/coffeescript-is-just-javascript</id>
        <content type="html">
          &lt;p&gt;Most of the JavaScript I have written over the last year has actually been &lt;a href=&quot;http://coffeescript.org/&quot;&gt;CoffeeScript&lt;/a&gt;. It occurred to me the other day that I’m in the same mental mode whether I’m writing JS or CS and I think that is because at it’s heart CoffeeScript is just a more succinct way to write the same language.&lt;/p&gt;

&lt;p&gt;There is very little extra functionality that you get with CoffeeScript that you couldn’t do with plain JS, it’s just nicer to write. A good example is the &lt;a href=&quot;http://coffeescript.org/#classes&quot;&gt;&lt;code&gt;class&lt;/code&gt;&lt;/a&gt; keyword, all it does is produce a constructor function with methods on the &lt;code&gt;prototype&lt;/code&gt; object – easy enough with JavaScript but more expressive and succinct with CoffeeScript.&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;class&lt;/span&gt; Bacon
  eat: -&amp;gt; &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;nom&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Compiles to&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;Bacon&lt;/span&gt;() {}

Bacon.prototype.&lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;eat&lt;/span&gt; = &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;() {
  &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;nom&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;;
};
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;If I were douchey enough I’d say it was like poetry. Actually I am and it is.&lt;/p&gt;

&lt;p&gt;I think the reason for this is that CoffeeScript doesn’t change any of the fundamental rules of the language. &lt;code&gt;this&lt;/code&gt; still behaves the same way and you can still use &lt;code&gt;call&lt;/code&gt; and &lt;code&gt;apply&lt;/code&gt; to invoke functions however you like regardless of where they originate.&lt;/p&gt;

&lt;p&gt;There was a brief period where loops would fake a new scope with an inner function but happily that’s gone. In fact the only fundamental change I can think of is that variables are local to the current scope by default and I think most people would agree that loosing &lt;code&gt;var&lt;/code&gt; is an improvement.&lt;/p&gt;

&lt;p&gt;For me this is why compile to JS languages like &lt;a href=&quot;http://www.dartlang.org/&quot;&gt;Dart&lt;/a&gt; and &lt;a href=&quot;http://www.typescriptlang.org/&quot;&gt;TypeScript&lt;/a&gt; are completely uninteresting. I don’t want another language, just a way to write the words &lt;code&gt;function&lt;/code&gt; and &lt;code&gt;prototype&lt;/code&gt; a little less often and with fewer curly braces and semicolons.&lt;/p&gt;


          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Grunt Coffee Server</title>
        <link href="http://floatleft.com/notebook/grunt-coffee-server"/>
        <updated>2012-11-18T00:00:00+00:00</updated>
        <id>http://floatleft.com/notebook/grunt-coffee-server</id>
        <content type="html">
          &lt;p&gt;TL;DR I wrote &lt;a href=&quot;https://npmjs.org/package/grunt-coffee-server&quot;&gt;a Grunt task&lt;/a&gt; to live compile CoffeeScript for local development.&lt;/p&gt;

&lt;h2 id=&quot;full-story&quot;&gt;Full story&lt;/h2&gt;
&lt;p&gt;Somewhat inspired by my colleague &lt;a href=&quot;http://philnash.co.uk/&quot;&gt;Phil’s&lt;/a&gt; &lt;a href=&quot;https://twitter.com/philnash/status/270135099599749121&quot;&gt;tweet&lt;/a&gt;, I’ve written a &lt;a href=&quot;http://gruntjs.com/&quot;&gt;Grunt&lt;/a&gt; plugin to make it easy to start writing any JavaScript project in CoffeeScript.&lt;/p&gt;

&lt;p&gt;It’s a simple static web server with a twist – request a .js file and it will be returned if it exists. If it doesn’t exist then the server will try and find a .coffee version of the file and return the compiled output if it can.&lt;/p&gt;

&lt;p&gt;N.B. It does not deal with compilation for deployment, &lt;a href=&quot;https://npmjs.org/package/grunt-contrib-coffee&quot;&gt;there’s already a plugin&lt;/a&gt; for that.&lt;/p&gt;

&lt;h2 id=&quot;usage&quot;&gt;Usage&lt;/h2&gt;
&lt;p&gt;This is packaged up as a Grunt task so you’ll need to install Grunt from &lt;a href=&quot;https://npmjs.org/&quot;&gt;NPM&lt;/a&gt; first (might as well do that globally):&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;npm install -g grunt
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Then install the task:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;npm install grunt-coffee-server
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Next you’ll need a gruntfile:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;grunt init:gruntfile
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Follow the instructions and take a look in your new &lt;code&gt;grunt.js&lt;/code&gt; file. We need to register the new task by adding the following line:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;grunt.loadNpmTasks(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;grunt-coffee-server&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;);
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;There are also a couple of configuration options available which are read from the &lt;code&gt;server&lt;/code&gt; config key:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;grunt.initConfig({
  &lt;span style=&quot;color:#606&quot;&gt;server&lt;/span&gt;: {
    &lt;span style=&quot;color:#606&quot;&gt;port&lt;/span&gt;: &lt;span style=&quot;color:#00D&quot;&gt;1337&lt;/span&gt; &lt;span style=&quot;color:#777&quot;&gt;// defaults to 3000 if not set&lt;/span&gt;
    base: &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;./public&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;color:#777&quot;&gt;// defaults to ./ if not set&lt;/span&gt;
  }
});
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Finally run the server:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;grunt coffee-server
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;I’ve written this kind of server manually a few times now for local development so I know it’ll be handy for me – hopefully it’ll be useful for you too.&lt;/p&gt;

&lt;p&gt;It’s on &lt;a href=&quot;https://github.com/mrappleton/grunt-coffee-server&quot;&gt;GitHub&lt;/a&gt; so feel free to fork, pull request etc!&lt;/p&gt;

          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Using Grunt and Jasmine with AMD</title>
        <link href="http://floatleft.com/notebook/using-grunt-and-jasmine-with-amd"/>
        <updated>2012-10-03T00:00:00+01:00</updated>
        <id>http://floatleft.com/notebook/using-grunt-and-jasmine-with-amd</id>
        <content type="html">
          &lt;p&gt;Since &lt;a href=&quot;http://floatleft.com/notebook/testing-your-javascript-with-jasmine-and-grunt&quot;&gt;yesterday’s post&lt;/a&gt; on running Jasmine specs with Grunt I have been working to integrate with a project which uses &lt;a href=&quot;http://requirejs.org&quot;&gt;RequireJS&lt;/a&gt;. The &lt;a href=&quot;https://github.com/jasmine-contrib/grunt-jasmine-runner&quot;&gt;Grunt Jasmine runner&lt;/a&gt; task I am using does not support AMD specs so I have created a fork which is &lt;a href=&quot;https://github.com/mrappleton/grunt-jasmine-runner&quot;&gt;available on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To use it you will need to specify the repo URL in your &lt;code&gt;package.json&lt;/code&gt; file…&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;dependencies&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;: {
  &lt;span style=&quot;color:#606&quot;&gt;&lt;span style=&quot;color:#404&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;grunt-jasmine-runner&lt;/span&gt;&lt;span style=&quot;color:#404&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;: &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;git://github.com/mrappleton/grunt-jasmine-runner.git&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
}
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;If the &lt;code&gt;amd&lt;/code&gt; flag is set in the &lt;code&gt;grunt.js&lt;/code&gt; config file specs will be loaded via an AMD require call. This does not make an assumption about the AMD library being used, you must specify the path to that in the helpers option. Here’s a full example gruntfile:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;module.&lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;exports&lt;/span&gt; = &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;(grunt) {
  grunt.initConfig({
    &lt;span style=&quot;color:#606&quot;&gt;jasmine&lt;/span&gt; : {
      &lt;span style=&quot;color:#606&quot;&gt;amd&lt;/span&gt;: &lt;span style=&quot;color:#069&quot;&gt;true&lt;/span&gt;,
      &lt;span style=&quot;color:#777&quot;&gt;// Your Jasmine spec files&lt;/span&gt;
      &lt;span style=&quot;color:#606&quot;&gt;specs&lt;/span&gt; : &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;specs/**/*spec.js&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,
      &lt;span style=&quot;color:#777&quot;&gt;// Your spec helper files&lt;/span&gt;
      &lt;span style=&quot;color:#606&quot;&gt;helpers&lt;/span&gt;: [
        &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;/path/to/require.js&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,
        &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;/path/to/requireConfig.js&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
      ],
    }
  });

  &lt;span style=&quot;color:#777&quot;&gt;// Register tasks.&lt;/span&gt;
  grunt.loadNpmTasks(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;grunt-jasmine-runner&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;);

  &lt;span style=&quot;color:#777&quot;&gt;// Default task.&lt;/span&gt;
  grunt.registerTask(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;default&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;jasmine&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;);
};
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This assumes that your spec files are AMD modules which require the source files as necessary, e.g.&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;define([&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;/src/myModule.js&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;], &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;(MyModule){
  describe(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;MyModule&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;(){
    &lt;span style=&quot;color:#777&quot;&gt;// etc...&lt;/span&gt;
  });
});
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The spec runner HTML file will then &lt;code&gt;require&lt;/code&gt; each spec file in turn and execute the contents.&lt;/p&gt;

&lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;

&lt;p&gt;This is not the most flexible implementation, but it works for my use case and I think is worth releasing. I opened a &lt;a href=&quot;https://github.com/jasmine-contrib/grunt-jasmine-runner/pull/9&quot;&gt;pull request&lt;/a&gt; on the &lt;a href=&quot;https://github.com/jasmine-contrib/grunt-jasmine-runner&quot;&gt;main repo&lt;/a&gt; which was (quite reasonably) declined as they are apparently already working on AMD support.&lt;/p&gt;

&lt;p&gt;I’ll most probably switch back to the original version once AMD support arrives but for now this fork will do nicely for me and I hope it can be useful to others.&lt;/p&gt;

          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Testing your JavaScript with Jasmine and Grunt</title>
        <link href="http://floatleft.com/notebook/testing-your-javascript-with-jasmine-and-grunt"/>
        <updated>2012-10-02T00:00:00+01:00</updated>
        <id>http://floatleft.com/notebook/testing-your-javascript-with-jasmine-and-grunt</id>
        <content type="html">
          &lt;p&gt;I’ve &lt;a href=&quot;http://floatleft.com/notebook/backbone-has-made-me-a-better-programmer&quot;&gt;written&lt;/a&gt; about clean modular JavaScript and a nice benefit of writing code that way is testability. Recently I’ve been using &lt;a href=&quot;http://pivotal.github.com/jasmine/&quot;&gt;Jasmine&lt;/a&gt; to write JS unit tests having also played with &lt;a href=&quot;http://visionmedia.github.com/mocha/&quot;&gt;Mocha&lt;/a&gt; and &lt;a href=&quot;http://qunitjs.com/&quot;&gt;Qunit&lt;/a&gt;. Jasmine has a clean interface, runs specs inside an HTML page and I find the finished spec files extremely readable thanks to rspec style test nesting.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/img/posts/jasmine-example.png&quot; alt=&quot;Jasmine example spec output&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Jasmine’s HTML spec runner is great for writing and running tests locally, but it is not very practical for integrating into a CI server – for that we need a command line tool.&lt;/p&gt;

&lt;h2 id=&quot;grunt&quot;&gt;Grunt&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;http://gruntjs.com&quot;&gt;Grunt&lt;/a&gt; is a really cool build tool for JavaScript. By default it includes tasks for linting, concatenating &amp;amp; minifying and running Qunit tests in a headless &lt;a href=&quot;http://phantomjs.org/&quot;&gt;Phantomjs&lt;/a&gt; instance. It has a nice collection of tasks available as modules on &lt;a href=&quot;https://npmjs.org/&quot;&gt;NPM&lt;/a&gt; including a few for running Jasmine specs.&lt;/p&gt;

&lt;p&gt;To get up and running we need to install Grunt, Phantomjs and the &lt;a href=&quot;https://github.com/jasmine-contrib/grunt-jasmine-runner&quot;&gt;Grunt Jasmine runner&lt;/a&gt; task from the command line (I’m assuming you have &lt;a href=&quot;http://nodejs.org/&quot;&gt;node&lt;/a&gt; and NPM installed):&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;$ cd /path/to/project
$ npm install grunt
$ npm install grunt-jasmine-runner
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;If you’re on a Mac and use Homebrew you can grab PhantomJS:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;$ brew install phantomjs
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;For other platforms there are a number of &lt;a href=&quot;http://phantomjs.org/download.html&quot;&gt;pre built binaries&lt;/a&gt; available.&lt;/p&gt;

&lt;p&gt;Now all we need to do is add the appropriate configuration to a &lt;code&gt;grunt.js&lt;/code&gt; file in the project’s root…&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;module.&lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;exports&lt;/span&gt; = &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;(grunt) {
  grunt.initConfig({
    &lt;span style=&quot;color:#606&quot;&gt;jasmine&lt;/span&gt; : {
      &lt;span style=&quot;color:#777&quot;&gt;// Your project's source files&lt;/span&gt;
      &lt;span style=&quot;color:#606&quot;&gt;src&lt;/span&gt; : &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;src/**/*.js&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,
      &lt;span style=&quot;color:#777&quot;&gt;// Your Jasmine spec files&lt;/span&gt;
      &lt;span style=&quot;color:#606&quot;&gt;specs&lt;/span&gt; : &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;specs/**/*spec.js&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,
      &lt;span style=&quot;color:#777&quot;&gt;// Your spec helper files&lt;/span&gt;
      &lt;span style=&quot;color:#606&quot;&gt;helpers&lt;/span&gt; : &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;specs/helpers/*.js&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
    }
  });

  &lt;span style=&quot;color:#777&quot;&gt;// Register tasks.&lt;/span&gt;
  grunt.loadNpmTasks(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;grunt-jasmine-runner&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;);

  &lt;span style=&quot;color:#777&quot;&gt;// Default task.&lt;/span&gt;
  grunt.registerTask(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;default&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;jasmine&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;);
};
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;…and run the tests!&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;$ grunt jasmine
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/public/img/posts/jasmine-grunt.png&quot; alt=&quot;Jasmine command line output&quot; /&gt;&lt;/p&gt;

          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Backbone has made me a better programmer</title>
        <link href="http://floatleft.com/notebook/backbone-has-made-me-a-better-programmer"/>
        <updated>2012-08-24T00:00:00+01:00</updated>
        <id>http://floatleft.com/notebook/backbone-has-made-me-a-better-programmer</id>
        <content type="html">
          &lt;blockquote class=&quot;twitter-tweet tw-align-center&quot;&gt;&lt;p&gt;the more i use backbone.js, the more i love it. probably because the more I use it the better I get at real javascript, not a framework.&lt;/p&gt;&amp;mdash; Johnny Megahan (@johnmegahan) &lt;a href=&quot;https://twitter.com/johnmegahan/status/237299183218987008&quot; data-datetime=&quot;2012-08-19T21:25:08+00:00&quot;&gt;August 19, 2012&lt;/a&gt;&lt;/blockquote&gt;
&lt;script src=&quot;//platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

&lt;p&gt;I saw &lt;a href=&quot;https://twitter.com/jashkenas&quot;&gt;Jeremy Ashkenas&lt;/a&gt; retweet this and it really struck a chord with me. I started playing with &lt;a href=&quot;http://backbonejs.org/&quot;&gt;Backbone&lt;/a&gt; about a year ago and have since used it on large and small projects at work and for fun.&lt;/p&gt;

&lt;p&gt;These last two weeks I have been refactoring some JavaScript on &lt;a href=&quot;http://stickygram.com&quot;&gt;StickyGram&lt;/a&gt; and I was really surprised at the state of the code I had written not all that long ago. I have been rewriting it to use a number of design patterns that I have (somewhat) inadvertently picked up from Backbone (and &lt;a href=&quot;http://underscorejs.org/&quot;&gt;underscore&lt;/a&gt;).&lt;/p&gt;

&lt;h2 id=&quot;one-object-one-responsibility&quot;&gt;One object one responsibility&lt;/h2&gt;
&lt;p&gt;We all write clean encapsulated object oriented JavaScript right? Guys? No me neither – it’s so easy to just fire off an event, nest a few levels of callbacks and be done with it.&lt;/p&gt;

&lt;p&gt;Here’s an example. We get some data via an xhr request, append it with a fade effect and then remove some other element.&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$&lt;/span&gt;.ajax({
  &lt;span style=&quot;color:#606&quot;&gt;url&lt;/span&gt;: &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;/wherever&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,
  &lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;success&lt;/span&gt;: &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;(data, status, xhr) {
    &lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$&lt;/span&gt;(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;selector&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).append(&lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$&lt;/span&gt;(data).hide().fadeIn(&lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;(){
      &lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$&lt;/span&gt;(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;other-selector&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).remove();
    }));
  }
});
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This is simple to write initially, but it becomes very tricky to extend. Say we also want to update another part of the document with a notice to say that the request was successful:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$&lt;/span&gt;.ajax({
  &lt;span style=&quot;color:#606&quot;&gt;url&lt;/span&gt;: &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;/wherever&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,
  &lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;success&lt;/span&gt;: &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;(data, status, xhr) {
    &lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$&lt;/span&gt;(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;selector&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).append(&lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$&lt;/span&gt;(data).hide().fadeIn(&lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;(){
      &lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$&lt;/span&gt;(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;other-selector&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).remove();
    }));
    &lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$&lt;/span&gt;(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;yet-another-selector&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).text(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;Request successful&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;);
  }
});
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;That success callback is gradually getting to be responsible for a lot of different things and is starting to get pretty tricky to read. This only gets worse as other developers come to the code and just need to add a small bit of extra functionality. I find myself cursing them later for the messy code when actually it’s &lt;strong&gt;my fault&lt;/strong&gt; for writing it this way in the first place.&lt;/p&gt;

&lt;p&gt;Here’s a much nicer way to deal with this:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;DataModel&lt;/span&gt;() {
  &lt;span style=&quot;color:#963&quot;&gt;this&lt;/span&gt;.url = &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;/wherever&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;;
}

DataModel.prototype.&lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;getData&lt;/span&gt; = &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;() {
  &lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$&lt;/span&gt;.ajax({
    &lt;span style=&quot;color:#606&quot;&gt;url&lt;/span&gt;: &lt;span style=&quot;color:#963&quot;&gt;this&lt;/span&gt;.url,
    &lt;span style=&quot;color:#606&quot;&gt;context&lt;/span&gt;: &lt;span style=&quot;color:#963&quot;&gt;this&lt;/span&gt;,
    &lt;span style=&quot;color:#606&quot;&gt;success&lt;/span&gt;: &lt;span style=&quot;color:#963&quot;&gt;this&lt;/span&gt;.onSuccess
  });
};

DataModel.prototype.&lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;onSuccess&lt;/span&gt; = &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;(data) {
  &lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$&lt;/span&gt;(window).trigger(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;DataModel:success&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, data);
};

&lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;var&lt;/span&gt; dataModel = &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;new&lt;/span&gt; DataModel();
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Now we have a &lt;code&gt;dataModel&lt;/code&gt; object which is concerned only with making the request. It triggers an event when it is done which we can listen for in other objects.&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;ListView&lt;/span&gt;(el) {
  &lt;span style=&quot;color:#963&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$el&lt;/span&gt; = &lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$&lt;/span&gt;(el);
  &lt;span style=&quot;color:#963&quot;&gt;this&lt;/span&gt;.bindEvents();
}

ListView.prototype.&lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;bindEvents&lt;/span&gt; = &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;() {
  &lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$&lt;/span&gt;(window).on(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;DataModel:success&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$&lt;/span&gt;.proxy(&lt;span style=&quot;color:#963&quot;&gt;this&lt;/span&gt;.addData, &lt;span style=&quot;color:#963&quot;&gt;this&lt;/span&gt;));
};

ListView.prototype.&lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;addData&lt;/span&gt; = &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;(data) {
  &lt;span style=&quot;color:#963&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$el&lt;/span&gt;.append(&lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$&lt;/span&gt;(data).hide().fadeIn(&lt;span style=&quot;color:#963&quot;&gt;this&lt;/span&gt;.removeOtherThing));
};

ListView.prototype.&lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;removeOtherThing&lt;/span&gt; = &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;(data) {
  &lt;span style=&quot;color:#963&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color:#369;font-weight:bold&quot;&gt;$el&lt;/span&gt;.find(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;other-selector&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).remove();
};

&lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;var&lt;/span&gt; listView = &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;new&lt;/span&gt; ListView(&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;selector&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;);
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Right now we have more lines of code, but what we also have is two separate objects each performing a discrete function. Each object has a number of methods and the methods each do one thing. It’s worth noting that we could easily write unit tests for this code – try doing that for the first example…&lt;/p&gt;

&lt;p&gt;So now when we need to add another callback to the AJAX completion all we need to do is create a new object type which will listen for the same &lt;code&gt;DataModel:success&lt;/code&gt; event and do its thing independently of our &lt;code&gt;listView&lt;/code&gt;. That’s pretty awesome and it means that our original code can stay responsible for the one task it was designed.&lt;/p&gt;

&lt;h2 id=&quot;thanks-backbone&quot;&gt;Thanks, Backbone!&lt;/h2&gt;
&lt;p&gt;This example follows the same Model/View pattern as Backbone without actually using the library. Actually it’s just well structured code but it’s often easy to take the (seemingly) quicker option.&lt;/p&gt;

&lt;p&gt;I’m spending more time up front thinking about the structure and maintainability of my code in the expectation that it will prevent it from getting to that tangled spaghetti-mess that we all hate coming back to and that is definitely a good thing.&lt;/p&gt;

          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Making Sublime Text 2 Beautiful</title>
        <link href="http://floatleft.com/notebook/making-sublime-text-2-beautiful"/>
        <updated>2012-08-06T00:00:00+01:00</updated>
        <id>http://floatleft.com/notebook/making-sublime-text-2-beautiful</id>
        <content type="html">
          &lt;p&gt;I’ve been using the &lt;a href=&quot;http://blog.macromates.com/2011/textmate-2-0-alpha/&quot;&gt;TextMate 2 alpha&lt;/a&gt; since christmas, but sometime in the last few weeks I got that sinking feeling that it was not getting better quickly enough and probably never would. I played around with &lt;a href=&quot;http://chocolatapp.com/&quot;&gt;Chocolat&lt;/a&gt; and &lt;a href=&quot;http://www.sublimetext.com/&quot;&gt;Sublime Text 2&lt;/a&gt; as potential alternatives and settled on Sublime because it is blazing fast and seems very stable.&lt;/p&gt;

&lt;p&gt;It is blazing fast and stable but it’s also pretty ugly. This might not bother a lot of people, but it bothers me – this is the Mac, &lt;a href=&quot;http://5by5.tv/buildanalyze/88&quot;&gt;things are pretty here&lt;/a&gt;. This is what I did to make Sublime Text look, er sublime (sorry).&lt;/p&gt;

&lt;h2 id=&quot;replace-that-god-awful-default-theme&quot;&gt;Replace that god-awful default theme&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;/public/img/posts/my-sublime-setup.png&quot; alt=&quot;Screengrab of my Sublime Text 2 setup&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/cafarm/aqua-theme&quot;&gt;Aqua&lt;/a&gt; is a great looking theme which brings a much more mac-like feel to Sublime. I took this theme and tweaked it slightly to &lt;a href=&quot;http://sublimetext.userecho.com/topic/19274-theming-of-the-sidebar/#comment_110552&quot;&gt;show file icons in the sidebar&lt;/a&gt;. My variation on the theme is available on &lt;a href=&quot;https://github.com/mrappleton/aqua-theme&quot;&gt;GitHub&lt;/a&gt; or you can add the repo to &lt;a href=&quot;http://wbond.net/sublime_packages/package_control&quot;&gt;package control&lt;/a&gt;: &lt;code&gt;git@github.com:mrappleton/aqua-theme.git&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;a-nicer-icon&quot;&gt;A nicer icon&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;/public/img/posts/sublime-icon.jpg&quot; alt=&quot;Replacement Sublime Text 2 Icon&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I quite liked the default icon but found it really difficult to pick out when I was switching between apps with cmd-tab. I found this icon by Dmitry Svetlichny &lt;a href=&quot;http://dribbble.com/shots/468176-Icon-Sublime-Text-for-themes-with-white-background&quot;&gt;on Dribbble&lt;/a&gt; via a tweet from &lt;a href=&quot;https://twitter.com/chrisrowe/status/230250793670950912&quot;&gt;Chris Rowe&lt;/a&gt;. It’s easier to spot and I think much prettier too.&lt;/p&gt;

&lt;h2 id=&quot;syntax-highlighting&quot;&gt;Syntax Highlighting&lt;/h2&gt;
&lt;p&gt;I was having trouble getting used to Sublime and I figured that it was down to things being similar but not identical to my previous editor. I switched from &lt;a href=&quot;http://railscasts.com/about/&quot;&gt;Railscasts&lt;/a&gt; to a new theme as a kind of constant reminder that I was using something different and not to expect it to be exactly like TextMate.&lt;/p&gt;

&lt;p&gt;I love the dark on light Espresso theme included in Aqua which I have been using with a single tweak to make the background a very light grey and the line highlight white.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/img/posts/espresso-syntax.png&quot; alt=&quot;Espresso syntax hilighting&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This tweaked version is included in &lt;a href=&quot;https://github.com/mrappleton/aqua-theme&quot;&gt;my fork of Aqua&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Overall I’m really pleased that Sublime is flexible enough to allow this kind of customisation but it would be nice if the developers could spend some time on making it a more native Mac experience. In the mean time I’m really happy with my current setup.&lt;/p&gt;

          
        </content>
      </entry>
    
  
    
      <entry>
        <title>JavaScript object creation performance</title>
        <link href="http://floatleft.com/notebook/javascript-object-creation-performance"/>
        <updated>2012-07-23T00:00:00+01:00</updated>
        <id>http://floatleft.com/notebook/javascript-object-creation-performance</id>
        <content type="html">
          &lt;p&gt;I gave a talk at the London JS meetup last Monday evening where I compared the performance of two popular object creation patterns in JavaScript – the slides are available at &lt;a href=&quot;https://speakerdeck.com/u/appltn/p/object-creation-pattern-performance&quot;&gt;Speaker Deck&lt;/a&gt;. Here’s a quick rundown of what  covered.&lt;/p&gt;

&lt;h2 id=&quot;module-pattern&quot;&gt;Module Pattern&lt;/h2&gt;
&lt;p&gt;I like using the module pattern for a number of reasons – not least that it provides a new function scope which can be used to hide variables and methods from the public interface of the object. The module pattern looks like this:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;Module&lt;/span&gt; = &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;(arg){&lt;span style=&quot;color:#F00;background-color:#FAA&quot;&gt; &lt;/span&gt;
  &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;var&lt;/span&gt; self = {&lt;span style=&quot;color:#F00;background-color:#FAA&quot;&gt; &lt;/span&gt;
    &lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;getArg&lt;/span&gt;: &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;(){
      &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;return&lt;/span&gt; arg1;
    }
  };
  &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;return&lt;/span&gt; self;
};
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;h2 id=&quot;constructor-functions&quot;&gt;Constructor Functions&lt;/h2&gt;
&lt;p&gt;Constructor functionas are built in to JavaScript. Calling any function with the &lt;code&gt;new&lt;/code&gt; keyword will cause the value of &lt;code&gt;this&lt;/code&gt; to be bound to the function object. This means that we can assign methods and properties to &lt;code&gt;this&lt;/code&gt; and access them later from the returned object.&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;Constructor&lt;/span&gt; = &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;(arg){
  &lt;span style=&quot;color:#963&quot;&gt;this&lt;/span&gt;.arg = arg;&lt;span style=&quot;color:#F00;background-color:#FAA&quot;&gt; &lt;/span&gt;
};
Constructor.prototype.&lt;span style=&quot;color:#06B;font-weight:bold&quot;&gt;getArg&lt;/span&gt; = &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;function&lt;/span&gt;(){&lt;span style=&quot;color:#F00;background-color:#FAA&quot;&gt; &lt;/span&gt;
  &lt;span style=&quot;color:#080;font-weight:bold&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color:#963&quot;&gt;this&lt;/span&gt;.arg;&lt;span style=&quot;color:#F00;background-color:#FAA&quot;&gt; &lt;/span&gt;
};
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;h2 id=&quot;performance-testing&quot;&gt;Performance Testing&lt;/h2&gt;
&lt;p&gt;I wanted to figure out which pattern is faster to instantiate and to call methods on so I set up a number of tests on &lt;a href=&quot;http://jsperf.com/&quot;&gt;JSPerf&lt;/a&gt;:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;http://jsperf.com/object-instantiation-test&quot;&gt;Object instantiation&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://jsperf.com/method-calling-test&quot;&gt;Method calls on instantiated objects&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://jsperf.com/intantiation-and-method-call-test&quot;&gt;Object instantiation and method calls&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://jsperf.com/instantiation-with-inheritance-test&quot;&gt;Object instantiation with inheritance&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://jsperf.com/method-calling-with-inheritance-test&quot;&gt;Method calls on instantiated objects with inheritance&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://jsperf.com/instantiation-and-method-call-test-with-inheritance&quot;&gt;Object instantiation and method calls with inheritance&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;vague-conclusions&quot;&gt;Vague Conclusions&lt;/h2&gt;
&lt;p&gt;The test results seem to indicate that Constructor functions are faster at instantiating an object than the module pattern. This makes sense to me as they are built into the language.&lt;/p&gt;

&lt;p&gt;The module patern seems faster at calling methods once the object is instantiated. Adding a level of inheritance into the mix doesn’t seem to make too much of a difference.&lt;/p&gt;

&lt;p&gt;For me this is useful information to have in the back of my mind as I am coding. There was some interesting discussion in the Q&amp;amp;A after my talk about premature optimization and judging each case on its merits. We discussed&lt;/p&gt;

&lt;p&gt;I think this kind of benchmarking is an interesting excercise and is useful to gain a better understanding of the language, but ultimately you need to be making performance decisions based on actual data from your actual code.&lt;/p&gt;

          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Speaking at London JS July 2012</title>
        <link href="http://floatleft.com/notebook/speaking-london-js"/>
        <updated>2012-07-07T00:00:00+01:00</updated>
        <id>http://floatleft.com/notebook/speaking-london-js</id>
        <content type="html">
          &lt;p&gt;I’m speaking at the &lt;a href=&quot;http://eventhandler.co.uk/&quot;&gt;LondonJS&lt;/a&gt; meetup next Monday, 16th July. My talk will look at the relative performance of different approaches for creating JavaScript objects.&lt;/p&gt;

&lt;p&gt;Tickets are all gone but you can get on the &lt;a href=&quot;http://londonjs-12.eventbrite.com&quot;&gt;waiting list&lt;/a&gt; if you’re interested.&lt;/p&gt;

          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Require.js 2.0</title>
        <link href="http://floatleft.com/notebook/requirejs-20"/>
        <updated>2012-07-02T00:00:00+01:00</updated>
        <id>http://floatleft.com/notebook/requirejs-20</id>
        <content type="html">
          &lt;p&gt;At some point over the last few weeks &lt;a href=&quot;http://requirejs.org/&quot;&gt;Require.js 2.0&lt;/a&gt; was released. It’s a really nice update which addresses a couple of pain points which I have experienced whilst using it.&lt;/p&gt;

&lt;h2 id=&quot;non-amd-shim&quot;&gt;Non AMD Shim&lt;/h2&gt;
&lt;p&gt;My favourite new feature is the built in shim for loading non-AMD compatible libraries. Loading non-AMD JavaScript in 1.x either required altering the code to include a define call or using the order plugin to manually configure the load order for different plugins.&lt;/p&gt;

&lt;p&gt;Neither option was particularly nice so in 2.0 we get the option to shim files in &lt;code&gt;requirejs.config()&lt;/code&gt;, for example:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;requirejs.config({
  &lt;span style=&quot;color:#606&quot;&gt;shim&lt;/span&gt;: {
    &lt;span style=&quot;color:#606&quot;&gt;&lt;span style=&quot;color:#404&quot;&gt;'&lt;/span&gt;&lt;span&gt;backbone&lt;/span&gt;&lt;span style=&quot;color:#404&quot;&gt;'&lt;/span&gt;&lt;/span&gt;: {
      &lt;span style=&quot;color:#777&quot;&gt;// Define dependencies&lt;/span&gt;
      &lt;span style=&quot;color:#606&quot;&gt;deps&lt;/span&gt;: [&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;underscore&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;jquery&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;],
      &lt;span style=&quot;color:#777&quot;&gt;// Set a value for the file to export&lt;/span&gt;
      &lt;span style=&quot;color:#606&quot;&gt;exports&lt;/span&gt;: &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;Backbone&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
    },
    &lt;span style=&quot;color:#606&quot;&gt;&lt;span style=&quot;color:#404&quot;&gt;'&lt;/span&gt;&lt;span&gt;backbone.validation&lt;/span&gt;&lt;span style=&quot;color:#404&quot;&gt;'&lt;/span&gt;&lt;/span&gt;: {
      &lt;span style=&quot;color:#606&quot;&gt;deps&lt;/span&gt;: [&lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;backbone&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;],
      &lt;span style=&quot;color:#606&quot;&gt;exports&lt;/span&gt;: &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;Backbone.Validation&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
    }
  }
});
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This makes it much easier to update non AMD libraries without worrying about breaking a wrapper. There are a &lt;a href=&quot;https://github.com/jrburke/requirejs/wiki/Upgrading-to-RequireJS-2.0#wiki-shim&quot;&gt;few caveats&lt;/a&gt; to using this, but on the whole it’s a big improvement.&lt;/p&gt;

&lt;h2 id=&quot;fallback-paths&quot;&gt;Fallback paths&lt;/h2&gt;
&lt;p&gt;2.0 has introduced errbacks - callbacks for error states. This allows us to account for modules which don’t load. A nice use for this is to specify a fallback path for the module - e.g. if we’re using a CDN version of a file.&lt;/p&gt;

&lt;p&gt;Again this can be set in &lt;code&gt;requirejs.config()&lt;/code&gt;:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;requirejs.config({
  &lt;span style=&quot;color:#606&quot;&gt;paths&lt;/span&gt;: {
    &lt;span style=&quot;color:#606&quot;&gt;jquery&lt;/span&gt;: [
      &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,
      &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;lib/jquery&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
    ]
  }
});
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Require will attempt to load the module from each path specified in the array until it is succesful.&lt;/p&gt;

&lt;h2 id=&quot;lazy-evaluation&quot;&gt;Lazy evaluation&lt;/h2&gt;
&lt;p&gt;In 1.x any built file (a bundle of a number of modules produced by the &lt;a href=&quot;http://requirejs.org/docs/optimization.html&quot;&gt;optimizer&lt;/a&gt;) would all be evaluated on load. This has changed in 2.0 and now code is only evaluated as it is called. This is a nice performance win as it defers a lot of browser work until it is needed.&lt;/p&gt;

&lt;p&gt;These are my favourite new features, but there’s plenty more so &lt;a href=&quot;https://github.com/jrburke/requirejs/wiki/Upgrading-to-RequireJS-2.0&quot;&gt;check it out&lt;/a&gt;.&lt;/p&gt;

          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Mac-like text navigation in Zsh</title>
        <link href="http://floatleft.com/notebook/mac-like-text-navigation-in-zsh"/>
        <updated>2012-06-27T00:00:00+01:00</updated>
        <id>http://floatleft.com/notebook/mac-like-text-navigation-in-zsh</id>
        <content type="html">
          &lt;p&gt;I switched my shell from Bash to &lt;a href=&quot;http://www.zsh.org/&quot;&gt;Zsh&lt;/a&gt; a few months ago and have been tinkering with &lt;a href=&quot;https://github.com/mrappleton/dotfiles&quot;&gt;my dotfiles&lt;/a&gt; ever since.&lt;/p&gt;

&lt;p&gt;One cool trick I’ve found is to configure Mac-like text navigation. I’m a Textmate user and my fingers are hard coded to hit cmd ← to skip to the begining of a line, opt → to jump to the end of a word etc.&lt;/p&gt;

&lt;p&gt;I believe that OSX’s built in terminal does this automatically since 10.7, but I’m using iTerm2 so needed something else. Turns out it’s pretty straightforward to add to your &lt;code&gt;.zshrc&lt;/code&gt; or &lt;code&gt;.zshenv&lt;/code&gt; file:&lt;/p&gt;

&lt;div&gt;&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span style=&quot;color:#777&quot;&gt;# Skip forward/back a word with opt-arrow&lt;/span&gt;
bindkey &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;[C&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt; forward-word
bindkey &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;[D&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt; backward-word

&lt;span style=&quot;color:#777&quot;&gt;# Skip to start/end of line with cmd-arrow&lt;/span&gt;
bindkey &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;[E&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt; beginning-of-line
bindkey &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;[F&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt; end-of-line

&lt;span style=&quot;color:#777&quot;&gt;# Delete word with opt-backspace/opt-delete&lt;/span&gt;
bindkey &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;[G&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt; backward-kill-word
bindkey &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;[H&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt; kill-word

&lt;span style=&quot;color:#777&quot;&gt;# Delete line with cmd-backspace&lt;/span&gt;
bindkey &lt;span style=&quot;background-color:hsla(0,100%,50%,0.05)&quot;&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;span style=&quot;color:#D20&quot;&gt;[I&lt;/span&gt;&lt;span style=&quot;color:#710&quot;&gt;'&lt;/span&gt;&lt;/span&gt; kill-whole-line
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Some of the actual aliases (e.g. &lt;code&gt;'[C'&lt;/code&gt;) might be different for you. These can be customised in iTerm → Preferences → Keys.&lt;/p&gt;

&lt;p&gt;If you feel like it, you can check out the rest of my dotfiles on &lt;a href=&quot;https://github.com/mrappleton/dotfiles&quot;&gt;Github&lt;/a&gt;.&lt;/p&gt;

          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Icomoon</title>
        <link href="http://floatleft.com/notebook/icomoon"/>
        <updated>2012-06-05T00:00:00+01:00</updated>
        <id>http://floatleft.com/notebook/icomoon</id>
        <content type="html">
          &lt;p&gt;Icomoon is an in browser icon font generator. Pick from a selection of free icon fonts or pay for access to a larger collection. You can even upload your own SVG files to have them added to the font.&lt;/p&gt;

&lt;p&gt;I used this to generate the icon font for the sidebar links on this site and I love it.&lt;/p&gt;

          &lt;a href="http://keyamoon.com/icomoon/"&gt;http://keyamoon.com/icomoon/ &lt;/a&gt;
        </content>
      </entry>
    
  
    
      <entry>
        <title>Redesign</title>
        <link href="http://floatleft.com/notebook/redesign"/>
        <updated>2012-06-03T00:00:00+01:00</updated>
        <id>http://floatleft.com/notebook/redesign</id>
        <content type="html">
          &lt;p&gt;I’ve updated the site design. I’ve gone for something simpler and have tried to put more focus on the blog in the hope that it will encourage me to post more regularly.&lt;/p&gt;

&lt;p&gt;I won’t go into too much detail as I know it’s pretty dull hearing people bang on about their own work, but here’s a brief overview of what’s new.&lt;/p&gt;

&lt;h2 id=&quot;design&quot;&gt;Design&lt;/h2&gt;
&lt;p&gt;This is a cleaner, simpler evolution of the previous design. Proxima Nova Condensed from &lt;a href=&quot;https://typekit.com/fonts/proxima-nova-condensed&quot;&gt;Typekit&lt;/a&gt; is used throughout and the site should scale up and down nicely thanks to a custom icon font and SVG logos.&lt;/p&gt;

&lt;h2 id=&quot;back-end&quot;&gt;Back end&lt;/h2&gt;
&lt;p&gt;I’ve dropped Wordpress in favour of &lt;a href=&quot;https://github.com/mojombo/jekyll&quot;&gt;Jekyll&lt;/a&gt;. Jekyll is a static blog generator which means that I get to write posts as markdown formatted plain text and publish the site as flat HTML.&lt;/p&gt;

&lt;p&gt;This is awesome for page load performance because it means zero back end processing. It is awesome for me as it means I get to keep the entire site (posts and all) in Git.&lt;/p&gt;

&lt;h2 id=&quot;to-do&quot;&gt;To do&lt;/h2&gt;
&lt;p&gt;Since the site is entirely static I have no means of gathering comments. I have still not decided how I want to address this but most likely I’ll either go to a &lt;a href=&quot;http://disqus.com/&quot;&gt;Disqus&lt;/a&gt; / &lt;a href=&quot;http://www.livefyre.com/&quot;&gt;Livefyre&lt;/a&gt; embed or just drop comments completely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; I’ve archived the old design at &lt;a href=&quot;http://2009.floatleft.com&quot;&gt;2009.floatleft.com&lt;/a&gt;.&lt;/p&gt;

          
        </content>
      </entry>
    
  
    
      <entry>
        <title>Future of Web Apps London 2012</title>
        <link href="http://floatleft.com/notebook/fowa-london"/>
        <updated>2012-05-31T00:00:00+01:00</updated>
        <id>http://floatleft.com/notebook/fowa-london</id>
        <content type="html">
          &lt;p&gt;I’m excited to be speaking at &lt;a href=&quot;http://futureofwebapps.com/london-2012/&quot;&gt;FOWA London&lt;/a&gt; in October this year! I’ll be delivering a talk on Backbone.js application structure so if you’re thinking of coming along you can check it out on &lt;a href=&quot;http://futureofwebapps.com/london-2012/schedule#session-337&quot;&gt;Tuesday afternoon&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here’s the summary…&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;The Modern JavaScript Application&lt;/h3&gt;

&lt;p&gt;Backbone is an awesome JavaScript library which provides just enough application structure to allow us to make our own design decisions. It isn't a full application framework and much of the plumbing required to use it as one is left up to us.&lt;/p&gt;

&lt;p&gt;But what should that extra plumbing look like? And how can a client side application grow and still remain organised and sane?&lt;/p&gt;

&lt;p&gt;We'll talk about lessons learned the hard way and ways to make life simpler and focus on the app rather than the framework. We'll also look at all the auxiliary benefits of taking the time to structure our apps in a clean modular fashion.&lt;/p&gt;
&lt;/blockquote&gt;

          
        </content>
      </entry>
    
  
</feed>
