Skip to content

Instantly share code, notes, and snippets.

View jah2488's full-sized avatar

Justin Herrick jah2488

View GitHub Profile

Elm Resources

So you want to learn Elm? Excited to hear it. To get started, its going to help to have some guidance along the way. Below I've collected various helpful resources and tips to get you started.

Starting Out

Things To Do

@jah2488
jah2488 / setup.rb
Last active May 3, 2017 00:56
A setup script for a new laptop. (Assumes you have homebrew and homebrew cask installed)
class Package < Struct.new(:command, :name, :opts)
def install!
if not_installed?
system("#{command} install #{name} #{opts.join(" ")}")
end
end
def not_installed?
!exists?
end
html {
background: #F7F7F7;
color: red;
height: 100%;
}
body {
min-height: 100%;
}
.wrapper {
@jah2488
jah2488 / Main.elm
Last active March 21, 2017 16:38
Do now for Tuesday the 21st of March. Converting a string into a dictionary by last names.
module Main exposing (..)
import Html exposing (Html, div, text)
import Dict exposing (Dict)
names : String -> Dict String (List String)
names str =
str
|> String.split ", "
|> List.map (\name -> String.split " " name)
@jah2488
jah2488 / 1-ruby-why-you.rb
Last active November 22, 2016 19:47
Ruby will allow you to do some pretty amazing... errr terrifying things.
class Foo
def initialize(default = case $glob
when "foo" then (def foobar; "hi!" end)
end)
@default = default
end
end
Foo.new #=> #<Foo:0x007f849f37be98 @default=nil>
$glob = 'foo'
# Structured and Nested
obj = {
container_a = {
name: "Foo",
contents: [item_a, item_b, item_e]
}
container_b = {
name: "Bar",
contents: [item_c, item_d, item_z]
}
it 'sets the state to "gameover" when there is a winner' do
game = Game.new
game.state = "running"
expect { game.winner! }.to change { game.state }.from("running").to("gameover")
end
@jah2488
jah2488 / Main.elm
Created August 8, 2016 21:35
New User form in Elm
module Main exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.App as App
import Html.Events exposing (onInput, onBlur, onClick)
import String exposing (length, left, dropLeft, slice, filter, fromList, toList)
import Char exposing (isDigit)
import Json.Decode as JsonD
import Json.Encode as JsonE
@jah2488
jah2488 / kata.rb
Created July 12, 2016 14:45
A ruby script for generating an empty kata project.
#!/usr/bin/env ruby
# This script will create the folder structure and files
# needed for doing a kata using TDD.
kata_name = (ARGV[0] || 'morning')
dir_name = kata_name + "_kata"
# These are all the commands we will run
# in the order in which we will run them.