February 2012
19 posts
4 tags
This week in open source
shoulda
shoulda is version 3.0.0! Someone needed to cut it, and Joe Ferris (jferris) stepped up to make the release (4f0c363).
high_voltage
A new version of high_voltage is out this week, with contributions from Matthew Horan (mhoran). Matt fixed the content_path hack on PagesController such that you can subclass and override the content path properly (0d84952, 9c7c0ad, 8884f70, and d4ba056,...
3 tags
Watch for turbulence
How important is the refactoring you’re working on? Michael Feathers has a metric you should consider when deciding: plot the complexity against the churn.
Chad Fowler’s turbulence gem does just that.
The “complexity” is some arbitrary number of how tricky the code is to read; this can range from the amount of indentation to the amount of metaprogramming, and everything...
5 tags
How To Use Arguments In a Rake Task
I came across this today. You can write Rake tasks that accept arguments, called like this:
rake tweets:send[cpytel]
You define the rask task like this:
namespace :tweets do
desc 'Send some tweets to a user'
task :send, [:username] => [:environment] do |t, args|
Tweet.send(args[:username])
end
end
Unfortunately, zsh can’t parse the call to the rake task correctly, so...
6 tags
Anonymizing user, company, and location data using...
Often during development it’s useful to have realistic data to get a sense of how an app would behave in the wild. Seed data is one useful method to get going pre-launch, but production data is always preferable.
However production data can contain sensitive user information, which is useful for the dev team but nerve-wracking for those looking to avoid a PR disaster, say if sensitive equipment...
3 tags
Bracket Expansion
Let’s say you want to update capybara and capybara-webkit. You’d normally type this:
gem update capybara capybara-webkit
But you’re busy, you don’t have time to type “capybara” twice. Let’s see what tab completion has for us:
gem update capybara{,-webkit}
The bracket expression expands to the same thing as above because the brackets expand to "capybara"...
2 tags
This week in open source
copycopter_client
Our little copycopter_client library, which talks to the amazing Copycopter app (which, in my opinion, is the best thing since sliced bread), got some infrastructure cleanup from Gabe Berke-Williams (gabebw) around themes like Travis CI (91ac190) and bundler (612fc4e), plus sorting the blurbs (500dac7). Chris Hunt (huntca) swooped in with the ability to export to YAML (7d44323,...
4 tags
Derive #inject for a better understanding
Let’s talk about Enumerable#inject. It’s special to me. In other cultures it’s called foldl, foldLeft, reduce, catamorphism, or bananas (PDF). We got our name from Smalltalk, which got it from, I dunno, a folk song?
Inject is an abstraction over structural recursion. For examples, imagine a list were defined like this:
class EmptyList
end
class ConsList
def...
1 tag
The Rhythm Method →
One of our goals for Trajectory is to provide a guided path to a better way to develop software. When possible, we let that influence the way Trajectory works. Iterations are each one week.
Read more on Trajectory’s blog, Mission Control.
3 tags
Run a command every time you change directories in...
You can run a command every time you change directories in zsh with the chpwd function:
export CURRENT_PROJECT_PATH=$HOME/.current-project
function chpwd {
echo $(pwd) >! $CURRENT_PROJECT_PATH
}
current() {
if [[ -f $CURRENT_PROJECT_PATH ]]; then
cd "$(cat $CURRENT_PROJECT_PATH)"
fi
}
current
This will write the current directory to a hidden file in $HOME; opening a new...
1 tag
Trajectory doesn't have an icebox →
Mission Control:
The icebox is a place where stories go to die. It’s typically used to hold two kinds of stories: Features that need more discussion or planning before they can be started
Features that are currently out of scope or very low priority
Read the full post on the Trajectory blog, Mission Control.
5 tags
Wildcards in Rails redirects
The captured wildcard in a Rails 3 route can be used in the redirect method:
match 'via/:source' => redirect('/?utm_source=%{source}')
This example is intended to improve metrics for customer acquisition campaigns. utm_source is for Google Analytics, which KISSMetrics logs as Ad Campaign Hits.
The URLs are now friendlier for...
3 tags
How to apply what you've learned from TDD to...
After doing TDD full time for years, I have a hard time writing code without a test. One example that I find particularly difficult is writing data migrations.
Some schema changes require more than just setting a default value for all existing rows. For example, let’s say you have this schema:
create_table :users do |table|
table.string :email
table.string...
5 tags
Convert Ruby 1.8 to 1.9 hash syntax
In vim, for an entire file:
:%s/:\([^ ]*\)\(\s*\)=>/\1:/g
In the shell, for an entire project:
perl -pi -e 's/:([\w\d_]+)(\s*)=>/\1:/g' **/*.rb
Now, instead of those old-school hashes like this:
get '/', :agent => MOBILE_BROWSERS do
You’ll have new-school hashes like this:
get '/', agent: MOBILE_BROWSERS do
6 tags
This week in open source
cocaine
The only user-visible change in cocaine this week was by Gabe Berke-Williams (gabebw), who modified the public API for CommandLine to change unix? from a class method to an instance method (4183c89). Otherwise it was more of Gabe refactoring things (ae8ae22 and 1b9742a) and Prem Sichanugrist (sikachu) playing with Travis CI (4eb18d2).
diesel
This week diesel, an abstraction and set of...
5 tags
Your next great teammate
Every company we speak with could use a great web designer or developer on their team. We think we know where to find such mysterious figures.
What does a great teammate look like?
Imagine a programmer next to you, noise-canceling headphones on, punishing his keyboard with forceful blows, punctuating each change by slamming the heels of his hands against his desk. While tests run, jolly meme...
4 tags
Airbrake acquired by Exceptional
Late last year, Airbrake was acquired by the team at Exceptional, inc. We’re extremely excited about this move and we’d like to explain why.
A brief history
We created Hoptoad in the fall of 2007 and launched it publicly in spring of 2008. We had been tracking our errors previously with an email notifier that flooded our inboxes with repeat errors, many generated by search engines...
3 tags
Design 101: Stop Yelling
How do you make yourself heard in a loud room? BY YELLING! And when it comes to design, that’s often the approach used for drawing attention to elements. LOUDER! BIGGER! FASTER!
But there’s a better way.
Imagine yourself in that loud room again. Now imagine that instead of yelling to get above the noise, you could just turn down everyone else. Instead of shouting at the person...
8 tags
This week in open source
bourbon
As a programmer I love the change that made it into version 1.3.6 (10f978d) of bourbon: Phil LaPier (plapier) added to work done by Frank (frankzilla) to add a monospaced font family, $monospace—with support for Bitstream Vera Sans Mono, my favorite monospace typeface (3467fe3 and c86e5687). Nice.
paperclip
Friday saw a new release of paperclip (1cb40e3), in accordance with the...
4 tags
Decoupling Data from Presentation
I’m really happy to see a resurgence in an understanding that writing
integration tests that use classes and DOM structure to perform assertions
within these tests is typically a bad idea. The DOM structure constantly
changes but the data displayed (the stuff we want to assert is present on a
page) typically doesn’t.
Why write tests against some markup that a designer may change,...