Skip to content

Instantly share code, notes, and snippets.

View jinjor's full-sized avatar

Yosuke Torii jinjor

View GitHub Profile
@jinjor
jinjor / program-spec.md
Last active November 12, 2018 23:26
Elm program spec

How Elm program works

Program .html .js embed flags port file
Html.node
Browser.sandbox
Browser.element
Browser.document
Browser.application
Platform.worker
module Return exposing
( Return
, map
, return
, toTuple
, withCommand
, withTask
)
import Http
@jinjor
jinjor / assets.md
Last active September 15, 2018 21:00
Asset Manager

シンプルな世界を目指したい

欲しい

  • TypeScript bundle (or concatenation)
  • CSS bundle (or concatenation)
  • ハッシュつきファイル
  • PostCSS
    • autoprefixer
  • minify

Programming in Japan

Pros

  • Single timezone
  • Simple month names
  • No plurals
  • No AM and PM
  • YYYY/MM/DD
  • Metric units
json = """{ "name": "tom", "age": 42 }"""
decodeString (maybe (field "age" int )) json -- Ok (Just 42)
decodeString (maybe (field "name" int )) json -- Ok Nothing
decodeString (maybe (field "height" float)) json -- Ok Nothing
decodeString (maybe (field "height" float)) "null" -- Ok Nothing
decodeString (maybe (field "height" float)) "\"hello\"" -- Ok Nothing
decodeString (maybe (field "height" float)) "" -- Err ...
decodeString (field "age" (maybe int )) json -- Ok (Just 42)
module Tuple3 exposing (..)
get1and2 : ( a, b, c ) -> ( a, b )
get1and2 ( a, b, c ) =
( a, b )
get2and3 : ( a, b, c ) -> ( b, c )
get2and3 ( a, b, c ) =
@jinjor
jinjor / elm-make-perf.sh
Last active April 23, 2022 13:32
elm-make one by one
# make sure every time only one file is re-compiled
echo "time\t\tlines\timports\tfile"
for f in `find src -name *.elm`
do
elm-make $f --output=/dev/null > /dev/null
sleep 1
touch $f
a=`wc -l $f | awk '{print $1}'`
module Util.HttpUtil exposing (..)
import Task exposing (..)
import Http exposing (..)
import Json.Decode as D exposing (Decoder)
import Json.Encode as E
encodeHeaders : List ( String, String ) -> E.Value
encodeHeaders headers =
@jinjor
jinjor / original.json
Last active July 20, 2017 09:28
Yet Another JSON Schema (thought experiment)
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "A representation of a person, company, organization, or place",
"type": "object",
"required": ["familyName", "givenName"],
"properties": {
"fn": {
"description": "Formatted Name",
"type": "string"
},
@jinjor
jinjor / JsxParserNotFinished.elm
Last active May 30, 2017 09:30
JSXパーサー途中まで書いたけどゴミ箱行き
module JsxParser
exposing
( JSXElement
, JSXAttribute
, JSXAttributeValue(..)
, JSXChild(..)
, run
)
{- JSX Parser