Skip to content

Instantly share code, notes, and snippets.

View lenary's full-sized avatar

Sam Elliott lenary

View GitHub Profile
class Chapter
include Mongoid::Document
field :position, :type => Integer
field :title, :type => String
field :identifier, :type => String
embedded_in :book
embeds_many :elements
def self.process!(git, file)
woop = {
foo: "bar",
qux: "baz"
}
woop.each.with_index do |(name, value), index|
puts "#{index}: #{name} = #{value}"
end
@lenary
lenary / hello.rb
Created February 3, 2012 14:48 — forked from urfolomeus/hello.rb
Class level privates
class Hello
def self.first
"Boo!"
end
private
def self.second
"Buh!"
end
@lenary
lenary / 00demo.md
Last active December 18, 2015 17:49 — forked from seancribbs/00demo.md
@lenary
lenary / gcounter.idr
Created June 25, 2014 14:31 — forked from mrb/cong.idr
module Main
import Prelude.Algebra
record GCounter : Type where
MkGCounter : (value : Int) -> GCounter
gcjoin : GCounter -> GCounter -> GCounter
gcjoin l r = (MkGCounter ((value l) + (value r)))
@lenary
lenary / test.hs
Last active October 10, 2017 20:40 — forked from elliotdavies/test.hs
Haskell pattern question
-- In `f` we want to keep piping (part of) the result of one function into
-- another, and stop as soon as something fails
f :: [A] -> Either String (B, [A])
f xs =
case f1 xs of
Left s -> Left s
Right (res1, xs') ->
case f2 xs' of
Left s -> Left s
Right (res2, xs'') ->