Skip to content

Instantly share code, notes, and snippets.

View jinjor's full-sized avatar

Yosuke Torii jinjor

View GitHub Profile
@jinjor
jinjor / gist:34d9ad541ea2212ac6e0
Created February 13, 2015 16:07
setImmediate with throw
var _setImmediate = function(f) {
setImmediate(function() {
try {
f.apply(null, arguments);
} catch (e) {
console.log('HAHAHA!');
}
});
};
@jinjor
jinjor / Button.elm
Last active August 29, 2015 14:23
How to make a 'stateful' component?
--------------------- Button module
import Html exposing (..)
import Html.Events exposing (..)
import Signal exposing (..)
type ButtonEvent = Increment | NoOp
type alias ButtonState = {
count: Int
}
@jinjor
jinjor / Util.elm
Last active September 16, 2015 08:42
elm-effects-util
module Lib.EffectsUtil where
import Task exposing (..)
import Effects exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Time exposing (..)
import Native.EffectsUtil
mapResult : (Result x a -> b) -> Task x a -> Task y b
@jinjor
jinjor / rest-api-test.js
Created May 12, 2016 03:14
Simple REST API Tester sample
var http = require( "http" );
var url = require( "url" );
var request = require('request');
var deepDiff = require('deep-diff');
var cp = require('child_process');
var testCase = withServer(function(done) {
var admin = user();
var server = host('http://localhost:3000');
test([
import Html exposing (Html, text, div)
import Html.Attributes exposing (style)
main =
view modelList
type VariousModel =
X ModelX | Y ModelY | Z ModelZ
import Html exposing (Html, text, button, div, p)
import Html.Attributes exposing (style)
main =
container [ view1, view2 ]
view1 : Html msg
view1 = button [] [ text "button" ]
import Html exposing (Html, text, button, div, p, ul, li)
import Html.Attributes exposing (style)
import Html.Events exposing (onClick)
type OuterMsg =
ContainerMsg InnerMsg | View1Click | View2Click
main : Html OuterMsg
import Html exposing (Attribute, div, button, text)
import Html.App exposing (beginnerProgram)
import Html.Attributes exposing (style)
import Html.Events exposing (onClick, onMouseEnter, onMouseLeave)
import Set exposing (Set)
main =
beginnerProgram { model = { count = 0, hover = hoverInit }, view = view, update = update }
import Html exposing (..)
import Html.App as Html
import Html.Attributes exposing (..)
import Html.Events exposing (on)
import Json.Decode as Json exposing ((:=))
import Mouse exposing (Position)
main =
Html.program <| debugOn
{ init = init
import Html exposing (..)
import Html.App exposing (beginnerProgram)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Json.Decode as Decode exposing (..)
main =
beginnerProgram { model = "", view = view, update = update }