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 selector | |
"Creates a selection process on list-el, a HTML list element. | |
Parameters | |
in: | |
a channel that should produce a number for the item to | |
highlight, :out to remove all highlighting, and :select to | |
signal user selection. | |
list-el: | |
a HTML list element. |
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 event-chan | |
([type] (event-chan js/window type)) | |
([el type] (event-chan (chan (sliding-buffer 1)) el type)) | |
([c el type] | |
(.addEventListener el type #(put! c %)) | |
c)) | |
(defn jsonp-chan | |
([uri] (jsonp-chan (chan) uri)) | |
([c uri] |
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 put-all! [cs x] | |
(doseq [c cs] | |
(put! c x))) | |
(defn multiplex [in cs-or-n] | |
(let [cs (if (number? cs-or-n) | |
(repeatedly cs-or-n chan) | |
cs-or-n)] | |
(go (loop [] | |
(let [x (<! in)] |
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 n01se.externs-for-cljs | |
(:require [clojure.java.io :as io] | |
[cljs.compiler :as comp] | |
[cljs.analyzer :as ana])) | |
(defn read-file [file] | |
(let [eof (Object.)] | |
(with-open [stream (clojure.lang.LineNumberingPushbackReader. (io/reader file))] | |
(vec (take-while #(not= % eof) | |
(repeatedly #(read stream false eof))))))) |
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
interceptor = (klass) -> | |
for own key, value of klass | |
f = (k, v) -> | |
if typeof value == "function" | |
klass[k] = -> | |
console.log "Called #{k} from #{arguments.callee.caller.toString()}", arguments | |
v.apply(this, arguments) | |
f key, value | |
// interceptor(Foo.prototype) |
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 dining-service | |
(:use aleph.core) | |
(:use aleph.http) | |
(:use net.cgrand.moustache) | |
) | |
(defn report-handler [response-channel request] | |
(enqueue response-channel | |
{:status 200 | |
:headers {"content-type" "text/plain"} |