Skip to content

Instantly share code, notes, and snippets.

View leojpod's full-sized avatar
🎯
UHK is the best keyboard

Leo Jpod leojpod

🎯
UHK is the best keyboard
View GitHub Profile
@leojpod
leojpod / sortedTree.hs
Created October 17, 2020 06:37
sortedTree for the futurelearn Haskell MOOC
{-# LANGUAGE TemplateHaskell #-}
-- sortedtree.hs
-- Jeremy.Singer@glasgow.ac.uk
-- Example code for #FLhaskell course
-- Nodes contain integers, Leaves are empty
data Tree = Leaf | Node Int Tree Tree deriving Show
@leojpod
leojpod / keybase.md
Created September 11, 2020 08:39
keybase.md

Keybase proof

I hereby claim:

  • I am leojpod on github.
  • I am leojpod (https://keybase.io/leojpod) on keybase.
  • I have a public key ASCrQ3PAFjUu4e0OvhkHDy2bf3blt2HTJt6UMujOG-6uLwo

To claim this, I am signing this object:

@leojpod
leojpod / View.elm
Created May 22, 2017 15:18
Svg version of Board/View.elm
import Svg exposing (Svg, svg, rect, circle)
import Svg.Attributes exposing (x, cx, y, cy, r, fill, width, height, viewBox)
boardDisplay : Board -> Html BoardMsg
boardDisplay board =
svg
[ viewBox "0 0 100 100"
]
(rect [ fill "#FFFFFF", x "0", y "0", width "100", height "100" ] []
:: List.concat (List.indexedMap rowView board)
@leojpod
leojpod / View.elm
Created May 22, 2017 14:58
View.elm for the board: HTML version
boardDisplay : Board -> Html BoardMsg
boardDisplay board =
table []
((tr []
((td [] [])
:: ((List.range 0 9)
|> List.map (\col -> td [] [ text (toString col) ])
)
)
)
@leojpod
leojpod / State.elm
Last active May 22, 2017 12:56
App's state file
init : ( Model, Cmd Msg )
init =
let
( subModuleInitModel, subModuleInitCommand ) =
SubModule.State.init
-- repeat for any submodule you have
model = Model subModuleInitModel ... -- init your model here
cmd = Cmd.batch [ subModuleInitCommand, ... ] -- init your commands here
in
( model, cmd )
@leojpod
leojpod / Types.elm
Created May 18, 2017 12:36
Main types game-of-like
import Setup.Types exposing (Setup, SetupMsg(..))
import Board.Types exposing (Board, BoardMsg)
-- MODEL
type alias Model =
{ board : Board, setup : Setup, mdl : Material.Model }
-- MESSAGE
type Msg
= BoardMsg BoardMsg
@leojpod
leojpod / state.elm
Created May 15, 2017 12:36
elm-mdl update
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
... -- rest of our apps messages
Mdl mdlMsg ->
Material.update Mdl mdlMsg model
@leojpod
leojpod / index.html
Created May 15, 2017 10:03
elm-mdl html setup
<!DOCTYPE HTML>
<!-- MDL -->
<link href='https://fonts.googleapis.com/css?family=Roboto:400,300,500|Roboto+Mono|Roboto+Condensed:400,700&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.min.css" />
<body>
<div></div>
<script src="elm.js"></script>
<script>Elm.App.embed(document.querySelector("div"));</script>
</body>
@leojpod
leojpod / model.elm
Created May 15, 2017 09:48
elm-mdl model
alias Model =
{ ... -- your usual model definition goes here
, mdl :
Material.Model
-- use elm-mdl's definition of their model
}
model : Model
model =
{ ... -- your initialization goes here
@leojpod
leojpod / assignTo.elm
Created March 30, 2017 15:22
the better way
assignTo : String -> Item -> Item
assignTo user task =
let
updateAssignee taskProperties =
{ taskProperties | assignee = Just user }
in
case task of
Task props ->
Task (updateAssignee props)
SubTask props ->