Skip to content

Instantly share code, notes, and snippets.

View dsturnbull's full-sized avatar

David Turnbull dsturnbull

View GitHub Profile
def Hash(*args, &block)
if args.any?
args[0]
else
Hash.from_block &block
end
end
class Hash
def self.from_block &block
@dsturnbull
dsturnbull / grapple.rb
Created August 26, 2008 06:10 — forked from atnan/grapple.rb
more elite version
require 'rubygems' rescue nil
require 'gosu'
require 'chipmunk'
class Array
# e.g. [1,2,3].each_link yields [1,2], [2,3]
def each_link
prev = first
self[1, size].each do |item|
yield prev, item
scope 'merb-gen' do
# do merb-gen stuff here
end
scope 'monkey' do
# do monkey stuff here
end
[ew[