Skip to content

Instantly share code, notes, and snippets.

View rramsden's full-sized avatar
♨️
Keep On Keeping On

Richard Ramsden rramsden

♨️
Keep On Keeping On
View GitHub Profile
def run_spec(file)
unless File.exist?(file)
puts "#{file} does not exist"
return
end
puts "Running #{file}"
system "spec #{file}"
puts
end
(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)
(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))
struct rb_thread {
rb_thread_t next, prev;
rb_jmpbuf_t context;
...
}
#ifdef USE_CONTEXT
typedef struct {
ucontext_t context;
volatile int status;
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
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
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
# we have to fake an enumerable object :) oh what fun!
block = proc {
[@zipfile].each do |file|
yield
end
}
@zip.stub!(:each).and_return(&block)
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
Domingo = {} || Domingo
->
class Camera
constructor: (args...) ->
console.log args
Domingo.Camera = Camera