Skip to content

Instantly share code, notes, and snippets.

View JeffCohen's full-sized avatar

Jeff Cohen JeffCohen

View GitHub Profile
@jimweirich
jimweirich / weird.rb
Created November 5, 2013 03:51
What does the following print? I was surprised. (Actually, I was surprised it was legal syntax.)
def foo(a=:default, b)
puts "a=#{a}, b=#{b}"
end
foo(:value)
foo(:x, :y)
@JeffCohen
JeffCohen / gist:5380180
Last active December 16, 2015 04:49
monopoly tests
require "test/unit"
#######################################################
#
# Your code starts on line 20.
#
# To run the tests from your command line:
#
# > rake
#
@srobbin
srobbin / index.html
Created March 19, 2013 13:06
jQuery Plugin Workshop Adding in Options
<h2>Antispam</h2>
<p>Email me at <span class="antispam">scott at-symbol robbin dot co</span></p>
@jakeonrails
jakeonrails / Ruby Notepad Bookmarklet
Created January 29, 2013 18:08
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@mikeebert
mikeebert / changekata_spec.rb
Created March 19, 2012 21:35
Coin Changer Kata
# Spec Step 1
describe CoinChanger do
it "should return a penny" do
CoinChanger.make_change(1).should == %w(p)
end
end
# Class Step 1 - after failed uninitialized constant, failed no method errors, failed wrong number of arguments and
# failed 'got nil expected ["p"]'
class CoinChanger
@jamis
jamis / recursive-backtracker.rb
Created December 24, 2010 22:41
Implementation of the recursive backtracking algorithm for maze generation
# Recursive backtracking algorithm for maze generation. Requires that
# the entire maze be stored in memory, but is quite fast, easy to
# learn and implement, and (with a few tweaks) gives fairly good mazes.
# Can also be customized in a variety of ways.
DIRS = (N, S, E, W = 1, 2, 4, 8)
DX = { E => 1, W => -1, N => 0, S => 0 }
DY = { E => 0, W => 0, N => -1, S => 1 }
OPPOSITE = { E => W, W => E, N => S, S => N }