I hereby claim:
- I am favila on github.
- I am favila (https://keybase.io/favila) on keybase.
- I have a public key whose fingerprint is 594B BA31 C16A BA70 3AF4 AFB5 173E 02EE 2F85 597C
To claim this, I am signing this object:
(defn tx-pipeline-inorder | |
"Transact transactions in core.async channel `from-ch` against datomic connection `conn` with a pipeline depth of `n`. | |
Returns a map with keys `:stop!` and `:result`. `:stop!` is a no-arg function you can call to immediately | |
cease sending transactions (already sent transactions cannot be stopped). `:result` is a promise channel | |
returning a variant of the result of the tx-pipelining after from-ch is closed and drained, or | |
:stop! is called and all send transaction futures are deref-ed, or a transaction produces an exception. | |
The variant returned from the :result channel may be one of: | |
;; Using clojurescript master 1.9.512 uberjar | |
;; Commit 52ff7a2bdcaacf840f7aae72f4be4575297f7db1 | |
(require 'cljs.build.api) | |
(cljs.build.api/build "src" {:optimizations :advanced | |
:pretty-print true | |
:pseudo-names true | |
:output-to "out/main.js"}) |
function assertSafe(n) { | |
if (!Number.isSafeInteger(n)) { | |
throw new RangeError("Not a double-safe integer: " + n); | |
} | |
} | |
function intBits(n) { | |
assertSafe(n); | |
var low32 = (n >>> 0).toString(2); | |
low32 = "0".repeat(32 - low32.length) + low32; |
(require '[datomic.api :as d]) | |
(def conn-uri "datomic:dev://localhost:4334/my-db") | |
;; This is normally how you would get a list of tx-ids outside a query. | |
;; However, there is some concern that this is not lazy. (I am pretty sure, | |
;; but not certain, that reading the tx-log is lazy.) | |
(-> conn-uri d/connect d/log (d/tx-range nil nil) | |
(->> (map :t) (take 10))) |
(defn partition-key-by | |
"Return a transducer which emits the value of `(f x)` every time it changes. | |
This is the same as the following, except far more efficient because it will | |
not retain large intermediate collections: | |
(comp | |
(map f) | |
(partition-all) | |
(map first)) |
(require '[datomic.api :as d]) | |
(defn entity-pull | |
"Like pull, but returns values consistent with d/entity, i.e., | |
entities with :db/ident are represented as keywords and sets are | |
used instead of vectors." | |
[db pat eid] | |
(->> (d/pull db pat eid) | |
(clojure.walk/prewalk | |
(fn [x] |
;; same thing using reduction over d/datoms. | |
;; Objective is to avoid realizing too much in memory | |
;; May still be slow, but won't OOM | |
(defn orgs->max-fks [db] | |
(reduce (fn [o->fk [content-eid _ content-fk]] | |
(let [org-id (-> (d/entity db content-eid) | |
:content/collection | |
:collection/organization | |
:db/id)] |
I hereby claim:
To claim this, I am signing this object:
package mytransit; | |
import com.cognitect.transit.TransitFactory; | |
import com.cognitect.transit.WriteHandler; | |
import com.cognitect.transit.Writer; | |
import java.io.ByteArrayOutputStream; | |
import java.io.OutputStream; | |
import java.util.HashMap; |
(defn promise-all | |
"Given a collection of takeable items, return a promise channel which will | |
contain a vector of the next available value taken from every item, preserving | |
order if it exists in the original collection. If any takeable is closed | |
the promise will be closed. | |
Runs as synchronously as possible using poll! and offer!, only becoming async | |
if one of the takeable items is not immediately takeable. | |
Example: |