(ns leiningen.pact-verify
  (:require [au.com.dius.pact.provider.lein.verify-provider :as verify]
            [clojure.string :as str])
  (:import (au.com.dius.pact.provider.lein LeinVerifierProxy)))

(defn- split-string [arg]
  (if (.contains arg "=")
    (let [key-val (str/split arg #"=")]
      [(read-string (first key-val)) (second key-val)])
    [(read-string arg) arg]))

(defn- parse-args [args]
  (if (not-empty args)
    (apply assoc {} (mapcat #(split-string %) args))
    {}))

(defn pact-verify
      "Verifies pact files against a provider"
      [project & args]
      (if (contains? project :pact)
        (let [verifier (LeinVerifierProxy. project (parse-args args))]
          (verify/verify verifier (-> project :pact)))
        (throw (ex-info "No pact definition was found in the project"))))

(ns leiningen.pact-verify
  (:require [au.com.dius.pact.provider.lein.verify-provider :as verify]
            [clojure.string :as str])
  (:import (au.com.dius.pact.provider.lein LeinVerifierProxy)))

(defn- split-string [arg]
  (if (.contains arg "=")
    (let [key-val (str/split arg #"=")]
      [(read-string (first key-val)) (second key-val)])
    [(read-string arg) arg]))

(defn- parse-args [args]
  (if (not-empty args)
    (apply assoc {} (mapcat #(split-string %) args))
    {}))

(defn pact-verify
      "Verifies pact files against a provider"
      [project & args]
      (if (contains? project :pact)
        (let [verifier (LeinVerifierProxy. project (parse-args args))]
          (verify/verify verifier (-> project :pact)))
        (throw (ex-info "No pact definition was found in the project" {}))))

Fix Wrong number of args passed to: ex-info

clojure.lang.ArityException  Wrong number of args (1) passed to: clojure.core/ex-info


{:user {
        :dependencies [[pjstadig/humane-test-output "0.6.0"]
                       [slamhound "1.5.5"]]
        :injections [(require 'pjstadig.humane-test-output)
                     (pjstadig.humane-test-output/activate!)]

        :plugins [
                  [lein-kibit "0.1.2"]
                  [lein-try "0.4.3"]
                  [cider/cider-nrepl "0.8.2"]
                  [lein-ancient "0.6.7"]
                  [lein-pprint "1.1.1"]]}}

{:user {
        :dependencies [[pjstadig/humane-test-output "0.6.0"]
                       [slamhound "1.5.5"]]
        :injections [(require 'pjstadig.humane-test-output)
                     (pjstadig.humane-test-output/activate!)]
        :jvm-opts ["-Xmx512m" "-server"]

        :plugins [
                  [lein-kibit "0.1.2"]
                  [lein-try "0.4.3"]
                  [cider/cider-nrepl "0.8.2"]
                  [lein-ancient "0.6.7"]
                  [lein-pprint "1.1.1"]]}}

Set defaut jvm opts for lein. Limit memory usage


(ns comic-reader.scrape
  (:require [clojure.string :refer [trim]]
            [net.cgrand.enlive-html :as html]))

(def sites
  {"Manga Fox" {:url "http://mangafox.me/manga/"
                :selector [:div.manga_list :ul :li :a]
                :normalize (fn [{name :content
                                 {url :href} :attrs}]
                             {:name name
                              :url url})}
   "Manga Reader" {:url "http://www.mangareader.net/alphabetical"
                   :selector [:div.series_alpha :ul :li :a]
                   :normalize (fn [{name :content
                                    {url :href} :attrs}]
                                {:name (trim name)
                                 :url url})}})

(defn fetch-url [url]
  (html/html-resource (java.net.URL. url)))

(defn fetch-site-list [{:keys [url selector normalize]}])

(ns comic-reader.scrape
  (:require [clojure.string :refer [trim]]
            [net.cgrand.enlive-html :as html])
  (:import java.net.URL))

(def sites
  {"Manga Fox" {:url "http://mangafox.me/manga/"
                :selector [:div.manga_list :ul :li :a]
                :normalize (fn [{name :content
                                 {url :href} :attrs}]
                             {:name name
                              :url url})}
   "Manga Reader" {:url "http://www.mangareader.net/alphabetical"
                   :selector [:div.series_alpha :ul :li :a]
                   :normalize (fn [{name :content
                                    {url :href} :attrs}]
                                {:name (trim name)
                                 :url url})}})

(defn fetch-url [url]
  (html/html-resource (java.net.URL. url)))

(defn fetch-site-list [{:keys [url selector normalize]}]
  (map normalize (html/select (fetch-url url) selector)))

Write a function to process the site data


;; Copyright 2013 Andrey Antukh <niwi@niwi.be>
;;
;; Licensed under the Apache License, Version 2.0 (the "License")
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;;     http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.

(ns buddy.core.keys
  (:require [buddy.core.codecs :refer [str->bytes bytes->hex]]))

(defprotocol SecretKey
  (key->bytes [key] "Normalize key to byte array")
  (key->str [key] "Normalize key String"))

(extend-protocol SecretKey
  (Class/forName "[B")
  (key->bytes [it] it)
  (key->str [it] (bytes->hex it))

  String
  (key->bytes [key] (str->bytes key))
  (key->str [key] key))

;; Copyright 2013 Andrey Antukh <niwi@niwi.be>
;;
;; Licensed under the Apache License, Version 2.0 (the "License")
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;;     http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.

(ns buddy.core.keys
  (:require [buddy.core.codecs :refer [str->bytes bytes->hex]]))

(defprotocol ISecretKey
  (key->bytes [key] "Normalize key to byte array")
  (key->str [key] "Normalize key String"))

(extend-protocol ISecretKey
  (Class/forName "[B")
  (key->bytes [it] it)
  (key->str [it] (bytes->hex it))

  String
  (key->bytes [key] (str->bytes key))
  (key->str [key] key))

Rename SecretKey protocol to ISecretKey

Rename SecretKey protocol to ISecretKey


(ns leipzig-live.core
    (:require [reagent.core :as reagent :refer [atom]]
              [reagent.session :as session]
              [secretary.core :as secretary :include-macros true]
              [accountant.core :as accountant]))

;; -------------------------
;; Views

(defn home-page []
  [:div [:h1 "Welcome to Leipzig Live!"]])

(defn current-page []
  [:div [(session/get :current-page)]])

;; -------------------------
;; Routes

(secretary/defroute "/" []
  (session/put! :current-page #'home-page))

;; -------------------------
;; Initialize app

(defn mount-root []
  (reagent/render [current-page] (.getElementById js/document "app")))

(defn init! []
  (accountant/configure-navigation!)
  (accountant/dispatch-current!)
  (mount-root))

(ns leipzig-live.core
    (:require [reagent.core :as reagent :refer [atom]]
              [reagent.session :as session]
              [secretary.core :as secretary :include-macros true]
              [accountant.core :as accountant]))

;; -------------------------
;; Model
(defonce music  (atom ""))

;; -------------------------
;; Views

(defn home-page []
  [:div [:h1 "Welcome to Leipzig Live!"]
   [:div [:input {:type "text"
                  :value (-> music deref print-str)
                  :on-change #(reset! music (-> % .-target .-value))}]]
   [:div @music ]])

(defn current-page []
  [:div [(session/get :current-page)]])

;; -------------------------
;; Routes

(secretary/defroute "/" []
  (session/put! :current-page #'home-page))

;; -------------------------
;; Initialize app

(defn mount-root []
  (reagent/render [current-page] (.getElementById js/document "app")))

(defn init! []
  (accountant/configure-navigation!)
  (accountant/dispatch-current!)
  (mount-root))

Store the contents of the scratchpad in an atom.


(ns hello.handler
  (:require
    [byte-streams :as bs]
    [clojure.tools.cli :as cli]
    [aleph.http :as http]
    [cheshire.core :as json]
    [clj-tuple :as t])
  (:gen-class))

(defn plaintext-response
  []
  (t/hash-map
    :status 200
    :headers (t/hash-map "content-type" "text/plain; charset=utf-8")
    :body (bs/to-byte-array "Hello, World!")))

(defn json-response
  []
  (t/hash-map
    :status 200
    :headers (t/hash-map "content-type" "application/json")))

(defn handler [{:keys [uri] :as req}]
  (cond
    (= "/plaintext" uri) (plaintext-response)
    (= "/json" uri) (assoc (json-response)
                      :body (json/encode (t/hash-map :message "Hello, World!")))
    :else {:status 404}))

;;;

(defn -main [& args]

  (let [[{:keys [help port]} _ banner]
        (cli/cli args
          ["-p" "--port" "Server port"
           :default 8080
           :parse-fn #(Integer/parseInt %)]
          ["-h" "--[no-]help"])]

    (when help
      (println banner)
      (System/exit 0))

    (aleph.netty/leak-detector-level! :disabled)
    (http/start-server handler {:port port, :executor :none})))

(ns hello.handler
  (:require
    [byte-streams :as bs]
    [clojure.tools.cli :as cli]
    [aleph.http :as http]
    [cheshire.core :as json]
    [clj-tuple :as t])
  (:gen-class))

(def plaintext-response
  (t/hash-map
    :status 200
    :headers (t/hash-map "content-type" "text/plain; charset=utf-8")
    :body (bs/to-byte-array "Hello, World!")))

(def json-response
  (t/hash-map
    :status 200
    :headers (t/hash-map "content-type" "application/json")))

(defn handler [{:keys [uri] :as req}]
  (cond
    (= "/plaintext" uri) plaintext-response
    (= "/json" uri) (assoc json-response
                      :body (json/encode (t/hash-map :message "Hello, World!")))
    :else {:status 404}))

;;;

(defn -main [& args]

  (let [[{:keys [help port]} _ banner]
        (cli/cli args
          ["-p" "--port" "Server port"
           :default 8080
           :parse-fn #(Integer/parseInt %)]
          ["-h" "--[no-]help"])]

    (when help
      (println banner)
      (System/exit 0))

    (aleph.netty/leak-detector-level! :disabled)
    (http/start-server handler {:port port, :executor :none})))

aleph: Undo all my changes. I was fixing a non-problem.


(ns ring.middleware.multipart-params.test.temp-file
  (:use clojure.test
        [ring.util.io :only (string-input-stream)]
        ring.middleware.multipart-params.temp-file))

(deftest test-temp-file-store
  (let [store  (temp-file-store)
        result (store
                {:filename "foo.txt"
                 :content-type "text/plain"
                 :stream (string-input-stream "foo")})]
    (is (= (:filename result) "foo.txt"))
    (is (= (:content-type result) "text/plain"))
    (is (= (:size result) 3))
    (is (instance? java.io.File (:tempfile result)))
    (is (.exists (:tempfile result)))
    (is (= (slurp (:tempfile result)) "foo"))))

(deftest test-temp-file-expiry
  (let [store  (temp-file-store {:expires-in 2})
        result (store
                {:filename "foo.txt"
                 :content-type "text/plain"
                 :stream (string-input-stream "foo")})]
    (is (.exists (:tempfile result)))
    (Thread/sleep 2500)
    (is (not (.exists (:tempfile result))))))

(defn all-threads []
  (.keySet (Thread/getAllStackTraces)))

(deftest test-temp-file-threads
  (let [store (temp-file-store)]
    (dotimes [_ 200]
      (store {:filename "foo.txt"
              :content-type "text/plain"
              :stream (string-input-stream "foo")}))
    (is (< (count (all-threads))
           100))))

Test to check for excessive temp-file-store threads


(ns dna)

(defn- strand-convert [ch]
    (if (= \T ch) \U ch)
)

(defn to-rna [dna]
    (apply str (map strand-convert dna))
)

(ns dna)

(def Thymine \T)
(def Uracil  \U)

(defn- strand-convert [ch]
    (if (= Thymine ch)
        Uracil
        ch)
)

(defn to-rna [dna]
    (apply str (map strand-convert dna))
)

Use symbols for Thymine and Uracil

Use symbols for Thymine and Uracil


(ns comic-reader.ui.component-css
  (:refer-clojure :exclude [merge])
  (:require [garden.core :as g]
            [re-frame.core :as re-frame]))

(defn get* [db]
  (:component-css db))

(defn merge* [db id garden-css]
  (assoc-in db [:component-css id] garden-css))

(defn setup! []
  (re-frame/reg-sub
   :component-css
   (fn [app-db _]
     (get* app-db)))

  (re-frame/reg-event-db
   :add-to-component-css
   (fn [db [_ id garden-css]]
     (merge* db id garden-css))))

(defn merge [id garden-css]
  (re-frame/dispatch [:add-to-component-css id garden-css]))

(defn component-garden-css []
  (when-let [css @(re-frame/subscribe [:component-css])]
    (vals css)))

(defn component-css []
  [:style (g/css (component-garden-css))])

(ns comic-reader.ui.component-css
  (:refer-clojure :exclude [merge])
  (:require [garden.core :as g]
            [re-frame.core :as re-frame]))

(defn get* [db]
  (:component-css db))

(defn merge* [db id garden-css]
  (assoc-in db [:component-css id] garden-css))

(defn setup! []
  (re-frame/reg-sub
   :component-css
   (fn [app-db _]
     (get* app-db)))

  (re-frame/reg-event-db
   :add-to-component-css
   (fn [db [_ id garden-css]]
     (merge* db id garden-css))))

(defn merge [id garden-css]
  (re-frame/dispatch [:add-to-component-css id garden-css]))

(defn component-garden-css []
  (when-let [css @(re-frame/subscribe [:component-css])]
    (vals css)))

(defn component-css []
  [:style {:dangerouslySetInnerHTML
           {:__html
            (g/css (component-garden-css))}}])

Use dangerouslySetINnerHTML for component-css rendering


(ns braid.ui.styles.imports
  (:require [garden.stylesheet :refer [at-import]]))

(def imports
  [(at-import      "https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css")
  (at-import "https://fonts.googleapis.com/css?family=Open+Sans:400,300,400italic,700")])

Fix small gap in line 5

Fix small gap in line 5


(ns ninjudd.eventual.client
  (:require [cljs.core.async :as async]
            [cljs.reader :refer [read-string]]))

(defn make-event [f event]
  (-> (f (.-data event))
      (vary-meta merge {:event-id (.-lastEventId event)
                        :event-type (keyword (.-type event))})))

(defn event-source [f url & [event-types]]
  (let [event-types (or event-types [:message])
        source (new js/EventSource url)
        channel (async/chan)]
    (doseq [event-type event-types]
      (.addEventListener source (name event-type)
                         (fn [event]
                           (async/put! channel (make-event f event)))))
    (set! (.-onerror source)
          (fn [error]
            (.close source)
            (async/close! channel)))
    {:event-source source
     :channel channel}))

(defn edn-event-source [url & [event-types]]
  (event-source read-string url event-types))

(defn json-event-source [url & [event-types]]
  (event-source #(.parse js/JSON %) url event-types))

(defn close-event-source! [{:keys [channel event-source]}]
  (when event-source
    (.close event-source))
  (async/close! channel))

(ns ninjudd.eventual.client
  (:require [cljs.core.async :as async]
            [cljs.reader :refer [read-string]]))

(defn make-event [f event]
  (-> (f (.-data event))
      (vary-meta merge {:event-id (.-lastEventId event)
                        :event-type (keyword (.-type event))})))

(defn event-source [f url & [event-types channel]]
  (let [event-types (or event-types [:message])
        source (new js/EventSource url)
        channel (or channel (async/chan))]
    (doseq [event-type event-types]
      (.addEventListener source (name event-type)
                         (fn [event]
                           (async/put! channel (make-event f event)))))
    (set! (.-onerror source)
          (fn [error]
            (.close source)
            (async/close! channel)))
    {:event-source source
     :channel channel}))

(defn edn-event-source [url & [event-types channel]]
  (event-source read-string url event-types channel))

(defn json-event-source [url & [event-types channel]]
  (event-source #(.parse js/JSON %) url event-types channel))

(defn close-event-source! [{:keys [channel event-source]}]
  (when event-source
    (.close event-source))
  (async/close! channel))

Add optional "channel" argument to event-source


(ns less4clj.util)

;;
;; Debugging
;; from boot.util
;;

(def ^:dynamic *verbosity* 1)

(defn- print*
  [verbosity args]
  (when (>= *verbosity* verbosity)
    (binding [*out* *err*]
      (apply printf args) (flush))))

(defn dbug [& more] (print* 2 more))
(defn info [& more] (print* 1 more))
(defn warn [& more] (print* 1 more))
(defn fail [& more] (print* 1 more))

(ns less4clj.util)

;;
;; Debugging
;; from boot.util
;;

(def ^:dynamic *verbosity* 1)

(defn- print*
  [verbosity args]
  (when (>= *verbosity* verbosity)
    (binding [*out* *err*]
      (print (if (seq (rest args))
               (apply format args)
               (first args)))
      (flush))))

(defn dbug [& more] (print* 2 more))
(defn info [& more] (print* 1 more))
(defn warn [& more] (print* 1 more))
(defn fail [& more] (print* 1 more))

Fix logging when message has % but doesn't use format args


{:user {:plugins [;;[lein-nodisassemble "0.1.2"]
                  [jonase/eastwood "0.1.4"]
                  [lein-try "0.4.3"]
                  [cider/cider-nrepl "0.8.0-SNAPSHOT"]
                  [lein-gorilla "0.3.3"]
                  [lein-exec "0.3.4"]]
        :dependencies [[slamhound "1.5.5"]
                       [criterium "0.4.3"]]
        :repl-options {:init (require '[criterium.core :as crit])}}}

{:user {:plugins [;;[lein-nodisassemble "0.1.2"]
                  [jonase/eastwood "0.1.4"]
                  [lein-try "0.4.3"]
                  [cider/cider-nrepl "0.9.0-SNAPSHOT"]
                  [lein-gorilla "0.3.3"]
                  [lein-exec "0.3.4"]]
        :dependencies [[slamhound "1.5.5"]
                       [criterium "0.4.3"]
                       [org.clojure/tools.nrepl "0.2.10"]]
        :repl-options {:init (require '[criterium.core :as crit])}}}

Bump and fix cider and deps

Bump and fix cider and deps


(ns doctopus.storage-test
  (:require [doctopus.storage :refer :all]
            [clojure.test :refer :all]))

(deftest storage
  (testing "Can we swap backends?"
    (is (= default-backend (get-key-from-backend backend :name))
        "Are we using the default backend?")
    (is (set-backend! backend :temp-fs)
        "Can we set the backend to a differen't implementation?")
    (is (set-backend! backend default-backend)
        "And can we set it back to the default"))
  )

(ns doctopus.storage-test
  (:require [doctopus.storage :refer :all]
            [clojure.test :refer :all]))

(deftest storage
  (testing "Can we swap backends?"
    (is (= default-backend (get-key-from-backend backend :name))
        "Are we using the default backend?")
    (is (set-backend! backend :temp-fs)
        "Can we set the backend to a differen't implementation?")
    (is (set-backend! backend default-backend)
        "And can we set it back to the default")
    (is (thrown? java.lang.RuntimeException (set-backend! backend :HOODYBOO))
        "Explode on an unsupported backend.")))

Check that setting nonsense backends explodes


(ns tests-cats
  #+cljs
  (:require-macros [cemerick.cljs.test
                    :refer (is deftest with-test run-tests testing test-var)])
  #+cljs
  (:require [cemerick.cljs.test :as ts]
            [cats.core :as m]
            [cats.types :as t])
  #+clj
  (:require [clojure.test :refer :all]
            [cats.core :as m]
            [cats.types :as t]))

(deftest test-maybe
  (testing "Test predicates"
    (let [m1 (t/just 1)]
      (is (t/maybe? m1))
      (is (t/just? m1))))

  #+clj
  (testing "Test fmap"
    (let [m1 (t/just 1)
          m2 (t/nothing)]
      (is (= (m/fmap inc m1) (t/just 2)))
      (is (= (m/fmap inc m2) (t/nothing))))))

(ns tests-cats
  #+cljs
  (:require-macros [cemerick.cljs.test
                    :refer (is deftest with-test run-tests testing test-var)])
  #+cljs
  (:require [cemerick.cljs.test :as ts]
            [cats.core :as m]
            [cats.types :as t])
  #+clj
  (:require [clojure.test :refer :all]
            [cats.core :as m]
            [cats.types :as t]))

(deftest test-maybe
  (testing "Test predicates"
    (let [m1 (t/just 1)]
      (is (t/maybe? m1))
      (is (t/just? m1))))

  #+clj
  (testing "Test fmap"
    (let [m1 (t/just 1)
          m2 (t/nothing)]
      (is (= (m/fmap inc m1) (t/just 2)))
      (is (= (m/fmap inc m2) (t/nothing)))))

  #+clj
  (testing "sequence-m"
    (is (= (m/sequence-m [(t/just 2) (t/just 3)])
           (t/just [2 3])))
    (is (= (m/sequence-m [(t/just 2) (t/nothing)])
           (t/nothing)))))

Test sequence-m for the Maybe monad

Test sequence-m for the Maybe monad


(ns cljs-nlp.tokenize.simple
  (:use [clojure.string :only [split]]))

(defn space-tokenizer [str]
  (split str #"[ ]"))

(defn tab-tokenizer [str]
  (split str #"\t"))

(defn whitespace-tokenizer [str]
  (split str #"\s+"))

(defn blankline-tokenizer [str]
  (split str #"\s*\n\s*\n\s*"))

(defn char-tokenizer [str]
  (vec (seq str)))

(defn line-tokenizer [str]
  (split str #"\n"))

(ns cljs-nlp.tokenize.simple
  (:use [clojure.string :only [split]]))

(defn space-tokenizer [s]
  (split s #"[ ]"))

(defn tab-tokenizer [s]
  (split s #"\t"))

(defn whitespace-tokenizer [s]
  (split s #"\s+"))

(defn blankline-tokenizer [s]
  (split s #"\s*\n\s*\n\s*"))

(defn char-tokenizer [s]
  (vec (seq s)))

(defn line-tokenizer [s]
  (split s #"\n"))

Change string variable name to not conflict with core function.


;; The Climate Corporation licenses this file to you under under the Apache
;; License, Version 2.0 (the "License"); you may not use this file except in
;; compliance with the License.  You may obtain a copy of the License at
;;
;;   http://www.apache.org/licenses/LICENSE-2.0
;;
;; See the NOTICE file distributed with this work for additional information
;; regarding copyright ownership.  Unless required by applicable law or agreed
;; to in writing, software distributed under the License is distributed on an
;; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
;; or implied.  See the License for the specific language governing permissions
;; and limitations under the License.

(defproject com.climate/claypoole
  "1.1.1"
  :description "Claypoole: Threadpool tools for Clojure."
  :url "http://github.com/TheClimateCorporation/claypoole/"
  :license {:name "Apache License Version 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0"
            :distribution :repo}
  :min-lein-version "2.0.0"
  :source-paths ["src/clj"]
  :java-source-paths ["src/java"]
  :pedantic? :warn
  :profiles {:dev {:dependencies [[org.clojure/clojure "1.8.0"]]}}
  :plugins [[jonase/eastwood "0.2.3"]
            [lein-ancient "0.6.8"]])

;; The Climate Corporation licenses this file to you under under the Apache
;; License, Version 2.0 (the "License"); you may not use this file except in
;; compliance with the License.  You may obtain a copy of the License at
;;
;;   http://www.apache.org/licenses/LICENSE-2.0
;;
;; See the NOTICE file distributed with this work for additional information
;; regarding copyright ownership.  Unless required by applicable law or agreed
;; to in writing, software distributed under the License is distributed on an
;; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
;; or implied.  See the License for the specific language governing permissions
;; and limitations under the License.

(defproject com.climate/claypoole
  "1.1.1-SNAPSHOT"
  :description "Claypoole: Threadpool tools for Clojure."
  :url "http://github.com/TheClimateCorporation/claypoole/"
  :license {:name "Apache License Version 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0"
            :distribution :repo}
  :min-lein-version "2.0.0"
  :source-paths ["src/clj"]
  :java-source-paths ["src/java"]
  :pedantic? :warn
  :profiles {:dev {:dependencies [[org.clojure/clojure "1.8.0"]]}}
  :plugins [[jonase/eastwood "0.2.3"]
            [lein-ancient "0.6.8"]])

Change version back to snapshot

Change version back to snapshot


(ns lens.middleware.wan-exception
  (:require [clj-stacktrace.repl :refer [pst-on]]))

(defn wrap-exception
  "Calls the handler in a try catch block returning a WAN error response."
  [handler]
  (fn [request]
    (try
      (handler request)
      (catch Throwable e
        (pst-on *err* false e)
        {:status 500
         :body {:error (.getMessage e)}}))))

(ns lens.middleware.wan-exception
  (:require [clj-stacktrace.repl :refer [pst-on]]))

(defn wrap-exception
  "Calls the handler in a try catch block returning a WAN error response."
  [handler]
  (fn [request]
    (try
      (handler request)
      (catch Throwable e
        (pst-on *err* false e)
        {:status 500
         :body
         {:links {:up {:href "/"}}
          :error (.getMessage e)}}))))

Add Up Link to Error Representation

Add Up Link to Error Representation


(ns afterglow.effects.color-test
  (:require [clojure.test :refer :all]
            [afterglow.effects.color :refer :all]
            [afterglow.channels :as channels]
            [com.evocomputing.colors :as colors]
            [afterglow.fixtures.chauvet :as chauvet]
            [taoensso.timbre :as timbre :refer [error warn info debug spy]]))

(deftest test-extract-rgb
  (testing "Finding RGB color channels")
  (is (= [2 3 4] (map :offset (#'afterglow.effects.color/extract-rgb [(chauvet/slimpar-hex3-irc)])))))

(ns afterglow.effects.color-test
  (:require [clojure.test :refer :all]
            [afterglow.effects.color :refer :all]
            [afterglow.channels :as channels]
            [com.evocomputing.colors :as colors]
            [afterglow.fixtures.chauvet :as chauvet]
            [taoensso.timbre :as timbre :refer [error warn info debug spy]]))

(deftest test-extract-rgb
  (testing "Finding RGB color channels")
  (is (= [:12-channel-mix-uv] (map :mode (#'afterglow.effects.color/find-rgb-heads [(chauvet/slimpar-hex3-irc)])))))

Update test. Still have far too few...

Update test. Still have far too few...


(ns proto.main
  (:require [clojure.contrib.io :as io])
  (:require [clj-yaml.core :as yaml])
  )

(defn init [& argv]
  (-> argv
      first
      io/reader
      slurp
      yaml/parse-string
      println))

(defn -main [& argv]
  (init *command-line-args*))

(ns proto.main
  (:require [clojure.contrib.io :as io])
  (:require [clojure.contrib.generic.functor :as functor])
  (:require [clj-yaml.core :as yaml]))

(declare autotools-handler)

(def handlers '(autotools-handler))

(defn run-handlers
  "Run all the handlers on a definition"
  [config]
  (map #(% config) handlers))

(defn process-handlers
  "For each project definition, run all the handlers on it"
  [configurations]
  (functor/fmap run-handlers configurations))

(defn autotools-handler
  [{type :type
    subdir :subdir
    configurations :configurations
    autoconf-version :autoconf-version}]
  (when (= type "autotools") "print autotools"))

(defn init [& argv]
  (-> argv
      first
      io/reader
      slurp
      yaml/parse-string
      process-handlers))

(defn -main [& argv]
  (init *command-line-args*))

Add simple pattern matching. Matchure and more complex matching weren't cutting it.


(ns cadence.migrations
  "Define some migrations yo."
  (:require [cadence.model.migration :refer [defmigration]]
            (monger [collection :as mc]
                    [operators :refer :all]))
  (:import (org.bson.types ObjectId)))

(defn- str-id
  "Helper function for generating an id when adding migrations."
  [] (str (ObjectId.)))

;; ## Define some migrations.

(defmigration "Add roles to users"
  "5108749844ae8febda9c2ed4"
  (do (mc/update "users" {} {$set {:roles [:user]}} :multi true)
      (mc/update "users" {:username "RyanMcG"} {$push {:roles :admin}}))
  (mc/update "users" {} {$unset {:roles ""}} :multi true))

(defmigration "Change my name (just for demo)"
  "51571b7244aedb2065e2a3d7"
  (mc/update "users" {:username "RyanMcG"} {$set {:name "Ryan Vincent McGowan"}})
  (mc/update "users" {:username "RyanMcG"} {$set {:name "Ryan McGowan"}}))

Add another migration for demo purposes.


(ns chatapp.view
  (:require [re-frame.core :as re-frame]))

(defn message [message]
  [:li {:class "list-group-item"}
   (:message message)])

(defn message-list []
  (let [messages (re-frame/subscribe [:messages])]
    (fn []
      [:div {:class "row"}
       [:div {:class "col-lg-6"}
        [:ul {:class "list-group"}
         (for [m @messages]
           (message m))]]])))

(defn message-input []
  (let [input (re-frame/subscribe [:message-input])]
    [:div {:class "row"}
     [:div {:class "col-lg-6"}
      [:div {:class "input-group"}
       [:input {:type        "text"
                :value       (:text @input)
                :placeholder "Enter text to reverse!"
                :class       "form-control"
                :on-change   #(re-frame/dispatch [:message-input-text (-> % .-target .-value)])}]
       [:span {:class "input-group-btn"}
        [:button {:type     "button"
                  :class    "btn btn-default"
                  :on-click #(re-frame/dispatch [:send-message])}
         "Send"]]
       ]]]))

(defn chat-ui []
  [:div {:class "container-fluid"}
   [:h1 "ChatApp"]
   [message-list]
   [message-input]])

(ns chatapp.view
  (:require [re-frame.core :as re-frame]))

(defn message [message]
  [:li {:class "list-group-item"}
   (:message message)])

(defn message-list []
  (let [messages (re-frame/subscribe [:messages])]
    (fn []
      [:div {:class "row"}
       [:div {:class "col-md-6"}
        [:ul {:class "list-group"}
         (for [m @messages]
           (message m))]]])))

(defn message-input []
  (let [input (re-frame/subscribe [:message-input])]
    (fn []
      [:input {:type        "text"
               :value       (:text @input)
               :placeholder "Enter text to reverse!"
               :class       "form-control"
               :auto-focus  true
               :on-key-press #(when (= 13 (.-charCode %))
                                (re-frame/dispatch [:send-message]))
               :on-change   #(re-frame/dispatch [:message-input-text (-> % .-target .-value)])}])))

(defn message-composer []
  [:div {:class "row"}
   [:div {:class "col-md-6"}
    [:div {:class "input-group"}
     [message-input]
     [:span {:class "input-group-btn"}
      [:button {:type     "button"
                :class    "btn btn-default"
                :on-click #(re-frame/dispatch [:send-message])}
       "Send"]]]]])

(defn chat-ui []
  [:div {:class "container-fluid"}
   [:div {:class "row"}
    [:div {:class "col-md-6"}
     [:h1 "ChatApp"]]]
   [message-list]
   [message-composer]])

Send message when enter is pressed

Send message when enter is pressed


;; The Climate Corporation licenses this file to you under under the Apache
;; License, Version 2.0 (the "License"); you may not use this file except in
;; compliance with the License.  You may obtain a copy of the License at
;;
;;   http://www.apache.org/licenses/LICENSE-2.0
;;
;; See the NOTICE file distributed with this work for additional information
;; regarding copyright ownership.  Unless required by applicable law or agreed
;; to in writing, software distributed under the License is distributed on an
;; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
;; or implied.  See the License for the specific language governing permissions
;; and limitations under the License.

(defproject com.climate/claypoole
  "1.0.0-SNAPSHOT"
  :description "Claypoole: Threadpool tools for Clojure."
  :url "http://github.com/TheClimateCorporation/claypoole/"
  :license {:name "Apache License Version 2.0"
            :url http://www.apache.org/licenses/LICENSE-2.0
            :distribution :repo}
  :min-lein-version "2.0.0"
  :source-paths ["src/clj"]
  :java-source-paths ["src/java"]
  :pedantic? :warn
  :dependencies [[org.clojure/clojure "1.6.0"]]
  :plugins [[jonase/eastwood "0.2.1"]])

;; The Climate Corporation licenses this file to you under under the Apache
;; License, Version 2.0 (the "License"); you may not use this file except in
;; compliance with the License.  You may obtain a copy of the License at
;;
;;   http://www.apache.org/licenses/LICENSE-2.0
;;
;; See the NOTICE file distributed with this work for additional information
;; regarding copyright ownership.  Unless required by applicable law or agreed
;; to in writing, software distributed under the License is distributed on an
;; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
;; or implied.  See the License for the specific language governing permissions
;; and limitations under the License.

(defproject com.climate/claypoole
  "1.0.0-SNAPSHOT"
  :description "Claypoole: Threadpool tools for Clojure."
  :url "http://github.com/TheClimateCorporation/claypoole/"
  :license {:name "Apache License Version 2.0"
            :url http://www.apache.org/licenses/LICENSE-2.0
            :distribution :repo}
  :min-lein-version "2.0.0"
  :source-paths ["src/clj"]
  :java-source-paths ["src/java"]
  :pedantic? :warn
  :profiles {:dev {:dependencies [[org.clojure/clojure "1.7.0"]]}}
  :plugins [[jonase/eastwood "0.2.1"]])

Move Clojure to dev dependency

Move Clojure to dev dependency


(defproject buddy/buddy-sign "1.0.0"
  :description "High level message signing for Clojure"
  :url "https://github.com/funcool/buddy-sign"
  :license {:name "Apache 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0"}
  :dependencies [[org.clojure/clojure "1.8.0" :scope "provided"]
                 [com.taoensso/nippy "2.11.1" :scope "provided"]
                 [buddy/buddy-core "0.12.1"]
                 [cheshire "5.6.1"]]
  :source-paths ["src"]
  :javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
  :test-paths ["test"])

(defproject buddy/buddy-sign "1.0.0"
  :description "High level message signing for Clojure"
  :url "https://github.com/funcool/buddy-sign"
  :license {:name "Apache 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0"}
  :dependencies [[org.clojure/clojure "1.8.0" :scope "provided"]
                 [com.taoensso/nippy "2.11.1" :scope "provided"]
                 [org.clojure/test.check "0.9.0" :scope "test"]
                 [buddy/buddy-core "0.13.0"]
                 [cheshire "5.6.1"]]
  :source-paths ["src"]
  :javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
  :test-paths ["test"])

Add test.check dependency and upgrade buddy-core dependency.


(defproject rpi-challenger "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "https://github.com/solita"
  :license {:name "MIT License"
            :url "http://opensource.org/licenses/MIT"}

  :dependencies [[org.clojure/clojure "1.4.0"]
                 [org.clojure/tools.cli "0.2.2"]
                 [http.async.client "0.5.0-SNAPSHOT"]
                 [ring/ring-core "1.1.6"]
                 [ring/ring-devel "1.1.6"]
                 [ring/ring-jetty-adapter "1.1.6"]
                 [compojure "1.1.3"]
                 [enlive "1.0.0"]]

  :main rpi-challenger.main)

(defproject rpi-challenger "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "https://github.com/solita"
  :license {:name "MIT License"
            :url "http://opensource.org/licenses/MIT"}

  :dependencies [[org.clojure/clojure "1.4.0"]
                 [org.clojure/tools.cli "0.2.2"]
                 [http.async.client "0.5.0-SNAPSHOT"]
                 [ch.qos.logback/logback-classic "1.0.7"]
                 [ring/ring-core "1.1.6"]
                 [ring/ring-devel "1.1.6"]
                 [ring/ring-jetty-adapter "1.1.6"]
                 [compojure "1.1.3"]
                 [enlive "1.0.0"]]

  :main rpi-challenger.main)

Use Logback, avoid warning about missing logger implementation


(defproject bukkure "0.4.2-SNAPSHOT"
  :description "Bringing Clojure to the Bukkit API"
  :url "http://github.com/SevereOverfl0w/Bukkure"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :java-source-paths ["javasrc"]
  :javac-options ["-d" "classes/" "-source" "1.7" "-target" "1.7"]
  :resource-paths ["resources/*"]
  :repositories [["spigot-repo" "https://hub.spigotmc.org/nexus/content/groups/public/"]]
  :plugins [[codox "0.8.13"]]
  :codox {:defaults {:doc/format :markdown}}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.bukkit/bukkit "1.8.7-R0.1-SNAPSHOT"]
                 [org.reflections/reflections "0.9.8"]
                 [org.clojure/tools.nrepl "0.2.3"]
                 [cheshire "5.2.0"]])

(defproject bukkure "0.4.2-SNAPSHOT"
  :description "Bringing Clojure to the Bukkit API"
  :url "http://github.com/SevereOverfl0w/Bukkure"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :java-source-paths ["javasrc"]
  :javac-options ["-d" "classes/" "-source" "1.7" "-target" "1.7"]
  :resource-paths ["resources/*"]
  :repositories [["spigot-repo" "https://hub.spigotmc.org/nexus/content/groups/public/"]]
  :plugins [[codox "0.8.13"]]
  :codox {:defaults {:doc/format :markdown}}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.reflections/reflections "0.9.8"]
                 [org.clojure/tools.nrepl "0.2.3"]
                 [cheshire "5.2.0"]]
  :profiles {:provided
              {:dependencies [[org.bukkit/bukkit "1.8.7-R0.1-SNAPSHOT"]]}})

Make bukkit a provided dependency.

Make bukkit a provided dependency.


(defproject onyx-app/lein-template "0.10.0.0-rc2"
  :description "Onyx Leiningen application template"
  :url "https://github.com/onyx-platform/onyx-template"
  :license {:name "MIT License"
            :url "http://choosealicense.com/licenses/mit/#"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

(defproject onyx-app/lein-template "0.10.0.0-SNAPSHOT"
  :description "Onyx Leiningen application template"
  :url "https://github.com/onyx-platform/onyx-template"
  :license {:name "MIT License"
            :url "http://choosealicense.com/licenses/mit/#"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

Prepare for next release cycle.

Prepare for next release cycle.


(ns user
  "Namespace to support hacking at the REPL."
  (:require [clojure.java.javadoc :refer [javadoc]]
            [clojure.pprint :refer [pp pprint]]
            [clojure.repl :refer :all]
            [clojure.string :as str]
            [clojure.tools.namespace.move :refer :all]
            [clojure.tools.namespace.repl :refer :all]
            [midje.repl :refer :all]))

;;;; ___________________________________________________________________________
;;;; ---- u-classpath ----

(defn u-classpath []
  (str/split (System/getProperty "java.class.path")
             #":"))

;;;; ___________________________________________________________________________
;;;; ---- u-move-ns-dev-src-test ----

(defn u-move-ns-dev-src-test [old-sym new-sym source-path]
  (move-ns old-sym new-sym source-path ["dev" "src" "test"]))

;;;; ___________________________________________________________________________
;;;; App-specific additional utilities for the REPL or command line

(do (autotest :stop)
    (autotest :filter (complement :slow)))

(ns user
  "Namespace to support hacking at the REPL."
  (:require [clojure.java.javadoc :refer [javadoc]]
            [clojure.pprint :refer [pp pprint]]
            [clojure.repl :refer :all]
            [clojure.string :as str]
            [clojure.tools.namespace.move :refer :all]
            [clojure.tools.namespace.repl :refer :all]
            [midje.repl :refer :all]))

;;;; ___________________________________________________________________________
;;;; ---- u-classpath ----

(defn u-classpath []
  (str/split (System/getProperty "java.class.path")
             #":"))

;;;; ___________________________________________________________________________
;;;; ---- u-move-ns-dev-src-test ----

(defn u-move-ns-dev-src-test [old-sym new-sym source-path]
  (move-ns old-sym new-sym source-path ["dev" "src" "test"]))

;;;; ___________________________________________________________________________
;;;; App-specific additional utilities for the REPL or command line

(comment

  (do (autotest :stop)
      (autotest :filter (complement :slow)))

  )

Comment out stuff in dev.clj

Comment out stuff in dev.clj


(ns {{name}}-devcards.core
    (:require
     [devcards.core :as dc :include-macros true]
     [{{name}}.core :as {{name}}]
     #_[om.core :as om :include-macros true]
     #_[sablono.core :as sab :include-macros true])
    (:require-macros
     [devcards.core :refer [defcard is are= are-not=]]))

(enable-console-print!)

(devcards.core/start-devcard-ui!)
(devcards.core/start-figwheel-reloader!)

;; remember to run lein figwheel and then browse to
;; http://localhost:3449/devcards/index.html

(defcard devcard-intro
  (dc/markdown-card
   "# Devcards for {{ name }}

    I can be found in `devcards_src/{{sanitized}}_devcards/core.cljs`.

    If you add cards to this file, they will appear here on this page.

    You can add devcards to any file as long as you require
    `devcards.core` like so:

    ```
    (:require [devcards.core :as dc :include-macros true])
    ```

    As you add cards to other namspaces, those namspaces will
    be listed on the Devcards **home** page.

    Here are some Devcard examples"))

(ns {{name}}-devcards.core
    (:require
     [devcards.core :as dc :include-macros true]
     [{{name}}.core :as {{name}}]
     #_[om.core :as om :include-macros true]
     #_[sablono.core :as sab :include-macros true])
    (:require-macros
     [devcards.core :refer [defcard is are= are-not=]]))

(enable-console-print!)

(devcards.core/start-devcard-ui!)
(devcards.core/start-figwheel-reloader!)

;; remember to run lein figwheel and then browse to
;; http://localhost:3449/devcards/index.html

(defcard devcard-intro
  (dc/markdown-card
   "# Devcards for {{ name }}

    I can be found in `devcards_src/{{sanitized}}_devcards/core.cljs`.

    If you add cards to this file, they will appear here on this page.
    As you add cards to other namespaces, those namespaces will
    be listed on the Devcards **home** page, provided you require
    those files in `devcards_src/{{sanitized}}_devcards/core.cljs`.

    You can add devcards to any file as long as you require
    `devcards.core` like so:

    ```
    (:require [devcards.core :as dc :include-macros true])
    ```

    Here are some Devcard examples"))

Document the process of adding namespaces to devcards home.

Clarified that devcards_src/core.cljs needs to be edited in order for
new namespaces to appear.


(ns app.app
  (:require [cljsjs.material]
            [reagent.core :as reagent]))

(defn fixed-header-and-drawer-component [content]
  [:div.mdl-layout.mdl-js-layout.mdl-layout--fixed-drawer.mdl-layout--fixed-header
   [:header.mdl-layout__header
    [:div.mdl-layout__header-row
     [:div.mdl-layout-spacer]]]
   [:div.mdl-layout__drawer
    [:span.mdl-layout-title "Resume"]
    [:nav.mdl-navigation
     [:a.mdl-navigation__link {:href "#"} "About"]]]
   [:main.mdl-layout__content
    [:div.page-content
     content]]])

(defn some-component []
  [:div
   [fixed-header-and-drawer-component
    [:h3 "This is your app"]]])

(defn init []
  (reagent/render-component [some-component]
                            (.getElementById js/document "container")))

(ns app.app
  (:require [cljsjs.material]
            [reagent.core :as reagent]
            [app.components :as comps]
            [app.res :refer [resume]]))

(defn fixed-header-and-drawer-component [content]
  [:div.mdl-layout.mdl-js-layout.mdl-layout--fixed-drawer.mdl-layout--fixed-header
   [:header.mdl-layout__header
    [:div.mdl-layout__header-row
     [:div.mdl-layout-spacer]]]
   [:div.mdl-layout__drawer
    [:span.mdl-layout-title "Resume"]
    [:nav.mdl-navigation
     [:a.mdl-navigation__link {:href "#contact"} "Contact"]
     [:a.mdl-navigation__link {:href "#about"} "About"]
     [:a.mdl-navigation__link {:href "#projects"} "Projects"]]]
   [:main.mdl-layout__content
    [:div.page-content
     content]]])

(defn main-component []
  [:div
   [fixed-header-and-drawer-component
    [:div
     [comps/contact-component (:name (:contact resume))
      (:email (:contact resume))
      (:phone (:contact resume))]
     [comps/about-component
      [:p (:profile resume)]]
     [comps/projects-component
      (:projects resume)]]]])

(defn init []
  (reagent/render-component [main-component]
                            (.getElementById js/document "container")))

Add projects section to sidebar

Add projects section to sidebar


(ns advent2016.day3
  (:require [clojure.java.io :as io]
            [clojure.string :as s]))

(defn read-sides [line]
  (map #(Integer/parseInt %) (remove s/blank? (s/split line #" "))))

(defn valid-triangle? [[a b c]]
  (and (> (+ a b) c)
       (> (+ a c) b)
       (> (+ b c) a)))

(def solution (->> "../day3.data"
                 io/reader
                 line-seq
                 (map read-sides)
                 (filter valid-triangle?)
                 count))

(ns advent2016.day3
  (:require [clojure.java.io :as io]
            [clojure.string :as s]))

(def puzzle (line-seq (io/reader "../day3.data")))

(defn read-sides [line]
  (map #(Integer/parseInt %) (remove s/blank? (s/split line #" "))))

(defn valid-triangle? [[a b c]]
  (and (> (+ a b) c)
       (> (+ a c) b)
       (> (+ b c) a)))

(def solution1 (->> puzzle
                    (map read-sides)
                    (filter valid-triangle?)
                    count))

(def solution2 (->> puzzle
                    (map read-sides)
                    (apply mapcat vector)
                    (partition 3)
                    (filter valid-triangle?)
                    count))

Implement part 2 of the Clojure day 3 solution.


(defproject simple "lein-git-inject/version"

  :dependencies [[org.clojure/clojure       "1.10.1"]
                 [org.clojure/clojurescript "1.10.520"
                  :exclusions [com.google.javascript/closure-compiler-unshaded
                               org.clojure/google-closure-library]]
                 [thheller/shadow-cljs      "2.8.69"]
                 [reagent                   "0.9.0-rc2"]
                 [re-frame                  "0.11.0-rc2"]]

  :plugins      [[day8/lein-git-inject "0.0.2"]
                 [lein-shadow          "0.1.6"]]

  :middleware   [leiningen.git-inject/middleware]

  :clean-targets ^{:protect false} [:target-path
                                    "shadow-cljs.edn"
                                    "package.json"
                                    "package-lock.json"
                                    "resources/public/js"]

  :shadow-cljs {:nrepl  {:port 8777}

                :builds {:client {:target     :browser
                                  :output-dir "resources/public/js"
                                  :modules    {:client {:init-fn simple.core/run}}
                                  :devtools   {:http-root "resources/public"
                                               :http-port 8280}}}}

  :aliases {"dev-auto" ["shadow" "watch" "client"]})

(defproject simple "lein-git-inject/version"

  :dependencies [[org.clojure/clojure       "1.10.1"]
                 [org.clojure/clojurescript "1.10.520"
                  :exclusions [com.google.javascript/closure-compiler-unshaded
                               org.clojure/google-closure-library
                               org.clojure/google-closure-library-third-party]]
                 [thheller/shadow-cljs      "2.8.69"]
                 [reagent                   "0.9.0-rc2"]
                 [re-frame                  "0.11.0-rc2"]]

  :plugins      [[day8/lein-git-inject "0.0.2"]
                 [lein-shadow          "0.1.6"]]

  :middleware   [leiningen.git-inject/middleware]

  :clean-targets ^{:protect false} [:target-path
                                    "shadow-cljs.edn"
                                    "package.json"
                                    "package-lock.json"
                                    "resources/public/js"]

  :shadow-cljs {:nrepl  {:port 8777}

                :builds {:client {:target     :browser
                                  :output-dir "resources/public/js"
                                  :modules    {:client {:init-fn simple.core/run}}
                                  :devtools   {:http-root "resources/public"
                                               :http-port 8280}}}}

  :aliases {"dev-auto" ["shadow" "watch" "client"]})

Add simple example org.clojure/google-closure-library-third-party exclusion


(ns nth-prime)

(defn sqrt
  "Wrapper around java's sqrt method."
  [number]
  (int (Math/ceil (Math/sqrt number))))

(defn divides?
  "Helper function to decide if a number is evenly divided by divisor."
  [number divisor]
  (zero? (mod number divisor)))

(defn- prime-by-trial-division?
  "Simple trial division prime check."
  [number]
  (empty? (for [n (range 3 (inc (sqrt number)) 2) :when (divides? number n)] n)))

(defn prime? [number]
  (cond
    (= 2 number) true
    (even? number) false
    :else (prime-by-trial-division? number)))

(defn next-prime [start]
  (loop [n (inc start)]
    (if (prime? n)
      n
      (recur (inc n)))))

(def primes (iterate next-prime 1))

(defn nth-prime [index]
  (when (not (pos? index))
    (throw (IllegalArgumentException. "nth-prime expects a positive integer for an argument")))
  (nth primes index))

(ns nth-prime)

(defn sqrt
  "Wrapper around java's sqrt method."
  [number]
  (int (Math/ceil (Math/sqrt number))))

(defn divides?
  "Helper function to decide if a number is evenly divided by divisor."
  [number divisor]
  (zero? (mod number divisor)))

(defn- prime-by-trial-division?
  "Simple trial division prime check."
  [number]
  (empty? (for [n (range 3 (inc (sqrt number)) 2) :when (divides? number n)] n)))

(defn prime? [number]
  (or (= 2 number)
      (and (odd? number) (prime-by-trial-division? number))))

(defn next-prime [start]
  (loop [n (inc start)]
    (if (prime? n)
      n
      (recur (inc n)))))

(def primes (iterate next-prime 1))

(defn nth-prime [index]
  (when-not (pos? index)
    (throw (IllegalArgumentException. "nth-prime expects a positive integer for an argument")))
  (nth primes index))

Update nth-prime in response to PR feedback

Replace `(when (not` with `when-not`, update `cond` to instead use `or`.


(ns desdemona.lifecycles.logging
  (:require [taoensso.timbre :refer [info]]))

  (let [task-name (:onyx/name (:onyx.core/task-map event))]
    (doseq [m (map :message (mapcat :leaves (:tree (:onyx.core/results event))))]
(defn log-batch
  [event lifecycle]
      (info task-name "logging segment:" m)))
  {})

(def log-calls
  {:lifecycle/after-batch log-batch})

(defn add-logging
  "Adds logging output to a task's output-batch."
  [job task]
  (if-let [entry (first (filter #(= (:onyx/name %) task) (:catalog job)))]
    (update-in
     job
     [:lifecycles]
     conj
     {:lifecycle/task task
      :lifecycle/calls ::log-calls})))

(ns desdemona.lifecycles.logging
  (:require [taoensso.timbre :refer [info]]))

(defn log-batch
  [event lifecycle]
  (let [task-name (-> event
                      :onyx.core/task-map
                      :onyx/name)]
    (doseq [m (->> event
                   :onyx.core/results
                   :tree
                   (mapcat :leaves)
                   (map :message))]
      (info task-name "logging segment:" m)))
  {})

(def log-calls
  {:lifecycle/after-batch log-batch})

(defn add-logging
  "Adds logging output to a task's output-batch."
  [job task]
  (if-let [entry (first (filter #(= (:onyx/name %) task) (:catalog job)))]
    (update-in
     job
     [:lifecycles]
     conj
     {:lifecycle/task task
      :lifecycle/calls ::log-calls})))

Use ->(>) for the impl

Use ->(>) for the impl


(ns comic-reader.history
  (:require [re-frame.core :as rf]
            [secretary.core :refer [dispatch!]]
            [goog.events :as events]
            [goog.history.EventType :as EventType])
  (:import goog.history.Html5History))

(defonce goog-history (atom nil))

(defn hook-browser-navigation! []
  (when (nil? @goog-history)
    (let [hist (Html5History. false
                         "/blank"
                         (.getElementById js/document
                                          "history_state"))]
      (reset! goog-history hist)
      (events/listen hist
          EventType/NAVIGATE
        (fn [event]
          (dispatch! (.-token event))))
      (doto hist
        (.setEnabled true)))))

(defn set-token [token]
  (.setToken @goog-history (str token)))

(ns comic-reader.history
  (:require [re-frame.core :as rf]
            [secretary.core :refer [dispatch!]]
            [goog.events :as events]
            [goog.history.EventType :as EventType])
  (:import goog.history.Html5History))

(defonce goog-history (atom nil))

(defn hook-browser-navigation! []
  (when (nil? @goog-history)
    (let [hist (Html5History. false
                         "/blank"
                         (.getElementById js/document
                                          "history_state"))]
      (reset! goog-history hist)
      (events/listen hist
          EventType/NAVIGATE
        (fn [event]
          (dispatch! (.-token event))))
      (doto hist
        (.setEnabled true)))))

(defn get-token []
  (when-let [h @goog-history]
    (.getToken h)))

(defn set-token [token]
  (when-let [h @goog-history]
    (.setToken h (str token))))

Add get-token and protect both token manipulators


(set-env!
  :resource-paths #{"resources"}
  :dependencies '[[org.clojure/clojure "1.8.0"]
                  [afrey/boot-asset-fingerprint "1.3.1"]
                  [tailrecursion/boot-jetty "0.1.3" :scope "test"]])

(require
  '[afrey.boot-asset-fingerprint :refer [asset-fingerprint]]
  '[tailrecursion.boot-jetty :as jetty])

(deftask dev []
  (comp
    (watch)
    (asset-fingerprint :extensions [".css" ".html"])
    (jetty/serve :port 5000)
    (target)))

(set-env!
  :resource-paths #{"resources"}
  :dependencies '[[org.clojure/clojure "1.8.0"]
                  [afrey/boot-asset-fingerprint "1.3.1"]
                  [tailrecursion/boot-jetty "0.1.3" :scope "test"]])

(require
  '[afrey.boot-asset-fingerprint :refer [asset-fingerprint]]
  '[tailrecursion.boot-jetty :as jetty])

(deftask dev
  [s skip bool]
  (comp
    (watch)
    (asset-fingerprint :extensions [".css" ".html"] :skip skip)
    (jetty/serve :port 5000)
    (target)))

Add skip option to example dev

Add skip option to example dev

for testing


(ns onyx.types)

(defrecord Leaf [message id acker-id completion-id ack-val hash-group route])

(defrecord Route [flow exclusions post-transformation action])

(defrecord Ack [id completion-id ack-val timestamp])

(defrecord Results [tree acks segments])

(defrecord Result [root leaves])

(defrecord Link [link timestamp])

(ns onyx.types)

(defrecord Leaf [message id acker-id completion-id ack-val hash-group route])

(defn input [id message]
  (->Leaf message id nil nil nil nil nil))

(defrecord Route [flow exclusions post-transformation action])

(defrecord Ack [id completion-id ack-val timestamp])

(defrecord Results [tree acks segments])

(defrecord Result [root leaves])

(defrecord Link [link timestamp])

Add input builder fn for use by plugins

Add input builder fn for use by plugins


(ns lazytest.find
  (:use lazytest.suite))

(defn- find-tests-for-var [this-var]
  (if-let [f (:find-tests (meta this-var))]
    (do (assert (fn? f)) (f))
    (when (bound? this-var)
      (let [value (var-get this-var)]
	(when (suite? value)
	  value)))))

(defn- test-seq-for-ns [this-ns]
  (vary-meta (remove nil? (map find-tests-for-var (vals (ns-interns this-ns))))
	     assoc :name (ns-name this-ns)))

(defn- find-tests-in-namespace [this-ns]
  (when-not (= (the-ns 'clojure.core) this-ns)
    (if-let [f (:find-tests (meta this-ns))]
      (do (assert (fn? f)) (f))
      (when-let [s (test-seq-for-ns this-ns)]
	(suite (fn [] (test-seq s)))))))

(defn find-tests [x]
  "Returns a seq of runnable tests. Processes the :focus metadata flag.
 Recurses on all Vars in a namespace, unless that namespace
 has :find-tests metadata."
  (cond (symbol? x)
	  (find-tests (the-ns x))
	(instance? clojure.lang.Namespace x)
	  (find-tests-in-namespace x)
	(var? x)
	  (find-tests-for-var x)
        :else nil))

(ns lazytest.find
  (:use lazytest.suite))

(defn- find-tests-for-var [this-var]
  (if-let [f (:find-tests (meta this-var))]
    (do (assert (fn? f)) (f))
    (when (bound? this-var)
      (let [value (var-get this-var)]
	(when (suite? value)
	  value)))))

(defn- test-seq-for-ns [this-ns]
  (let [s (remove nil? (map find-tests-for-var (vals (ns-interns this-ns))))]
    (when (seq s)
      (vary-meta s assoc :name (ns-name this-ns)))))

(defn- find-tests-in-namespace [this-ns]
  (when-not (= (the-ns 'clojure.core) this-ns)
    (if-let [f (:find-tests (meta this-ns))]
      (do (assert (fn? f)) (f))
      (when-let [s (test-seq-for-ns this-ns)]
	(suite (fn [] (test-seq s)))))))

(defn find-tests [x]
  "Returns a seq of runnable tests. Processes the :focus metadata flag.
 Recurses on all Vars in a namespace, unless that namespace
 has :find-tests metadata."
  (cond (symbol? x)
	  (find-tests (the-ns x))
	(instance? clojure.lang.Namespace x)
	  (find-tests-in-namespace x)
	(var? x)
	  (find-tests-for-var x)
        :else nil))

Return nil instead of empty sequence from test-seq-for-ns


(ns cmr.graph.rest.response
  (:require
   [cheshire.core :as json]
   [ring.util.http-response :as response]
   [taoensso.timbre :as log]))

(defn ok
  [_request & args]
  (response/ok args))

(defn json
  [_request data]
  (-> data
      json/generate-string
      response/ok
      (response/content-type "application/json")))

(defn text
  [_request data]
  (-> data
      response/ok
      (response/content-type "text/plain")))

(defn not-found
  [_request]
  (response/content-type
   (response/not-found "Not Found")
   "plain/text"))

(defn cors
  [request response]
  (case (:request-method request)
    :options (-> response
                 (response/content-type "text/plain; charset=utf-8")
                 (response/header "Access-Control-Allow-Origin" "*")
                 (response/header "Access-Control-Allow-Methods" "POST, PUT, GET, DELETE, OPTIONS")
                 (response/header "Access-Control-Allow-Headers" "Content-Type")
                 (response/header "Access-Control-Max-Age" "2592000"))
    :get (response/header response "Access-Control-Allow-Origin" "*")
    response))

(ns cmr.graph.rest.response
  (:require
   [cheshire.core :as json]
   [ring.util.http-response :as response]
   [taoensso.timbre :as log]))

(defn ok
  [_request & args]
  (response/ok args))

(defn json
  [_request data]
  (-> data
      json/generate-string
      response/ok
      (response/content-type "application/json")))

(defn text
  [_request data]
  (-> data
      response/ok
      (response/content-type "text/plain")))

(defn not-found
  [_request]
  (response/content-type
   (response/not-found "Not Found")
   "plain/text"))

(defn cors
  [request response]
  (case (:request-method request)
    :options (-> response
                 (response/content-type "text/plain; charset=utf-8")
                 (response/header "Access-Control-Allow-Origin" "*")
                 (response/header "Access-Control-Allow-Methods" "POST, PUT, GET, DELETE, OPTIONS")
                 (response/header "Access-Control-Allow-Headers" "Content-Type")
                 (response/header "Access-Control-Max-Age" "2592000"))
    :get (response/header response "Access-Control-Allow-Origin" "*")
    :post (response/header response "Access-Control-Allow-Origin" "*")
    response))

Set CORS header on POSTs

Set CORS header on POSTs


(ns circle.Init ;; capitalized for JRuby
  ;; (:require circle.swank)
  (:require circle.db)
  (:require circle.web)
  (:require circle.repl)
  (:require circle.logging)
  ;; (:require circle.backend.nodes
  ;;           circle.backend.project.rails
  ;;           circle.backend.project.circle)
  (:gen-class :name circle.Init :main true)
  )

(def init*
  (delay
   (try
     (circle.logging/init)
     ;; workaround for Heroku not liking us starting up swank
     (when (System/getenv "SWANK")
       (require 'circle.swank)
       (.invoke (ns-resolve 'circle.swank 'init)))
     (circle.db/init)
     (circle.web/init)
     (circle.repl/init)
     (println (java.util.Date.))
     true
     (catch Exception e
       (println "caught exception on startup:")
       (.printStackTrace e)
       (println "exiting")
       (System/exit 1)))))

(defn init
  "Start everything up. idempotent."
  []
  @init*)

(defn -main []
  (init))

(ns circle.Init ;; capitalized for JRuby
  ;; (:require circle.swank)
  (:require circle.db)
  (:require circle.web)
  (:require circle.repl)
  (:require circle.logging)
  ;; (:require circle.backend.nodes
  ;;           circle.backend.project.rails
  ;;           circle.backend.project.circle)
  (:gen-class :name circle.Init)
  )

(def init*
  (delay
   (try
     (circle.logging/init)
     ;; workaround for Heroku not liking us starting up swank
     (when (System/getenv "SWANK")
       (require 'circle.swank)
       (.invoke (ns-resolve 'circle.swank 'init)))
     (circle.db/init)
     (circle.web/init)
     (circle.repl/init)
     (println (java.util.Date.))
     true
     (catch Exception e
       (println "caught exception on startup:")
       (.printStackTrace e)
       (println "exiting")
       (System/exit 1)))))

(defn init
  "Start everything up. idempotent."
  []
  @init*)

(defn -main []
  (init))

Make uberjar work at the command line with the name circle.Init.


(defproject guangyin/guangyin "0.1.1-SNAPSHOT"
  :description "Clojure date and time library wrapping java.time"
  :url "https://github.com/juhovh/guangyin"
  :license {:name "MIT License"
            :url "http://opensource.org/licenses/MIT"
            :distribution :repo}
  :dependencies [[org.clojure/clojure "1.6.0"]]
  :min-lein-version "2.0.0"
  :source-paths ["src/clj"]
  :java-source-paths ["src/java"]
  :profiles {:dev {:plugins [[codox "0.8.11"]
                             [lein-cloverage "1.0.2"]]
                   :codox {:include [guangyin.core guangyin.format]}}})

(defproject guangyin/guangyin "0.1.1-SNAPSHOT"
  :description "Clojure date and time library wrapping java.time"
  :url "https://github.com/juhovh/guangyin"
  :license {:name "MIT License"
            :url "http://opensource.org/licenses/MIT"
            :distribution :repo}
  :dependencies [[org.clojure/clojure "1.6.0"]]
  :min-lein-version "2.0.0"
  :source-paths ["src/clj"]
  :java-source-paths ["src/java"]
  :javac-options ["-target" "1.8" "-source" "1.8"]
  :profiles {:dev {:plugins [[codox "0.8.11"]
                             [lein-cloverage "1.0.2"]]
                   :codox {:include [guangyin.core guangyin.format]}}})

Update source and target javac properties to 1.8.


(defproject breeze-quiescent "0.1.1-SNAPSHOT"
  :description "A minimal, functional ClojureScript wrapper for ReactJS"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/clojurescript "0.0-2173" :scope "provided"]
                 [com.facebook/react "0.9.0"]]
  :source-paths ["src"]

  ;; development concerns
  :profiles {:dev {:source-paths ["src" "examples/src"]
                   :resource-paths ["examples/resources"]
                   :plugins [[lein-cljsbuild "1.0.1"]]
                   :cljsbuild
                   {:builds
                    [{:source-paths ["src" "examples/src"]
                      :compiler
                      {:output-to "examples/resources/public/main.js"
                       :output-dir "examples/resources/public/build"
                       :optimizations :whitespace
                       :preamble ["react/react.min.js"]
                       :externs ["react/externs/react.js"]
                       :pretty-print true
                       :source-map
                       "examples/resources/public/main.js.map"
                       :closure-warnings {:non-standard-jsdoc :off}}}]}}})

(defproject breeze-quiescent "0.1.1-SNAPSHOT"
  :description "A minimal, functional ClojureScript wrapper for ReactJS"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/clojurescript "0.0-2173" :scope "provided"]
                 [com.facebook/react "0.9.0.1"]]
  :source-paths ["src"]

  ;; development concerns
  :profiles {:dev {:source-paths ["src" "examples/src"]
                   :resource-paths ["examples/resources"]
                   :plugins [[lein-cljsbuild "1.0.1"]]
                   :cljsbuild
                   {:builds
                    [{:source-paths ["src" "examples/src"]
                      :compiler
                      {:output-to "examples/resources/public/main.js"
                       :output-dir "examples/resources/public/build"
                       :optimizations :whitespace
                       :preamble ["react/react.min.js"]
                       :externs ["react/externs/react.js"]
                       :pretty-print true
                       :source-map
                       "examples/resources/public/main.js.map"
                       :closure-warnings {:non-standard-jsdoc :off}}}]}}})

Increase react version to 0.9.0.1 to fix missing article and aside externs.


(defproject statuses "1.0.0-SNAPSHOT"
  :description "Statuses app for innoQ"
  :url "https://github.com/innoq/statuses"
  :license {:name "Apache License, Version 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0"
            :distribution :repo
            :comments "A business-friendly OSS license"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [ring "1.3.2"]
                 [compojure "1.3.1"]
                 [clj-time "0.8.0"]
                 [org.clojure/data.json "0.2.5"]]
  :pedantic? :abort
  :plugins [[jonase/eastwood "0.2.0"]]
  :profiles {:dev {:dependencies [[ring-mock "0.1.5"]]}
             :uberjar {:aot [statuses.server]}}
  :main statuses.server
  :aliases {"lint" "eastwood"}
  :eastwood {:exclude-linters [:constant-test]})

(defproject statuses "1.0.0-SNAPSHOT"
  :description "Statuses app for innoQ"
  :url "https://github.com/innoq/statuses"
  :license {:name "Apache License, Version 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0"
            :distribution :repo
            :comments "A business-friendly OSS license"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [ring "1.3.2"]
                 [compojure "1.3.1"]
                 [clj-time "0.9.0"]
                 [org.clojure/data.json "0.2.5"]]
  :pedantic? :abort
  :plugins [[jonase/eastwood "0.2.0"]]
  :profiles {:dev {:dependencies [[ring-mock "0.1.5"]]}
             :uberjar {:aot [statuses.server]}}
  :main statuses.server
  :aliases {"lint" "eastwood"}
  :eastwood {:exclude-linters [:constant-test]})

Update clj-time from 0.8.0 to 0.9.0.

Update clj-time from 0.8.0 to 0.9.0.

Keep up to date with all dependencies.


(defproject cljs-workspace "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :plugins [[lein-cljsbuild "1.0.4-SNAPSHOT"]]

  :source-paths ["src/clj", "src/cljs"]

  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/clojurescript "0.0-2760"]
                 [http-kit "2.1.16"]
                 [compojure "1.1.5"]
                 [ring "1.3.1"]
				         [fogus/ring-edn "0.2.0"]
                 [om "0.8.0-rc1"]
                 [org.clojure/core.async "0.1.303.0-886421-alpha"]
                 [cljs-tooling "0.1.3"]]

  :cljsbuild {:builds [{:id "om-test"
                        :source-paths ["src/cljs"]
                        :compiler {
                                   :main main.core
                                   :output-to "resources/public/js/om-test.js"
                                   :output-dir "resources/public/js/"
                                   :optimizations :none
                                   :source-map "resources/public/js/om-test.js.map"}}]})

(defproject cljs-workspace "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :plugins [[lein-cljsbuild "1.0.4-SNAPSHOT"]]

  :source-paths ["src/clj", "src/cljs"]

  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/clojurescript "0.0-2760"]
                 [org.rksm/cloxp-com "0.1.3"]
                 [http-kit "2.1.19"]
                 [compojure/compojure "1.3.2"]
                 [ring "1.3.1"]
				         [fogus/ring-edn "0.2.0"]
                 [om "0.8.0-rc1"]
                 [org.clojure/core.async "0.1.303.0-886421-alpha"]
                 [cljs-tooling "0.1.3"]]

  :cljsbuild {:builds [{:id "om-test"
                        :source-paths ["src/cljs"]
                        :compiler {
                                   :main main.core
                                   :output-to "resources/public/js/om-test.js"
                                   :output-dir "resources/public/js/"
                                   :optimizations :none
                                   :source-map "resources/public/js/om-test.js.map"}}]})

Update deps for cloxp cljs integration

Update deps for cloxp cljs integration


(defproject playasophy/wonderdome "1.0.0-SNAPSHOT"
  :description "Control and rendering software for driving an LED strip art project with various visualizations."
  :url "https://github.com/playasophy/wonderdome"
  :license {:name "Public Domain"
            :url "http://unlicense.org/"}

  :native-path "target/native"
  :jvm-opts ^:replace ["-Djava.library.path=target/native/linux"]

  ; TODO: write some simple dev code to search for dot files in the doc folder and generate SVG graphs.
  ;:aliases {"sysgraph" ["dot" "-Tsvg" "<" "doc/system-processes.dot" ">" "target/system-processes.svg"]}

  ; TODO: host this on a static S3 website
  :repositories
  [["local" "file:///home/greg/projects/playasophy/wonderdome/lib/repo"]]

  :dependencies
  [[com.codeminders/hidapi "1.1"]
   [com.heroicrobot/pixelpusher "20130916"]
   [com.stuartsierra/component "0.2.1"]
   [org.clojure/clojure "1.6.0"]
   [org.clojure/core.async "0.1.303.0-886421-alpha"]]

  :hiera
  {:cluster-depth 4
   :vertical? false
   :ignore-ns #{com.stuartsierra quil}}

  :profiles
  {:dev
   {:source-paths ["dev"]
    :dependencies
    [[quil "2.1.0"]
     [org.clojure/tools.namespace "0.2.4"]]}})

(defproject playasophy/wonderdome "1.0.0-SNAPSHOT"
  :description "Control and rendering software for driving an LED strip art project with various visualizations."
  :url "https://github.com/playasophy/wonderdome"
  :license {:name "Public Domain"
            :url "http://unlicense.org/"}

  :native-path "target/native"
  :jvm-opts ^:replace ["-Djava.library.path=target/native/linux"]

  ; TODO: write some simple dev code to search for dot files in the doc folder and generate SVG graphs.
  ;:aliases {"sysgraph" ["dot" "-Tsvg" "<" "doc/system-processes.dot" ">" "target/system-processes.svg"]}

  :repositories
  [["mvxcvi" "http://mvxcvi.com/libs/repo"]]

  :dependencies
  [[com.codeminders/hidapi "1.1"]
   [com.heroicrobot/pixelpusher "20130916"]
   [com.stuartsierra/component "0.2.1"]
   [org.clojure/clojure "1.6.0"]
   [org.clojure/core.async "0.1.303.0-886421-alpha"]]

  :hiera
  {:cluster-depth 4
   :vertical? false
   :ignore-ns #{com.stuartsierra quil}}

  :profiles
  {:dev
   {:source-paths ["dev"]
    :dependencies
    [[quil "2.1.0"]
     [org.clojure/tools.namespace "0.2.4"]]}})

Switch to website-hosted MVXCVI repo.

Switch to website-hosted MVXCVI repo.


(defproject prismatic/fnhouse "0.1.2-SNAPSHOT"
  :description "Transform lightly-annotated functions into a full-fledged web service"
  :license {:name "Eclipse Public License - v 1.0"
            :url "http://www.eclipse.org/legal/epl-v10.html"
            :distribution :repo}
  :url "https://github.com/Prismatic/fnhouse"
  :dependencies [[prismatic/plumbing "0.3.3"]]
  :profiles {:dev {:dependencies [[org.clojure/clojure "1.5.1"]]
                   :warn-on-reflection true}
             :1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}}
  :aliases {"all" ["with-profile" "dev:dev,1.6"]}
  :lein-release {:deploy-via :shell
                 :shell ["lein" "deploy" "clojars"]})

(defproject prismatic/fnhouse "0.1.2-SNAPSHOT"
  :description "Transform lightly-annotated functions into a full-fledged web service"
  :license {:name "Eclipse Public License - v 1.0"
            :url "http://www.eclipse.org/legal/epl-v10.html"
            :distribution :repo}
  :url "https://github.com/Prismatic/fnhouse"
  :dependencies [[prismatic/plumbing "0.4.1"]]
  :profiles {:dev {:dependencies [[org.clojure/clojure "1.6.0"]]
                   :global-vars {*warn-on-reflection* true}}
             :1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]}
             :1.7 {:dependencies [[org.clojure/clojure "1.7.0-alpha6"]]}}
  :aliases {"all" ["with-profile" "dev:dev,1.5:dev,1.7"]}
  :lein-release {:deploy-via :shell
                 :shell ["lein" "deploy" "clojars"]})

Bump plumbing version and test on 1.7

Bump plumbing version and test on 1.7


(defproject statuses "1.0.0-SNAPSHOT"
  :description "Statuses app for innoQ"
  :url "https://github.com/innoq/statuses"
  :license {:name "Apache License, Version 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0"
            :distribution :repo
            :comments "A business-friendly OSS license"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [ring "1.3.2"]
                 [compojure "1.3.1"]
                 [clj-time "0.9.0"]
                 [org.clojure/data.json "0.2.5"]]
  :pedantic? :abort
  :plugins [[jonase/eastwood "0.2.0"]]
  :profiles {:dev {:dependencies [[ring-mock "0.1.5"]]}
             :uberjar {:aot [statuses.server]}}
  :main statuses.server
  :aliases {"lint" "eastwood"}
  :eastwood {:exclude-linters [:constant-test]})

(defproject statuses "1.0.0-SNAPSHOT"
  :description "Statuses app for innoQ"
  :url "https://github.com/innoq/statuses"
  :license {:name "Apache License, Version 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0"
            :distribution :repo
            :comments "A business-friendly OSS license"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [ring "1.3.2"]
                 [compojure "1.3.2"]
                 [clj-time "0.9.0"]
                 [org.clojure/data.json "0.2.5"]]
  :pedantic? :abort
  :plugins [[jonase/eastwood "0.2.0"]]
  :profiles {:dev {:dependencies [[ring-mock "0.1.5"]]}
             :uberjar {:aot [statuses.server]}}
  :main statuses.server
  :aliases {"lint" "eastwood"}
  :eastwood {:exclude-linters [:constant-test]})

Update compojure from 1.3.1 to 1.3.2.

Update compojure from 1.3.1 to 1.3.2.


(ns rp.util.number)

(defn nat-num?
  [x]
  (and (number? x)
       (not (neg? x))))

(defn longitude?
  [x]
  (and (number? x)
       (<= -180 x 180)))

(defn latitude?
  [x]
  (and (number? x)
       (<= -90 x 90)))

(defn within-bounding-box?
  [[lng1 lat1 lng2 lat2] [longitude latitude]]
  (and (<= lng1 longitude lng2)
       (<= lat1 latitude lat2)))

Add predicate for checking if coordinates are within a bounding box


(ns hacker-agent.utils)

(defn dissoc-in [data path]
  (let [prefix (butlast path)
        key (last path)]
    (if prefix
      (update-in data prefix dissoc key)
      (dissoc data key))))

(defn log-clj [o]
  (.log js/console (clj->js o)))

(defn domain [url]
  (let [re (new js/RegExp "^https?\\:\\/\\/(www\\.)?([^\\/:?#]+)(?:[\\/:?#]|$)")
        matches (.exec re url)]
    (and matches (get matches 2))))

(defn keys-in [m]
  (if (map? m)
    (mapcat (fn [[k v]]
              (let [sub (keys-in v)]
                (conj sub k)))
            m)
    []))

Add keys-in utility for getting all map keys


(do
  ;; Imports and aliases
  (clojure.core/use '[clojure.core])
  (require '[clojure.string :as str])
  (require '[clojure.pprint :as pp])
  (require '[clojure.math.numeric-tower :as math])

  ;; Convenience functions
  (defn codeblock [s & { type :type }] (str "```" type "\n" s "\n```"))

  (defn delete-self [] (alter-var-root #'k9.sandbox/*delete-self* (constantly true)))

  ;; Embed utilities
  (defn embed-create [title desc & fields]
    (let [builder (sx.blah.discord.util.EmbedBuilder.)]
      (do
        (when title (.withTitle       builder title))
        (when desc  (.withDescription builder desc))
        (doseq [[t d i] (partition 3 fields)] (.appendField builder t d i))
        builder)))

  (defn embed-stamp [embed] (do (.withTimestamp embed (java.time.LocalDateTime/ofInstant (java.time.Instant/now) (java.time.ZoneId/of "UTC"))) embed))

  ;; Simple embed function bindings
  (def embed-field (memfn appendField title desc inline))
  (def embed-color (memfn withColor r g b))
  (def embed-image (memfn withImage url))
  (def embed-thumb (memfn withThumbnail url))
  (def embed-url   (memfn withUrl url))
  (def embed-build (memfn build))
)

(do
  ;; Imports and aliases
  (clojure.core/use '[clojure.core])
  (require '[clojure.string :as str])
  (require '[clojure.pprint :as pp])
  (require '[clojure.math.numeric-tower :as math])

  ;; Convenience functions
  (defn codeblock [s & { type :type }] (str "```" type "\n" s "\n```"))

  (defn delete-self [] (alter-var-root #'k9.sandbox/*delete-self* (constantly true)))

  ;; Embed utilities
  (defn embed-create [title desc & fields]
    (let [builder (sx.blah.discord.util.EmbedBuilder.)]
      (do
        (when title (.withTitle       builder title))
        (when desc  (.withDescription builder desc))
        (doseq [[t d i] (partition 3 fields)] (.appendField builder t d i))
        builder)))

  (defn embed-stamp [embed] (do (.withTimestamp embed (java.time.Instant/now) ) embed))

  ;; Simple embed function bindings
  (def embed-field (memfn appendField title desc inline))
  (def embed-color (memfn withColor r g b))
  (def embed-image (memfn withImage url))
  (def embed-thumb (memfn withThumbnail url))
  (def embed-url   (memfn withUrl url))
  (def embed-build (memfn build))
)

Fix embed-stamp for new D4J methods

Fix embed-stamp for new D4J methods


(ns overtunes.songs.frere-jacques
  (:use [overtone.live])
  (:use [overtunes.core])
  (:use [overtunes.instruments.foo]))

(def frère-jacques [:C4 :D4 :E4 :C4])
(def dormez-vous [:E4 :F4 :G4 :rest])
(def sonnez-les-matines [:G4 :G4 :E4 :C4])
(def din-dan-don [:C4 :G3 :C4 :rest])

(def melody (concat
  frère-jacques frère-jacques
  dormez-vous dormez-vous
  sonnez-les-matines sonnez-les-matines
  din-dan-don din-dan-don))

(defn frere-jacques-round []
  (let [metro (metronome 120)]
    (play-melody melody foo metro)
    (play-melody melody foo (metronome-from metro 8))
    (play-melody melody foo (metronome-from metro 16))
    (play-melody melody foo (metronome-from metro 24))))

(ns overtunes.songs.frere-jacques
  (:use [overtone.live])
  (:use [overtunes.core])
  (:use [overtunes.instruments.foo]))

(def Frère-Jacques [:C4 :D4 :E4 :C4])
(def Dormez-vous? [:E4 :F4 :G4 :rest])
(def Sonnez-les-matines! [:G4 :G4 :E4 :C4])
(def Din-dan-don [:C4 :G3 :C4 :rest])

(def melody (concat
  Frère-Jacques Frère-Jacques
  Dormez-vous? Dormez-vous?
  Sonnez-les-matines! Sonnez-les-matines!
  Din-dan-don Din-dan-don))

(defn frere-jacques []
  (let [metro (metronome 120)]
    (play-melody melody foo metro)
    (play-melody melody foo (metronome-from metro 8))
    (play-melody melody foo (metronome-from metro 16))
    (play-melody melody foo (metronome-from metro 24))))

Use capitalised letters to make the music read more like the lyrics.


(ns obb-rules.game-mode
  (:require [obb-rules.board :as board]
            [obb-rules.game :as game]))

(defn final?
  "Checks if the game is finished"
  [game]
  (or
    (board/empty-board? game :p1)
    (board/empty-board? game :p2)))

(defn winner
  "Gets the winner of the given game"
  [game]
  (cond
    (board/empty-board? game :p1) :p2
    (board/empty-board? game :p2) :p1
    :else :none))

(defn- finalize
  "Marks a game as final"
  [game]
  (game/state game :final))

(defn process
  "Checks if a given game is finished and updates it's state.
   Returns the given game if not finished"
  [game]
  (if (final? game)
    (finalize game)
    game))

(ns obb-rules.game-mode
  (:require [obb-rules.board :as board]
            [obb-rules.game :as game]))

(defn final?
  "Checks if the game is finished"
  [game]
  (and
    (not (= game/state :deploy))
    (or
      (board/empty-board? game :p1)
      (board/empty-board? game :p2))))

(defn winner
  "Gets the winner of the given game"
  [game]
  (cond
    (board/empty-board? game :p1) :p2
    (board/empty-board? game :p2) :p1
    :else :none))

(defn- finalize
  "Marks a game as final"
  [game]
  (game/state game :final))

(defn process
  "Checks if a given game is finished and updates it's state.
   Returns the given game if not finished"
  [game]
  (if (final? game)
    (finalize game)
    game))

Make final if not in deploy state

Make final if not in deploy state


(defproject soy-clj "0.1.0-SNAPSHOT"
  :description "An idiomatic Clojure wrapper for Google's Closure templating system."
  :url "https://github.com/codahale/soy-clj"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.8.0-RC2"]
                 [org.clojure/core.cache "0.6.4"]
                 [com.google.template/soy "2015-04-10"]]
  :plugins [[codox "0.9.0"]])

(defproject soy-clj "0.1.0-SNAPSHOT"
  :description "An idiomatic Clojure wrapper for Google's Closure templating system."
  :url "https://github.com/codahale/soy-clj"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/core.cache "0.6.4"]
                 [com.google.template/soy "2015-04-10"]]
  :profiles {:dev {:dependencies [[org.clojure/clojure "1.8.0-RC2"]]}}
  :plugins [[codox "0.9.0"]])

Move Clojure dep to dev profile.

Move Clojure dep to dev profile.


(defproject stencil "0.2.0"
  :description "Mustache in Clojure"
  :dependencies [[clojure "1.3.0"]
                 [slingshot "0.8.0"]]
  :multi-deps {"1.2" [[org.clojure/clojure "1.2.1"]]
               "1.3" [[org.clojure/clojure "1.3.0"]]
               :all [[slingshot "0.8.0"]]}
  :dev-dependencies [[ritz "0.2.0"]
                     [org.clojure/data.json "0.1.1"]]
  :extra-files-to-clean ["test/spec"])

(defproject stencil "0.2.0"
  :description "Mustache in Clojure"
  :dependencies [[clojure "1.3.0"]
                 [slingshot "0.8.0"]]
  :multi-deps {"1.2" [[org.clojure/clojure "1.2.1"]]
               "1.3" [[org.clojure/clojure "1.3.0"]]
               "1.4" [[org.clojure/clojure "1.4.0-beta1"]]
               :all [[slingshot "0.8.0"]]}
  :dev-dependencies [[ritz "0.2.0"]
                     [org.clojure/data.json "0.1.1"]]
  :extra-files-to-clean ["test/spec"])

Add Clojure 1.4.0-beta1 to lein-multi deps.


(defproject reply "0.1.0-SNAPSHOT"
  :description "REPL-y: A fitter, happier, more productive REPL for Clojure."
  :dependencies [[org.clojure/clojure "1.3.0"]
                 [jline "2.6"]
                 [org.thnetos/cd-client "0.3.1" :exclusions [org.clojure/clojure]]
                 [clj-stacktrace "0.2.4"]
                 [clojure-complete "0.2.1" :exclusions [org.clojure/clojure]]
                 [org.clojure/tools.nrepl "0.2.0-beta1"]]
  :dev-dependencies [[midje "1.3-alpha4" :exclusions [org.clojure/clojure]]
                     [lein-midje "[1.0.0,)"]]
  :aot [reply.reader.jline.JlineInputReader]
  :source-path "src/clj"
  :java-source-path "src/java")

(defproject reply "0.1.0-alpha6"
  :description "REPL-y: A fitter, happier, more productive REPL for Clojure."
  :dependencies [[org.clojure/clojure "1.3.0"]
                 [jline "2.6"]
                 [org.thnetos/cd-client "0.3.1" :exclusions [org.clojure/clojure]]
                 [clj-stacktrace "0.2.4"]
                 [clojure-complete "0.2.1" :exclusions [org.clojure/clojure]]
                 [org.clojure/tools.nrepl "0.2.0-beta1"]]
  :dev-dependencies [[midje "1.3-alpha4" :exclusions [org.clojure/clojure]]
                     [lein-midje "[1.0.0,)"]]
  :aot [reply.reader.jline.JlineInputReader]
  :source-path "src/clj"
  :java-source-path "src/java")

Bump version for alpha6 release

Bump version for alpha6 release


(defproject naughtmq "0.0.1"
  :description "A native-embedding wrapper for jzmq"
  :url "https://github.com/gaverhae/naughtmq"
  :scm {:name "git"
        :url "https://github.com/gaverhae/naughtmq"}
  :signing {:gpg-key "gary.verhaegen@gmail.com"}
  :deploy-repositories [["clojars" {:creds :gpg}]]
  :pom-addition [:developers [:developer
                              [:name "Gary Verhaegen"]
                              [:url "https://github.com/gaverhae"]
                              [:email "gary.verhaegen@gmail.com"]
                              [:timezone "+1"]]]
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [com.taoensso/timbre "3.1.6"]
                 [org.zeromq/jzmq "2.2.2"]]
  :java-source-paths ["src"])

(defproject naughtmq "0.0.2-SNAPSHOT"
  :description "A native-embedding wrapper for jzmq"
  :url "https://github.com/gaverhae/naughtmq"
  :scm {:name "git"
        :url "https://github.com/gaverhae/naughtmq"}
  :signing {:gpg-key "gary.verhaegen@gmail.com"}
  :deploy-repositories [["clojars" {:creds :gpg}]]
  :pom-addition [:developers [:developer
                              [:name "Gary Verhaegen"]
                              [:url "https://github.com/gaverhae"]
                              [:email "gary.verhaegen@gmail.com"]
                              [:timezone "+1"]]]
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [com.taoensso/timbre "3.1.6"]
                 [org.zeromq/jzmq "2.2.2"]]
  :java-source-paths ["src"])

Prepare for next development iteration

Prepare for next development iteration


(ns reabledit.core
  (:require [reabledit.components :as components]
            [reabledit.keyboard :as keyboard]
            [reagent.core :as reagent]))

;;
;; Convenience API
;;

(defn update-row
  [data nth-row new-row]
  (let [[init tail] (split-at nth-row data)]
    (into [] (concat init [new-row] (rest tail)))))

;;
;; Main component
;;

(defn data-table
  [columns data row-change-fn]
  (let [state (reagent/atom {})
        element-id (gensym "reabledit-focusable")]
    (fn [columns data row-change-fn]
      [:div.reabledit
       {:id element-id
        :tabIndex 0
        :on-key-down #(keyboard/handle-key-down %
                                                columns
                                                data
                                                state
                                                row-change-fn
                                                element-id)}
       [:table
        [components/data-table-headers columns]
        [:tbody
         (for [[nth-row row-data] (map-indexed vector data)]
           ^{:key nth-row}
           [components/data-table-row columns data row-data nth-row state])]]])))

(ns reabledit.core
  (:require [reabledit.components :as components]
            [reabledit.keyboard :as keyboard]
            [reabledit.util :as util]
            [reagent.core :as reagent]))

;;
;; Convenience API
;;

(defn update-row
  [data nth-row new-row]
  (let [[init tail] (split-at nth-row data)]
    (into [] (concat init [new-row] (rest tail)))))

;;
;; Main component
;;

(defn data-table
  [columns data row-change-fn]
  (let [state (reagent/atom {})
        element-id (gensym "reabledit-focusable")]
    (fn [columns data row-change-fn]
      [:div.reabledit
       {:id element-id
        :tabIndex 0
        :on-key-down #(keyboard/handle-key-down %
                                                columns
                                                data
                                                state
                                                row-change-fn
                                                element-id)
        :on-double-click #(util/enable-edit! columns data state)}
       [:table
        [components/data-table-headers columns]
        [:tbody
         (for [[nth-row row-data] (map-indexed vector data)]
           ^{:key nth-row}
           [components/data-table-row columns data row-data nth-row state])]]])))

Implement moving to edit state upon double click


(ns clj_record.core
  (:require [clojure.contrib.sql :as sql]))

(defn table-name [model-name]
  (if (keyword? model-name) (.getName model-name) model-name))

(defn find-record [model-name id]
  (sql/with-connection db
    (sql/with-results rows (format "select * from %s where id = %s" (table-name model-name) id)
      (merge {} (first rows)))))

(defn create [model-name attributes]
  (sql/with-connection db
    (let
      [key-vector (keys attributes)
       val-vector (map attributes key-vector)
       id (sql/transaction
            (sql/insert-values (table-name model-name) key-vector val-vector)
            (sql/with-results rows "VALUES IDENTITY_VAL_LOCAL()" (:1 (first rows))))]
      (find-record model-name id))))

(defmacro setup-model [model-name]
  (let [find-record-fn-name 'find-record
        create-fn-name 'create]
    `[(defn ~find-record-fn-name [id#]
        (find-record ~model-name id#))
      (defn ~create-fn-name [attributes#]
        (create ~model-name attributes#))]))

(ns clj_record.core
  (:require [clojure.contrib.sql :as sql]))

(defn table-name [model-name]
  (if (keyword? model-name) (.getName model-name) model-name))

(defn find-record [model-name id]
  (sql/with-connection db
    (sql/with-results rows (format "select * from %s where id = %s" (table-name model-name) id)
      (merge {} (first rows)))))

(defn create [model-name attributes]
  (sql/with-connection db
    (let
      [key-vector (keys attributes)
       val-vector (map attributes key-vector)
       id (sql/transaction
            (sql/insert-values (table-name model-name) key-vector val-vector)
            (sql/with-results rows "VALUES IDENTITY_VAL_LOCAL()" (:1 (first rows))))]
      (find-record model-name id))))

(defmacro setup-model [model-name]
  `[(defn ~'find-record [id#]
      (find-record ~model-name id#))
    (defn ~'create [attributes#]
      (create ~model-name attributes#))])

Remove the let hack by inlining it exactly, which is the idiom. Somehow it didn't occur to me to try that.


(ns useful.amalloy.debug)

(defmacro ?
  "A useful debugging tool when you can't figure out what's going on:
  wrap a form with and-print, and the form will be printed alongside
  its result. The result will still be passed along."
  [val]
  `(let [x# ~val]
     (prn '~val '~'is x#)
     x#))

(ns useful.amalloy.debug)

(defmacro ?
  "A useful debugging tool when you can't figure out what's going on:
  wrap a form with ?, and the form will be printed alongside
  its result. The result will still be passed along."
  [val]
  `(let [x# ~val]
     (prn '~val '~'is x#)
     x#))

Fix that damn docstring AGAIN

Fix that damn docstring AGAIN


;; Example of using clj-chrome-devtools with babashka
;;
;; Make a .classpath
;; $ clj -A:bb -Spath > .classpath
;;
;; Start Chrome in the background:
;; /some/chrome-binary --remote-debugging-port=9222 --headless &
;;
;; Run with:
;; $ bb --classpath $(cat .classpath) bb.clj

(require '[clj-chrome-devtools.core :as core]
         '[clj-chrome-devtools.automation :as auto])

(println "Printing to bb.pdf")
(def a (auto/create-automation (core/connect)))
(auto/to a "https://babashka.org")
(auto/print-pdf a "bb.pdf"
                {:print-background true
                 :paper-width 8.3
                 :paper-height 11.7})

;; Example of using clj-chrome-devtools with babashka
;;
;; Start Chrome in the background:
;; /some/chrome-binary --remote-debugging-port=9222 --headless &
;;
;; Run with:
;; $ bb bb.clj

(require '[babashka.deps :as deps])
(deps/add-deps
 '{:deps {tatut/devtools {:git/url "https://github.com/tatut/clj-chrome-devtools"
                          :git/sha "cc96255433ca406aaba8bcee17d0d0b3b16dc423"}
          org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
                                   :git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}}})

(require '[clj-chrome-devtools.core :as core]
         '[clj-chrome-devtools.automation :as auto])

(println "Printing to bb.pdf")
(def a (auto/create-automation (core/connect)))
(auto/to a "https://babashka.org")
(auto/print-pdf a "bb.pdf"
                {:print-background true
                 :paper-width 8.3
                 :paper-height 11.7})

Use babashka.deps instead of creating a separate .classpath file


(ns org.zalando.stups.friboo.system.cron-test
  (:require [org.zalando.stups.friboo.system.cron :refer :all]
            [clojure.test :refer :all]
            [overtone.at-at :as at]
            [com.stuartsierra.component :as component]))

(def-cron-component TestCron [state]
  (at/at (at/now) (job deliver state 42) pool))

(deftest test-cron-component-lifecycle
  ;; Here we make sure that the component is started and stopped properly.
  (let [state (promise)
        cron-component (map->TestCron {:state state})]
    (-> cron-component
        component/start
        component/stop
        component/stop) ; stopping twice shouldn't break anything
    (is (= 42 (deref state 500 :not-delivered)))))

(ns org.zalando.stups.friboo.system.cron-test
  (:require [org.zalando.stups.friboo.system.cron :refer :all]
            [clojure.test :refer :all]
            [overtone.at-at :as at]
            [com.stuartsierra.component :as component]))

(def-cron-component TestCron [state]
  (at/at (at/now) (job deliver state 42) pool))

(deftest test-cron-component-lifecycle
  ;; Here we make sure that the component is started and stopped properly.
  (let [state (promise)
        cron-component (component/start (map->TestCron {:state state}))]
    (is (= 42 (deref state 500 :not-delivered)))
    (-> cron-component
        component/stop
        component/stop))) ; stopping twice shouldn't break anything

Fix race condition in unit test

Fix race condition in unit test

Multithreading is tricky... :/