Skip to content

Instantly share code, notes, and snippets.

@chr15m
chr15m / set_timeout.cljs
Last active March 24, 2017 16:09
ClojureScript setTimeout that fires reliably in a background tab.
; uses a web worker background thread
(let [metronome-worker-js "self.onmessage=function(e){setTimeout(function(){postMessage(e.data);},e.data.interval);};console.log('Metronome worker loaded.');"
worker-blob (js/Blob. (clj->js [metronome-worker-js]) {:type "application/javascript"})
worker (js/Worker. (.createObjectURL js/URL worker-blob))
call-id (atom 0)]
(defn make-worker-listener [id callback]
(fn [e]
(when (= e.data.id id)
(callback)
@chr15m
chr15m / README.md
Last active August 29, 2015 14:26
Hy REPL in Django
  • Make sure you've installed hy or put it in requirements.txt
  • Put hy.py in management/commands/hy.py
  ./manage.py hy
  hy 0.11.0 using CPython(default) 2.7.6 on Linux
  => (import [yourapp [settings]])
  => settings.DEBUG
  True
I would expect this:
(defn x []
(try
(some-call)
(catch [e Exception] 1)
(else 2)))
To compile to this:
@chr15m
chr15m / keybase.md
Created April 15, 2015 06:23
keybase proof

Keybase proof

I hereby claim:

  • I am chr15m on github.
  • I am chr15m (https://keybase.io/chr15m) on keybase.
  • I have a public key whose fingerprint is 30AE 7153 C922 21F3 3BEE B492 09D8 C88A 5F65 515A

To claim this, I am signing this object: