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
| (def xf-a | |
| (atom (map inc))) | |
| (defn xf [& args-out] | |
| (fn [& args] | |
| ;; TODO: Cache the inner (apply...) | |
| (apply (apply @xf-a args-out) args))) | |
| (def ch (chan 1 xf)) |
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
| (ns x.y | |
| (:import | |
| [java.io File])) | |
| (defn ls-match | |
| "Given the directory handle d, lists all files matching the given | |
| regex. Returns the Java File instances. | |
| Example: | |
| (ls-match (File. \"./dir\") #\"(?i).drl$\")" | |
| ([^File d] |
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 assoc-if-nil | |
| "Takes a map as the first argument and a succession of key value pairs that | |
| are used to set the key to value if the key of the map is nil. The value part | |
| is only evaluated if the key is nil (thus different semantics to (merge)). | |
| Example: | |
| (assoc-if-nil {:a {:b :set}} | |
| [:a :b] :non-def | |
| [:a :c] :non-def | |
| :d :non-def) | |
| ;; =>{:a {:b :set, :c :non-def}, :d :non-def}" |
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 quantizer | |
| "Returns a function that quantizes input data which when called with 'x' returns: | |
| o <1st val> if -Inf < x <= <1st bound> | |
| o <2st val> if <1st bound> < x <= <2st bound> | |
| o ... | |
| o <last val> if <last-1 bound> < x <= <last bound> | |
| o >max if x > <last bound> | |
| where m is a vector of vectors where the first element specifies the boundary and | |
| the second element the value which to return. |
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 between | |
| [min max] | |
| (s/pred #(<= min % max) (list 'between min max))) |
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
| (ns srs-c.utils.keyboard | |
| (:require-macros | |
| [klang.macros :refer [log! debg! trac! info! warn! erro! crit! fata! env!]] | |
| [srs-c.macros :refer [onlydev onlyprod]]) | |
| (:require [goog.events]) | |
| (:import [goog.ui KeyboardShortcutHandler])) | |
| (defn install-shortcut! | |
| "Installs a Keyboard Shortcut handler. |
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
| -- Datomic SQUUID layout: | |
| -- xxxxxxxx-xxxx-4xxx-Vxxx-xxxxxxxxxxxx | |
| -- ^^^^^^^^ ^^^^ ^ | |
| -- | | |^^^ ^ | |
| -- | | | | |^^^-^^^^^^^^^^^^ | |
| -- | | | | | | | |
| -- | | | | | |- random | |
| -- | | | | |- IETF variant {8,9,a,b} | |
| -- | | | |- random | |
| -- | | |- Version 4 |
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
| (spec/def :datascript.db/id int?) | |
| (spec/def :datomic.db/id #(instance? DbId %)) | |
| (spec/def :db/id (spec/or :datascript :datascript.db/id | |
| :datomic :datomic.db/id)) | |
| (defn datomic-id? | |
| "Checks a conformed spec and ensures the :db/id was a datomic id" | |
| [{[kw] :db/id}] | |
| (= kw :datomic)) | |
| (defn datascript-id? | |
| "Checks a conformed spec and ensures the :db/id was a datascript id" |
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 take-while+ | |
| "Identical to take-while but includes the false element." | |
| [pred coll] | |
| (lazy-seq | |
| (when-let [[f & r] (seq coll)] | |
| (if (pred f) | |
| (cons f (take-while+ pred r)) | |
| [f])))) | |
| (defn partition-after |
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 map-all | |
| "Like map but if given multiple collections will call the function f | |
| with as many arguments as there are elements still left." | |
| ([f] (map f)) | |
| ([f coll] (map f coll)) | |
| ([f c1 & colls] | |
| (let [step (fn step [cs] | |
| (lazy-seq | |
| (let [ss (keep seq cs)] | |
| (when (seq ss) |
OlderNewer