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:
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:
var stepTime = 1; | |
var col = undefined; | |
var Cell = Backbone.Model.extend({ | |
x: -1, | |
y: -1, | |
alive: false, | |
nextAlive: false, | |
initialize: function() { |
Conway's Game of Life in Erlang, in 2 hours, with 0 Erlang experience, in 20 lines of code.
1337 h4x0rs:
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.
I've spec'd out the following basic object structure:
def points(x) | |
{ | |
1 => 1, | |
2 => 2, | |
3 => 5, | |
4 => 7, | |
6 => 15, | |
8 => 21 | |
}[x.to_i] | |
end |
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) (.*?) \[(.*)\]$/) |
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) (.*?) \[(.*)\]$/) |
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 |
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) |