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
def run_spec(file) | |
unless File.exist?(file) | |
puts "#{file} does not exist" | |
return | |
end | |
puts "Running #{file}" | |
system "spec #{file}" | |
puts | |
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
(define HEIGHT 600) | |
(start WIDTH HEIGHT) | |
; post | |
(draw-solid-line (make-posn 0 10) (make-posn (/ WIDTH 2) 10) 'black) | |
(draw-solid-line (make-posn (/ WIDTH 2) 10) (make-posn (/ WIDTH 2) 50) 'black) | |
(define draw-head | |
(and (draw-circle (make-posn (/ WIDTH 2) 80) 30 'red) |
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
(define (draw-head) | |
(draw-circle (make-posn (/ WIDTH 2) 80) 30 'red) | |
(draw-solid-line (make-posn (/ WIDTH 2) 50) (make-posn (/ WIDTH 2) 60) 'black)) |
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
struct rb_thread { | |
rb_thread_t next, prev; | |
rb_jmpbuf_t context; | |
... | |
} | |
#ifdef USE_CONTEXT | |
typedef struct { | |
ucontext_t context; | |
volatile int status; |
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
RAILS 3.0.7 | |
ruby-1.9.2-p136 :006 > c = Category.new(:title => "test") | |
=> #<Category id: nil, title: "test", created_at: nil, updated_at: nil> | |
ruby-1.9.2-p136 :007 > c.new_record? | |
=> true | |
ruby-1.9.2-p136 :008 > c.update_attribute(:title, "change me") | |
=> true | |
ruby-1.9.2-p136 :009 > c.new_record? | |
=> false |
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
Website.reflect_on_all_associations( :has_many ).each do | assoc | | |
instance_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 | |
puts "looking at #{assoc.name}" | |
if #{assoc.name}.first.respond_to?(:to_backup) | |
puts "#{assoc.name} responded" | |
xml.#{assoc.name} do | |
#{assoc.name}.each {|collection| xml << collection.to_backup} | |
end unless #{assoc.name}.blank? | |
end | |
RUBY_EVAL |
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
Website.reflect_on_all_associations( :has_many ).each do | assoc | | |
instance_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 | |
if #{assoc.name}.first.respond_to?(:to_backup) | |
xml.#{assoc.name} do | |
#{assoc.name}.each {|collection| xml << collection.to_backup} | |
end unless #{assoc.name}.blank? | |
end | |
RUBY_EVAL | |
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
# we have to fake an enumerable object :) oh what fun! | |
block = proc { | |
[@zipfile].each do |file| | |
yield | |
end | |
} | |
@zip.stub!(:each).and_return(&block) |
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 A | |
def initialize | |
@stub = lambda {|&block| [1,2,3,4].each{|n| block.call(n)}} | |
end | |
def each(&block) | |
@stub.call(&block) | |
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
Domingo = {} || Domingo | |
-> | |
class Camera | |
constructor: (args...) -> | |
console.log args | |
Domingo.Camera = Camera |