Skip to content

Instantly share code, notes, and snippets.

View TheSeamau5's full-sized avatar

Hassan Hayat TheSeamau5

  • Entrepreneur
  • Austin, TX
View GitHub Profile
@TheSeamau5
TheSeamau5 / OutlineWebAudioAPI.elm
Created May 7, 2015 17:34
Outline for Web Audio API in Elm
----------------------------
-- Basic Audio Operations --
----------------------------
getAudio : String -> Task Http.Error Audio
play : Audio -> Task error ()
stop : Audio -> Task error ()
@TheSeamau5
TheSeamau5 / Components.elm
Last active August 29, 2015 14:21
UI Components in Elm
import Html exposing (Html, button, text)
import Html.Attributes exposing (style)
import Html.Events exposing (..)
import Signal exposing (Signal, Mailbox, Address, mailbox, send)
import Task exposing (Task, andThen, succeed, spawn, ThreadID)
import Graphics.Element exposing (show)
type alias Component state action view
= { initial : (state, action)
, view : Address action -> state -> view
, address : Address action
, history : Signal (List (state, action))
}
makeComponent
: state
import Signal exposing (Address, Mailbox, Signal, forwardTo)
import Html exposing (Html, div, ul, li)
import List
update : ID -> (state -> state) -> ContainerState state -> ContainerState state
update id f list =
case list of
[] -> []
(id', x) :: xs ->
if id == id'
import Color exposing (Color)
import Graphics.Collage exposing (collage, circle, move, filled)
import Graphics.Element exposing (Element, show)
import Signal exposing (Signal)
import Time
type alias Wave =
{ center : { x : Float, y : Float }
, radius : Float
, color : Color
import Html exposing (Html)
import Html.Events exposing (onClick)
import Signal exposing (Signal, Address, Mailbox)
import Json.Decode as Decode exposing (Decoder, (:=))
import Json.Encode as Encode exposing (Value)
import List
--------------------------------------------
-- Example :
initial = 0
import Signal
import Time
import List
import Graphics.Element exposing (show)
import Graphics.Collage as Collage
import Color
import Random
initial =
import Signal exposing (Signal)
import Html exposing (Html)
import Time
import Random exposing (Generator)
import Json.Decode exposing (Decoder)
import Json.Encode exposing (Value)
type alias Encoder a = a -> Value
mock
@TheSeamau5
TheSeamau5 / divmouse.elm
Created June 5, 2015 16:25
Div follows mouse example
import Html
import Html.Attributes exposing (style)
import Html.Events exposing (on)
import Signal exposing (mailbox)
import Json.Decode exposing (Decoder, (:=), int)
positionDecoder =
@TheSeamau5
TheSeamau5 / buttonAnim.elm
Last active August 29, 2015 14:22
Button in Elm with animation
import Html exposing (Html)
import Html.Attributes exposing (style)
import Html.Events exposing (onClick, onMouseOver, onMouseOut)
import Signal exposing (Signal, Address)
import Time
(=>) = (,)
type alias Options =