Skip to content

Instantly share code, notes, and snippets.

@marksim
marksim / game_of_life_spec.rb
Created June 6, 2013 18:07
A quick pairing exercise with @mattr- to learn a bit more about how to approach tests.
require 'rspec'
class Game
attr_reader :alive_cells
def initialize(living_cells)
@living_cells = {}
living_cells.each do |coords|
@living_cells[coords] = Cell.new(true)
end
end
@marksim
marksim / tictactoe.rb
Created May 16, 2013 14:59
Tic Tac Toe pairing with @kmeister2000
class TicTacToe
SIZE = 3
def initialize
@board = []
SIZE.times do
row = []
SIZE.times do
row << nil
@marksim
marksim / game_of_life_spec.rb
Created May 14, 2013 03:26
First pass at Conway's Game of Life implementation with @thecommongeek
require 'rspec'
class Life
def initialize
@cells = [
[Cell.new, Cell.new, Cell.new],
[Cell.new, Cell.new, Cell.new],
[Cell.new, Cell.new, Cell.new],
]
end
@marksim
marksim / tictactoe.rb
Last active December 16, 2015 16:08
Tic Tac Toe implementation through TDD As If you Mean It - (http://cumulative-hypotheses.org/2011/08/30/tdd-as-if-you-meant-it/)
require 'rspec'
# Tic Tac Toe is
# a game
# with a 3x3 board
# and two players
# one is 'X'
# one is 'O'
# X begins
# Players take turns
# placing an indicator on the board
@marksim
marksim / dreamhost.rb
Last active December 11, 2015 20:49
Rails 3.2 template for Dreamhost functioning with twitter bootstrap, simple_form, and sorcery
# To use, type:
# rails new <application> -m https://gist.github.com/raw/4658117
create_file ".rvmrc", "rvm use ruby-1.8.7-p358"
# Basic Gems
gem 'sorcery'
gem 'cancan'
gem 'mini_magick'
gem 'carrierwave'
gem 'haml-rails'
@marksim
marksim / README.md
Created July 10, 2012 16:18
How to isolate mail dependency without integrating into data model?

I'm not sure how to remove the dependency on VerificationMailer without pushing it into the profile model and making the model suddenly care about how to mail verifications.

I WANT to remove it so I don't have any need to load up rails when running the tests, but also want to keep my models sensible and without a lot of knowledge of business logic.

Example usage:

profile = Profile.find(1)
profile.extend Verifier

profile.verify(email: 'myemail@example.com')

@marksim
marksim / OSX_Sublime.keymap
Created March 14, 2012 22:01
User sublime keymap for mapping CMD-T to the universal "goto"
[
{ "keys": ["super+t"], "command": "show_overlay", "args": {"overlay": "goto"} }
]
@marksim
marksim / gist:1355316
Created November 10, 2011 16:34
.bash_profile git ninja stuff
export PS1='\[\033[00;32m\]\u\[\033[01m\]@\[\033[00;36m\]\h\[\033[01m\]:\[\033[00;35m\]\w\[\033[00m\]\[\033[01;33m\]`git branch 2>/dev/null|cut -f2 -d\* -s`\[\033[00m\]\$ '
source ~/.git-completion.bash
@marksim
marksim / game_of_life.rb
Created November 4, 2011 17:54
Game of Life with Rspec
require 'rspec'
class Cell
attr_accessor :x, :y, :world
def initialize(world, x=0, y=0)
@world = world
@x = x; @y = y
@world.add(self)
end
@marksim
marksim / basic.rb
Created July 28, 2011 13:03
Basic mechanics of the game
SpaceTruckin.play("John", "Paul", "George") do |game|
until game.finished?
game.reset_stages
game.players.each do |player|
stage_name = game.available_stage_names[rand(game.available_stage_names.length)]
case stage_name
when "Demand"