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
(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] |
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 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)) |
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
(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))) |
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
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; |
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
;; 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"}) |
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 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: | |
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 str-test | |
(:import goog.string.StringBuffer)) | |
(defn ^:export str-tostr | |
([x] (if (nil? x) | |
"" | |
(.toString x))) | |
([x & ys] | |
(loop [sb (StringBuffer. (str-tostr x)) more ys] | |
(if more |
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
'[[(component-reachable [?se] ?e ?a ?v ?tx) | |
[(identity ?se) ?e] | |
[?e ?a ?v ?tx]] | |
[(component-reachable [?se] ?e ?a ?v ?tx) | |
[?se ?sa ?sv ?tx] | |
[?sa :db/isComponent true] | |
[?sa :db/valueType ?type] | |
[?type :db/ident :db.type/ref] | |
(component-reachable ?sv ?e ?a ?v ?tx)]] |
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
;; Documentation on the storm site http://storm.apache.org/releases/1.0.3/Distributed-RPC.html | |
;; has an example that constructs DRPCClient in a way that is out-of-date. | |
;; And all the example code uses the LocalDRPCClient, so there's no docs on how to construct this object. | |
;; The problem is the new first parameter to the DRPCClient constructors. This should be the storm config map, | |
;; the same one topologies get and the one configured via storm.yaml. Ideally it is the identical map, but | |
;; if you are running the DRPCClient on a different process you may not have access to it. | |
;; Below is the minimum you need to get started on a not-very-customized storm cluster |
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 kafka-workbench | |
(:require [franzy.clients.consumer.protocols :as c] | |
[franzy.clients.producer.protocols :as p] | |
[franzy.serialization.serializers :as serializers] | |
[franzy.serialization.deserializers :as deserializers] | |
[franzy.clients.consumer.client :as consumer] | |
[franzy.clients.producer.client :as producer])) | |
(def kafka-brokers []) |