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 last-touched-tx | |
"Return the tx of the oldest assertion on `entity` or any of its components." | |
[db entity] | |
(or (d/q '[:find (max ?tx) . | |
:in $ % ?root | |
:where | |
(component-entities ?root ?ce) | |
(union ?root ?ce ?e) | |
[?e _ _ ?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
(ns favila.transit-uuid-reader | |
"Use as a data reader for cljs-in-cljs or clj-for-cljs compilation to emit a | |
transit uuid type from a uuid string. | |
For clj-for-cljs compilation you must require this namespace at the top of | |
your cljs code somehow so that the emitted code can call | |
`transit-uuid-from-ints`" | |
#?(:clj (:import | |
(com.cognitect.transit types) | |
(goog.math Long)) |
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]) | |
(d/create-database "datomic:mem://counter-example") | |
;=> true | |
(def c (d/connect "datomic:mem://counter-example")) | |
;=> #'user/c | |
;; The essential features of creating and using an auto-increment counter in datomic: | |
;; | |
;; 1. A counter entity must store the current value and a nonce. |
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 com.breezeehr.spec-utils | |
(:require [clojure.spec.alpha :as s])) | |
(s/def ::relation-arg-pair | |
(s/cat | |
:k (s/and keyword? #(not= % ::relation-tail)) | |
:v #(not (s/regex? %)))) | |
(defn- distinct-relation-keys? [{:keys [req opt]}] | |
(apply distinct? (concat (map :k req) (map :k opt)))) |
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
;;; immutant.web >= 2.1.7 will block subsequent requests on the same connection | |
;;; when using an async/as-channel response if the request body InputStream is | |
;;; not closed | |
;;; The essential difference seems to be the undertow dependency: 1.3.x | |
;;; does not care if the request is closed, but 1.4.x seems to care. | |
;;; Immutant 2.1.6 used undertow 1.3.x, but 2.1.7 switched to 1.4.x | |
;; leinigen Dependency: [[org.immutant/web "2.1.9"]] |
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
(letfn [(cmp [^objects vec-b+maxi i a] | |
;; INVARIANT: vec-a is longer than or equal-len vec-b | |
;; INVARIANT: vec-a and vec-b are len >= 1 | |
(let [vec-b (aget vec-b+maxi 0) | |
maxi (aget vec-b+maxi 1) | |
b (nth vec-b i) | |
diff (compare a b)] | |
(if (zero? diff) | |
(if (== i maxi) | |
(reduced vec-b+maxi) |
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 []) |
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
'[[(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
(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 |