Skip to content

Instantly share code, notes, and snippets.

View amitrathore's full-sized avatar

Amit Rathore amitrathore

View GitHub Profile
@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))
{:user/first-name "amit"
:user/last-name "rathore"
:db/id 123123123}
@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)))
{:first-name "amit"
:last-name "rathore"
:db/id 123123123}
@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))
@amitrathore
amitrathore / using_pmapcat.clj
Created November 26, 2012 08:20
using pmapcat
(defn handle-batch [batch]
(blah blah...))
(->> coll
(partition-all n)
(pmapcat handle-batch))
@amitrathore
amitrathore / m.clj
Last active December 10, 2015 23:19
{:a 1,
:c {:a 1, :c {:a 1, :b 2}, :b 2},
:b [2 3],
:d [{:a 1, :c 3, :b 2} {:a [1 2 3], :b {:a 1, :b 2}}]}
user> (println m "blah blah" m)
{:a 1, :c {:a 1, :c {:a 1, :b 2}, :b 2}, :b [2 3], :d [{:a 1, :c 3, :b 2} {:a [1 2 3], :b {:a 1, :b 2}}]} blah blah {:a 1, :c {:a 1, :c {:a 1, :b 2}, :b 2}, :b [2 3], :d [{:a 1, :c 3, :b 2} {:a [1 2 3], :b {:a 1, :b 2}}]}
user> (println (pp-str m "blah blah" m))
{:a 1,
:c {:a 1, :c {:a 1, :b 2}, :b 2},
:b [2 3],
:d [{:a 1, :c 3, :b 2} {:a [1 2 3], :b {:a 1, :b 2}}]}
"blah blah"
{:a 1,
:c {:a 1, :c {:a 1, :b 2}, :b 2},
:b [2 3],
:d [{:a 1, :c 3, :b 2} {:a [1 2 3], :b {:a 1, :b 2}}]}