Skip to content

Instantly share code, notes, and snippets.

Avatar

David Demaree ddemaree

View GitHub Profile
View 2012-04-27-cucumber.mdown

RubySource Talks to Matt Wynne About Cucumber

Link: http://rubysource.com/matt-wynne-on-using-cucumber/

Wynne is the co-author (with Aslak Hellesøy) of Pragmatic's The Cucumber Book. In this interview by Pat Shaughnessy, he explains a bit about what Cucumber is for and how it can help teams deliver good software:

Q: So do you view Cucumber as a pair or group programming tool?

Wynne: I view it as a team communication or collaboration tool really. So by playing the game, forcing yourselves to try to describe what you want the software to do, together, what you end up doing is surfacing all the things that you haven’t actually figured out yet and all the things that you’re not really sure about. This is what Dan North calls deliberate discovery.

@ddemaree
ddemaree / hiw01_ruby.mdown
Created Feb 25, 2012
How I Work, Part I: Ruby
View hiw01_ruby.mdown

How I Work, Part 1: Ruby

Since the first of the year I've been trying to write one of that sort of post where the blogger describes the tools they use. Obviously, I haven't succeeded yet. And what's more, it's taken me until now to precisely identify why it's been so hard.

It's not that I find these "setup" posts to be a form of pornography. They are, and I do, but in this scenario I would be the porn star, not the lonely guy who looks for tips on productivity blogs in lieu of an actual life. And it's not that my setup isn't interesting. It's not that mind-blowing or innovative, honestly, but over the years I've learned a lot about what I need to do my job and that knowledge feels worth sharing.

What I've concluded, rather, is that in trying to talk about my tools in a single post, I was going about it totally the wrong way. Tools and best practices are things I care deeply about, and trying to cram everything into a single, 5,000-word monster post would be exhausting for me to write, at least as tir

@ddemaree
ddemaree / 01_README.md
Created Nov 30, 2011
How Sunspot implements its wonderful search/index DSL
View 01_README.md

This code is extracted/adapted from Mat Brown's Sunspot gem. One of Sunspot's nicest features is an expressive DSL for defining search indexes and performing queries. It works by instance_eval-ing a block you pass into it in the context of its own search builder object. In this code, the pig thing1 statement is roughly equivalent to zoo = Zoo.new; zoo.pig(thing1).

Sunspot's DSL has to resort to trickery: the instance_eval_with_context method uses eval to get the block to give up the object it considers to be self, then sets up an elaborate system of delegates and method_missing calls so any methods not handled by the DSL are forwarded to the surrounding object. But as a result, this syntax is minimal and beautiful, and it works the way you expect whether or not you prefer blocks to yield an object.

Without this trick the block would be restricted to either the original, "calling" context (as a closure) or the DSL's "receiving" context (using instance_eval), but not both.

Using `ins

@ddemaree
ddemaree / .gitignore
Created Oct 6, 2011
@font-face code examples for AIGA Chicago presentation
View .gitignore
*.woff
*.svg
*.ttf
*.eot
@ddemaree
ddemaree / application.js.coffee
Created Jun 12, 2011
Simple Google Maps API v3 integration in CoffeeScript, with non-JS Static Maps fallback
View application.js.coffee
#= require jquery
#= require jquery_ujs
#= require lib/modernizr
#= require lib/jquery.lettering
#= require_tree .
$ ->
$('*[data-googlemap]').googleMap()
true
@ddemaree
ddemaree / 01_random_specs.rake
Created Jun 8, 2011
Rake task for running a random sampling of RSpec tests
View 01_random_specs.rake
namespace :spec do
SPEC_SUITES = %w(models requests integration helpers controllers lib)
def sample_spec_files(num=5)
[].tap do |specs|
SPEC_SUITES.each do |dirname|
files = Dir[Rails.root.join("spec", dirname, "**", "*_spec.rb")]
specs.concat files.shuffle.first(num)
end.shuffle
end
@ddemaree
ddemaree / 01_ticket.rb
Created May 30, 2011
I cannot believe this is valid Ruby syntax. P.S. - I love Ruby
View 01_ticket.rb
class Ticket < ActiveRecord::Base
SEARCH_COLUMNS = {
:tickets => [:token, :subject, :body, :customer_name, :customer_email],
:notes => [:body, :author_name, :author_email]
}
def self.conditions_for_keyword_search(table, keywords)
# Because we may use this string elsewhere, we don't want to mutate the only copy
query_words = keywords.dup
@ddemaree
ddemaree / config.ru
Created Apr 9, 2011
Rackup file for Rails 2.3.x projects (very useful for getting legacy apps running on pow.cx)
View config.ru
# Rails.root/config.ru
require "config/environment"
use Rails::Rack::LogTailer
use Rails::Rack::Static
run ActionController::Dispatcher.new
@ddemaree
ddemaree / GBItemDetailCell.m
Created Feb 1, 2011
Yes, @polgfred, some people do align setters in languages other than Ruby. :)
View GBItemDetailCell.m
#import "GBItemDetailCell.h"
@implementation GBItemDetailCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Text view for item value
// Dimensions are identical to the value label;
@ddemaree
ddemaree / mysql.rb
Created Jan 3, 2011
Homebrew formula for installing Metromix's legacy MySQL 5.0.34
View mysql.rb
require 'formula'
class Mysql < Formula
homepage 'http://dev.mysql.com/doc/refman/5.0/en/'
url 'http://lockjaw.s3.amazonaws.com/homebrew/mysql-5.0.34.tar.gz'
md5 '043c8cb8820b6d1fb67d679e54daba5d'
depends_on 'readline'
def options