GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS

Written by thoughtbot

Back to Basics: Writing SQL Queries

Almost all applications store data in one format or another somewhere. Us developers spend a lot of time thinking about our data. In a most cases we end up storing that data in a relational database. The advent of the ORM has made writing raw SQL...

Introducing Hound

We're pleased to announce Hound, a hosted service that comments on Ruby style guide violations in your GitHub pull requests.

Hound is currently free and available for public and private GitHub projects. We intend to charge in the near future to ensure...

Back to Basics: Writing Unit Tests First

The value of unit tests and TDD are well documented. Unfortunately, it's still daunting to start practicing it. Here's a primer.

Our desired code

We need to write a method that:

  • takes a string as an argument
  • reverses the string
  • saves the string...

What's new in edge Rails: Active Record enums

In an Active Record model, usually you will have a column that can only have a set of pre-defined values (such as a status column). Normally, you would define a constant for those values as well as several helper methods like the following example...

Welcome Aboard: You're Riding iOS on Rails!

When I sat down to write my first API with Rails, I was overwhelmed with the abundance of options available to me. From ActiveModel::Serializers to JBuilder to Rabl to simply calling .as_json, just choosing which library to use for rendering JSON was...

A Closer Look at Color Lightness

As much as we strive to control every detail of what we build, we are sometimes left with little choice but to leave some design decisions to algorithms. The challenges associated with these decisions become a lot more significant when human perception...

Liftoff 1.0

Way back in January of 2013, we released Liftoff to help developers quickly configure Xcode projects. We used it heavily internally, but felt like it was only solving part of the problem. So we've improved it, and are proud to announce Liftoff 1.0...

Printing Ralph

I have a 3D printer. It's a lot of work, but is also a lot of fun. It's fun because turning 3D models into actual, tangible objects is just cool. It's work, because it requires a lot of tinkering to get it right. You need to churn out a lot of small...

EmberJS with a Separate Rails API

We just wrapped up a large client project using EmberJS and we learned a few things that are interesting to share.

Ember made this project easier. There are times that a JavaScript framework is unnecessary and there are times that it makes the code...

Avoid the Three-state Boolean Problem

Quick, what's wrong with this Rails migration?

add_column :users, :admin, :boolean

Yep - it can be null. Your Boolean column is supposed to be only true or false. But now you're in the madness of three-state Booleans: it can be true, false, or

iOS Code Review: Loose Guidelines

From time to time I've been asked to do an independent code review, to determine the overall health of a client's code base. Unlike a code walkthrough, where someone familiar with the code shows the main components, this is a code review where an outside...

A Guide to Core Data Concurrency

The iOS ethos of instant responsive UI elements means putting as much work as possible in background threads and as little work in the main thread. For most cases we are fine with using an NSOperationQueue or GCD, but getting concurrency to work in...

Using Arel to Compose SQL Queries

Rails gives us a great DSL for constructing most queries. With its knowledge of the relationships between our tables, it's able to construct join clauses with nothing more than the name of a table. It even aliases your tables automatically!

The method...

Function Currying in CoffeeScript

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))

updateUser = (db, user) -> db.update("users...

Announcing gitsh

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 take sub-commands...

rcm, an rc file manager

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 gone by...

How to Edit an Existing Vim Macro

Here's the situation:

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...

Replacing NERDTree with Ctrl-P

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-installed NERDTree from my .vimrc

ActiveRecord's where.not

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 ...

Recursive Macros in Vim

Macros in vim can be a huge time saver, especially if they apply to a large number of lines. A trick I've been using recently is to use recursive macros to format large chunks of a file.

Let's say we have the following list of thousands of dates:

sed 102: Replace In-Place

Many people know how to use basic sed:

$ sed 's/hello/bonjour/' greetings.txt
$ echo "hi there" | sed 's/hi/hello/'

That'll cover 80% of your sed usage. This post is about the other 20%. Think of it as a followup course after sed 101.

So you can...

How We Test Rails Applications

I'm frequently asked what it takes to begin testing Rails applications. The hardest part of being a beginner is that you often don't know the terminology or what questions you should be asking. What follows is a high-level overview of the tools we...

Arduino-Based Bathroom Occupancy Detector

At the thoughtbot Boston office, when nature calls, there is an arduous, uphill both ways and often snow covered trek to the bathroom area. The bathrooms are also out of sight from anywhere in the office. Many times someone will turn the corner to...