Skip to content

Instantly share code, notes, and snippets.

View rab's full-sized avatar
👨‍💻
Home Office is a mess (as usual)

Rob Biedenharn rab

👨‍💻
Home Office is a mess (as usual)
View GitHub Profile
first_name last_name employer
Fred Flintstone Bedrock Quarry
Clark Kent The Daily Planet
Ralph Kramden Metro Bus
Joe Friday LAPD
David Hansson 37Signals
Jim Weirich EdgeCase
def mask(x)y=x.dup;y[6...-4]=y[6...-4].gsub(/./,'*');y end
@rab
rab / distinct_sets.rb
Created November 22, 2009 06:00
Ruby Quiz #225 Distinct Sets (with Tests)
require 'set'
def distinct_sets(setlist)
Set.new( setlist.map{|s|Set.new(s)} ).
divide {|a,b| ! (a&b).empty? }.to_a.
map{|e|e.to_a.inject{|b,l|b|l}.to_a.sort{|a,b| if Numeric === a && Numeric === b
a <=> b
else
a.to_s <=> b.to_s
end }}
@rab
rab / rails aliases.bash
Created June 16, 2009 23:03
Bash functions to start mongrel_rails and webrick applications
cons () { if [ -e Gemfile ]; then
be='bundle exec'
else
be=""
fi
if [ -x "script/console" ]; then
${be} ruby script/console ${1:-${RAILS_ENV:-development}}
else
${be} rails console ${1:-${RAILS_ENV:-development}}
fi
@rab
rab / quiz.rb
Created May 20, 2009 00:15 — forked from ryanb/quiz.rb
added test for puts/gets swap
# COMMUNITY CHALLENGE
#
# How would you test this Quiz#problem method? Only two rules:
#
# 1. The tests should fail if any part of the application breaks.
# For example: If "gets" is moved before "puts" then the tests should
# fail since that breaks the application.
#
# 2. You cannot change the Quiz class. But you can use whatever framework
# and tools you want for the tests. (RSpec, Cucumber, etc.)
@rab
rab / image_size.rb
Created April 3, 2009 12:46
ImageSize finds the width x height
# image_size.rb
#
# Copyright (c) 2007 Rob Biedenharn
# Rob [at] AgileConsultingLLC.com
# Rob_Biedenharn [at] alum.mit.edu
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
@rab
rab / poi.rb
Created January 25, 2009 20:20
POI helpers for your GPSr
#!/usr/bin/env ruby -w
#
# Copyright (c) 2008 Rob Biedenharn
# Rob [at] AgileConsultingLLC.com
# Rob_Biedenharn [at] alum.mit.edu
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or