I hereby claim:
- I am kriyative on github.
- I am kriyative (https://keybase.io/kriyative) on keybase.
- I have a public key ASDVywUMRecXvN790Ek_OwvexKhPQXoVZyVGsq7Z5g5inwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
(defun set-inputs-parse-devices () | |
(let ((dev-re (concat | |
"^[^A-Za-z]*\\([A-Za-z][-A-Za-z0-9/:,_ ]+" | |
"[-A-Za-z0-9/:,_]\\)" | |
"[ \t]*id=\\([0-9]+\\)" | |
"[ \t]*\\[\\(\\w+\\)" | |
"[ \t]*\\(\\w+\\)")) | |
devices) | |
(with-temp-buffer | |
(call-process "xinput" nil t) |
(defn uuid [] | |
"Return an RFC1422 ver.4 compliant UUID" | |
(let [format "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx" | |
hex "0123456789abcdef" | |
gen #(case % | |
\x (get hex (rand-int 16)) | |
\y (get hex (bit-or 0x8 (bit-and 0x3 (rand-int 16)))) | |
%)] | |
(apply str (map gen format)))) |
(def ^{:dynamic true} *print-progress* true) | |
(defmacro with-progress | |
"Bind a `reportfn` function, and evaluate `body` wherein | |
calling (report!) will invoke the report function with the current | |
state of the iteration." | |
[reportfn & body] | |
`(let [iter# (atom 0) | |
reporter# ~reportfn] | |
(letfn [(~'report! [] |
(ns extmap | |
(:import | |
[clojure.lang ILookup Associative])) | |
;; ---------------------------------------------------------------- | |
;; TrackableMap is a persistent map which keeps track of the number of | |
;; times `get` was called on it. | |
(defprotocol Trackable | |
(getStats [self])) |
(in-ns 'user) | |
;; An alternate `defmacro2` definition based on the example from | |
;; "Macros are Hard" presentation by @david_mcneil. This | |
;; implementation defines a macro called `name` and a function | |
;; equivalent called `name+` which still evaluates at compile time as | |
;; opposed to execution time | |
(defmacro defmacro2 [name args & body] | |
`(do | |
(defmacro ~name ~args ~@body) |
(in-ns 'user) | |
;; An alternate `defmacro2` definition based on the example from | |
;; "Macros are Hard" presentation by @david_mcneil. This | |
;; implementation defines a macro called `name` and a function | |
;; equivalent called `name+` which still evaluates at compile time as | |
;; opposed to execution time | |
(defmacro defmacro2 [name args & body] | |
`(do | |
(defmacro ~name ~args ~@body) |
(defmacro -> (x &rest args) | |
"A Common-Lisp implementation of the Clojure `thrush` operator." | |
(destructuring-bind (form &rest more) | |
args | |
(cond | |
(more `(-> (-> ,x ,form) ,@more)) | |
((and (consp form) | |
(or (eq (car form) 'lambda) | |
(eq (car form) 'function))) | |
`(funcall ,form ,x)) |
(defmacro bind (clauses &body body) | |
"This macro combines the behaviour of the forms `let*', `destructuring-bind', | |
and `multiple-value-bind', permitting the following style of binding form: | |
(bind (((:values m n) (values 10 20)) | |
((a b &key (c 10)) '(1 2)) | |
(x 5)) | |
(+ x a b c m n)) | |
=> 48 |
(bind (((x y) point) | |
((x1 y1 w h) frame) | |
(x2 (+ x1 w)) | |
(y2 (+ y1 h))) | |
(and (>= x x1) (<= x x2) (>= y y1) (<= y y2))) |