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 / 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 / Main.elm
Created May 18, 2016 06:54
Elm 0.17. A simple filtering digits from Keyboard.presses example
import Html exposing (Html, text, div)
import Html.App as Html
import Keyboard exposing (..)
import Char exposing (..)
main =
Html.program
{ init = init
, view = view
, update = update
@chrisbuttery
chrisbuttery / Main.elm
Last active May 8, 2017 03:42
Elm 0.17. A simple Keyboard.presses example
import Html exposing (Html, text, div)
import Html.App as Html
import Keyboard exposing (..)
import Char exposing (..)
main =
Html.program
{ init = init
, view = view
, update = update
@chrisbuttery
chrisbuttery / Main.elm
Last active May 18, 2016 05:51
Elm 0.17. A simple Window.resizes example.
import Html exposing (Html, text, div)
import Html.App as Html
import Window exposing (..)
main =
Html.program
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
@chrisbuttery
chrisbuttery / Main.elm
Last active January 3, 2018 17:15
Elm 0.17. A simple Mouse.moves example
import Html exposing (Html, text, div)
import Html.App as Html
import Mouse exposing (..)
main =
Html.program
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
@chrisbuttery
chrisbuttery / Main.elm
Last active May 18, 2016 05:51
Elm 0.17. A simple 'mouse clicks' example
import Html exposing (Html, text, div)
import Html.App as Html
import Mouse exposing (..)
main =
Html.program
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
@chrisbuttery
chrisbuttery / Main.elm
Last active March 18, 2016 12:04
ELM: Prevent ships from positioning over each other
module Game (..) where
import Graphics.Element exposing (..)
import Graphics.Collage exposing (..)
import Color exposing (red, blue, gray, green)
import Keyboard
import Window
-- ALIAS
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 / Main.elm
Created March 4, 2016 06:28
Fun with Signals
module Main (..) where
import Graphics.Element exposing (..)
import Time exposing (Time, second)
import Effects exposing (Effects)
import Keyboard
type alias DebounceState =
Maybe