alias_method argument order
If you're anything like me, you can never remember the argument order for alias_method. I always think to myself "it's the other way around than I think it is", but then end up doing it wrong anyway....
View ArticleSass 3.2 blocks
A lot of websites have side bars. On normal desktop browsers, this fits nicely. But on smaller screens, it will create horizontal scrollbars. And those are a bad user experience. Luckily, CSS supports...
View ArticleTesting ActiveRecord in isolation
Testing ActiveRecord doesn't have to be slow. With some clever loading you can require only the parts that you need and it isn't even that difficult. Another reason might be that you're using...
View ArticleGetting the Most out of Bundler Groups
Did you know you can create as many groups in Bundler as you like? You can and I think you should! Let me show you some ways I use groups to clean up my Gemfile. Why groups? Speed: Requiring gems can...
View ArticleBackends in Rails 3.1
If you find yourself needing a backend interface, you can either get an admin plugin of the shelf, like RailsAdmin or ActiveAdmin, or build your own. The of-the-shelf options provide a lot of...
View ArticleCucumber vs. Steak
Jeff Kreeftmeijer talked about Cucumber and Steak at the last Amsterdam Ruby Meetup. He hit upon an important theme in software development: reducing complexity; in this case the extra layers of...
View ArticleEasier MetricFu with Metrical
TL;DR: I've just released metrical. It is a tiny wrapper around metric_fu. MetricFu is awesome. It helps me keep my code clean by identifying problem spots in my code. Unfortunately, it's difficult to...
View ArticleRSpec Array Matcher
If you're testing arrays a lot, like ActiveRecord's (named) scopes, you should know the following RSpec matcher: =~. It doesn't care about sorting and it gives you all the output you need when the spec...
View ArticleYour argument doesn't cut wood
About once a month I read an article on comparing Ruby to another programming language. Usually it makes the point that Ruby is dynamic and open and therefore it is less suited for reliable...
View ArticleGemfile vim syntax file
I've updated my Gemfile syntax file, adding a dash of color and making sure it supports all elements of the Bundler DSL. You can get it here. You'll also need to tell vim to automatically use it when...
View ArticleBuilding Blocks of DDD: Services
As promised, here is an example of how to use the idea of services from Domain Driven Design to help you design your code better. Let's start with some theoretical stuff, before we dive into some...
View ArticleDomain Driven Design: Building Blocks in Ruby
A few weeks ago I talked about Domain Driven Design in Ruby at the local Ruby user group: Rotterdam.rb. It had a great turnup (even though the weather prevented some from coming) and there was a good...
View ArticleCustomizing IRB, 2010 edition
TL;DR: Check out my new .irbrc-file! Customizing my work environment is a nerdish hobby of mine. I spend far to much time tweaking my terminal. While I'll save my terminal customizations for another...
View ArticleUsing Sass with jQuery UI
Want to build a quick website or backend? Want to make it look good, but without adding too much effort in it? Then this recipe is for you! The jQuery UI framework contains some nice styles and some...
View ArticleAbout structs
Recently I talked about a monkey patch called attr_initializer, allowing you to write code like this: class FooBar attr_initializer :foo, :bar def to_s "your #{foo} is #{bar}" end end FooBar.new('foo',...
View ArticleCheating Performance With A Little Javascript
This little trick works with most websites with a menubar. When you have a menu that changes color pending on which page you are, you can cheat a bit on the perceived performance of loading pages. And...
View ArticleHelpers Are Code Too!
I think I've talked about this before, and there has been a Railscasts episode about it too, but I want to touch on it again. I know we're supposed to keep views simple, but that doesn't mean that...
View ArticleConway's Game of Life; or: Writing Perl in Ruby
We had a programming exercise this week at work. We were set out to write Conway's Game of Life, using pair programming and TDD. It was a fun and educational evening. I even did some Scala. Programmers...
View ArticleViewTranslator, a dynamic dispatcher
I'm a sucker for syntax. So once again, here's a small experiment. It might not be the most useful snippet out there, but maybe it inspires you to do something awesome. The 'Dynamic Dispatcher' is a...
View ArticleQu'est-ce que c'est Rubyesque?
This is a translation of the post I originally wrote down in Dutch for my company. I recently gave a presentation at my company Finalist IT Group about the philosophy behind Ruby. Code written with...
View Article