Skip to content

Instantly share code, notes, and snippets.

View dcmorse's full-sized avatar

Dave Morse dcmorse

View GitHub Profile
@dcmorse
dcmorse / TreeOfInt.elm
Created October 14, 2018 23:52
parsing recursive, lisp-like JSON in elm
-- I feel very uncertain this is the Right Thing.
-- tested against Elm 0.19
import Json.Decode exposing (..)
type TreeOfInt
= Branch (List TreeOfInt)
| Leaf Int
-- decodeString treeOfInt "[7, [10]]" => Branch [Leaf 7, Branch [Leaf 10]]
treeOfInt : Decoder TreeOfInt
class A
public
def do_thing(x)
super_secret_internal_implementation_function_xpjdljadhlhjjalj(x) * 10
end
private
# randomly chosen name no one else is likely to use:
def super_secret_internal_implementation_function_xpjdljadhlhjjalj(x)
x*x
=begin
Class Hierarchy
A
/ \
B1 B2
/ \
C1 C2
@dcmorse
dcmorse / gamelog.sh
Last active May 4, 2016 11:32
GameLog Rails Demo
echo lets practice has-and-belongs-to-many-relationships in rails
echo lets create a record of which players know how to play which games
rails new gamelog
cd gamelog/
rake db:create
rails generate model Player name:string
rails generate model Game name:string
echo add has_and_belongs_to_many calls to both models
echo see http://guides.rubyonrails.org/association_basics.html#the-has-and-belongs-to-many-association for details
echo this next command isnt what I want because it doesnt create .players and .games methods