Skip to content

Instantly share code, notes, and snippets.

1=2-1
1=2-(2-1)
1=2-(2-(2-1))
1=2-(2-(2-(2-1)))
1=2-(2-(2-(2-(2-1))))
1=2-(2-(2-(2-(2-(2-1)))))
(defmethod perform :start
[_ config components roles]
(println "Starting persistent service" components)
(let [system (volatile! (system/create-system config components roles))
runtime (Runtime/getRuntime)
shutdown? (promise)]
(.addShutdownHook runtime
(Thread. (fn []
(println "Shutting down persistent service")
(system/stop @system)
### Keybase proof
I hereby claim:
* I am dball on github.
* I am dball (https://keybase.io/dball) on keybase.
* I have a public key ASD3cNyASKB_AH3rqwzAKMQBK6ILjglZ9evrD9g90d17kwo
To claim this, I am signing this object:
(set-env!
:wagons (fn [wagons]
(conj wagons '[sparkfund/aws-maven "5.1.0"
:schemes {"s3" #(org.springframework.build.aws.maven.SimpleStorageServiceWagon.)}]))
:repositories (fn [repos]
(conj repos
'["sparkfund-snapshots" {:url "s3://sparkfund-maven/snapshots"}]))
:dependencies '[[sparkfund/private-secret-library "0.0.1"]])
(defn charseq-in
[& options]
(let [{:keys [count min-count max-count chars]} options]
(s/coll-of (or chars char?)
:count count
:min-count min-count
:max-count max-count)))
(defn string-like
[spec-or-k]
(defn charseq-in
[& options]
(let [{:keys [count min-count max-count chars]} options]
(s/coll-of (or chars char?)
:count count
:min-count min-count
:max-count max-count)))
(defn string-in
[& options]
@dball
dball / protocol.clj
Last active June 4, 2016 21:14
Protocol Example
(defprotocol UserStore
(load [_ id])
(save! [_ id user])
(delete! [_ id]))
(defrecord Database [db]
UserStore
(load [_ id]
(first (jdbc/query db ["select * from users where id = ?" id])))
...)
@dball
dball / datomic-txn-fns.clj
Created January 12, 2016 21:16
Trouble with datomic transaction fns
(deftxnfn increase-book-quality
[db eid attr quality]
(do
(assert (= :book/quality attr))
(if (q '[:find ?eid .
:in $ ?ords ?eid ?quality'
:where
[?eid :book/quality ?quality-eid]
[?quality-eid :db/ident ?quality]
[(get ?ords ?quality' -1) ?ord']
TypeResolver
(resolve-types [_]))
(extend-protocol TypeResolver
clojure.lang.Keyword
(resolve-types [type]
(when-let [spec (spark.spec-tacular/get-spec type)]
(resolve-types spec)))
clojure.lang.Var
(resolve-types [var]
type Point a = (a, a)
type PointFn a = ((a -> a), (a -> a))
data Board a = Board { boardMin :: Point a,
boardMax :: Point a }
deriving (Show)
makeBoard :: (Enum a, Ord a) => Point Int -> Board a
makeBoard (x, y) = Board (z, z) (toEnum x, toEnum y)
where z = toEnum 0