Skip to content

Instantly share code, notes, and snippets.

@toothrot
toothrot / output.txt
Created July 9, 2010 21:45
how setups get run in Riot
context setups
+ asserts should only run the setup once
+ asserts even with multiple assertions
context setups that are nested
+ asserts gets run again
+ asserts only once per nesting, even with multiple assertions
4 passes, 0 failures, 0 errors in 0.000148 seconds
@toothrot
toothrot / eigenclass_your_face.rb
Created July 9, 2010 21:44
a modular way to smack up eigenclass
module Farts
def farts
"pfft"
end
end
hey = "yo"
hey.farts # NoMethodError: undefined method `farts' for "yo":String
@toothrot
toothrot / what_is_self.rb
Created July 2, 2010 17:09
blocks are funky.
outside = "foo"
classy = Class.new do
define_method(:get_thing) do
outside
end
def get_thing_with_def
outside
end
# via jaknowlden:
irb(main):001:0> (k, v), *rest = [[1,2], [3,4], [5,6]]
=> [[1, 2], [3, 4], [5, 6]]
irb(main):002:0> k
=> 1
irb(main):003:0> v
=> 2
irb(main):004:0> rest
=> [[3, 4], [5, 6]]
@toothrot
toothrot / weird.rb
Created June 15, 2010 22:53
if it's seen by the compiler, it's not a NameError
hey = nil
yo = "foo"
baz = 3 if false
puts hey.inspect
puts yo.inspect
puts baz.inspect # Nil!!
puts spaz.inspect # Name Error
#!/usr/bin/env ruby
require 'rubygems'
require 'growl'
require 'zendesk-api'
require 'tinder'
@z = Zendesk::Main.new("", "", "", :format => "json")
def count_for_rule(rule)
ticket_count = 0
irb(main):039:0* require 'zendesk-api'
MissingSourceFile: no such file to load -- curb
from /Users/alexrakoczy/local/Cellar/ruby-enterprise-edition/2009.10/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Users/alexrakoczy/local/Cellar/ruby-enterprise-edition/2009.10/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/alexrakoczy/local/Cellar/ruby-enterprise-edition/2009.10/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from /Users/alexrakoczy/local/Cellar/ruby-enterprise-edition/2009.10/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /Users/alexrakoczy/local/Cellar/ruby-enterprise-edition/2009.10/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from /Users/alexrakoczy/local/Cellar/ruby-enterprise-edition/2009.10/lib/ruby/gems/1.8/ge
#!/usr/bin/env ruby
require 'rubygems'
require 'growl'
require 'lighthouse/console'
Lighthouse.account = "thepoint"
Lighthouse.token = raise("Get your own key")
proj_id = "13151-support"
@toothrot
toothrot / index.txt
Created November 30, 2009 20:21 — forked from mmcgrana/index.txt
For each Ruby module/class, we have Ruby methods on the left and the equivalent
Clojure functions and/or relevant notes are on the right.
For clojure functions, symbols indicate existing method definitions, in the
clojure namespace if none is explicitly given. clojure.contrib.*/* functions can
be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master,
ruby-to-clojure.*/* functions can be obtained from the source files in this
gist.
If no method symbol is given, we use the following notation:
#!/home/arakoczy/local/bin/ruby
require 'rubygems'
require 'cgi'
require 'open-uri'
require 'hpricot'
query = CGI.escape(ARGV.shift)
puts (Hpricot(open("http://google.com/search?q=#{query}"))%('.r b')).innerHTML