Skip to content

Instantly share code, notes, and snippets.

View jszmajda's full-sized avatar

Jess Szmajda jszmajda

View GitHub Profile
@jszmajda
jszmajda / gol_backbone.md
Created September 18, 2011 15:03
Game of Life in Backbone Design

Model: Cell {x, y, alive} View: CellView {model: Cell} Collection: Cells


CellView renders a div CellView listens to Cell.change to change b.g. color

On app init:

@jszmajda
jszmajda / game_of_life.js
Created September 18, 2011 16:41
Game of Life in Backbone.js
var stepTime = 1;
var col = undefined;
var Cell = Backbone.Model.extend({
x: -1,
y: -1,
alive: false,
nextAlive: false,
initialize: function() {
@jszmajda
jszmajda / Readme.md
Created September 18, 2011 20:22
Game of Life in Erlang

Conway's Game of Life in Erlang, in 2 hours, with 0 Erlang experience, in 20 lines of code.

1337 h4x0rs:

  • @jszmajda
  • @ngauthier
  • @ericoestrich
  • @danivovich
  • @kafuchau
@jszmajda
jszmajda / README.md
Created October 17, 2011 22:16
A potential spec for a ruby X.commerce gem

Overview

This is a rough spec for a gem I would like to use to connect to X.commerce. As X.commerce is new and my experience with it is limited, I'd like to discuss with the community first how best to structure the interaction before actual code is written.

Structure

I've spec'd out the following basic object structure:

@jszmajda
jszmajda / ticket_to_ride_score.rb
Created December 19, 2011 03:21
Ticket To Ride Scoring
def points(x)
{
1 => 1,
2 => 2,
3 => 5,
4 => 7,
6 => 15,
8 => 21
}[x.to_i]
end
@jszmajda
jszmajda / stories.rb
Created March 12, 2012 16:39
Something to quickly create and deliver pivotal stories
require 'pivotal-tracker'
module PivotalTracker
class Project
def create_stories(options={})
req = options[:requester]
own = options[:owner]
stories = options[:stories]
stories.split(/\n/).each do |story|
md = story.strip.match(/^([fcb])(\d) (.*?) \[(.*)\]$/)
@jszmajda
jszmajda / gist:3076527
Created July 9, 2012 13:20
Utility script to create Pivotal Tracker stories
require 'pivotal-tracker'
module PivotalTracker
class Project
def create_stories(options={})
req = options[:requester]
own = options[:owner]
stories = options[:stories]
stories.split(/\n/).each do |story|
md = story.strip.match(/^([fcb])(\d) (.*?) \[(.*)\]$/)
@jszmajda
jszmajda / gist:3800974
Created September 28, 2012 17:00
Evil ping-pong pairing is fun
describe World do
it "should return no cell on a new board" do
w = World.new
w.cell_at(2,2).should be_nil
end
it "should allow cell creation" do
w = World.new
w.make_cell(2,2)
w.cell_at(2,2).should be_kind_of(Cell)
end
def index
if params[:client_id].present? && params[:listing_group_id].present?
@deltas = some lookup...
respond_with @deltas, ajax: { partial: render_to_string(partial: 'histories', locals: {deltas: @deltas}) }
else
data_table_request(catalog_item_deltas_table) # or whatever
end
end
@jszmajda
jszmajda / gol.hs
Created November 3, 2012 22:35
Game of life in Haskell
data Aliveness = Alive | Dead deriving (Show, Eq)
survives :: Aliveness -> Int -> Aliveness
survives _ 3 = Alive
survives Alive 2 = Alive
survives _ _ = Dead
data Point = Point { px :: Int, py :: Int } deriving (Show, Eq)
data Cell = Cell { pt :: Point } deriving (Show, Eq)
data Grid = Grid { cells :: [Cell] } deriving (Show)