This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- ruby -*- | |
# This is a fully-functional set of donkey patches that will break | |
# Ruby so badly that it makes all of the Ruby Koans pass right out of | |
# the box. ALl you need to do is patch edgecase.rb with this line: | |
# | |
# require File.expand_path(File.dirname(__FILE__) + '/donkey_patches') | |
# | |
# so it's the first line of the file. Then save this file as |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- ruby -*- | |
require 'test/unit/assertions' | |
class Object | |
def method_missing *args | |
true | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2) Creating a document as the owner of the bucket behaves like a successful create should create the document | |
Failure/Error: before { @file = api_create @bucket, @key } | |
JSON::ParserError: | |
706: unexpected token at '"{\"key\":\"jwstntycxp\"}"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATA.each_line do |line| | |
puts line if line =~ /metasyntactic/ .. line =~ /regular/ | |
end | |
__END__ | |
blah | |
blarg | |
bleem | |
here are some metasyntactic variables | |
foo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StoreProductCollaborator | |
def initialize(product_or_id, store_or_id) | |
# I use this pattern everywhere. I would like to abstract it, but | |
# can't think of a good name for the abstraction. | |
@product = Product.find(product_or_id) unless product_or_id.is_a? Product | |
@store = Store.find(store_or_id) unless store_or_id.is_a? Store | |
end | |
# Intended usage examples: | |
# sp1 = StoreProductCollaborator.new(42, 13) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to do this algorithm in Smalltalk? Call a function on each pair of elements | |
// in a set once. Do not call func(b,a) if func(a,b) has already been called. | |
var i,j,ray,func; | |
ray = [3,2,11,7,5]; | |
func = function(a,b) { | |
console.log(a + "x" + b + " -> " + a*b); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Transcript clear. | |
(1 to: 100) do: [ :i | (i \\ 15 = 0) | |
ifTrue: [Transcript show: 'FizzBuzz'] | |
ifFalse: [ | |
(i \\ 3 = 0) | |
ifTrue: [ Transcript show: 'Fizz'] | |
ifFalse: [ | |
(i \\ 5 = 0) | |
ifTrue: [ Transcript show: 'Buzz' ] | |
ifFalse: [Transcript show: i]. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
unless RUBY_VERSION.start_with? "1.9" | |
puts "This test file is for Ruby 1.9.x" | |
exit -1 | |
end | |
require 'csv' | |
require 'test/unit' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun run-vim () | |
(interactive) | |
(eshell) | |
(switch-to-buffer "*eshell*") | |
(insert "vi") | |
(eshell-send-input)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# THIS IS FIXED! TL;DR: Sprockets has a bug in betas 3, 4, and 5, roll back to beta 2. | |
# | |
# See: http://umwhatnow.com/rails-fix-your-3-1-beta-1-sprockets-problem/ | |
# | |
# Wots of wuv, Dave and Bwandon | |
∫ rails g devise_install | |
/Users/dbrady/.rvm/gems/ruby-1.9.2-p180@ian/gems/actionpack-3.1.0.beta1/lib/sprockets/railtie.rb:37:in `block (2 levels) in <class:Railtie>': undefined method `context' for #<Sprockets::Environment:0x0000010098f840> (NoMethodError) | |
from /Users/dbrady/.rvm/gems/ruby-1.9.2-p180@ian/gems/activesupport-3.1.0.beta1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval' | |
from /Users/dbrady/.rvm/gems/ruby-1.9.2-p180@ian/gems/activesupport-3.1.0.beta1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook' |