Skip to content

Instantly share code, notes, and snippets.

View zspencer's full-sized avatar

Zee zspencer

View GitHub Profile
@zspencer
zspencer / custom_assertion_spec.rb
Created November 24, 2012 21:31
3 Variations of Spec Files
require './numeral_converter'
require 'minitest/autorun'
describe NumeralConverter do
describe "#to_roman" do
it "converts 1 to I" do
1.must_equal_roman "I"
end
it "converts 2 to II" do
2.must_equal_roman "II"
@zspencer
zspencer / tic_tac_toe_kata.rb
Last active December 10, 2015 18:38
Playing around with custom contexts in rspec for making succinct yet communicative test definitions and defining methods to be used as blocks.
class TicTacToe < Struct.new(:board)
CATS_GAME = :c; INCOMPLETE_GAME = :e; PLAYERS = [:x, :o]
def winner
winning_row.first
end
private
def clear_winner?
!winning_permutation.nil?
(verse 1)
The boss thinks you are get-ting la-zy and fat,
Want's you to get up and get off your ass.
What's a better motivator than a stat?
Even better if it just happens like that.
Take off your shoes and walk on the grass
I'm on your belt and I don't take any sass
(chorus)
@zspencer
zspencer / things.rb
Created January 30, 2013 02:23
blocks, procs, lambdas, and methods
class String
def fuck_yea(&block)
each_char do |c|
p yield(c)
end
end
def fuck_yea_with_callback(callback)
each_char do |c|
callback.call(c)
@zspencer
zspencer / .rvmrc
Last active December 12, 2015 07:28
A parser that takes tweets and builds relationships between tweeters.
rvm use system@network-graph --create
@zspencer
zspencer / config.yml
Created March 3, 2013 18:03
Host assets on CloudFront while keeping HTML on S3 with Jekyll
asset_url:
- production: http://assets.zeespencer.com/assets
- development: /assets
@import "susy";
$total-columns: 12;
$column-width: 4em;
$gutter-width: 1em;
$grid-padding: $grid-padding;
body {
font-family: Helvetica, sans-serif;
background-image: image-url('gray_jean.png');
[zee@prime ~]$ sudo salt 'hedgehog.makeheadspace.com' grains.items
hedgehog.makeheadspace.com:
cpu_flags: fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx lm rep_good unfair_spinlock pni vmx cx16 popcnt hypervisor lahf_lm
cpu_model: QEMU Virtual CPU version 1.0
cpuarch: x86_64
defaultencoding: None
defaultlanguage: None
domain: makeheadspace.com
fqdn: hedgehog.makeheadspace.com
gpus:
@zspencer
zspencer / game_of_life.rb
Created October 10, 2013 19:46
Conways Game of Life
class Judge
def cast_judgement(cell)
if cell.neighbor_count < 2 || cell.neighbor_count > 3
cell.kill!
end
end
end
class Cell
(defn inc-all []
(let [x '(1,2,3)]
(println (map inc x))
(println x)))
(inc-all)