Skip to content

Instantly share code, notes, and snippets.

var myObj = {
number: 10,
createElementsPType: function() {
new_element.click(this.showNumber.bind(this));
}
createElementsjQuery: function() {
new_element.click(this.showNumber);
},
result = {"Location" => "http://dev.mypunchbowl.com"}
# ...
# somewhere down the line:
result["Location"] # => "http://c.dev.mypunchbowl.com" ... "c"?!?
class OhHaiObj
class RawRenderer < WillPaginate::LinkRenderer
def prepare col, opt, template
@collection = col
@options = opt
@options[:container] = nil
@template = template
@total_pages = @collection.total_pages
end
ra:code$ rails new r3
create
create README
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
@ryana
ryana / error
Created January 11, 2011 23:05
Errors running mongo_mapper on 1.9.2
ra:mongomapper ryan$ rvm use 1.8.7@mongo_mapper && rake test
info: Using ruby 1.8.7 p302 with gemset mongo_mapper
(in /Users/ryan/code/mongomapper)
--- Active Support Version: 3.0.0 ---
Loaded suite /Users/ryan/.rvm/gems/ruby-1.8.7-p302@mongo_mapper/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
@ryana
ryana / methods.rb
Created March 2, 2011 20:32
WTF is Ruby1.9 doing this to us?
ra:~ ryan$ rvm list
rvm rubies
=> ree-1.8.6-20090610 [ x86_64 ]
ree-1.8.7-2010.01 [ i386 ]
ree-1.8.7-2010.02 [ x86_64 ]
ruby-1.8.7-p249 [ i386 ]
ruby-1.8.7-p302 [ x86_64 ]
ruby-1.9.1-p243 [ ]
@ryana
ryana / gist:957555
Created May 5, 2011 18:08
nerdrage
ruby-1.9.2-p180 :013 > false.to_json
=> "false"
ruby-1.9.2-p180 :014 > JSON.parse(false.to_json)
JSON::ParserError: 737: unexpected token at 'false'
from /Users/ryan/.rvm/gems/ruby-1.9.2-p180@4seg/gems/json-1.5.1/lib/json/common.rb:148:in `parse'
...
from script/rails:6:in `<main>'
ruby-1.9.2-p180 :015 >
@ryana
ryana / example.rb
Created May 27, 2011 20:33
mulligan - a concept for dealing with things that can fail frequently
Mulligan.initialize
puts "BEGIN"
#succeeding
mulligan(:times => 4) do
puts "mulligan!"
end.on_failure do
puts "fail"
Connection Times (ms)
min mean[+/-sd] median max
Connect: 51 57 4.5 55 72
Processing: 60 71 7.9 70 158
Waiting: 53 62 7.3 61 150
Total: 111 127 8.3 126 210
Percentage of the requests served within a certain time (ms)
50% 126
66% 128
@ryana
ryana / presenter_example.rb
Created June 19, 2011 23:53
doing hayzoos' job :P
class Vid < AR::Base
after_save :encode
private
def encode
VidEncoder.go(self)
end
end
class VidEncoder