Skip to content

Instantly share code, notes, and snippets.

View crimsonknave's full-sized avatar

Joseph Henrich crimsonknave

  • GitHub
  • Boston, MA
  • 03:29 (UTC -04:00)
View GitHub Profile

Keybase proof

I hereby claim:

  • I am crimsonknave on github.
  • I am crimsonknave (https://keybase.io/crimsonknave) on keybase.
  • I have a public key whose fingerprint is 4C19 2860 9F42 931C 06D8 5B85 4406 5D8D BD2E 4BEC

To claim this, I am signing this object:

@crimsonknave
crimsonknave / pythonesque_case.rb
Created April 8, 2015 21:30
Example of a pythonesque case using a hash with lambdas for values
def parse_options(opts)
parsed = {}
opts.each do |option|
parsed.merge! option_handlers[option].call option
end
parsed
end
def option_handlers
{
def example(&block)
puts 'before we call the block'
yield
puts 'after we call the block'
end
example do
puts 'foo'
end
@crimsonknave
crimsonknave / gist:2127942
Created March 19, 2012 22:55
Finding log lines that don't test if @log in vim
/\v\@log\.\w+\(.*\)( if \@log)@!$
@crimsonknave
crimsonknave / gist:1871244
Created February 20, 2012 20:35
Adding descriptions to json_spec matchers
class JsonSpec::Matchers::BeJsonEql
def description
"be equal to #{@expected}#{" at path #{@path}" if @path}"
end
end
class JsonSpec::Matchers::HaveJsonPath
def description
"have json path #{@path}"
end
end
@crimsonknave
crimsonknave / jruby-hash-print.rb
Created November 29, 2011 22:50
printing hashes nicely in jruby
# Jruby not running in 1.9 mode squashes hashes, ruby doesn't so we'll do a bit of unsquashing for those in jruby land
my_hash = {1 => 2, 3 => "asdf", 4 => :whee}
# In jruby you would get
# puts my_hash
# 123asdf4whee
# with this you get
# {1 => 2, 3 => "asdf", 4 => "whee"}