Skip to content

Instantly share code, notes, and snippets.

View amitrathore's full-sized avatar

Amit Rathore amitrathore

View GitHub Profile
@amitrathore
amitrathore / pmapcat.clj
Created November 26, 2012 08:07
pmapcat function
(defn pmapcat [f batches]
(->> batches
(pmap f)
(apply concat)
doall))
@amitrathore
amitrathore / doeach.clj
Created November 21, 2012 07:09
doeach
(defn doeach [function coll]
(doseq [c coll]
(function c)))
@amitrathore
amitrathore / domap.clj
Created November 21, 2012 07:09
domap
(defn domap [function coll]
(->> coll (map function) doall))
{:first-name "amit"
:last-name "rathore"
:db/id 123123123}
{:user/first-name "amit"
:user/last-name "rathore"
:db/id 123123123}
@amitrathore
amitrathore / demonic_usage_2.clj
Created May 8, 2012 18:20
datomic-key->regular-key
(defn datomic-key->regular-key [datomic-key]
(-> datomic-key
name
any-other-transform
keyword))
@amitrathore
amitrathore / demonic_usage_1.clj
Created May 8, 2012 18:18
convert-to-regular-map
(defn convert-to-regular-map [user-entity]
(-> user-entity
(select-keys some-interesting-keys)
(maps/update-all-map-keys datomic-key->regular-key)))
@amitrathore
amitrathore / demonic.clj
Created May 8, 2012 08:14
demonic-load-and-transform-with
(defn insert-and-transform-with [a-map transform]
(-> a-map
insert
transform))
@amitrathore
amitrathore / demonic.clj
Created May 8, 2012 08:13
demonic-load-and-transform-with
(defn load-and-transform-with [eid transform]
(-> eid
load-entity
transform))
(deftest test-demonic-testing
(demonic-testing "check not present, insert, then check present"
(is (nil? (:db/id (find-by-id some-id))))
(demonic/insert some-map)
(is (not (nil? (:db/id (find-by-id some-id)))))))