Skip to content

Instantly share code, notes, and snippets.

View jinjor's full-sized avatar

Yosuke Torii jinjor

View GitHub Profile
@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
@jinjor
jinjor / ObjectCreator.elm
Last active May 18, 2017 03:11
Sample for generating id
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Random exposing (..)
main =
program
{ init = init
, update = update
@jinjor
jinjor / TypeClassSim.elm
Last active May 18, 2017 01:12
type class exercise in Elm
import Html exposing (text)
main =
text (toString <| allTheSame equal [ obj1, obj2, obj3 ])
obj1 = { id = 1, name = "foo" }
obj2 = { id = 1, name = "bar" }
obj3 = { id = 1, name = "baz" }
interface BeginnerProgram<Model, Msg> {
Model model();
Model update(Msg msg, Model model);
Html<Msg> view(Model model);
}
@jinjor
jinjor / normalize.js
Last active April 6, 2017 09:07
Query normalizer for casual use
// https://gist.github.com/kawanet/5553478
function normalizeKana(src) {
return src.replace(/[\u30a1-\u30f6]/g, function(match) {
var chr = match.charCodeAt(0) - 0x60;
return String.fromCharCode(chr);
});
}
// http://www13.plala.or.jp/bigdata/kanji_2.html
function normalizeKanji(src) {
@jinjor
jinjor / simple-markdown.html
Created March 29, 2017 10:11
Casual Markdown Documentation for Japanese
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.6/marked.min.js"></script>
<link href="https://fonts.googleapis.com/earlyaccess/roundedmplus1c.css" rel="stylesheet" />
<style>
html { background-color: #eee; }
body { background-color: #fff; margin: 0; padding: 20px 40px; font-family: "Rounded Mplus 1c"; max-width: 500px; margin-left: auto; margin-right: auto; }
h2 { border-bottom: solid 1px; margin-top: 2em; }
@jinjor
jinjor / Colors.elm
Created March 18, 2017 00:17
Material Colors in Elm
module Colors exposing (..)
{-
https://material.io/guidelines/style/color.html
$$('.color-group').filter((_,i) => i < 19).map(g => $('.main-color .name',g).textContent.toLowerCase()).join('\n')
$$('.color-group').filter((_,i) => i < 19).map(g => $('.main-color .name',g).textContent.toLowerCase() + ' =\n [ ' + $$('li.color', g).filter((c, i) => i >= 1 && i <= 10).map(c => '(' + c.textContent.split('#')[0] + ', "#'+c.textContent.split('#')[1] + '")').join('\n , ') + '\n ]').join('\n\n')
-}
depth : Int -> List String
headOrDead : List a -> a
headOrDead list =
case list of
[] ->
Debug.crash "oh?"
x :: _ ->
x
@jinjor
jinjor / Konami.elm
Last active February 3, 2017 03:23
port module Konami exposing (..)
import Char
import Keyboard exposing (KeyCode)
main =
Platform.program
{ init = init