Stuart Halloway stuarthalloway

View how-many-datoms.clj
1 2 3 4 5 6 7 8 9
(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)))
View schema_history.clj
1 2 3 4 5 6 7 8 9 10
;; Complete schema history for a live Datomic database.
(require
'[clojure.pprint :as pp]
'[clojure.set :as set]
'[datomic.api :as d])
 
;; fill this in with your own database connection
(def uri "datomic:dev://localhost:4334/your-db")
(def conn (d/connect uri))
(def db (d/db conn))
View entity map expansion
1 2 3 4 5 6 7 8 9 10
(require '[datomic.api :as d])
 
(def uri "datomic:mem://foo")
(d/create-database uri)
(def conn (d/connect uri))
 
@(d/transact conn [{:db/id (d/tempid :db.part/db)
:db/ident :card-1-reference
:db/valueType :db.type/ref
:db/isComponent true
View CSP cljs example tweaks
1 2 3 4 5 6 7 8 9 10
;; proposed change #1, objective: make update to q more evident
(defn peekn
"Returns vector of (up to) n items from the end of vector v"
[v n]
(if (> (count v) n)
(subvec v (- (count v) n))
v))
 
(let [el (by-id "ex0")
out (by-id "ex0-out")]
View gist:5199642
1 2 3 4 5 6 7 8 9 10
;; from leiningen, use [dorothy/dorothy "0.0.3"]
(require '[dorothy.core :as dot])
 
;; dataflow copied from chat
;; https://github.com/pedestal/samples/blob/master/chat/chat-client/app/src/chat_client/behavior.clj
(def dataflow '{:transform
{:outbound {:init {} :fn outbound-transform}
:inbound {:init {} :fn inbound-transform}
:nickname {:init nil :fn nickname-transform}}
:effect {:outbound send-message-to-server}
View gist:3068749
1 2 3 4 5 6 7 8 9 10
;; Datomic example code
;; Demonstrates using datalog with Clojure defrecords
(use '[datomic.api :only [q db] :as d])
 
;;; http://www.lshift.net/blog/2010/08/21/some-relational-algebra-with-datatypes-in-clojure-12
(defrecord Supplier [number name status city])
(defrecord Part [number name colour weight city])
(defrecord Shipment [supplier part quantity])
 
;; sample data
View gist:3026504
1 2 3 4 5 6 7 8 9 10
;; groovy-datomic example (https://github.com/jeffbrown/groovy-datomic) in Clojure
 
(use '[datomic.api :only (q db) :as d])
(def uri "datomic:mem://comics")
(d/create-database uri)
(def conn (d/connect uri))
(d/transact
conn
[{:db/id #db/id[:db.part/db]
:db/ident :issue/comic
View Datomic News Updates
1 2 3 4 5 6 7 8 9 10
;; Datomic example code
 
;; demonstrates various update scenarios, using a news database
;; that contains stories, users, and upvotes
 
;; grab an in memory database
(use '[datomic.api :only (q db) :as d])
(def uri "datomic:mem://foo")
(d/create-database uri)
(def conn (d/connect uri))
View gist:2651196
1 2 3 4 5 6 7 8 9 10
// Datomic example code
 
package datomic.examples;
 
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
 
import static datomic.Peer.*;
View gist:2645453
1 2 3 4 5 6 7 8 9 10
;; Datomic example code
(use '[datomic.api :only (db q) :as d])
 
;; ?answer binds a scalar
(q '[:find ?answer :in ?answer]
42)
 
;; of course you can bind more than one of anything
(q '[:find ?last ?first :in ?last ?first]
"Doe" "John")
Something went wrong with that request. Please try again.