The system obeys the Tell don't Ask principle where you should tell an object to do something as opposed to extracting data from it and implementing behavior on the caller code. Here, instead of asking a monkey if it is eating in order to display a state message, we tell it to give us...
Function Currying in CoffeeScript Sean Griffin February 12, 2014 javascript Have you had a function that takes two arguments, but you want to pass the second argument in later? Here's one possible example: updateUsers = (db, users) -> _.map(users, (user) -> updateUser(db, user)) updat...
Request bodies are defined by a form's markup. In the form tag there is an attribute called enctype , this attribute tells the browser how to encode the form data. There are several different values this attribute can have. The default is application/x-www-form-urlencoded , which tell...
Dan Croak December 29, 2010 ruby open source Do you know Ruby's pessimistic operator? It looks like this: ~> You've seen it in some Gemfile s. Here's an example gem 'rails', '~> 3.0.3' gem 'thin', '~> 1.1' ~> 3.0.3 means that when you bundle install , you'll get the highest-released g...
If You Gaze Into nil, nil Gazes Also Into You Joe Ferris July 28, 2011 ruby good code Every developer runs into the dreaded nil object error: NoMethodError in Ruby, AttributeError in Python, and NullPointerException in Java. These errors are one of the largest sources of bugs . Even m...
Gabe Berke-Williams February 11, 2014 osx No, it's not about tea. We're continuing our rundown of lesser-known Homebrew features with brew leaves . Let's check the man brew page: leaves Show installed formulae that are not dependencies of another installed formula. Or, in more compute...
How to Evaluate Your Rails JSON API for Performance Improvements Laila Winner February 10, 2014 performance rails Let's say your company's product is a mobile app that gets its data from an internal JSON API. The API, built using Rails, is a few years old. Response objects are large, ...
George Brocklehurst February 10, 2014 git open source gitsh is a new way to use Git: instead of running Git commands in a general purpose shell like zsh or bash, gitsh provides you with a dedicated shell just for your Git commands. Many of the early Unix utilities, like dc , didn't ta...
George Brocklehurst February 10, 2014 git open source gitsh is a new way to use Git: instead of running Git commands in a general purpose shell like zsh or bash, gitsh provides you with a dedicated shell just for your Git commands. Many of the early Unix utilities, like dc , didn't ta...
Use Capybara On Any HTML Fragment Or Page Nick Quaranto July 26, 2011 testing ruby rails I was upgrading Gemcutter to Cucumber and Capybara 1.0 yesterday from Webrat (a change long overdue!), and I discovered a neat little class within Capybara that is worth sharing. Basically, since ...
cd'ing to frequently-used directories in ZSH Gabe Berke-Williams September 30, 2011 unix Josh just dropped some sweet, sweet ZSH knowledge. I spend a lot of time in the directories under $HOME/thoughtbot/ and $HOME/src , and to get there I type (for example) cd ~/thoughtbot/hoptoad . ...
Chat Example App Using Server-Sent Events Mason Fischer July 14, 2013 rails redis Rails 4 can stream data to the browser with ActionController::Live using server-sent events (SSEs) . I was curious how server sent events worked so I decided to use them to implement a simple chat applic...
Mike Burns February 06, 2014 rcm open source We have built a suite of tools for managing your rc files. The rcm suite of tools is for managing dotfiles directories. This is a directory containing all the .*rc files in your home directory (.zshrc , .vimrc , and so on). These files have...
Request bodies are defined by a form's markup. In the form tag there is an attribute called enctype , this attribute tells the browser how to encode the form data. There are several different values this attribute can have. The default is application/x-www-form-urlencoded , which tell...
Automatically wait for AJAX with Capybara Gabe Berke-Williams February 04, 2014 rails testing Capybara's very good about waiting for AJAX . For example, this code will keep checking the page for the element for Capybara.default_wait_time seconds, allowing AJAX calls to finish: expect(...
Opening an Austin Office Britt Ballard February 03, 2014 austin news We're pleased to announce that we're opening an office in Austin, Texas! Starting in early March we'll have a team in town consisting of myself and Alex (at least temporarily). Caleb will join shortly thereafter. Thi...
Maintainability: we now had two ways of looking for error messages: from the errors collection, and from an exception raised during validation. This commit makes it clear that at least six places need to change if we add any more. Maintainability: this commit revealed that AllowValueM...
thoughtbot is filled with vim and vigor December 19, 2008 rails ruby vim Slowly over the past year thoughtbot has turned from an all-TextMate (and one Emacs) group into a mostly-vim group. Here are some tips, tricks, and scripts we've mastered along the way: From Mike Burns I've been ...
Josh Clayton January 06, 2012 vim Ever get the urge to update a ton of files? I know I do. For example, I recently changed multiple hundred coffeescript files from the syntax of MyGreatClass = Backbone.Model.extend( defaults: awesome: true ) to class @MyGreatClass extends Backbone.Mod...
GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS
You've just written an awesome vim macro and stopped recording. However, when you try an run the macro you realize that you forgot to add a ^ to the beginning of it and now it only works if you go back to the beginning of the line before running it. You might be thinking that its time...
ActiveRecord, Caching, and the Single Responsibility Principle Josh Clayton August 19, 2011 rails good code I was working on a messaging system earlier this week and noticed a pretty tight coupling between two classes. class Message < ActiveRecord::Base belongs_to :author, :class_name...
Introducing Bourbon Neat, a Sass-based responsive grid framework Reda Lemeden September 05, 2012 design open source Bourbon Neat —or Neat for short—is a lightweight, open source fluid grid framework built on top of Sass and Bourbon with an emphasis on flexibility and ease of use. The ...
Replacing NERDTree with Ctrl-P Lisa Sy January 29, 2014 vim For many months, I used NERDTree to view my project directory within Vim. During my introduction to Rails application development, it was valuable to see the Rails tree structure in my left sidebar. Two weeks ago, I un-instal...
Rescue StandardError, Not Exception Jon Yurek November 18, 2013 ruby Sometimes our Ruby programs throw errors which we don't have full control over, such as network timeouts. So, we need to catch and handle those errors. To do so, we need to choose an Exception -descended class (or cl...
Gabe Berke-Williams January 22, 2014 rails Rails 4.0 introduced a helpful new method for ActiveRecord queries: where.not . It can make clunky queries easier to read. Usage This query: User.where.not(name: 'Gabe') is effectively the same as this: User.where('name != ?', 'Gabe') It's "e...
I’m glad I got to meet you last night. If you’re still going to be in town next week I’d be glad to meet with you and talk about what you guys are doing at example.com, what we do here at thoughtbot and how we could help you out. If you haven’t already, take a look at our site http://...
Starting and Stopping Background Services with Homebrew Gabe Berke-Williams January 21, 2014 osx I love Homebrew , but sometimes it really gets me down, you know? Especially when I have to deal with launchctl . launchctl loads and unloads services that start at login. In OS X, these s...
Brewfile: a Gemfile, but for Homebrew Gabe Berke-Williams January 20, 2014 osx Bundler users define dependencies for Ruby applications in a Gemfile and install those dependencies by running bundle install. Homebrew users can define dependencies for their OS X operating system with a B...
When I Enter the Office, the Imperial March Plays Jon Yurek July 07, 2009 ruby A long time ago in an office far, far away... robot wars! I mean, budget surplus! We had a bit extra in the budget a while back and so we did what any responsible business owners would have done: ask the em...