Skip to content

Instantly share code, notes, and snippets.

View chrisbuttery's full-sized avatar
🏠
Working from home

Chris Buttery chrisbuttery

🏠
Working from home
View GitHub Profile
@chrisbuttery
chrisbuttery / destructuring.md
Created October 23, 2016 23:45 — forked from yang-wei/destructuring.md
Elm Destructuring (or Pattern Matching) cheatsheet

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !

Tuple

myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))

let
  (a,b,c) = myTuple
@chrisbuttery
chrisbuttery / main.elm
Created November 14, 2016 05:21
elm-pascal
module Main exposing (..)
import Html exposing (..)
depth : number
depth =
10

Use these rapid keyboard shortcuts to control the GitHub Atom text editor on Mac OSX.

Key to the Keys

  • ⌘ : Command key
  • ⌃ : Control key
  • ⌫ : Delete key
  • ← : Left arrow key
  • → : Right arrow key
  • ↑ : Up arrow key
@chrisbuttery
chrisbuttery / PascalsTriangles.js
Created June 30, 2016 12:37 — forked from kgates-github/PascalsTriangles.js
Two ways to create a Pascal's Triangle in JavaScript.
var numTiers = 100,
triangle,
start,
stop;
/**
*
* First version uses recursion
*
*/
@chrisbuttery
chrisbuttery / Main.elm
Last active May 20, 2016 05:23 — forked from hoelzro/Shuffle.elm
List shuffle implementation in Elm
import Html exposing (..)
import Html.App as Html
import Html.Events exposing (..)
import Random exposing (Generator)
import List
users =
[ {name = "one", username = "@one"}
, {name = "two", username = "@two"}
, {name = "three", username = "@three"}
@chrisbuttery
chrisbuttery / shuffle.elm
Created May 19, 2016 05:08 — forked from AlexNisnevich/shuffle.elm
Shuffling a list in Elm
import List
import Random
without : Int -> [a] -> [a]
without i arr =
let before = take i arr
after = drop (i+1) arr
in
before ++ after
@chrisbuttery
chrisbuttery / introrx.md
Created January 19, 2016 22:07 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
type Action
= Updated Response
| APIError Error
update : Action -> Model -> ( Model, Effects Action )
update action model =
case action of
Updated response -> -- do things
APIError error ->
let
@chrisbuttery
chrisbuttery / CustomStartApp.elm
Created March 4, 2016 01:51 — forked from danyx23/CustomStartApp.elm
Use ports with customized StartApp and "PortActions"
module CustomStartApp (start, App, Config) where
import Html exposing (Html)
import Effects exposing (Effects, Never)
import Task
type alias Config model action portAction =
{ init : ( model, Effects action, portAction )
, update : action -> model -> ( model, Effects action, Maybe portAction )
@chrisbuttery
chrisbuttery / elm-package.json
Created March 4, 2016 01:51 — forked from danyx23/elm-package.json
Simple example of using Ports in Elm
{
"version": "1.0.0",
"summary": "helpful summary of your project, less than 80 characters",
"repository": "https://github.com/user/project.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {