Skip to content

Instantly share code, notes, and snippets.

View jquery.fail.js
var myObj = {
number: 10,
createElementsPType: function() {
new_element.click(this.showNumber.bind(this));
}
createElementsjQuery: function() {
new_element.click(this.showNumber);
},
View gist:532286
result = {"Location" => "http://dev.mypunchbowl.com"}
# ...
# somewhere down the line:
result["Location"] # => "http://c.dev.mypunchbowl.com" ... "c"?!?
class OhHaiObj
View create.your.own.renderer.rb
class RawRenderer < WillPaginate::LinkRenderer
def prepare col, opt, template
@collection = col
@options = opt
@options[:container] = nil
@template = template
@total_pages = @collection.total_pages
end
View gist:561487
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 Jan 11, 2011
Errors running mongo_mapper on 1.9.2
View error
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 Mar 2, 2011
WTF is Ruby1.9 doing this to us?
View methods.rb
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 [ ]
View gist:957555
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
mulligan - a concept for dealing with things that can fail frequently
View example.rb
Mulligan.initialize
puts "BEGIN"
#succeeding
mulligan(:times => 4) do
puts "mulligan!"
end.on_failure do
puts "fail"
View after.txt
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 Jun 19, 2011
doing hayzoos' job :P
View presenter_example.rb
class Vid < AR::Base
after_save :encode
private
def encode
VidEncoder.go(self)
end
end
class VidEncoder