May 2012
1 post
Rails Mass Assignment Protection in the Controller
Github recently had a rails mass assignment bug that caused quite a stir. In the aftermath, several people proposed new ways of handling mass assignment protection in rails. One of the proposals, authored by Yehuda Katz, advocated for protecting against mass assignment in the controller rather than the model. I thought it was a great idea, so I built a little gem called Params Cleaner.
Params...
December 2011
1 post
Testing Express with Jasmine
I recently worked on a side project using node. In the past, I’ve used vows extensively as a testing framework. There are many great things about vows including speed of execution and seemless support for testing asynchronous functions. However, looking back on that project I feel I spent more time debugging vows issues than actually testing/writing my code. I’ve previously used...
November 2009
1 post
Make your cucumber steps definitions time aware
If you’re like me, you’ve found yourself with a cucumber step definition like this:
And you want to write a step definition like this:
Instead of doing all that extra work, I threw together a cucumber step that lets you add times to any existing step definition:
To make things even easier I created a gem called Timebomb. It lets you append time constraints to your...
July 2009
1 post
Vim Plugin for Ruby Testing
If you’re using ruby and you’re using vim, you’ve probably noticed some awesome tools out there (mostly created by Tim Pope). You’ve got rails.vim, ruby.vim, etc. However, I noticed that there was a lack of support for some features that Textmate users have been taking for granted for a long time. I’m talking about the support Textmate provides around running your...
December 2008
2 posts
Sinatra Dances on Passenger's Stage
I wrote briefly in my last post about how I’ve been working with sinatra quite a bit lately. After some great experiences at work, I decided to move my homepage over to sinatra from rails. It was totally inane to have the site written in rails in the first place, but I’d been learning the framework at the time and when you have a hammer…well, you know.
Anyway, I learned quite a...
Mashup your RSS Feeds with ruby + sinatra + pipe
I’ve been doing some build work lately and I stumbled upon a situation last week where I needed to take a bunch of RSS feeds, aggregate them and filter only the specific items I wanted. This actually manifested itself with continuous integration boxes. We have a lot of CI boxes running a lot of builds but each team is only interested in several of these builds.
One option is using...
September 2008
1 post
I finally got around to a small side project I have wanted to work on: a new ruby wrapper for the Digg API. There’s one existing library out there that I know of, but I didn’t like the syntax all that much. So, like any good developer, I’ve reinvented the wheel! My library is called diggr and it strives to be simple and consistent with the Digg API endpoints listed here. Rather...
June 2008
1 post
Ruby and Macros: An Experiment
Lately I’ve been doing a lot of reading about Lisp. This got me thinking about how I could implement something similar to Lisp macros in ruby. DISCLAIMER: I am not a Lisp guru. I’m sure I’m missing the finer points of Lisp macros. I’m sure I’m an idiot.
That said, what I wanted to come up with was a way to define methods such that you received both the arguments to...
May 2008
4 posts
Remote Git Repos on Ubuntu: The Right Way
Overview
Over the past week or so I’ve been setting up remote git repositories on my slice. I figured it would be helpful to put together a post regarding what I’ve found to be the right way to set up remote git repos. The info in this post is basically collected from several blogs and articles, but I’ve yet to see all of it in a single post.
Before we get started, I’m...
Don't Cry Over Spilled Context
Let’s talk a bit about a DSL pattern called spill-over context. In keeping with the whole “picture worth a thousand words” thing, let’s take a look at a snippet of code from a rakefile to get an idea of what spill-over context actually is:
desc "I describe the task below me!"
task :stuff
# do stuff here
end
What’s cool about the code above is that the desc...
Conditional includes
This little problem came up at work a few days ago: what if you want to include a module but, based on the including class, get some different behavior? Enter conditional includes.
module Foo
module Bar
def hello
puts "hi from bar"
end
end
module Baz
def hello
puts "hi from baz"
end
end
def self.included(klass)
if klass.to_s == "Blah"
...
Micro DSLs
Three things you need to know about me: I spend a lot of time on planes, I like DSLs and I’m lazy. With these powers combined, I’ve created my new hobby: creating micro DSLs. What is a micro DSL? Basically, during my (seemingly) never ending flights from San Fran to Chicago I try to recreate DSLs I like in as few lines as possible. Oh, and one more thing: I give the resulting DSLs...
April 2008
1 post
The rubinius community rocks
The rubinius community is impressive. Really impressive. After watching Evan Phoenix’s talk at MountainWest RubyConf, I decided to see what all the fuss was about. Sure enough, it was just as easy to get involved as he claimed.
How easy? I went from downloading source code to having a patch committed in less than 24 hours. And this is the first open source project I’ve contributed to...