Skip to content

Instantly share code, notes, and snippets.

# coding: utf-8
# Can ruby have method names have newlines/be crazy?
class BadKitty
FACE = "
|\\_/|
/ @ @ \\
( > º < )
`>>x<<´
@rafer
rafer / file1.txt
Created June 11, 2013 19:26
Test from Api
The content
@rafer
rafer / file1.txt
Created June 11, 2013 19:25
Test from Api
The content
@rafer
rafer / file1.txt
Created June 11, 2013 19:24
Test from Api
The content
class Thing
include Mongoid::Document
field :integer_field, :type => Integer
field :big_decimal_field, :type => BigDecimal
field :date_field, :type => Date
end
thing = Thing.new
class Product
def list_price=(price)
write_price(:list_price, price)
end
def sales_price=(price)
write_price(:sales_price, price)
end
private
require "open-uri"
loop do
begin
open("http://google.com", :read_timeout => 5)
rescue
puts "Timed out at #{Time.now}"
next
end
@rafer
rafer / question_18.rb
Created April 14, 2011 20:41
ROB 4/14/2011 Trivia: Question 18
# Question 18A. What happens when the following is run?
lambda { |i,j| }.call(1,2,3)
# Question 18B. What happens when the following is run?
Proc.new { |i,j| }.call(1,2,3)
@rafer
rafer / question_15.rb
Created April 14, 2011 20:38
ROB 4/14/2011 Trivia: Question 15
# Question 15. What are the values of a, b, c and d?
a, (b, *c), d = 1, [2, 3, 4], 5
@rafer
rafer / gist:920464
Created April 14, 2011 20:35
ROB 4/14/2011 Trivia: Question 12
# Question 12. What does the following print (as of Ruby 1.9)?
thang = "biscuits"
[1,2,3].each { |n; thang| thang = n }
puts thang