Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Chris Buttery chrisbuttery

🏠
Working from home
View GitHub Profile
@chrisbuttery
chrisbuttery / Main.elm
Last active May 20, 2016 — forked from hoelzro/Shuffle.elm
List shuffle implementation in Elm
View Main.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 — forked from AlexNisnevich/shuffle.elm
Shuffling a list in Elm
View shuffle.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
Elm 0.17. A simple filtering digits from Keyboard.presses example
View Main.elm
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
Elm 0.17. A simple Keyboard.presses example
View Main.elm
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
Elm 0.17. A simple Window.resizes example.
View Main.elm
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 Jan 3, 2018
Elm 0.17. A simple Mouse.moves example
View Main.elm
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
Elm 0.17. A simple 'mouse clicks' example
View Main.elm
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 Mar 18, 2016
ELM: Prevent ships from positioning over each other
View Main.elm
module Game (..) where
import Graphics.Element exposing (..)
import Graphics.Collage exposing (..)
import Color exposing (red, blue, gray, green)
import Keyboard
import Window
-- ALIAS
View alternative.elm
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
View Main.elm
module Main (..) where
import Graphics.Element exposing (..)
import Time exposing (Time, second)
import Effects exposing (Effects)
import Keyboard
type alias DebounceState =
Maybe