Skip to content

Instantly share code, notes, and snippets.

+ [[ -z '' ]]
+ export 'PS4=+[${BASH_SOURCE}] : ${LINENO} : ${FUNCNAME[0]:+${FUNCNAME[0]}() $ }'
+ PS4='+[${BASH_SOURCE}] : ${LINENO} : ${FUNCNAME[0]:+${FUNCNAME[0]}() $ }'
+[/Users/oem/.rvm/scripts/cli] : 564 : __rvm_parse_args() $ [[ -z '' ]]
+[/Users/oem/.rvm/scripts/cli] : 564 : __rvm_parse_args() $ [[ -n '' ]]
+[/Users/oem/.rvm/scripts/cli] : 566 : __rvm_parse_args() $ [[ 0 -eq 1 ]]
+[/Users/oem/.rvm/scripts/cli] : 566 : __rvm_parse_args() $ [[ -n '' ]]
+[/Users/oem/.rvm/scripts/cli] : 15 : __rvm_parse_args() $ [[ -n copy ]]
+[/Users/oem/.rvm/scripts/cli] : 17 : __rvm_parse_args() $ rvm_token=copy
+[/Users/oem/.rvm/scripts/cli] : 19 : __rvm_parse_args() $ [[ 2 -gt 0 ]]
+ [[ -z '' ]]
+ export 'PS4=+[${BASH_SOURCE}] : ${LINENO} : ${FUNCNAME[0]:+${FUNCNAME[0]}() $ }'
+ PS4='+[${BASH_SOURCE}] : ${LINENO} : ${FUNCNAME[0]:+${FUNCNAME[0]}() $ }'
+[/Users/oem/.rvm/scripts/cli] : 564 : __rvm_parse_args() $ [[ -z '' ]]
+[/Users/oem/.rvm/scripts/cli] : 564 : __rvm_parse_args() $ [[ -n '' ]]
+[/Users/oem/.rvm/scripts/cli] : 566 : __rvm_parse_args() $ [[ 0 -eq 1 ]]
+[/Users/oem/.rvm/scripts/cli] : 566 : __rvm_parse_args() $ [[ -n '' ]]
+[/Users/oem/.rvm/scripts/cli] : 15 : __rvm_parse_args() $ [[ -n use ]]
+[/Users/oem/.rvm/scripts/cli] : 17 : __rvm_parse_args() $ rvm_token=use
+[/Users/oem/.rvm/scripts/cli] : 19 : __rvm_parse_args() $ [[ 2 -gt 0 ]]
@oem
oem / recursive_ls.rb
Created October 25, 2010 11:17
print the folder structure recursively from the current folder
def read_dir(current, indent="")
Dir[current + "/*"].each do |dir|
puts indent + dir.to_s.scan(/[^\/]+$/).to_s
read_dir(dir, indent + " ") if FileTest.directory?(dir)
end
end
read_dir(".")
@oem
oem / gist:746446
Created December 18, 2010 12:06
all my tools installed on this box?
#!/usr/bin/env ruby
# What's missing from my toolbox?
require "rubygems"
begin
require "term/ansicolor"
rescue LoadError
nil
end
@oem
oem / gist:758561
Created December 29, 2010 14:01
capybara date select step definition for cucumber
# capybara step definition for a quick and dirty date select
# For example:
# When I select "May 7, 2010" as the post "published_on" date
When /^I select "([^"]*)" as the (.+) "([^"]*)" date$/ do |date, model, selector|
date = Date.parse(date)
select(date.year.to_s, :from => "#{model}[#{selector}(1i)]")
select(date.strftime("%B"), :from => "#{model}[#{selector}(2i)]")
select(date.day.to_s, :from => "#{model}[#{selector}(3i)]")
end
@oem
oem / gist:834395
Created February 18, 2011 21:00
kestrels in rails
# in Combinatory Logic, a Kestrel is a function that returns a constant function
# An example would be to have a return value and injecting some side effects before returning the value
def first_user_notified
user = User.first
user.send_email("foo")
user
end
# => first user
@oem
oem / gist:834915
Created February 19, 2011 07:59
Use method_missing to dynamically create "faked" class methods
# method missing fun to fake class methods
class Foo
def tell(something)
puts something
puts yield
end
def self.method_missing(name, *args, &block)
File.open("file_with_utf-8_encoding.moo", "r:utf-8").read
@oem
oem / gist:957699
Created May 5, 2011 19:18
small excercise to refresh some metaprogramming stuff
# just a small refresher on some meta stuff - haven't commited all of it to
# muscle memory yet
class NoteBook
attr_accessor :notes
class << self
attr_accessor :subclasses
end
@oem
oem / gist:1290627
Created October 16, 2011 07:51
my notes to rachel davies' talk at magrails (very minimal)

The quest for agility

Rachel Davies

let's do the maximum agile rather than the minimum (pretending by having process-facades)

Agile != meeting hell

Agile is for developing software!