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
(require | |
'[datomic.api :as d]) | |
(defn how-many-datoms-did-tx-make? | |
"Return the number of datoms created by transaction at | |
time t, defaulting t to the most recent transaction." | |
([conn] (how-many-datoms-did-tx-make? conn (-> conn d/db d/basis-t))) | |
([conn t] | |
(some-> (d/log conn) (d/tx-range t nil) first :data count))) |
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
(def zap (partial + 1)) | |
(d/q '[:find ?b | |
:in ?a | |
:where [(user/zap ?a) ?b]] | |
1) | |
;; #{[2]} | |
(def zap (partial + 2)) |
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
(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) |
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
;; 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 |
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
;; 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]) |
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
;; 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]) |
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
;; licensed like Clojure, copyright 2010 by Stuart Halloway | |
(ns | |
#^{:author "Stuart Halloway" | |
:doc "Protocols for type-aware collection functions"} | |
clojure.contrib.collections | |
(:import [java.util ArrayList Collection])) | |
(declare slice do-slice) |
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
;; Copyright 2010 Relevance, Inc. Same license as Clojure http://clojure.org. You know the drill. | |
(ns clojure.core.protocols | |
(:refer-clojure :exclude [reduce nth count])) | |
#_(def array-classes | |
(map | |
#(Class/forName %) | |
["[Ljava.lang.Object;" | |
"[B" "[F" "[I" "[D" "[Z" "[J" "[C"])) |
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
(deftest various-beans-are-readable | |
(testing "that all java.lang beans can be read without error" | |
(doseq [mb (jmx/mbean-names "*:*")] | |
(jmx/mbean mb)))) |
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
; response to http://toinfinity.wordpress.com/2010/05/01/does-groovy-know-you-are-seeing-clojure | |
; tell the gnomes! phase two is (map - closing-prices)! | |
; prior to 1.2, reductions is in clojure.contrib.seq-utils | |
(->> (reductions min closing-prices) ;; lowest prices at each point | |
(map - closing-prices) ;; possible profit at each point | |
(apply max)) ;; profit! | |
OlderNewer