Skip to content

Instantly share code, notes, and snippets.

Avatar

Erik Ferguson muraiki

View GitHub Profile
@muraiki
muraiki / gist:5cc72eaeb20a57da31bc
Created Mar 19, 2015
KO model with getters/setters and json update support
View gist:5cc72eaeb20a57da31bc
function FooModel () {
Object.defineProperties(this, {
_foo: {
value: ko.observable(x.name),
enumerable: true,
configurable: true
},
_bar: {
value: ko.observable(x.server_id || x.instance_id || x.instanceId),
enumerable: true,
View gist:492539f842085f980349
def groupBy[A](xs: List[A]): Map[A, Int] =
xs.foldLeft(Map[A, Int]()) { (m: Map[A, Int], x: A) => m + (x -> (m.get(x).getOrElse(0) + 1)) }
@muraiki
muraiki / fib.pl6
Last active Aug 29, 2015
multi+cached+subset
View fib.pl6
subset NonNegativeInt of Int where * >= 0;
proto fib (|) is cached returns NonNegativeInt {*}
multi fib (0) { 0 }
multi fib (1) { 1 }
multi fib (NonNegativeInt $n) { fib($n - 1) + fib($n - 2) }
say fib(100)
@muraiki
muraiki / core.clj
Created Oct 8, 2014
ajax-to-websocket
View core.clj
(ns ajax-to-websocket.core
(:require [org.httpkit.server :as server]
[org.httpkit.client :as client]
[clojure.data.json :as json]
[clojure.data :as data]
[clojure.core.async :refer [chan <! >! go timeout onto-chan]]))
(defn channel-closed
"called when websocket channel is closed"
[status]