View clojure_spec_missing_piece.clj
;; clojure.spec's missing piece, work in progress
;; this is only halfway done, somebody else will need to do the other 95%
(require
'[clojure.spec :as s]
'[clojure.spec.test :as test])
(defn naive-english-explain
"Copy and paste this into your app. Figure out what it does by
trying it in production."
View errors_as_data.clj
;; spec errors are data, and as such are composable with all the rest
;; of Clojure. The forms below show getting to an interesting part
;; of an error in a larger data structure, taking advantage of
;; edn-reading, pretty-printing, *print-length* and threading macro.
;; It is difficult to maintain the compositionality shown here
;; once you convert error data into e.g. ASCII art.
(require
'[clojure.edn :as edn]
View client_transduce_skeleton.clj
(a/transduce
(comp
(halt-when error?)
(map ...)
(filter ...))
(completing ...)
accumulator
query)
View add_at.clj
;; non-working add-at
(require '[boot.core :as core]
'[boot.tmpdir :as tmpd]
'[clojure.java.io :as io])
(deftask add-at
"Like sift :add-*, but lets you make a dest path in fileset"
[r rolekey ROLEKEY kw "rolekey"
s source SOURCE file "source path in project"
d dest DEST file "dest path in fileset"]
View gist:736cd82a51eb9ad24c65bfcac06f5101
(s/keys :req [::first-name
::last-name
::middle-initial])
(s/keys :req [::first-name
::last-name
::middle-initial]
:opt-un [::middle-name])
View log_size.clj
;; bin/run log_size.clj DB-URI t
;; Estimates the total in-memory size of all log entries from t to end of data.
;; Scans log from t to the end, so run against a backup instead of production if possible!
(require
'[clojure.edn :as edn]
'[clojure.pprint :as pp]
'[datomic.api :as d]
'[datomic.memory-size :as size])
View crosscheck_tx_instants.clj
;; bin/run crosscheck_tx_instants.clj DB-URI t
;; This program walks the log to find txInstants
;; and then finds the same instants in the indexes.
;; Scans log from t to the end, so run against a backup instead of production if possible!
(require
'[clojure.edn :as edn]
'[clojure.pprint :as pp]
'[datomic.api :as d])
View log_as.clj
;; bin/run log_as.clj DB-URI t attr
;; This program walks the log extracting datoms about a particular attribute.
;; Reveals domain data, but only about that one attribute.
;; Scans log from t to the end, so run against a backup instead of production if possible!
(require
'[clojure.edn :as edn]
'[clojure.pprint :as pp]
'[datomic.api :as d])
View log_ts.clj
;; This program walks the entire log extracting information about t
;; Does not reveal any domain data.
;; Scans entire log, so run against a backup instead of production if possible!
(require '[datomic.api :as d]
'[clojure.pprint :as pp])
(defn max-t
"Returns the maximum t mentioned in a collection of datoms"
[datoms]
(reduce
View entity-summary.clj
(require '[datomic.api :as d])
(defn entity-summary
"Returns a map with
:eavt vector of all eavt history datoms with eid
:log vector of all log entries containing those datoms"
[conn eid]
(let [log (d/log conn)
db (d/db conn)
hist (d/history db)