ngauthier · Hire me · Backbone.js Training

Hey there!

I'm Nick Gauthier and this is my blog.

I post about a variety of technical topics like Ruby on Rails, Javascript, and Backbone.js. I'm a freelance web developer based out of Baltimore.

Hire me » Backbone.js Training »

Posts

RSpec with Domino 2012-05-08

Using Domino with RSpec is awesome. I'll let the code speak for itself. We have an html page: <!doctype html> <html> <head> <title>Domino Rspec</title> </head> <body> <h1>Domino Rspec</h1> <ul> <li><sp...

var self = lame 2012-04-11

var self = this I see this in a lot of javascript code. The first thing it makes me think of is Avdi Grimm's excellent talk Confident Code. I think that var self = this is an example of "timid code" in javascript. Avdi explains how timid code suffers from a "Lack of certainty" and it "lives i...

Deploy Ruby as a Gem 2012-04-09

Background I was looking at git-deploy and it looks really awesome. But it got me thinking: We have tools like bundler and rack that can handle gem versioning and dependencies, and creating clean interfaces for web applications. Why can't we use those tools for deploying our own code? I think r...

Raphael.js + Backbone.js + Traer.js 2012-02-23

Raphael.js is a cool vector graphic drawing library for javascript. It uses SVG (VML on IE) to draw just about anything, and provides lots of easy helper methods. The coolest thing about SVG is that since it's XML it can be inserted directly into the dom, so every element has its own dom node. O...

Playing with Ember.js 2012-02-19

Today I played around with Ember.js. I wanted to make my own Pomodoro timer, and I figured it would be a good way to try it out. One of the reasons I'm really excited about Ember is that its goal is to cut down on boilerplate code especially in regards to keeping views up to date. I'd like to m...

Quick Ruby Tests with Bash 2012-02-16

In Ruby on Rails development, we have great gems like Guard that will re-run tests or other tasks based on changing files. I was interested in finding something more lightweight but less configurable and flexible that I could use on smaller projects. I ended up writing this quick bash script tha...

Ruby and the Web 2012-02-14

Here's a talk I gave at Bmore on Rails (Baltimore's Rails user group). I talk about MVC vs Model 2 and how they apply to Rails. I talk about Frameworks vs Libraries and White Box vs Black box. Also I talk about a theoretical framework I experimented with to try to implement a more object oriented...

Simple ruby setup on ubuntu 2012-01-30

Today I setup a new development machine. My preferred OS is Xubuntu, which is Ubuntu + XFCE (a light window manager). In the past I've used RVM and have been happy with it, except for one thing: compiling. I used to use Gentoo, which is a linux distribution in which all software is installed by ...

Galaxy Nexus First Impressions 2012-01-04

I got a Samsung Galaxy Nexus yesterday and @reillyhawk asked me to share a review. Disclaimer: I've had this device for 20 hours. It's big, but it's the same weight as my old HTC Incredible (135g vs 130g). It has an extra inch of screen space (4.65" vs 3.7"). The feeling in your hand is like a ...

Open for Business 2012-01-02

I'm excited to announce that I'm now open for business! If you don't already know me, let me introduce myself: my name is Nick Gauthier and I am a Ruby and Javascript coder and I specialize in web development with the Rails framework. I particularly enjoy performance-tweaking applications, desig...

Recipes with Backbone Released! 2011-12-07

Chris Strom and I have finished our e-book on Backbone JS: "Recipes with Backbone". It is now available at http://recipeswithbackbone.com for $24.The book is targeted at the intermediate to advanced level backbone developer, but that's not to say beginners won't get anything out of it. To quote ...

Mocking on Rails 2011-11-03

Gregory Moeck's awesome post Stubbing is Not Enough got my brain back on the subject of mocking. Readers of this blog may note that I had quite a rant against mocking almost a year ago and Gregory posted a response. I think the result of that post and the discussion that ensued was not that mock...

Alpha of "Recipes with Backbone" Released 2011-10-01

Chris Strom and I have released the alpha of Recipes with Backbone. It's an e-book containing intermediate to advanced design patterns and best practices for Backbone.js. Grab it now for 50% off the list price. You'll get future versions of the book for free when you buy the alpha.http://recipes...

