(function isBound() {return !!isBound}); isBound();
// ReferenceError: isBound is not defined
function isBound() {return !!isBound}; isBound();
// true
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This module doesn't work on arbitrarily nested JSON. | |
-- See the AnyDecoderFixed module, also in this gist, | |
-- for a version that does work with any JSON. | |
module AnyDecoderBroken where | |
import Json.Decode as Js exposing (Decoder, (:=)) | |
import Dict exposing (Dict) | |
import Array exposing (Array) | |
import Graphics.Element exposing (show) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- inspired by: https://groups.google.com/d/msg/elm-discuss/2LxEUVe0UBo/ZgJ_ldUH6ygJ | |
-- thanks for the help: http://learnyouahaskell.com/functors-applicative-functors-and-monoids | |
module UserDecoder where | |
import Date exposing (Date) | |
import User exposing (User) | |
import Json.Decode as Js exposing ((:=)) | |
-- Applicative's `pure`: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AttributeReaders | |
class <<self | |
# str = "foo" | |
# overrides = { | |
# another_reverse: :reverse, | |
# exclaimed: ->(str) { str + "!" }, | |
# to_sym: ->(str) { str.reverse.to_sym } | |
# } | |
# reader = AttributeReaders.object_reader(str, overrides) | |
# [:reverse, :another_reverse, :exclaimed, :to_sym].map(&reader) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Mouse | |
import Array | |
buildAppDataMap delta pos history = | |
{ frameDelta=delta | |
, mousePosition=pos | |
, clickHistory=history } | |
arrayTakeLast n array = | |
let inputLen = Array.length array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
debounce : Time -> Signal a -> Signal a | |
debounce t sig = sig |> sampleOn (Time.since t sig |> keepIf not False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -I https://shopify.github.io/dashing/ | |
HTTP/1.1 200 OK | |
Date: Sat, 14 Jun 2014 16:57:15 GMT | |
Server: GitHub.com | |
Content-Type: text/html; charset=utf-8 | |
Last-Modified: Wed, 07 May 2014 03:44:03 GMT | |
Expires: Sat, 14 Jun 2014 17:07:15 GMT | |
Cache-Control: max-age=600 | |
Content-Length: 15154 | |
Accept-Ranges: bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Module | |
# Takes symbols representing instance methods defined in the module. | |
# Returns a new anonymous module with only those instance methods defined. | |
def slice(*methods) | |
src = self | |
Module.new do | |
methods.each do |sym| | |
define_method(sym, src.instance_method(sym)) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn debounce | |
([input ms] (debounce (chan) input ms)) | |
([output input ms] | |
(go | |
(loop [val (<! input)] | |
(let [t (timeout ms) | |
[next-val port] (alts! [input t])] | |
(if (= port t) | |
(do | |
(>! output val) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns jamesmacaulay.console) | |
(defn log [& xs] (.apply console/log js/console (apply array xs))) | |
(defn logjs [& xs] (.apply console/log js/console (clj->js xs))) |