Skip to content

Instantly share code, notes, and snippets.

View hlship's full-sized avatar

Howard M. Lewis Ship hlship

View GitHub Profile
> boot hello
Hello, Howard
> boot hello -g Bonjour
Bonjour, Howard
>
> boot hello --help
Prints a greeting.
Options:
-h, --help Print this help info.
-g, --greeting GREETING GREETING sets greeting to use.
-n, --name NAME NAME sets name to greet.
(ns example.tasks
(:require
[boot.core :refer :all]
[boot.util :refer [info]]))
(deftask hello
"Prints a greeting."
[g greeting GREETING str "Greeting to use."
n name NAME str "name to greet."]
(with-pass-thru _
boot pom jar install
:lein-plugin-runtime {:dependencies [[leiningen-core "2.6.1"]]}
@hlship
hlship / db.clj
Created May 6, 2016 18:58
consumer oriented loop
(defn customers [db ch]
(let [db-ch (exec-customer-query db :all)]
(go-loop []
(when-let [customer (<! db-ch)]
(>! ch customer)
(recur)))))
(defn customers [db]
(let [ch (chan 100)
db-ch (exec-customer-query db :all)]
(go-loop []
(when-let [customer (<! db-ch)]
(>! ch customer)
(recur)))
ch))
@hlship
hlship / loop.clj
Created May 6, 2016 18:43
looping state
(go-loop [n 0]
(when-let [x (<! input-ch)]
(>! output-ch x)
(recur (inc n))
n))
@hlship
hlship / atom-loop.clj
Last active May 6, 2016 18:45
CSP using atom for state
(let [n (atom 0)]
(go-loop []
(when-let [x (<! ch)]
(>! next-ch x)
(swap! n inc)
(recur))
@n))
@hlship
hlship / web-server.clj
Created July 8, 2015 18:02
Web Server Config
(s/defschema WebServerConfig
{:port s/Int
(s/optional-key :max-threads) s/Int})