This file contains hidden or 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
const selectKeys = (m, keys) => { | |
return keys.reduce((acc, k) => { | |
acc[k] = m[k]; | |
return acc; | |
}, {}); | |
} | |
const invertMap = (m) => | |
Object.keys(m).reduce((acc, k) => { | |
acc[m[k]] = k; |
This file contains hidden or 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 spit-url [content] | |
(let [blob (js/Blob. (js/Array. content) {:type "text/plain;charset=utf-8"})] | |
(.createObjectURL js/URL blob))) |
This file contains hidden or 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 relate [& pairs] | |
(assert (even? (count pairs)) "relate requires an even number of arguments") | |
(->> pairs | |
(partition 2) | |
(map (fn [[k vs]] (map #(hash-map k %) vs))) | |
(apply map merge))) | |
(defn matches-specmap? [specmap m] | |
(reduce-kv |
This file contains hidden or 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
(defmacro with-timeout [seconds & body] | |
`(let [f# (future ~@body)] | |
(try | |
(.get f# ~seconds java.util.concurrent.TimeUnit/SECONDS) | |
(catch java.util.concurrent.TimeoutException e# | |
(do (future-cancel f#) nil))))) |
NewerOlder