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
SHELL=/bin/bash | |
NGINX:=$(abspath software/nginx/sbin/nginx) | |
CONF:=$(abspath conf/nginx.conf) | |
OPENRESTY_V:=1.9.15.1 | |
OPENRESTY_F:=openresty-$(OPENRESTY_V) | |
OPENRESTY_RUN_DIR:=$(PWD)/openresty | |
.PHONY: def_target run reload stop auto-reload |
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
(ns your.macros-for-cljs.ns | |
(:require [sablono.compiler :as sablono-c])) | |
;; Make sablono also walk into other forms: | |
;; if, for, let, do: Already exist | |
(.addMethod @(var sablono-c/compile-form) "when" | |
(fn | |
[[_ bindings & body]] | |
`(when ~bindings ~@(for [x body] (sablono-c/compile-html x))))) |
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 updated-entity | |
"Updates the given entity if the db has changed since the entity was last pulled." | |
[entity] | |
(let [prev-db (d/entity-db entity) | |
curr-db @conn] | |
(if (identical? prev-db curr-db) | |
entity | |
(d/entity curr-db (:db/id entity))))) | |
(defn qes |
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) |
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 datomic-fn | |
"Creates a datomic function given (fn [db e a ...] code...)" | |
[[_ args & body]] | |
`(d/function '{:lang "clojure" | |
:params ~args | |
:code (do ~@body)})) | |
(defn trinity-new | |
"1. If a is a ref: | |
Ensures that |
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 startup-time | |
[] | |
(into [] | |
(for [v [18 19]] | |
(let [jar (case v | |
18 "/tmp/clojure-1.8.0.jar" | |
19 "/tmp/clojure-1.9.0-alpha14.jar") | |
jvm-opts ["-Xverify:none" | |
"-XX:+TieredCompilation" |