This file contains 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 relate [& pairs] | |
(assert (even? (count pairs)) "relate requires an even number of arguments") | |
(->> pairs | |
(partition 2) | |
(map (fn [[k vs]] (map #(hash-map k %) vs))) | |
(apply map merge))) | |
(defn matches-specmap? [specmap m] | |
(reduce-kv |
This file contains 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 excel.api.s3 | |
(:require [cognitect.aws.client.api :as aws] | |
[integrant.core :as ig] | |
[clojure.tools.logging :as log])) | |
(defmethod ig/init-key ::client | |
[_ _] | |
(create-s3-client)) | |
;; Code below may end up being a periodic background process for limiting s3 |
This file contains 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
;; Assumes https://github.com/jstepien/flames available | |
;; requires http://riemann.io to be installed. | |
(def flames (atom nil)) | |
(defn flames-start! [] | |
;; We resolve explicitly here, to avoid warnings when not working | |
;; with flamegraphs | |
(if-not @flames | |
(let [config {:port 54321, :host "localhost"}] | |
(reset! flames ((requiring-resolve 'flames.core/start!) config)) |
This file contains 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
;; LWW Register | |
;; https://speakerdeck.com/ept/data-structures-as-queries-expressing-crdts-using-datalog?slide=15 | |
(def schema | |
{:assign/time {:db/valueType :Number} | |
:assign/key {:db/valueType :Number} | |
:assign/value {:db/valueType :Number}}) | |
(def rules | |
'[[(older ?t1 ?key) |
This file contains 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
;; RGA | |
;; https://speakerdeck.com/ept/data-structures-as-queries-expressing-crdts-using-datalog?slide=22 | |
(def schema | |
{:id/node {:db/valueType :Number} | |
:id/ctr {:db/valueType :Number} | |
:insert/id {:db/valueType :Eid} | |
:insert/parent {:db/valueType :Eid} | |
:assign/id {:db/valueType :Eid} | |
:assign/elem {:db/valueType :Eid} |
This file contains 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 recursive-rule | |
"A recursive rule for establishing prototype inheritance/isa relationship. | |
Can specify a maximum depth to travel, or none if there are no restrictinos. | |
rule The name of the rule | |
e The entity | |
a The attribute | |
v The value | |
Should be creating the rule like: (recursive-rule 'isa '?e '?a '?v) | |
Then within a query, can refer to it like this: | |
(isa ?e :thing/isa ?v) " |
This file contains 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 user) | |
; Hey, I've been playing a bit with graphing out the structure of a module for Lightpad. | |
; It worked well, I've found the target function that I'll need change to add a new feature. | |
; Tweet with a screenshot https://twitter.com/spacegangster/status/1324760381735272450 | |
; lein coordinate | |
; [com.gfredericks/clj-usage-graph "0.3.0"] | |
; https://github.com/gfredericks/clj-usage-graph | |
This file contains 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 kc.datomic | |
"Datomic utility functions | |
Usage Notes: | |
Some functions in this namespace take sequences of facts and return them modified in some way. Some up-front modifications are useful for those functions, like replacing all map-form facts with vector-form facts. In order to avoid doing these modifications repeatedly to same the same set of facts (which would be harmless but wasteful), two versions of these functions exist: a \"safe\" version that does those up-front modifications, and an \"unsafe\" version that expects those modifications to already have been performed. The unsafe versions are named like the safe ones, but with a single quote appended. | |
TODO: | |
- consider implementing all fns that branch based on operation as multimethods | |
These fns mostly support :db/add, :db/retract :db.fn/retractEntity, :db.fn/cas, |
NewerOlder