Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Spurling alexspurling

View GitHub Profile
@alexspurling
alexspurling / XMLLexer.g4
Last active Jun 18, 2018
Adaptation to XML ANTLR Grammar
View XMLLexer.g4
/*
[The "BSD licence"]
Copyright (c) 2013 Terence Parr
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
@alexspurling
alexspurling / Canvas.elm
Created Aug 21, 2016
Possible Elm model update syntax
View Canvas.elm
update : Msg -> Model -> Model
update msg model =
case msg of
CanvasResized canvasSize ->
model
|> :canvas
|> updateCanvasSize canvasSize
|> updateVisibleTiles
@alexspurling
alexspurling / Decoder.elm
Created Nov 10, 2015
Not sure how to complete these Json Decoder example.
View Decoder.elm
type alias Answer =
{ name : String,
imgUrl : String
}
decodeAnswers : Json.Decoder (List Answer)
decodeAnswers =
let
imageUrlDecoder = ("url" := Json.string)
@alexspurling
alexspurling / randomexample.elm
Last active Sep 15, 2015
Elm example for producing random values in a model
View randomexample.elm
import Html exposing (div, button, text)
import Html.Events exposing (onClick)
import StartApp.Simple as StartApp
import Random exposing (Seed)
type alias Model = { seed : Seed, values : List Int }
initialModel : Model
initialModel =
{ seed = (Random.initialSeed 0),
View HttpTest.elm
import Html exposing (..)
import Html.Events exposing (onClick)
import Http
import Json.Decode as Json exposing((:=))
import StartApp.Simple as StartApp
type alias Model =
{ name : String
, amount : Int
@alexspurling
alexspurling / Distances.elm
Created Aug 3, 2015
Two methods for generating a random distance matrix one in Elm and one in Javascript.
View Distances.elm
import Array
import Debug
import Random
import Matrix
planetNames : Array.Array String
planetNames = Array.fromList [
"Terra",
"Vulcan",
"Omicron Persei 8",
@alexspurling
alexspurling / InitialValues.elm
Last active Sep 15, 2015
Port initial value example
View InitialValues.elm
module InitialValues where
import Graphics.Element exposing (..)
port timestamp : Int
main =
show ("Hello" ++ (toString (timestamp + 2)))
@alexspurling
alexspurling / bash_aliases
Last active Aug 29, 2015
OSX terminal notification for completed builds
View bash_aliases
#Add an alias for your build commands for example:
alias make='notify make'
alias mvn='notify mvn'
@alexspurling
alexspurling / bash_aliases
Created Feb 11, 2015
OSX terminal notification for completed builds
View bash_aliases
#Add an alias for your build commands for example:
alias make='notify make'
alias mvn='notify mvn'