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 ^:dynamic *get-datomic-conn-fn* | |
"The function that the restify.clj spec-tacular plugin will use to | |
get a connection to datomic." | |
(fn [] | |
(throw (ex-info "Must set *get-datomic-conn-fn*." {})))) |
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
(declare complete-mask) | |
(deftype CompleteMask [spec] | |
clojure.lang.IPersistentMap | |
(assoc [_ k v] | |
(throw (ex-info "Mask function not implemented." {:name "assoc"}))) | |
(assocEx [_ k v] | |
(throw (ex-info "Mask function not implemented." {:name "assocEx"}))) | |
(without [_ k] | |
(throw (ex-info "Mask function not implemented." {:name "without"}))) |
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
(defun jim/cider-test-is-test-ns (ns) | |
(let ((suffix "-test")) | |
(string-match (rx-to-string `(: ,suffix eos) t) ns))) | |
(defun jim/cider-test-impl-ns-fn (ns) | |
(when ns | |
(let ((suffix "-test")) | |
(if (string-match (rx-to-string `(: ,suffix eos) t) ns) | |
(s-replace suffix "" ns) |
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
(defun jim/cider-test-is-test-ns (ns) | |
(let ((suffix "-test")) | |
(string-match (rx-to-string `(: ,suffix eos) t) ns))) | |
(defun jim/cider-test-impl-ns-fn (ns) | |
(when ns | |
(let ((suffix "-test")) | |
(if (string-match (rx-to-string `(: ,suffix eos) t) ns) | |
(s-replace suffix "" ns) |
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 sp->transactions-helper | |
[db sp deletions-atom] | |
(let [{sname :name :as spec} (get-spec sp) | |
eid (or (-> sp :db-ref :eid) (get-eid db sp spec)) | |
db-val (db/entity db (get-eid db sp spec))] | |
(with-meta | |
(hash-map | |
(for [{iname :name [cardinality type] :type :as item} (:items spec)] | |
(let [datomic-key (keyword (datomic-ns spec) (name iname)) |
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 rested-removed-data-should-reflect-in-db | |
(with-test-db simple-schema | |
(let [scm-a (scm {:val1 "name" :val2 123124}) | |
scm-b (scm {:val1 "name"})] | |
@(db/transact *conn* [(sp->nested-map-for-transaction (db) scm-a)]) | |
@(db/transact *conn* [(sp->nested-map-for-transaction (db) scm-b)]) | |
(let [eid (ffirst (db/q '[:find ?eid :where [?eid :scm/val1 "name"]] (db))) | |
entity (db/entity (db) eid)] | |
(is (nil? (:scm/val2 entity))))))) |
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 rested-removed-data-should-reflect-in-db | |
(with-test-db simple-schema | |
(let [scm-a (scm {:val1 "name" :val2 123124}) | |
scm-b (scm {:val1 "name"})] | |
@(db/transact *conn* [(sp->nested-map-for-transaction (db) scm-a)]) | |
@(db/transact *conn* [(sp->nested-map-for-transaction (db) scm-b)]) | |
(let [eid (ffirst (db/q '[:find ?eid :where [?eid :scm/val1 "name"]] (db))) | |
entity (db/entity (db) eid)] | |
(is (nil? (:scm/val1 entity))))))) |
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
(import '[clojure.lang Reflector]) | |
(defn static-invoke [class member & args] | |
(if (zero? (count args)) | |
(try | |
(Reflector/getStaticField class member) | |
(catch Exception e | |
(Reflector/invokeStaticMethod | |
class member clojure.lang.RT/EMPTY_ARRAY))) | |
(Reflector/invokeStaticMethod class member (object-array args)))) |
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
(defun jim/setup-pintos () | |
(interactive) | |
(set-variable | |
'ede-project-directories | |
(quote | |
("/Users/jim/classes/systems/pint-heads/src/lib/user" | |
"/Users/jim/classes/systems/pint-heads/src/lib/kernel" | |
"/Users/jim/classes/systems/pint-heads/src/lib" | |
"/Users/jim/classes/systems/pint-heads/src/threads" | |
"/Users/jim/classes/systems/pint-heads/src/userprog" |
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
entities->remove_if([] (const Entity& e) { | |
return e.has_component("TTL") | |
&& dynamic_cast<const TTLComponent*>(e.get_component("TTL"))->is_dead(); | |
}); |
NewerOlder