Using Exceptions to manage control flow in Rails Controllers 2011-09-26

Ah yes, the Rails Controller, a source of much contention among Rails developers. So many different ways to manage control flow, load objects, respond in standard and erroneous ways. My opinion up until recently was "I'll just put a bunch of conditionals in there for different situations."Recent...

How I test EventMachine 2011-09-20

EventMachine's asynchronous and evented nature can be pretty tough to test. Here are some simple Test::Unit helpers I use along with a sample example:def eventmachine(timeout = 1) Timeout::timeout(timeout) do EM.run do EM.epoll yield end end rescue Timeout::Error ...

Backbone JS: View signatures to prevent repaints 2011-03-10

A nice thing about backbone is being able to bind a view render to new data. But sometimes you get new data, but it's not actually new, it's the same data that has not been updated. This will still cause the view to repaint because the event will fire.To combat this, I've started putting signatu...

jQuery Deferred and Backbone JS 2011-03-09

Backbone is a really interesting framework, and my favorite part so far is the following idea:If you use a callback, you're Doing It WrongThis has held true for me for my development with Backbone so far. When you make data calls to the server, you let the appropriate events notify interested pa...

Backbone and Rails Forgery Protection 2011-02-21

I just had a tough time getting Rails 3 to play nice with Backbone JS, and it turned out to be a simple problem with a simple solution. Backbone was not sending the csrf authenticity token embedded in the page when it sent create/update/delete requests, and Rails was destroying the session when ...

View Abstraction in Integration Tests 2011-02-05

Goal: Make integration tests drier by adding a view abstraction layerRuby on Rails has a bunch of popular of test frameworks, such as:RSpecCucumberTest::UnitSteakBut one common aspect to all of the frameworks, out of the box, is that they're very procedural. Cucumber is designed so that each sce...

My Workflow 2011-01-07

Stemming from a workflow discussion on twitter featuring @bryanl, @eee_c, @pjb3, @stevenhaddox, and @webandy, I decided to share my workflow. Originally, we were talking about Mac Apps (specifically the paid ones), but that turned into "how do you work". Here are my goals for a good workflow:Goa...

Everything that is wrong with mocking, bdd, and rspec 2010-12-02

Below is a public excerpt from the recently release RSpec book:module Codebreaker describe Game do describe "#start" do it "sends a welcome message" do output = double('output') game = Game.new(output) output.should_receive(:puts).with('Welcome to Codebreaker!') ...

Microgem: JSLintRB-v8 2010-11-29

GOAL: Provide a Ruby interface for running JSLint on javascript files using v8.require 'jslintrb-v8'puts JSLint.new.check("var x = 5")Will return the string:Error at line 1 character 1: Missing "use strict" statement. var x = 5 Error at line 1 character 10: Missing semicolon. var x = 5Also, ...

Using Rails's Object#to_json to create a clean JSON Presenter 2010-11-17

The problem: You have an ActiveRecord model (or any object, really) and you want to output it to json, but you need some specific methods and maybe some processing of its attributes before you can call .to_json.Let's pretend we have the following object:class Widget attr_accessor :id attr_acce...

Minimal cucumber stack for testing a rich javascript application 2010-11-11

These are instructions for setting up a very bare cucumber stack for testing a rich javascript application.All code available here: https://github.com/ngauthier/cucumber-webapp-demoThe following stack is used: Cucumber Capybara Selenium WEBrickFirst, we make our awesome javascript powered we...

PRY - Please Repeat Yourself 2010-11-08

It's the canonical ruby metaprogramming example. You have this:def large_image image_base + '-large.png'enddef medium_image image_base + '-medium.png'enddef small_image image_base + '-small.png'endAnd you do some dynamic programming to define the methods with similar content:%w(large medium s...

RESTful Many to Many Relationships in Rails 2010-11-04

GET /people => List peoplePOST /people => Create personPUT /people => Replace the collectionDELETE /people => Delete the collectionGET /people/:id => List attribute of a personPUT /people/:id => update the attributes of a personPOST /people/:id => create a new collection under a ...