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 [in ms] | |
(let [out (chan)] | |
(go-loop [last-val nil] | |
(let [val (if (nil? last-val) (<! in) last-val) | |
timer (timeout ms) | |
[new-val ch] (alts! [in timer])] | |
(condp = ch | |
timer (do (>! out val) (recur nil)) | |
in (recur new-val)))) | |
out)) |
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
clojure -e "(require '[cljs.closure :as cc] '[clojure.pprint :refer [pprint]]) (pprint (cc/index-node-modules-dir $(cat cljsc_opts.edn)))" > npm-deps.edn |
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
;; Rename clj/cljs/cljc buffers to their namespace name, so you see | |
;; `foo.bar.core' in the modeline, rather than `core.clj' | |
(advice-add 'rename-buffer :around #'plexus/clj-ns--rename-buffer-advice) | |
(defun plexus/clj-ns--rename-buffer-advice (rb-fun newname &optional unique &rest args) | |
(let ((filename (buffer-file-name (current-buffer))) | |
(buf-start (buffer-substring-no-properties (point-min) (point-min)))) | |
(if (and (string-match "\\.clj[cxs]?$" filename) | |
(string-match "(ns \\([^\n )]+\\)" buf-start)) | |
(match-string-no-properties 1 buf-start) |