(ns circle.init
  ;; (: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)
  )

(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
  (:require circle.swank)
  (:require circle.db)
  (:require circle.web)
  (:require circle.repl)
  (:require circle.logging))

(def init*
  (delay
   (try
     (circle.logging/init)
     (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))

Remove the heroku hack for swank, start swank unconditionally.


(defproject gov.nasa.earthdata/cmr-site-templates "0.1.0-SNAPSHOT"
  :description "Selmer templates for CMR documentation, directory pages, and various static web content"
  :url "https://github.com/nasa/Common-Metadata-Repository/site-templates"
  :license {
    :name "Apache License, Version 2.0"
    :url "http://www.apache.org/licenses/LICENSE-2.0"}
  :dependencies [
    [org.clojure/clojure "1.8.0"]]
  :profiles {
    :test {
      :plugins [
        [lein-shell "0.5.0"]
        [test2junit "1.4.0"]]}}
  :aliases {
    ;; The following aliases are needed for the CMR build process.
    "generate-static" ["with-profile" "+test" "shell" "echo" "NO OP"]
    "test-out" ["with-profile" "+test" "test2junit"]})

(defproject gov.nasa.earthdata/cmr-site-templates "0.1.0-SNAPSHOT"
  :description "Selmer templates for CMR documentation, directory pages, and various static web content"
  :url "https://github.com/nasa/Common-Metadata-Repository/site-templates"
  :license {
    :name "Apache License, Version 2.0"
    :url "http://www.apache.org/licenses/LICENSE-2.0"}
  :dependencies [
    [org.clojure/clojure "1.10.0"]]
  :profiles {
    :test {
      :plugins [
        [lein-shell "0.5.0"]
        [test2junit "1.4.0"]]}}
  :aliases {
    ;; The following aliases are needed for the CMR build process.
    "generate-static" ["with-profile" "+test" "shell" "echo" "NO OP"]
    "test-out" ["with-profile" "+test" "test2junit"]})

Update site templates to Clojure 1.10.

CMR-5389: Update site templates to Clojure 1.10.


(ns clstreams.testutil.mockito
  (:import org.mockito.Mockito))

(defn mock [cls] (Mockito/mock cls))

(defn mock-fn [] (mock clojure.lang.IFn))

(defmacro return-> [mock-obj-expr method-invocation-form return-value-expr]
  `(let [mock-obj# ~mock-obj-expr]
     (-> (Mockito/doReturn ~return-value-expr)
         (.when mock-obj#)
         ~method-invocation-form)
     mock-obj#))

(defmacro on-call [mock-fn-expr parameter-expr-list return-value-expr]
  `(return-> ~mock-fn-expr (.invoke ~@parameter-expr-list) ~return-value-expr))

(defmacro verify->
  ([mock-obj-expr method-invocation-form]
   `(verify-> ~mock-obj-expr ~method-invocation-form (Mockito/times 1)))
  ([mock-obj-expr method-invocation-form counting-predicate-expr]
   `(-> ~mock-obj-expr (Mockito/verify ~counting-predicate-expr) ~method-invocation-form)))

(defmacro verify-fn
  ([mock-fn-expr parameter-expr-list]
   `(verify-> ~mock-fn-expr (.invoke ~@parameter-expr-list)))
  ([mock-fn-expr parameter-expr-list counting-predicate-expr]
   `(verify-> ~mock-fn-expr (.invoke ~@parameter-expr-list) ~counting-predicate-expr)))

(defn times [n] (Mockito/times n))
(defn at-least-once [] (Mockito/atLeastOnce))
(defn at-least [n] (Mockito/atLeast n))
(defn at-most [n] (Mockito/atMost n))
(defn never [] (Mockito/never))

Add verify functions to Mockito wrapper

Add verify functions to Mockito wrapper


(ns flambo.accumulator-test
  (:use midje.sweet))

(facts
 "about accumulators"
 (future-fact "some tests"))

(ns flambo.accumulator-test
  (:use midje.sweet)
  (:require [flambo.accumulator :as a]
            [flambo.conf :as conf]
            [flambo.api :as f]))

(facts
 "about accumulators"
  (let [conf (-> (conf/spark-conf)
                 (conf/master "local")
                 (conf/app-name "accumulator-test"))]
    (f/with-context c conf
      (facts "about basic accumulation"
        (let [acc (a/accumulator c 0)
              named-acc (a/accumulator c 0 "my-acc")
              rdd (f/parallelize c (range 21))]
          (fact "acc should be 210"
            (f/foreach rdd (f/fn [x] (a/add acc x)))
            (a/value acc) => 210)
          (fact "named-acc should be 210 and have a name"
            (f/foreach rdd (f/fn [x] (a/add named-acc x)))
            (a/value named-acc) => 210
            (a/name named-acc) => "my-acc"))))))

Implement basic tests for accumulator api


(ns leiningen.ring.server
  (:use leiningen.core.eval))

(defn load-namespaces
  "Create require forms for each of the supplied symbols. This exists because
  Clojure cannot load and use a new namespace in the same eval form."
  [& syms]
  `(require
    ~@(for [s syms :when s]
        `'~(if-let [ns (namespace s)]
             (symbol ns)
             s))))

(defn server-task
  "Shared logic for server and server-headless tasks."
  [project options]
  (let [project (update-in project [:ring] merge options)]
    (eval-in-project
     (update-in project [:dependencies] conj ['ring-server "0.2.1"])
     `(ring.server.leiningen/serve '~project)
     (load-namespaces
      'ring.server.leiningen
      (-> project :ring :handler)
      (-> project :ring :init)
      (-> project :ring :destroy)))))

(defn server
  "Start a Ring server and open a browser."
  ([project]
     (server-task project {}))
  ([project port]
     (server-task project {:port port})))

(ns leiningen.ring.server)

(defn load-namespaces
  "Create require forms for each of the supplied symbols. This exists because
  Clojure cannot load and use a new namespace in the same eval form."
  [& syms]
  `(require
    ~@(for [s syms :when s]
        `'~(if-let [ns (namespace s)]
             (symbol ns)
             s))))

(defn eval-in-project
  "Support eval-in-project in both Leiningen 1.x and 2.x."
  [project form init]
  (let [[eip two?] (or (try (require 'leiningen.core.eval)
                            [(resolve 'leiningen.core.eval/eval-in-project)
                             true]
                            (catch java.io.FileNotFoundException _))
                       (try (require 'leiningen.compile)
                            [(resolve 'leiningen.compile/eval-in-project)]
                            (catch java.io.FileNotFoundException _)))]
    (if two?
      (eip project form init)
      (eip project form nil nil init))))

(defn server-task
  "Shared logic for server and server-headless tasks."
  [project options]
  (let [project (update-in project [:ring] merge options)]
    (eval-in-project
     (update-in project [:dependencies] conj ['ring-server "0.2.1"])
     `(ring.server.leiningen/serve '~project)
     (load-namespaces
      'ring.server.leiningen
      (-> project :ring :handler)
      (-> project :ring :init)
      (-> project :ring :destroy)))))

(defn server
  "Start a Ring server and open a browser."
  ([project]
     (server-task project {}))
  ([project port]
     (server-task project {:port port})))

Add backwards-compatibility with Leiningen 1.x.


(ns cljam.io.sequence-bench
  (:require [libra.bench :refer :all]
            [libra.criterium :as c]
            [cljam.test-common :as tcommon]
            [cljam.io.sequence :as cseq]))

(defbench read-all-sequences-test
  (are [f opts] (c/quick-bench (with-open [rdr (cseq/reader f)]
                                 (dorun (cseq/read-all-sequences rdr opts))))
    tcommon/medium-fa-file {}
    tcommon/medium-fa-file {:mask? true}
    tcommon/medium-twobit-file {}
    tcommon/medium-twobit-file {:mask? true}))

(defbench read-sequence-once-test
  (are [f opts]
      (let [region {:chr "chr7",
                    :start 10000,
                    :end 45000}]
        (c/quick-bench
         (with-open [rdr (cseq/reader f)]
           (cseq/read-sequence rdr region opts))))
    tcommon/medium-fa-file {}
    tcommon/medium-fa-file {:mask? true}
    tcommon/medium-twobit-file {}
    tcommon/medium-twobit-file {:mask? true}))

(defbench read-sequence-test
  (are [f opts]
      (let [region {:chr "chr7",
                    :start 10000,
                    :end 45000}]
        (with-open [rdr (cseq/reader f)]
          ;; warm up
          (cseq/read-sequence rdr region opts)
          (c/quick-bench
           (cseq/read-sequence rdr region opts))))
    tcommon/medium-fa-file {}
    tcommon/medium-fa-file {:mask? true}
    tcommon/medium-twobit-file {}
    tcommon/medium-twobit-file {:mask? true}))

Add benchmarking scripts for sequence readers


(ns {{project-ns}}.styles
  (:require [garden-reloader.def :refer [defstyles]]))

(defstyles style
  [:h1 {:text-decoration "underline"}])

(ns {{project-ns}}.styles
  (:require [garden-watcher.def :refer [defstyles]]))

(defstyles style
  [:h1 {:text-decoration "underline"}])

Use correct namespace name for garden-watcher


(ns test-nom-nom-nom
  (:use [nom.nom.nom]
        [clojure.test]))

(defn f [x]
  (.list x))

(deftest should-use-1.1.0-SNAPSHOT
  (is (= "1.1.0-master-SNAPSHOT" (clojure-version)))
  (f (java.io.File. "/tmp")))

(ns test-nom-nom-nom
  (:use [nom.nom.nom]
        [clojure.test]))

(defn f [x]
  (.list x))

(deftest should-use-1.1.0
  (is (= "1.1.0" (clojure-version)))
  (f (java.io.File. "/tmp")))

Remove clojure snapshot dep from test project.


(ns advent-2017.day-17)

(def input 345)

(defn spin [step [current-pos value buffer]]
  (let [new-pos (inc (mod (+ current-pos step) value))]
    [new-pos (inc value) (-> (subvec buffer 0 new-pos)
                           (into [value])
                           (into (subvec buffer new-pos)))]))

(defn part-1 []
  (let [[current-pos _ buffer] (nth (iterate (partial spin input) [0 1 [0]]) 2017)]
    (buffer (inc current-pos))))

(defn spin' [step [current-pos value after-zero]]
  (let [new-pos (inc (mod (+ current-pos step) value))]
    [new-pos (inc value) (if (== 1 new-pos)
                           value
                           after-zero)]))

(defn part-2 []
  (last (nth (iterate (partial spin' input) [0 1 nil]) 50000000)))

(ns advent-2017.day-17)

(def input 345)

(defn spin [step [current-pos value buffer]]
  (let [new-pos (inc (mod (+ current-pos step) value))]
    [new-pos (inc value) (-> (subvec buffer 0 new-pos)
                           (into [value])
                           (into (subvec buffer new-pos)))]))

(defn part-1 []
  (let [[current-pos _ buffer] (nth (iterate (partial spin input) [0 1 [0]]) 2017)]
    (buffer (inc current-pos))))

(defn part-2 []
  (loop [current-pos 0 value 1 after-zero nil]
    (if (== (dec value) 50000000)
      after-zero
      (let [new-pos (inc (mod (+ current-pos input) value))]
        (recur new-pos (inc value) (if (== 1 new-pos)
                                     value
                                     after-zero))))))

Switch to loop / recur for part 2

Switch to loop / recur for part 2

ClojureScript doesn’t have locals clearing
and memory usage can affect perf


(ns clopack-native.core)

(require '[net.n01se.clojure-jna :as jna])

(defn foo
  "I don't do a whole lot."
  [x]
  (println x "Hello, World!"))

(ns clopack-native.core)

(require '[net.n01se.clojure-jna :as jna])

; Refer to 'clopack_native' as 'cn'.
(jna/to-ns cn clopack_native)

(defn create-ctx [interface]
  "Creates a new packet context with the given interface.
   Returns a packet context on success, nil on errors."
  (let [handle  jna/invoke Integer cn/dev_open interface
        buf-len jna/invoke Integer cn/dev_buf_len]
    (when-not (= handle -1)
      {:handle  handle
       :buf-len buf-len})))

(defn read-frame [ctx]
  "Reads a data frame as from a packet context.
   Returns a byte-array on success, nil otherwise"
  (let [handle    (:handle ctx)
        buf-len   (:buf-len ctx)
        buf       (byte-array buf-len)
        num-read  (jna/invoke Integer cn/dev_read handle buf buf-len)]
    (when-not (= num-read -1)
      (take num-read buf))))

(defn write-frame [ctx buf]
  "Writes the given byte-array as a data frame through a packet context.
   Returns the number of bytes written on success, nil otherwise."
  (let [handle      (:handle ctx)
        buf-len     (count buf)
        num-written (jna/invoke Integer cn/dev_write handle buf buf-len)]
    (when-not (= num-written -1)
      num-written)))

(defn destroy-ctx [ctx]
  "Destroys a packet context."
  (jna/invoke Integer cn/dev_close (:handle ctx))
  nil)

Define wrapper routines to access native C code


(ns {{name}}.test-common
  (:require [cheshire.core :as json]
            [clojure.string :as str]
            [environ.core :refer [env]]))

(defn url+ [& suffix]
  (apply str (format (env :service-url) (env :service-port)) suffix))

(defn json-body
  "Reads the body of the request as json and parses it into a map with keywords.

   Fails pre-condition if content type is not application/json."
  [resp]
  {:pre [(re-matches #"application/(.+)?json.+" (get-in resp [:headers "content-type"]))]}
  (json/parse-string (:body resp) true))

(ns {{name}}.test-common
  (:require [cheshire.core :as json]
            [clojure.string :as str]
            [environ.core :refer [env]]))

(defn url+ [& suffix]
  (apply str (format (env :service-url) (env :service-port)) suffix))

(defn json-body
  "Reads the body of the request as json and parses it into a map with keywords.

   Fails pre-condition if content type is not application/json."
  [resp]
  {:pre [(re-matches #"application/(.+\+)?json.*" (get-in resp [:headers "content-type"]))]}
  (json/parse-string (:body resp) true))

Improve validation of content type in json-body

Custom MIME types should end with +json.
Characters following json MIME type should be optional.


(ns ^:figwheel-always instantetymonline.client
    (:require [reagent.core :as r]
              [instantetymonline.dict :refer [dict]]))

(enable-console-print!)

(defn etym-lookup []
  (let [local (r/atom {:word ""})]   ;; not included in render
    (fn []                           ;; render from here
      (let [word (get @local :word)]
        [:div.center
         [:form
          [:input.h2 {:id "etym"
                   :type "text"
                   :value word
                   :on-change (fn [e]
                                (reset! local {:word (-> e .-target .-value)}))}]]
         [:div [:p (get dict word)]]]))))

(defn main-component []
  [:div
   [:h1.center "Etymologically delicious"]
   [etym-lookup]])

(r/render-component [main-component]
  (. js/document (getElementById "app")))

(ns ^:figwheel-always instantetymonline.client
    (:require [reagent.core :as r]
              [instantetymonline.dict :refer [dict]]))

(enable-console-print!)

(defn etym-lookup []
  (let [local (r/atom {:word ""})]   ;; not included in render
    (fn []                           ;; render from here
      (let [word (get @local :word)]
        [:div
         [:form
          [:input.h2
           {:id "etym"
            :type "text"
            :value word
            :on-change (fn [e] (reset! local {:word (-> e .-target .-value)}))}]]
         [:br]
         [:p {:style {"max-width" "35em"}} (get dict word)]]))))

(defn main-component []
  [:div.p1
   [:h1 "Etym Deli"]
   [etym-lookup]])

(r/render-component [main-component]
  (. js/document (getElementById "app")))

Make design a bit more readable

Make design a bit more readable


(ns overtone-workspace.layers.lines-layer
  (:require [quil.core :as q])
  (:use [quil-layer.layer]))

(def num-of-lines 5)

(defn- setup [] {})
(defn- update-state [state] {})

(defn- draw-state [state]
  (let [r (/ (q/width) num-of-lines)
        rr (- r)]
    (q/smooth)

    (q/color-mode :rgb)
    (q/background 200)
    (q/fill 220)
    (q/stroke 220)

    (dorun
      (for [i (range 0 num-of-lines)]
        (let [x (+ (* i (/ (q/width) num-of-lines)) (q/random rr r))
            y 2
            x2 (+ (* i (/ (q/width) num-of-lines)) (q/random rr r))
            y2 (- (q/height) 2)]
          (q/stroke-weight r)
          (q/line x y x2 y2))
      )))
  )

(defrecord LinesLayer [state]
  Layer
  (setup-layer-state [this]
                     (setup))
  (update-layer-state [this state]
                      (update-state state))
  (draw-layer-state [this state]
                    (draw-state state)))

(ns overtone-workspace.layers.lines-layer
  (:require [quil.core :as q])
  (:use [quil-layer.layer]))

(def num-of-lines 5)

(defn- setup [] {})
(defn- update-state [state] {})

(defn- draw-state [state]
  (let [r (/ (q/width) num-of-lines)]
    (q/smooth)

    (q/no-stroke)
    (q/color-mode :hsb)
    (q/fill (.backgroundColor (q/current-graphics)) 100)
    (q/rect 0 0 (q/width) (q/height))

    (q/color-mode :rgb)
;    (q/background 200)

    (q/fill 220)
    (q/stroke 220)
    (q/stroke-weight r)

    (dorun
      (for [i (range 0 num-of-lines)]
        (let [top 2
              x (+ (* i (/ (q/width) num-of-lines)) (q/random (- r) r))
              y top
              x2 (+ (* i (/ (q/width) num-of-lines)) (q/random (- r) r))
              y2 (- (q/height) top)]
          (q/line x y x2 y2))
      )))
  )

(defrecord LinesLayer [state]
  Layer
  (setup-layer-state [this]
                     (setup))
  (update-layer-state [this state]
                      (update-state state))
  (draw-layer-state [this state]
                    (draw-state state)))

Change not to use q/background

Change not to use q/background


(ns icecap.schema-test
  (:require [icecap.schema :refer :all]
            [clojure.test :refer :all]
            [schema.core :as s]))

(def simple-http-action {:target "http://example.test"})
(def simple-https-action {:target "https://example.test"})
(def simple-ftp-action {:target "ftp://example.test"})

(deftest PlanTests
  (testing "Correct plans validate"
    (are [example] (s/validate Plan example)
         simple-http-action
         simple-https-action
         #{simple-http-action simple-https-action}))
  (testing "Empty plans don't validate"
    (are [example reason] (= (pr-str (s/check Plan example))
                             (pr-str reason))
         [] '(not ("collection of one or more plans" []))
         #{} '(not ("collection of one or more plans" #{}))))
  (testing "Plans with empty in them don't validate"
    (are [example reason] (= (pr-str (s/check Plan example))
                             (pr-str reason))
      [#{} simple-http-action] ['(not ("collection of one or more plans" #{})) nil]))
  (testing "plans with unknown/unsupported schemes don't validate"
    ;; Comparing string representations isn't great, but it's the best
    ;; easily available tool until maybe one day cddr/integrity's
    ;; humanize function is on Clojars + can humanize these errors :-)
    (are [example reason] (= (pr-str (s/check Plan example))
                             (pr-str reason))
         simple-ftp-action {:target '(not ("supported-scheme?" "ftp://example.test"))})))

(ns icecap.schema-test
  (:require [icecap.schema :refer :all]
            [clojure.test :refer :all]
            [schema.core :as s]))

(def simple-http-action {:target "http://example.test"})
(def simple-https-action {:target "https://example.test"})
(def simple-ftp-action {:target "ftp://example.test"})

(deftest PlanTests
  (testing "Correct plans validate"
    (are [example] (s/validate Plan example)
         simple-http-action
         simple-https-action
         #{simple-http-action simple-https-action}))
  (testing "Empty plans don't validate"
    (are [example reason] (= (pr-str (s/check Plan example))
                             (pr-str reason))
         [] '(not ("collection of one or more plans" []))
         #{} '(not ("collection of one or more plans" #{}))))
  (testing "Plans with empty in them don't validate"
    (are [example reason] (= (pr-str (s/check Plan example))
                             (pr-str reason))
      [#{} simple-http-action] ['(not ("collection of one or more plans" #{})) nil]))
  (testing "plans with unknown/unsupported schemes don't validate"))
(are [example reason] (= (pr-str (s/check Plan example))
                         (pr-str reason))
     simple-ftp-action {:target '(not ("supported-scheme?" "ftp://example.test"))})

Replace scary comment with issue

Replace scary comment with issue

Refs #2.


(ns onyx.log.full-test
  (:require [clojure.core.async :refer [chan >!! <!! close!]]
            [com.stuartsierra.component :as component]
            [onyx.system :refer [onyx-development-env]]
            [onyx.log.entry :refer [create-log-entry]]
            [onyx.extensions :as extensions]
            [onyx.api :as api]
            [midje.sweet :refer :all]
            [zookeeper :as zk]))

(def onyx-id (java.util.UUID/randomUUID))

(def config (read-string (slurp (clojure.java.io/resource "test-config.edn"))))

(def dev (onyx-development-env onyx-id (:env config)))

(def env (component/start dev))

(def peer-opts
  {:inbox-capacity 100
   :outbox-capacity 100})

(def v-peers (onyx.api/start-peers! onyx-id 10 (:peer config) peer-opts))

#_(doseq [v-peer v-peers]
  (try
    ((:shutdown-fn v-peer))
    (catch Exception e (prn e))))

;;(component/stop env)

(ns onyx.log.full-test
  (:require [clojure.core.async :refer [chan >!! <!! close!]]
            [com.stuartsierra.component :as component]
            [onyx.system :refer [onyx-development-env]]
            [onyx.log.entry :refer [create-log-entry]]
            [onyx.extensions :as extensions]
            [onyx.api :as api]
            [midje.sweet :refer :all]
            [zookeeper :as zk]))

(def onyx-id (java.util.UUID/randomUUID))

(def config (read-string (slurp (clojure.java.io/resource "test-config.edn"))))

(def dev (onyx-development-env onyx-id (:env config)))

(def env (component/start dev))

(def peer-opts
  {:inbox-capacity 100
   :outbox-capacity 100})

(def n-peers 50)

(def v-peers (onyx.api/start-peers! onyx-id n-peers (:peer config) peer-opts))

(def ch (chan n-peers))

(extensions/subscribe-to-log (:log env) 0 ch)

(def replica
  (loop [replica {}]
    (let [position (<!! ch)
          entry (extensions/read-log-entry (:log env) position)
          new-replica (extensions/apply-log-entry entry replica)]
      (if (< (count (:pairs new-replica)) n-peers)
        (recur new-replica)
        new-replica))))

(fact (:prepared replica) => {})
(fact (:accepted replica) => {})
(fact (count (:peers replica)) => n-peers)

(doseq [v-peer v-peers]
  (try
    ((:shutdown-fn v-peer))
    (catch Exception e (prn e))))

(component/stop env)

Test for converging 50 peers into the cluster.


(ns cortex.optimize.functions
  (:refer-clojure :exclude [+ - * /])
  (:require [clojure.core.matrix :as m]
            [clojure.core.matrix.operators :refer [+ - * /]]
            [cortex.optimize.protocols :as P]))

(extend-protocol P/Function
  clojure.lang.IPersistentMap
  (value [this params] ((:value this) params))
  (gradient [this params] ((:gradient this) params)))

(def cross-paraboloid
  "Depending on the number of args passed to it, generates
  functions of the form:

  f(x, y) = (x + y)² + (y + x)²
  f(x, y, z) = (x + y)² + (y + z)² + (z + x)²
  f(x, y, z, w) = (x + y)² + (y + z)² + (z + w)² + (w + x)²"
  {:value (fn [args]
            (->> args
              vec
              cycle
              (take (inc (m/ecount args)))
              (partition 2 1)
              (map (partial apply +))
              (map m/square)
              (apply +)))
   :gradient (fn [args]
               (->> args
                 vec
                 cycle
                 (drop (dec (m/ecount args)))
                 (take (+ 3 (dec (m/ecount args))))
                 (partition 3 1)
                 (map (partial map * [2 4 2]))
                 (map (partial apply +))
                 (m/array :vectorz)))})

(ns cortex.optimize.functions
  (:refer-clojure :exclude [+ - * /])
  (:require [clojure.core.matrix :as m]
            [clojure.core.matrix.operators :refer [+ - * /]]
            [cortex.optimize.protocols :as P]))

(extend-protocol P/Function
  clojure.lang.IPersistentMap
  (value [this params] ((:value this) params))
  (gradient [this params] ((:gradient this) params)))

(def cross-paraboloid
  "Depending on the length of the parameter vector, generates
  functions of the form:

  f(x, y) = (x + y)² + (y + x)²
  f(x, y, z) = (x + y)² + (y + z)² + (z + x)²
  f(x, y, z, w) = (x + y)² + (y + z)² + (z + w)² + (w + x)²"
  {:value (fn [params]
            (->> params
              vec
              cycle
              (take (inc (m/ecount params)))
              (partition 2 1)
              (map (partial apply +))
              (map m/square)
              (apply +)))
   :gradient (fn [params]
               (->> params
                 vec
                 cycle
                 (drop (dec (m/ecount params)))
                 (take (+ 3 (dec (m/ecount params))))
                 (partition 3 1)
                 (map (partial map * [2 4 2]))
                 (map (partial apply +))
                 (m/array :vectorz)))})

Update nomenclature in cross-paraboloid Function


(ns discuss.components.sidebar
  "Controlling the sidebar."
  (:require [om.core :as om]
            [om.dom :as dom]
            [discuss.utils.common :as lib]
            [discuss.utils.views :as vlib]))

(def id (lib/prefix-name "sidebar"))

(defn toggle
  "Toggle visibility of sidebar."
  ([]
   (let [sidebar-dom (.getElementById js/document id)
         main-wrapper (.getElementById js/document "main-wrapper")]
     (lib/toggle-class sidebar-dom "active")
     (lib/toggle-class main-wrapper "active")))
  ([bool]
   (let [sidebar-dom (.getElementById js/document id)
         main-wrapper (.getElementById js/document "main-wrapper")]
     (lib/toggle-class sidebar-dom "active" bool)
     (lib/toggle-class main-wrapper "active" bool))))

(defn show
  "Show sidebar."
  []
  (toggle true))

(defn hide
  "Hide sidebar."
  []
  (toggle false))

;;;; Sidebar
(defn view [data]
  (reify om/IRender
    (render [_]
      (dom/div nil
               (vlib/fa-icon "fa-bars" hide)
               (om/build discuss.views/main-view data)))))

(ns discuss.components.sidebar
  "Controlling the sidebar."
  (:require [om.core :as om]
            [om.dom :as dom]
            [goog.dom :as gdom]
            [discuss.utils.common :as lib]
            [discuss.utils.views :as vlib]))

(def id (lib/prefix-name "sidebar"))

(defn toggle
  "Toggle visibility of sidebar."
  ([]
   (let [sidebar-dom (gdom/getElement id)
         main-wrapper (gdom/getElement "main-wrapper")]
     (lib/toggle-class sidebar-dom "active")
     (lib/toggle-class main-wrapper "active")))
  ([bool]
   (let [sidebar-dom (gdom/getElement id)
         main-wrapper (gdom/getElement "main-wrapper")]
     (lib/toggle-class sidebar-dom "active" bool)
     (lib/toggle-class main-wrapper "active" bool))))

(defn show
  "Show sidebar."
  []
  (toggle true))

(defn hide
  "Hide sidebar."
  []
  (toggle false))

;;;; Sidebar
(defn view [data]
  (reify om/IRender
    (render [_]
      (dom/div nil
               (vlib/fa-icon "fa-bars" hide)
               (om/build discuss.views/main-view data)))))

Use Google Closure to find dom element

Use Google Closure to find dom element


(ns datascript-dom.core-test
  (:require [clojure.test :refer :all]
            [datascript-dom.core :refer :all]))

(deftest a-test
  (testing "FIXME, I fail."
    (is (= 0 1))))

(ns datascript-dom.core-test
  (:require [clojure.test :refer :all]
            [datascript-dom.core :refer :all]
            [pl.danieljanus.tagsoup :as html]))

(deftest test-dom->transaction
  (is (=
       [{:tag :html, :db/id -1}
        {:tag :body, :parent -1, :db/id -2}
        {:tag :p, :parent -2, :db/id -3}
        {:tag :text-node, :text "A", :parent -3, :db/id -4}
        {:tag :b, :parent -3, :prev-sibling -4, :db/id -5}
        {:tag :text-node, :text "B", :parent -5, :db/id -6}
        {:tag :text-node, :text "C", :parent -3, :prev-sibling -5, :db/id -7}
        {:tag :i, :parent -3, :prev-sibling -7, :db/id -8}
        {:tag :text-node, :text "D", :parent -8, :db/id -9}
        {:tag :text-node, :text "E", :parent -3, :prev-sibling -8, :db/id -10}
        {:tag :p, :parent -2, :prev-sibling -3, :db/id -11}
        {:tag :text-node, :text "hohoho", :parent -11, :db/id -12}]
       (dom->transaction
        (html/parse-string "
ABCDE

hohoho
")))))

Test dom to transaction code

Test dom to transaction code


(defproject onyx-plugin/lein-template "0.7.0"
  :description "A Leiningen 2.0 template for new Onyx plugins"
  :url "http://github.com/MichaelDrogalis/onyx-plugin"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies  []
  :plugins [[lein-set-version "0.4.1"]]
  :eval-in-leiningen true)

(defproject onyx-plugin/lein-template "0.7.0.0"
  :description "A Leiningen 2.0 template for new Onyx plugins"
  :url "http://github.com/MichaelDrogalis/onyx-plugin"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies  []
  :plugins [[lein-set-version "0.4.1"]]
  :eval-in-leiningen true)

Use 4 point versioning so that template version can match Onyx


(defproject org.timmc/heim-logger "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"}
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [cheshire "5.6.3"]

                 ;; v1

                 [aleph "0.4.1"]

                 ;; v2

                 ;; I had trouble with http.async.client -- I got a
                 ;; 403 when connecting to euphoria.io.
                 [stylefruits/gniazdo "1.0.0"]
                 ]
  :main ^:no-aot org.timmc.heim-logger.v1
  :jvm-opts ["-Xmx100M"]
  )

(defproject org.timmc/heim-logger "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"}
  :dependencies
  [[org.clojure/clojure "1.8.0"]
   [cheshire "5.6.3"]

   ;; v1

   [aleph "0.4.1"]
   ;; JAXB APIs for aleph to link against in newer JDKs. According to
   ;; https://stackoverflow.com/questions/43574426 JAXB is present in
   ;; JDK 6/7/8, and while it is present in 9 and 10, it is in a module
   ;; that is not loaded by default. In 11, it is missing entirely.
   ;; This has only been tested with JDK 11, manually.
   [javax.xml.bind/jaxb-api "2.3.1"]
   [com.sun.xml.bind/jaxb-impl "2.3.2"]
   [org.glassfish.jaxb/jaxb-runtime "2.3.2"]
   [javax.activation/javax.activation-api "1.2.0"]

   ;; v2

   ;; I had trouble with http.async.client -- I got a
   ;; 403 when connecting to euphoria.io.
   [stylefruits/gniazdo "1.0.0"]
   ]
  :main ^:no-aot org.timmc.heim-logger.v1
  :jvm-opts ["-Xmx100M"]
  )

Add JAXB deps for JDK 11 compat

Add JAXB deps for JDK 11 compat


(defproject jungerer "0.1.1"
  :description "Clojure network/graph library wrapping JUNG"
  :url "https://github.com/totakke/jungerer"
  :license {:name "The BSD 3-Clause License"
            :url "https://opensource.org/licenses/BSD-3-Clause"}
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [net.sf.jung/jung-algorithms "2.1"]
                 [net.sf.jung/jung-api "2.1"]
                 [net.sf.jung/jung-graph-impl "2.1"]
                 [net.sf.jung/jung-visualization "2.1"]]
  :profiles {:dev {:global-vars {*warn-on-reflection* true}}
             :1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}}
  :codox {:source-uri "https://github.com/totakke/jungerer/blob/{version}/{filepath}#L{line}"})

(defproject jungerer "0.1.2-SNAPSHOT"
  :description "Clojure network/graph library wrapping JUNG"
  :url "https://github.com/totakke/jungerer"
  :license {:name "The BSD 3-Clause License"
            :url "https://opensource.org/licenses/BSD-3-Clause"}
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [net.sf.jung/jung-algorithms "2.1"]
                 [net.sf.jung/jung-api "2.1"]
                 [net.sf.jung/jung-graph-impl "2.1"]
                 [net.sf.jung/jung-visualization "2.1"]]
  :profiles {:dev {:global-vars {*warn-on-reflection* true}}
             :1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}}
  :codox {:source-uri "https://github.com/totakke/jungerer/blob/{version}/{filepath}#L{line}"})

Prepare for next development iteration (0.1.2-SNAPSHOT)


;   Copyright (c) Rich Hickey. All rights reserved.
;   The use and distribution terms for this software are covered by the
;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;   which can be found in the file epl-v10.html at the root of this distribution.
;   By using this software in any fashion, you are agreeing to be bound by
;   the terms of this license.
;   You must not remove this notice, or any other, from this software.

(ns ^{:doc "Tests for emit to print XML text."
      :author "Herwig Hochleitner"}
  clojure.data.xml.test-pprint
  (:require
   [clojure.test :refer :all]
   [clojure.data.xml :refer :all]))

(def xml
  "<foo><bar/></foo>")
(def indented-xml
  ;; FIXME indent first
  "<?xml version=\"1.0\" encoding=\"UTF-8\"?><foo>
  <bar/>
</foo>
")

(deftest test-indent
  (is (= indented-xml (indent-str (parse-str xml)))))

;   Copyright (c) Rich Hickey. All rights reserved.
;   The use and distribution terms for this software are covered by the
;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;   which can be found in the file epl-v10.html at the root of this distribution.
;   By using this software in any fashion, you are agreeing to be bound by
;   the terms of this license.
;   You must not remove this notice, or any other, from this software.

(ns ^{:doc "Tests for emit to print XML text."
      :author "Herwig Hochleitner"}
  clojure.data.xml.test-pprint
  (:require
   [clojure.test :refer :all]
   [clojure.data.xml :refer :all]))

(def xml
  "<foo><bar/></foo>")

(defn jdk8? []
  (-> (System/getProperty "java.version")
      (.startsWith "1.8")))

(def indented-xml
  (str
   "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
   (when-not (jdk8?) "\n")
   "<foo>
  <bar/>
</foo>
"))

(deftest test-indent
  (is (= indented-xml (indent-str (parse-str xml)))))

Fix indentation on a test for JDK 6 and 7

JDK 8 includes a newline after the XML declaration, JDK 6 and 7 do not
which is causing the build to fail on 6 and 7.


(ns akvo.lumen.specs
  (:require [clojure.spec.alpha :as s]
            [clojure.spec.gen.alpha :as gen]
            [akvo.lumen.util :refer (squuid)]
            [clojure.tools.logging :as log]))

(defn keyname [key] (str (namespace key) "/" (name key)))

(defn sample-with-gen [s map-gen amount]
  (map first (s/exercise s amount map-gen)))

(defn sample
  ([s]
   (sample s 1))
  ([s amount]
   (let [res (map first (s/exercise s amount))]
     (if (== 1 amount)
       (first res)
       res))))

(defn str-uuid? [v]
  (when (some? v)
    (uuid? (read-string (format "#uuid \"%s\"" v)))))

(s/def ::str-uuid
  (s/with-gen
    str-uuid?
    #(s/gen (reduce (fn [c _] (conj c (str (squuid)))) #{} (range 100)))))

(s/def ::sort #{"ASC" "DESC"})

(defn sample-with-filter
  "generates a sample satisfying a filter condition."
  ([spec filter-fun]
   (sample-with-filter spec filter-fun 10))
  ([spec filter-fun attempts]
   (loop [attempt 0]
     (let [res (filter filter-fun (sample spec attempts))]
       (if (and (empty? res) (< attempt attempts))
         (recur (inc attempt))
         (first res))))))

Add sample-with-filter generator utility spec function


(ns devcards.discuss.add-statements
  (:require [devcards.core :as dc :refer-macros [defcard defcard-om-next]]
            [discuss.parser :as parser]
            [discuss.views :as views]
            [devcards.discuss.utils :as dutils]
            [om.next :as om]))

(defcard shortcuts dutils/shortcuts)

(def sample-api-route "/town-has-to-cut-spending/justify/37/agree?history=/attitude/37")

(def ^:private stmts-reconciler
  (om/reconciler {:state (assoc @(om/app-state parser/reconciler) :api/last-call sample-api-route)
                  :parser (om/parser {:read parser/read :mutate parser/mutate})}))

(defcard-om-next main-content-view
  views/MainContentView
  parser/reconciler)

(defcard-om-next add-new-statement
  views/AddElement
  parser/reconciler)

(ns devcards.discuss.add-statements
  (:require [devcards.core :as dc :refer-macros [defcard defcard-om-next]]
            [discuss.parser :as parser]
            [discuss.views :as views]
            [devcards.discuss.utils :as dutils]
            [om.next :as om]
            [discuss.utils.common :as lib]))

(defcard shortcuts
  dutils/shortcuts)

(def sample-api-route "/town-has-to-cut-spending/justify/37/agree?history=/attitude/37")

(defcard-om-next main-content-view
  views/MainContentView
  parser/reconciler)

(dc/defcard-doc
  "Do request to the following Route:"
  sample-api-route)

(defcard-om-next add-new-statement
  views/AddElement
  parser/reconciler)

Prepare defcard to add new statements

Prepare defcard to add new statements


(ns leiningen.new.devcards
  (:require [leiningen.new.templates :refer [renderer name-to-path ->files]]
            [leiningen.core.main :as main]))

(def render (renderer "devcards"))

(defn devcards
  [name]
  (let [data {:name name
              :sanitized (name-to-path name)}]
    (main/info (str "Generating fresh 'lein new' devcards project.\n"
                    "cd into your project directory\n"
                    "Run 'lein figwheel' and then open localhost:3449/cards.html in your browser."
                    ""))
    (->files data
             ["project.clj" (render "project.clj" data)]
             ["resources/public/cards.html" (render "resources/index.html" data)]
             ["resources/public/index.html" (render "resources/app_index.html" data)]
             ["resources/public/css/{{sanitized}}_style.css" (render "style.css" data)]
             ["src/{{sanitized}}/core.cljs" (render "core.cljs" data)])))

(ns leiningen.new.devcards
  (:require [leiningen.new.templates :refer [renderer name-to-path ->files]]
            [leiningen.core.main :as main]))

(def render (renderer "devcards"))

(defn devcards
  [name]
  (let [data {:name name
              :sanitized (name-to-path name)}]
    (main/info (str "Generating fresh 'lein new' devcards project.\n"
                    "cd into your project directory\n"
                    "Run 'lein figwheel' and then open http://localhost:3449/cards.html in your browser."
                    ""))
    (->files data
             ["project.clj" (render "project.clj" data)]
             ["resources/public/cards.html" (render "resources/index.html" data)]
             ["resources/public/index.html" (render "resources/app_index.html" data)]
             ["resources/public/css/{{sanitized}}_style.css" (render "style.css" data)]
             ["src/{{sanitized}}/core.cljs" (render "core.cljs" data)])))

Make the URL to cards.html clickable

Make the URL to cards.html clickable

Many terminal emulators (such as iTerm) will recognize a URL and let you click it, but only if it includes the scheme.


{:user {:plugins [[lein-ancient "0.6.10"]
                  [lein-cljfmt "0.5.6"]
                  [lein-kibit "0.1.5" :exclusions [org.clojure/clojure]]
                  [lein-cloverage "1.0.9"]]}}

{:user {:plugins [[lein-ancient "0.6.10"]
                  [lein-cljfmt "0.5.6"]
                  [lein-kibit "0.1.5" :exclusions [org.clojure/clojure]]
                  [lein-cloverage "1.0.9"]
                  [jonase/eastwood "0.2.4"]]}}

Add eastwood to lein profile

Add eastwood to lein profile


(ns circle.init
  ;; (: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)
  )

(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
  ;; (: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 :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))

Add :gen-class for main, removing one of two bugs preventing `lein uberjar` from working.

The other is that midje requires :skip-aot, which of course prevents jars from being properly generated.


(defproject mvxcvi/vault "0.3.0-SNAPSHOT"
  :description "Content-addressable data store."
  :url "https://github.com/greglook/vault"
  :license {:name "Public Domain"
            :url "http://unlicense.org/"}

  :dependencies
  [[byte-streams "0.1.10"]
   [clj-time "0.7.0"]
   [environ "0.5.0"]
   [potemkin "0.3.4"]
   [mvxcvi/clj-pgp "0.5.2"]
   [mvxcvi/puget "0.5.2"]
   [org.clojure/clojure "1.6.0"]
   [org.clojure/data.codec "0.1.0"]
   [prismatic/schema "0.2.3"]]

  :hiera
  {:cluster-depth 2
   :ignore-ns #{clojure byte-streams clj-time potemkin}}

  :profiles
  {:coverage
   {:plugins
    [[lein-cloverage "1.0.2"]]}

   :tool
   {:dependencies
    [[mvxcvi/directive "0.4.2"]
     [org.clojure/tools.namespace "0.2.4"]]
    :jvm-opts []
    :repl-options {:init-ns vault.system}
    :source-paths ["tool"]}

   :repl [:tool]})

(defproject mvxcvi/vault "0.3.0-SNAPSHOT"
  :description "Content-addressable data store."
  :url "https://github.com/greglook/vault"
  :license {:name "Public Domain"
            :url "http://unlicense.org/"}

  :dependencies
  [[byte-streams "0.1.11"]
   [clj-time "0.7.0"]
   [environ "0.5.0"]
   [potemkin "0.3.4"]
   [mvxcvi/clj-pgp "0.5.2"]
   [mvxcvi/puget "0.6.2"]
   [org.clojure/clojure "1.6.0"]
   [org.clojure/data.codec "0.1.0"]
   [prismatic/schema "0.2.4"]]

  :hiera
  {:cluster-depth 2
   :ignore-ns #{clojure byte-streams clj-time potemkin}}

  :profiles
  {:coverage
   {:plugins
    [[lein-cloverage "1.0.2"]]}

   :tool
   {:dependencies
    [[mvxcvi/directive "0.4.2"]
     [org.clojure/tools.namespace "0.2.4"]]
    :jvm-opts []
    :repl-options {:init-ns vault.system}
    :source-paths ["tool"]}

   :repl [:tool]})

Update puget, schema, and byte-streams dependencies.


;; 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.2"
  :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.2-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


(defproject cli4clj "1.5.0"
;(defproject cli4clj "1.5.1-SNAPSHOT"
  :description "Create simple interactive CLIs for Clojure applications."
  :url "https://github.com/ruedigergad/cli4clj"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [clj-assorted-utils "1.18.2"]
                 [org.clojure/core.async "0.4.474"]
                 [jline/jline "2.14.6"]]
  :global-vars {*warn-on-reflection* true}
  :html5-docs-docs-dir "ghpages/doc"
  :html5-docs-ns-includes #"^cli4clj.*"
  :html5-docs-repository-url "https://github.com/ruedigergad/cli4clj/blob/master"
  :test2junit-output-dir "ghpages/test-results"
  :test2junit-run-ant true
  :main cli4clj.example
  :plugins [[lein-cloverage "1.0.2"] [test2junit "1.3.3"] [lein-html5-docs "3.0.3"]]
  :profiles  {:repl  {:dependencies  [[jonase/eastwood "0.2.6" :exclusions  [org.clojure/clojure]]]}}
)

;(defproject cli4clj "1.5.0"
(defproject cli4clj "1.5.1-SNAPSHOT"
  :description "Create simple interactive CLIs for Clojure applications."
  :url "https://github.com/ruedigergad/cli4clj"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [clj-assorted-utils "1.18.2"]
                 [org.clojure/core.async "0.4.474"]
                 [jline/jline "2.14.6"]]
  :global-vars {*warn-on-reflection* true}
  :html5-docs-docs-dir "ghpages/doc"
  :html5-docs-ns-includes #"^cli4clj.*"
  :html5-docs-repository-url "https://github.com/ruedigergad/cli4clj/blob/master"
  :test2junit-output-dir "ghpages/test-results"
  :test2junit-run-ant true
  :main cli4clj.example
  :plugins [[lein-cloverage "1.0.2"] [test2junit "1.3.3"] [lein-html5-docs "3.0.3"]]
  :profiles  {:repl  {:dependencies  [[jonase/eastwood "0.2.6" :exclusions  [org.clojure/clojure]]]}}
)

Revert back to snapshot version.

Revert back to snapshot version.


(ns bytebuf.bytes
  (:import java.util.Arrays
           java.security.SecureRandom))

(defn random-bytes
  "Generate a byte array of scpecified length with random
  bytes taken from secure random number generator.
  This method should be used for generate a random
  iv/salt or arbitrary length."
  ([^long numbytes]
   (random-bytes numbytes (SecureRandom.)))
  ([^long numbytes ^SecureRandom sr]
   (let [buffer (byte-array numbytes)]
     (.nextBytes sr buffer)
     buffer)))

(defn slice
  "Given a byte array, get a copy of it. If offset
  and limit is provided, a slice will be returned."
  [^bytes input ^long offset ^long limit]
  (Arrays/copyOfRange input offset limit))

(defn zeropad!
  "Add zero byte padding to the given byte array
  to the remaining bytes after specified data length."
  [^bytes input ^long datalength]
  (Arrays/fill input datalength (count input) (byte 0)))

(defn zeropad-count
  "Given a byte array, returns a number of bytes
  allocated with zero padding (zero byte)."
  [^bytes input]
  (let [mark (byte 0)]
    (reduce (fn [sum index]
              (let [value (aget input index)]
                (if (= value mark)
                  (inc sum)
                  (reduced sum))))
            0
            (reverse (range (count input))))))

(ns bytebuf.bytes
  (:import java.util.Arrays
           java.security.SecureRandom))

(defn random-bytes
  "Generate a byte array of scpecified length with random
  bytes taken from secure random number generator.
  This method should be used for generate a random
  iv/salt or arbitrary length."
  ([^long numbytes]
   (random-bytes numbytes (SecureRandom.)))
  ([^long numbytes ^SecureRandom sr]
   (let [buffer (byte-array numbytes)]
     (.nextBytes sr buffer)
     buffer)))

(defn slice
  "Given a byte array, get a copy of it. If offset
  and limit is provided, a slice will be returned."
  [^bytes input ^long offset ^long limit]
  (Arrays/copyOfRange input offset limit))

(defn equals?
  "Check if two byte arrays are equals."
  [^bytes a ^bytes b]
  (Arrays/equals a b))

(defn zeropad!
  "Add zero byte padding to the given byte array
  to the remaining bytes after specified data length."
  [^bytes input ^long datalength]
  (Arrays/fill input datalength (count input) (byte 0)))

(defn zeropad-count
  "Given a byte array, returns a number of bytes
  allocated with zero padding (zero byte)."
  [^bytes input]
  (let [mark (byte 0)]
    (reduce (fn [sum index]
              (let [value (aget input index)]
                (if (= value mark)
                  (inc sum)
                  (reduced sum))))
            0
            (reverse (range (count input))))))

Add simple function for check byte array equality.


(ns juxt.crux.demo.foo
  (:require
    crux.api
    [yada.yada :as yada]
    [integrant.core :as ig]))

(def id #uuid "50005565-299f-4c08-86d0-b1919bf4b7a9")

(defmethod ig/init-key ::read-write
  [_ {:keys [system]}]
  (yada/resource
    {:id ::read-write
     :methods
     {:get
      {:produces ["text/html" "application/edn" "application/json"]
       :response (fn [ctx]
                   (let [db (crux.api/db system)]
                     (map
                       #(crux.api/entity db (first %))
                       (crux.api/q
                         db
                         {:find '[?e]
                          :where [['?e :crux.db/id id]]}))))}
      :post
      {:produces "text/plain"
       :consumes "application/edn"
       :response
       (fn [ctx]
         (crux.api/submit-tx
           system
           [[:crux.tx/put id
             (merge {:crux.db/id id} (:body ctx))]])
         (yada/redirect ctx ::read-write))}}}))

;; To populate data using cURL:
; $ curl -H "Content-Type: application/edn" -d '{:foo/username "Bart"}' localhost:8300

(ns juxt.crux.demo.foo
  (:require
    crux.api
    [yada.yada :as yada]
    [integrant.core :as ig]))

(def id #uuid "50005565-299f-4c08-86d0-b1919bf4b7a9")

(defmethod ig/init-key ::read-write
  [_ {:keys [system]}]
  (yada/resource
    {:id ::read-write
     :methods
     {:get
      {:produces ["text/html" "application/edn" "application/json"]
       :response (fn [ctx]
                   (let [db (crux.api/db system)]
                     (map
                       #(crux.api/entity db (first %))
                       (crux.api/q
                         db
                         {:find '[?e]
                          :where [['?e :crux.db/id id]]}))))}
      :post
      {:produces "text/plain"
       :consumes "application/edn"
       :response
       (fn [ctx]
         (crux.api/submit-tx
           system
           [[:crux.tx/put (merge {:crux.db/id id} (:body ctx))]])
         (yada/redirect ctx ::read-write))}}}))

;; To populate data using cURL:
; $ curl -H "Content-Type: application/edn" -d '{:foo/username "Bart"}' localhost:8300

Update crux example app with new put api


(ns decktouch.handler
  (:require [decktouch.dev :refer [browser-repl start-figwheel]]
            [compojure.core :refer [GET defroutes]]
            [compojure.route :refer [not-found resources]]
            [ring.middleware.defaults :refer [site-defaults wrap-defaults]]
            [selmer.parser :refer [render-file]]
            [environ.core :refer [env]]
            [prone.middleware :refer [wrap-exceptions]]))

(defroutes routes
  (GET "/" [] (render-file "templates/index.html" {:dev (env :dev?)}))
  (resources "/")
  (not-found "Not Found"))

(def app
  (let [handler (wrap-defaults routes site-defaults)]
    (if (env :dev?) (wrap-exceptions handler) handler)))

(ns decktouch.handler
  (:require [decktouch.dev :refer [browser-repl start-figwheel]]
            [compojure.core :refer [GET defroutes]]
            [compojure.route :refer [not-found resources]]
            [ring.middleware.defaults :refer [site-defaults wrap-defaults]]
            [selmer.parser :refer [render-file]]
            [environ.core :refer [env]]
            [prone.middleware :refer [wrap-exceptions]]
            [decktouch.mtg-card-master :as mtg-card-master]
            [clojure.data.json :as json]))

(defroutes routes
  (GET "/" [] (render-file "templates/index.html" {:dev (env :dev?)}))
  (GET "/data/input/:query" [query]
       (json/write-str
         (mtg-card-master/get-cards-matching-query query)))
  (resources "/")
  (not-found "Not Found"))

(def app
  (let [handler (wrap-defaults routes site-defaults)]
    (if (env :dev?) (wrap-exceptions handler) handler)))

Add route for querying card master

Add route for querying card master


(defproject get-here "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/data.csv "0.1.2"]
                 [clj-time "0.7.0"]
                 [aysylu/loom "0.4.2"]
                 [ring "1.3.0"]
                 [ring/ring-jetty-adapter "1.3.0"]
                 [ring/ring-json "0.3.1"]
                 [cheshire "5.3.1"]
                 [compojure "1.1.8"]
                 [org.clojure/core.memoize "0.5.6"]]

  :main get-here.core

  :profiles {:dev {:main get-here.core/-dev-main}}

  :min-lein-version "2.0.0"
  :uberjar-name "get-here.jar")

(defproject get-here "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/data.csv "0.1.2"]
                 [clj-time "0.7.0"]
                 [aysylu/loom "0.4.2"]
                 [ring "1.3.0"]
                 [ring/ring-jetty-adapter "1.3.0"]
                 [ring/ring-json "0.3.1"]
                 [cheshire "5.3.1"]
                 [compojure "1.1.8"]
                 [org.clojure/core.memoize "0.5.6"]]

  :main get-here.core

  :profiles {:dev {:main get-here.core/-dev-main}}

  :min-lein-version "2.0.0"
  :jar-name "get-here.jar"
  :uberjar-name "get-standalone-here.jar")

Rename jars, upgrade to Clojure 1.6

Rename jars, upgrade to Clojure 1.6


(defproject dungeon-crusade "0.0.1-SNAPSHOT"
  :description "dungeon-crusade"
  :plugins      [[lein-marginalia "0.7.1"]
                 [lein-kibit "0.0.8"]]
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/core.async "0.1.303.0-886421-alpha"]
                 [org.clojure/tools.reader "0.8.4"]
                 [org.clojure/core.typed "0.2.44"]
                 [org.clojure/math.combinatorics "0.0.7"]
                 [org.clojure/clojure-contrib "1.2.0"]
                 [org.clojars.vishk/algotools "0.1.0"]
                 [net.mikera/clisk "0.9.1-SNAPSHOT"]
                 [com.palletops/thread-expr "1.3.0"]
                 [tinter "0.1.1-SNAPSHOT"]
                 [clj-tiny-astar "0.1.0-SNAPSHOT"]
                 [dorothy "0.0.3"]
                 [com.taoensso/timbre "3.2.1"]
                 [org.clojars.folcon/clojure-lanterna "0.9.5-SNAPSHOT"]]
  :main dungeon-crusade.core
  :repl-init dungeon-crusade.main)

(defproject dungeon-crusade "0.0.1-SNAPSHOT"
  :description "dungeon-crusade"
  :plugins      [[lein-marginalia "0.7.1"]
                 [lein-kibit "0.0.8"]]
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/core.async "0.1.303.0-886421-alpha"]
                 [org.clojure/tools.reader "0.8.4"]
                 [org.clojure/core.typed "0.2.44"]
                 [org.clojure/math.combinatorics "0.0.7"]
                 [org.clojure/clojure-contrib "1.2.0"]
                 [org.clojars.vishk/algotools "0.1.0"]
                 [net.mikera/clisk "0.10.0"]
                 [com.palletops/thread-expr "1.3.0"]
                 [tinter "0.1.1-SNAPSHOT"]
                 [clj-tiny-astar "0.1.0-SNAPSHOT"]
                 [dorothy "0.0.3"]
                 [com.taoensso/timbre "3.2.1"]
                 [org.clojars.folcon/clojure-lanterna "0.9.5-SNAPSHOT"]]
  :main dungeon-crusade.core
  :repl-init dungeon-crusade.main)

Stop using custom clisk snapshot. 0.10.0 includes required changes


(defproject compojure "1.5.1"
  :description "A concise routing library for Ring"
  :url "https://github.com/weavejester/compojure"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/tools.macro "0.1.5"]
                 [clout "2.1.2"]
                 [medley "0.8.2"]
                 [ring/ring-core "1.5.0"]
                 [ring/ring-codec "1.0.1"]]
  :plugins [[lein-codox "0.9.5"]]
  :codox
  {:output-path "codox"
   :metadata {:doc/format :markdown}
   :source-uri "http://github.com/weavejester/compojure/blob/{version}/{filepath}#L{line}"}
  :aliases
  {"test-all" ["with-profile" "default:+1.8" "test"]}
  :profiles
  {:dev {:jvm-opts ^:replace []
         :dependencies [[ring/ring-mock "0.3.0"]
                        [criterium "0.4.3"]
                        [javax.servlet/servlet-api "2.5"]]}
   :1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]}})

(defproject compojure "1.5.1"
  :description "A concise routing library for Ring"
  :url "https://github.com/weavejester/compojure"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/tools.macro "0.1.5"]
                 [clout "2.1.2"]
                 [medley "0.8.2"]
                 [ring/ring-core "1.5.1"]
                 [ring/ring-codec "1.0.1"]]
  :plugins [[lein-codox "0.9.5"]]
  :codox
  {:output-path "codox"
   :metadata {:doc/format :markdown}
   :source-uri "http://github.com/weavejester/compojure/blob/{version}/{filepath}#L{line}"}
  :aliases
  {"test-all" ["with-profile" "default:+1.8" "test"]}
  :profiles
  {:dev {:jvm-opts ^:replace []
         :dependencies [[ring/ring-mock "0.3.0"]
                        [criterium "0.4.3"]
                        [javax.servlet/servlet-api "2.5"]]}
   :1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]}})

Update Ring version to 1.5.1

Update Ring version to 1.5.1

Fixes path traversal vulnerability in route/resources.


(defproject org.onyxplatform/onyx-metrics "0.7.2.1-SNAPSHOT"
  :description "Instrument Onyx workflows"
  :url "https://github.com/MichaelDrogalis/onyx"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/core.async "0.1.346.0-17112a-alpha"]
                 [com.mdrogalis/rotating-seq "0.1.3"]
                 [com.taoensso/timbre "3.0.1"]
                 [stylefruits/gniazdo "0.4.0"]
                 [riemann-clojure-client "0.4.1"]]
  :profiles {:dev {:dependencies [[org.onyxplatform/onyx "0.7.2"]
                                  [midje "1.6.3"]]
                   :plugins [[lein-midje "3.1.1"]]}})

(defproject org.onyxplatform/onyx-metrics "0.7.2.1-SNAPSHOT"
  :description "Instrument Onyx workflows"
  :url "https://github.com/MichaelDrogalis/onyx"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [com.mdrogalis/rotating-seq "0.1.3"]
                 [stylefruits/gniazdo "0.4.0"]]
  :profiles {:dev {:dependencies [[org.onyxplatform/onyx "0.7.3"]
                                  [org.clojure/core.async "0.1.346.0-17112a-alpha"]
                                  [riemann-clojure-client "0.4.1"]
                                  [com.taoensso/timbre "3.0.1"]
                                  [midje "1.7.0"]]
                   :plugins [[lein-midje "3.1.3"]]}})

Switch dependencies to dev dependencies

Switch dependencies to dev dependencies


;;;; This file is part of algebolic. Copyright (C) 2014-, Jony Hudson.
;;;;
;;;; algebolic is licenced to you under the MIT licence. See the file LICENCE.txt for full details.

(defproject algebolic "0.1.0-SNAPSHOT"
  :description "A library for doing symbolic regression with algebraic manipulation."
  :license {:name "MIT"}
  :dependencies [[org.clojure/clojure "1.6.0"]]
  :plugins [[lein-gorilla "0.3.4-SNAPSHOT"]]
  :jvm-opts ["-server" "-Xmx4g"])

;;;; This file is part of algebolic. Copyright (C) 2014-, Jony Hudson.
;;;;
;;;; algebolic is licenced to you under the MIT licence. See the file LICENCE.txt for full details.

(defproject algebolic "0.1.0-SNAPSHOT"
  :description "A library for doing symbolic regression with algebraic manipulation."
  :license {:name "MIT"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [clj-kdtree "1.2.0" :exclusions [org.clojure/clojure]]]
  :plugins [[lein-gorilla "0.3.4-SNAPSHOT"]]
  :jvm-opts ["-server" "-Xmx4g"])

Add dependencies for last commit :-(

Add dependencies for last commit :-(


(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"]]}})

(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.8-R0.1-SNAPSHOT"]]}})

Bump up bukkit dependency version.

Bump up bukkit dependency version.


(defproject frereth-common "0.0.1-SNAPSHOT"
  :description "Pieces that the different Frereth parts share"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  ;; TODO: Could I totally pull datomic dependencies out of everything else?
  :dependencies [[com.stuartsierra/component "0.2.2"]
                 [com.taoensso/timbre "3.3.1"]
                 [im.chit/ribol "0.4.0"]
                 [mvxcvi/puget "0.6.4"]
                 [org.clojure/clojure "1.6.0"]
                 [prismatic/schema "0.3.3"]]

  :profiles {:dev {:source-paths ["dev"]
                   :dependencies [[org.clojure/tools.namespace "0.2.7"]
                                  [org.clojure/java.classpath "0.2.2"]]}
             :uberjar {:aot :all}}
  :repl-options {:init-ns user})

(defproject frereth-common "0.0.1-SNAPSHOT"
  :description "Pieces that the different Frereth parts share"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  ;; TODO: Could I totally pull datomic dependencies out of everything else?
  :dependencies [[com.stuartsierra/component "0.2.2"]
                 [com.taoensso/timbre "3.3.1" :exclusions [org.clojure/tools.reader]]
                 [im.chit/ribol "0.4.0"]
                 [mvxcvi/puget "0.6.4"]
                 [org.clojure/clojure "1.6.0"]
                 [prismatic/schema "0.3.3"]]

  :profiles {:dev {:source-paths ["dev"]
                   :dependencies [[org.clojure/tools.namespace "0.2.7"]
                                  [org.clojure/java.classpath "0.2.2"]]}
             :uberjar {:aot :all}}
  :repl-options {:init-ns user})

Fix up conflicts in the renderer

Fix up conflicts in the renderer


(ns lazytest.group
  (:use [lazytest.testable :only (Testable get-tests)]
	[lazytest.runnable-test :only (RunnableTest
				       run-tests
				       skip-or-pending
				       try-expectations
				       runnable-test?)]
	[lazytest.fixture :only (setup teardown fixture?)]
	[lazytest.test-result :only (result-group)]))

(defrecord TestCase [fixtures f]
  Testable
  (get-tests [this] (list this))
  RunnableTest
  (run-tests [this]
	     (lazy-seq
	      (list
	       (or (skip-or-pending this)
		   (try-expectations
		    this
		    (apply f (map setup fixtures))
		    (dorun (map teardown fixtures))))))))

(defn test-case [fixtures f]
  {:pre [(every? fixture? fixtures) (fn? f)]}
  (TestCase. fixtures f))

(defrecord TestGroup [children]
  Testable
  (get-tests [this] (list this))
  RunnableTest
  (run-tests [this]
	     (or (skip-or-pending this)
		 (result-group this (lazy-seq (mapcat run-tests children))))))

(defn test-group [children]
  {:pre [(every? (runnable-test? children))]}
  (TestGroup. children))

(ns lazytest.group
  (:use [lazytest.testable :only (Testable get-tests)]
	[lazytest.runnable-test :only (RunnableTest
				       run-tests
				       skip-or-pending
				       try-expectations
				       runnable-test?)]
	[lazytest.fixture :only (setup teardown fixture?)]
	[lazytest.test-result :only (result-group)]))

(defrecord TestCase [fixtures f]
  Testable
  (get-tests [this] (list this))
  RunnableTest
  (run-tests [this]
	     (lazy-seq
	      (list
	       (or (skip-or-pending this)
		   (try-expectations
		    this
		    (apply f (map setup fixtures))
		    (dorun (map teardown fixtures))))))))

(defn test-case
  ([fixtures f] (test-case fixtures f nil))
  ([fixtures f metadata]
     {:pre [(every? fixture? fixtures) (fn? f)]}
     (TestCase. fixtures f metadata nil)))

(defrecord TestGroup [children]
  Testable
  (get-tests [this] (list this))
  RunnableTest
  (run-tests [this]
	     (or (skip-or-pending this)
		 (result-group this (lazy-seq (mapcat run-tests children))))))

(defn test-group
  ([children] (test-group children nil))
  ([children metadata]
     {:pre [(every? (runnable-test? children))]}
     (TestGroup. children metadata nil)))

Support metadata in TestCase and TestGroup constructors


(ns pfrt-js.templates
  (:require [crate.core :refer [html]]
            [domina :refer [log]]
            [clojure.string :as str]))

(defn- hostname->domid
  "Convert host name to valid
  dom identifier."
  [host]
  (str "host" (str/join (str/split host #"\."))))

(defn host-entry
  [host data]
  (let [downloaded      (get data "in")
        uploaded        (get data "out")
        download-speed  (get data "speed-in")
        upload-speed    (get data "speed-out")]
    (html [:tr {:id (hostname->domid host)}
           [:td (:name data host)]
           [:td (js/filesize downloaded)]
           [:td (js/filesize uploaded)]
           [:td (str (js/filesize download-speed) "/s")]
           [:td (str (js/filesize upload-speed) "/s")]])))

(defn stats-layout
  []
  (html
   [:div {:class "container table-container"}
    [:table {:id "stats-container" :class "stats-container"}
     [:thead
      [:tr
       [:td "Hostname"]
       [:td "Download"]
       [:td "Upload"]
       [:td "Download Speed"]
       [:td "Upload Speed"]]]
     [:tbody]]]))

(defn base-layout
  "Main layout for all pages."
  []
  (html
   [:div {:class "wrapper"}
    [:div {:class "container header-container"}
     [:h1 "Pr0n Stats"]]
    [:div {:class "container body-container"}]]))

(ns pfrt-js.templates
  (:require [crate.core :refer [html]]
            [domina :refer [log]]
            [clojure.string :as str]))

(defn- hostname->domid
  "Convert host name to valid
  dom identifier."
  [host]
  (str "host" (str/join (str/split host #"\."))))

(defn host-entry
  [host data]
  (let [{:strs [in out speed-in speed-out]} data]
    (html [:tr {:id (hostname->domid host)}
           [:td host]
           [:td (js/filesize in)]
           [:td (js/filesize out)]
           [:td (str (js/filesize speed-in) "/s")]
           [:td (str (js/filesize speed-out) "/s")]])))

(defn stats-layout
  []
  (html
   [:div {:class "container table-container"}
    [:table {:id "stats-container" :class "stats-container"}
     [:thead
      [:tr
       [:td "Hostname"]
       [:td "Download"]
       [:td "Upload"]
       [:td "Download Speed"]
       [:td "Upload Speed"]]]
     [:tbody]]]))

(defn base-layout
  "Main layout for all pages."
  []
  (html
   [:div {:class "wrapper"}
    [:div {:class "container header-container"}
     [:h1 "Pr0n Stats"]]
    [:div {:class "container body-container"}]]))

Add :strs destructig (thanks to @dialelo suggestion)


(defproject com.palletops/hyde-pallet "0.1.0-SNAPSHOT"
  :description "Site generation for clojure projects"
  :url "https://github.com/paleltops/hyde-pallet"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :plugins [[lein-modules "0.3.1"]]
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [com.palletops/hyde "0.1.0"]])

(defproject com.palletops/hyde-pallet "0.1.0-SNAPSHOT"
  :description "Site generation for clojure projects"
  :url "https://github.com/paleltops/hyde-pallet"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :plugins [[lein-modules "0.3.1"]]
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [com.palletops/hyde "0.1.1-SNAPSHOT"]])

Update dep to hyde 1.1-SNAPSHOT

Update dep to hyde 1.1-SNAPSHOT


(defproject sketch "0.1.0-SNAPSHOT"
  :description "A template for a sketch with Quil/Processing"
  :dependencies [[org.clojure/clojure "1.10.1"]
                 [genartlib/genartlib "0.1.20"] ; utility functions
                 [com.seisw/gpcj "2.2.0"]] ; polygon clipping
  :jvm-opts ["-Xms4000m" "-Xmx4000M" "-server"] ; 4GB heap size
  :source-paths ["src/clj"]
  :java-source-paths ["src/java"]
  :aot [sketch.dynamic])

(defproject sketch "0.1.0-SNAPSHOT"
  :description "A template for a sketch with Quil/Processing"
  :dependencies [[org.clojure/clojure "1.10.1"]
                 [genartlib/genartlib "0.1.20"] ; utility functions
                 [com.seisw/gpcj "2.2.0"]] ; polygon clipping
  :jvm-opts ["-Xms4000m" "-Xmx4000M" ; 4GB heap size
             "-server"
             "-Dsun.java2d.uiScale=1.0"] ; adjust scaling for high DPI displays
  :source-paths ["src/clj"]
  :java-source-paths ["src/java"]
  :aot [sketch.dynamic])

Make it easy to scale display for high DPI


(ns apio.concurrency.core
  (import (java.util.concurrent ForkJoinPool)))

;; TODO: initialize forkjoin pool in dynamic context
;; using dynamic loaded configuration.
(def *thread-pool* (ForkJoinPool.))

(ns apio.concurrency.core
  (import (java.util.concurrent Executors)))

;; TODO: initialize forkjoin pool in dynamic context
;; using dynamic loaded configuration.

(defn num-processes [] (.availableProcessors Runtime/getRuntime))
(def *thread-pool* (Executors/newFixedThreadPool (* (num-processes) 2)))

Replace forkjoin with standard fixed thread pool.


(ns adzerk.boot-cljs.util
  (:require [boot.core :as core]
            [clojure.java.io :as io]
            [clojure.string :as string]))

(defn path->js
  "Given a path to a CLJS namespace source file, returns the corresponding
  Google Closure namespace name for goog.provide() or goog.require()."
  [path]
  (-> path
      (string/replace #"\.clj[s|c]$" "")
      (string/replace #"[/\\]" ".")))

(defn path->ns
  "Given a path to a CLJS namespace source file, returns the corresponding
  CLJS namespace name."
  [path]
  (-> (path->js path) (string/replace #"_" "-")))

(defn get-name
  [path-or-file]
  (-> path-or-file io/file .getName))

(defn cljs-files
  [fileset]
  (->> fileset core/input-files (core/by-ext [".cljs" ".cljc"]) (sort-by :path)))

(defn path [& parts]
  (.getPath (apply io/file parts)))

(defn main-files [fileset id]
  (let [select (if (seq id)
                 #(core/by-name [(str id ".cljs.edn")] %)
                 #(core/by-ext [".cljs.edn"] %))]
    (->> fileset
         core/input-files
         select
         (sort-by :path))))

(defn tmp-file->docroot [tmp-file]
  (.getParent (io/file (core/tmp-path tmp-file))))

(ns adzerk.boot-cljs.util
  (:require [boot.core :as core]
            [clojure.java.io :as io]
            [clojure.string :as string]))

(defn path->js
  "Given a path to a CLJS namespace source file, returns the corresponding
  Google Closure namespace name for goog.provide() or goog.require()."
  [path]
  (-> path
      (string/replace #"\.clj[s|c]$" "")
      (string/replace #"[/\\]" ".")))

(defn path->ns
  "Given a path to a CLJS namespace source file, returns the corresponding
  CLJS namespace name."
  [path]
  (-> (path->js path) (string/replace #"_" "-")))

(defn get-name
  [path-or-file]
  (-> path-or-file io/file .getName))

(defn cljs-files
  [fileset]
  (->> fileset core/input-files (core/by-ext [".cljs" ".cljc"]) (sort-by :path)))

(defn path [& parts]
  (.getPath (apply io/file parts)))

(defn main-files [fileset id]
  (let [select (if (seq id)
                 #(core/by-name [(str id ".cljs.edn")] %)
                 #(core/by-ext [".cljs.edn"] %))]
    (->> fileset
         core/input-files
         select
         (sort-by :path))))

(defn tmp-file->docroot [tmp-file]
  (or (.getParent (io/file (core/tmp-path tmp-file))) ""))

Fix case where docroot is nil

Fix case where docroot is nil


(defproject angelic "1.0.0-SNAPSHOT"
  :description "Angelic hierarchical planning"
  :dependencies [[org.clojure/clojure "1.2.0"]
                 [org.clojure/clojure-contrib "1.2.0"]
;                [org.clojars.robertpfeiffer/vijual "0.1.0-SNAPSHOT"]
                 [org.swinglabs/pdf-renderer "1.0.5"]
                 [incanter "1.2.3-SNAPSHOT"]
                 ]
  :dev-dependencies [[swank-clojure "1.2.1"] [mycroft/mycroft "0.0.2"]]
  :jvm-opts ["-server" "-Xmx1g"
             "-agentpath:/Applications/YourKit_Java_Profiler_9.0.0.app/bin/mac/libyjpagent.jnilib"
             #_ "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5000" ]
  )

(ns leiningen.jswat
  (:use
   [clojure.contrib.shell-out :only [sh]]
   [leiningen.classpath]
   [clojure.string :only [join]]))

(defn jswat
  ([project] (jswat project "/Users/jawolfe/Library/clojure/jswat-4.5/bin/jswat"))
  ([project & [path]]
     (let [cp (join java.io.File/pathSeparatorChar (get-classpath project))]
       ;; jswat --cp:p <classpath>
       (sh path "--cp:p" cp))))

(defproject angelic "1.0.0-SNAPSHOT"
  :description "Angelic hierarchical planning"
  :dependencies [[org.clojure/clojure "1.2.0"]
                 [org.clojure/clojure-contrib "1.2.0"]
;                [org.clojars.robertpfeiffer/vijual "0.1.0-SNAPSHOT"]
                 [org.swinglabs/pdf-renderer "1.0.5"]
                 [incanter "1.2.3-SNAPSHOT"]
                 ]
  :dev-dependencies [[swank-clojure "1.2.1"] [mycroft/mycroft "0.0.2"]
                     [swank-clj "0.1.6"]]
  :jvm-opts ["-server" "-Xmx1g"
             "-agentpath:/Applications/YourKit_Java_Profiler_9.0.0.app/bin/mac/libyjpagent.jnilib"
             #_ "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5000" ]
  )

(ns leiningen.jswat
  (:use
   [clojure.contrib.shell-out :only [sh]]
   [leiningen.classpath]
   [clojure.string :only [join]]))

(defn jswat
  ([project] (jswat project "/Users/jawolfe/Library/clojure/jswat-4.5/bin/jswat"))
  ([project & [path]]
     (let [cp (join java.io.File/pathSeparatorChar (get-classpath project))]
       ;; jswat --cp:p <classpath>
       (sh path "--cp:p" cp))))

Add dev dep on swank-clj

Add dev dep on swank-clj


(ns status-im.ui.screens.profile.group-chat.styles
  (:require [status-im.ui.components.colors :as colors]))

(def action-container
  {:background-color colors/white
   :padding-top      24})

(def action
  {:background-color (colors/alpha colors/blue 0.1)
   :border-radius    50})

(def action-label
  {:color colors/blue})

(def action-separator
  {:height           1
   :background-color colors/gray-light
   :margin-left      50})

(def action-icon-opts
  {:color colors/blue})

(ns status-im.ui.screens.profile.group-chat.styles
  (:require [status-im.ui.components.colors :as colors]))

(def action-container
  {:background-color colors/white
   :padding-top      24})

(def action
  {:background-color (colors/alpha colors/blue 0.1)
   :border-radius    50})

; Action label style is expected to be a fn
(defn action-label [_]
  {:color colors/blue})

(def action-separator
  {:height           1
   :background-color colors/gray-light
   :margin-left      50})

(def action-icon-opts
  {:color colors/blue})

Fix group chat info labels

Fix group chat info labels

Signed-off-by: Andrey Shovkoplyas <b713972e59b8e606e23253c4a13e948139fea4d1@gmail.com>


Add corner case found in generative tests


(ns ontrail.test.crypto
  (:use [ontrail.crypto])
  (:use [clojure.test]))

(deftest hash-properly
  (is (com.lambdaworks.crypto.SCryptUtil/check "keijo" (password-hash "keijo"))))

(deftest match-properly
  (is (password-match? "keijo" (com.lambdaworks.crypto.SCryptUtil/scrypt "keijo" 16384 8 1))))

(deftest base64-decodes
  (is (= "esko" (byte-array-to-string (base64-decode "ZXNrbw==")))))

(deftest encrypt-and-decrypt-does-what-it-should-do
  (is (= "foo2" (decrypt (encrypt "foo2")))))

(deftest decrypt-does-what-it-should-do
  (is (= "foo2" (decrypt "hcmlYlBedinIG2d5PohVCRKkEGg="))))

(ns ontrail.test.crypto
  (:use [ontrail.crypto])
  (:use [clojure.test]))

(deftest hash-properly
  (is (com.lambdaworks.crypto.SCryptUtil/check "keijo" (password-hash "keijo"))))

(deftest match-properly
  (is (password-match? "keijo" (com.lambdaworks.crypto.SCryptUtil/scrypt "keijo" 16384 8 1))))

(deftest not-match-invalid-pwd
  (not (password-match? "keijo2" (com.lambdaworks.crypto.SCryptUtil/scrypt "keijo" 16384 8 1))))

(deftest base64-decodes
  (is (= "esko" (byte-array-to-string (base64-decode "ZXNrbw==")))))

(deftest encrypt-and-decrypt-does-what-it-should-do
  (is (= "foo2" (decrypt (encrypt "foo2")))))

(deftest decrypt-does-what-it-should-do
  (is (= "foo2" (decrypt "hcmlYlBedinIG2d5PohVCRKkEGg="))))

Add test for false case also

Add test for false case also


(defproject leiningen/lein-swank "1.1.0"
  :description "A leiningen plugin to launch a swank server."
  :dependencies [[swank-clojure "1.1.0"]
                 [org.apache.maven/maven-ant-tasks "2.0.10"]])

(defproject leiningen/lein-swank "1.2.0-SNAPSHOT"
  :description "A leiningen plugin to launch a swank server."
  :dependencies [[swank-clojure "1.2.0-break-SNAPSHOT"]
                 [ant/ant "1.6.5"]
                 [ant/ant-launcher "1.6.5"]
                 [org.apache.maven/maven-ant-tasks "2.0.10"]])

Update lein-swank version and deps.

Update lein-swank version and deps.


(defproject cljs-browser "0.0.1-SNAPSHOT"
  :description ""
  :dependencies [[org.clojure/clojure "1.4.0-beta4"]
                 [org.clojure/clojurescript "0.0-993"]
                 [ring "1.0.0-RC1"]
                 [compojure "0.6.4"]
                 [enlive "1.0.0"]]
  :repl-init one.sample.repl
  :source-path "src/app/clj"
  :extra-classpath-dirs ["src/app/cljs"
                         "src/app/cljs-macros"
                         "src/lib/clj"
                         "src/lib/cljs"
                         "templates"
                         "../src"
                         "../domina/src/cljs"])

(defproject cljs-browser "0.0.1-SNAPSHOT"
  :description ""
  :dependencies [[org.clojure/clojure "1.4.0-beta4"]
                 [org.clojure/clojurescript "0.0-1236"]
                 [ring "1.0.0-RC1"]
                 [compojure "0.6.4"]
                 [enlive "1.0.0"]]
  :repl-init one.sample.repl
  :source-path "src/app/clj"
  :extra-classpath-dirs ["src/app/cljs"
                         "src/app/cljs-macros"
                         "src/lib/clj"
                         "src/lib/cljs"
                         "templates"
                         "../src"
                         "../domina/src/cljs"])

Update to ClojureScript release 0.0-1236


(ns circle.backend.nodes.circle-artifact
  (:require
   pallet.core
   pallet.phase
   [pallet.action.user :as user]
   [pallet.action.directory :as directory]
   [pallet.action.package :as package]
   [pallet.crate.java :as java]
   [pallet.action.remote-file :as remote-file]
   [pallet.action.service :as service]
   [pallet.crate.automated-admin-user :as automated-admin-user]
   [pallet.crate.git :as git]
   [pallet.crate.ssh-key :as ssh-key]
   [pallet.thread-expr :as thread-expr]))

(def circle-artifact-group
  (pallet.core/group-spec
   "circle"
   :circle-node-spec {:ami "ami-e913dd80"
                      :availability-zone "us-east-1a"
                      :instance-type "t1.micro"
                      :keypair-name "www"
                      :security-groups ["artifacts-server"]
                      :username "ubuntu"
                      :public-key (slurp "www.id_rsa.pub")
                      :private-key (slurp "www.id_rsa")}))

(ns circle.backend.nodes.circle-artifact
  (:require
   pallet.core
   pallet.phase
   [pallet.action.user :as user]
   [pallet.action.directory :as directory]
   [pallet.action.package :as package]
   [pallet.crate.java :as java]
   [pallet.action.remote-file :as remote-file]
   [pallet.action.service :as service]
   [pallet.crate.automated-admin-user :as automated-admin-user]
   [pallet.crate.git :as git]
   [pallet.crate.ssh-key :as ssh-key]
   [pallet.thread-expr :as thread-expr])
  (:require circle.dns)
  (:require [circle.backend.ec2 :as ec2]))

(def circle-artifact-group
  (pallet.core/group-spec
   "circle"
   :circle-node-spec {:ami "ami-e913dd80"
                      :availability-zone "us-east-1a"
                      :instance-type "t1.micro"
                      :keypair-name "www"
                      :security-groups ["artifacts-server"]
                      :username "ubuntu"
                      :public-key (slurp "www.id_rsa.pub")
                      :private-key (slurp "www.id_rsa")}))

(defn update-dns
  "Updates the DNS record for artifacts.circle.com to point at the given instance id"
  [instance-id]
  (circle.dns/update-record {:name "artifacts.circleci.com."} {:value (ec2/public-ip instance-id)}))

Add utils for working w/ artifacts DNS

Add utils for working w/ artifacts DNS


(ns desdemona.launcher.launch-prod-peers
  (:require [desdemona.launcher.utils :as utils]
            [taoensso.timbre :as t]
            [onyx.plugin.kafka]
            [onyx.plugin.sql]
            [onyx.plugin.core-async]
            [onyx.plugin.seq]
            [desdemona.functions.sample-functions]
            [desdemona.jobs.sample-submit-job]
            [desdemona.lifecycles.sample-lifecycle])
  (:gen-class))

(defn -main [n & args]
  (let [n-peers (Integer/parseInt n)
        {:keys [peer-config env-config]} (utils/read-config!)
        peer-group (onyx.api/start-peer-group peer-config)
        env (onyx.api/start-env env-config)
        peers (onyx.api/start-peers n-peers peer-group)]
    (println "Connecting to Zookeeper: " (:zookeeper/address peer-config))
    (utils/add-shutdown-hook! (fn []
                                (onyx.api/shutdown-peers peers)
                                (onyx.api/shutdown-peer-group peer-group)
                                (shutdown-agents)))
    (println "Started peers. Blocking forever.")
    (utils/block-forever!)))

(ns desdemona.launcher.launch-prod-peers
  (:require [desdemona.launcher.utils :as utils]
            [taoensso.timbre :as t]
            [onyx.plugin.kafka]
            [onyx.plugin.sql]
            [onyx.plugin.core-async]
            [onyx.plugin.seq]
            [desdemona.functions.sample-functions]
            [desdemona.jobs.sample-submit-job]
            [desdemona.lifecycles.sample-lifecycle])
  (:gen-class))

(defn -main [n & args]
  (let [n-peers (Integer/parseInt n)
        {:keys [peer-config env-config]} (utils/read-config!)
        peer-group (onyx.api/start-peer-group peer-config)
        _ (onyx.api/start-env env-config)
        peers (onyx.api/start-peers n-peers peer-group)]
    (println "Connecting to Zookeeper: " (:zookeeper/address peer-config))
    (utils/add-shutdown-hook! (fn []
                                (onyx.api/shutdown-peers peers)
                                (onyx.api/shutdown-peer-group peer-group)
                                (shutdown-agents)))
    (println "Started peers. Blocking forever.")
    (utils/block-forever!)))

Clarify that env isn't used

Clarify that env isn't used


(ns codewars.runners.groovy-test
  (:require [clojure.test :refer :all]
            [clojure.test.junit :refer [with-junit-output]]
            [cheshire.core :as json]
            [codewars.core :refer [-main] :as core]
            [codewars.utils :refer [with-java-out-str]]
  )

(deftest groovy-code-only
  (testing "-main can handle a groovy code with no fixture"
    (with-in-str
      (json/generate-string
       {:language "groovy"
        :code "1 + 1"})
      (is (= 2 (-main)))
    )
  )
)

(deftest groovy-java-out
  (testing "-main can handle a groovy code with no setup code but no fixture"
    (with-in-str
      (json/generate-string
       {:language "groovy"
        :code "print 'Hello Groovy!'"}
      )
      (is (= "Hello Groovy!" (with-java-out-str (-main))) )
    )
  )
)

(deftest groovy-java-fixt
  (testing "-main can handle a groovy code with no setup code but no fixture"
    (with-in-str
      (json/generate-string
       {:language "groovy"
        :code "class Greeter { static greet = { name -> 'Hello '+name } }"
        :fixture "class MyTestCase extends GroovyTestCase { void testGreet(){def result = Greeter.greet('Ruslan');assert result == 'Hello Ruslan';println 'Lets sum'}}"}
      )
      ;(with-java-out-str (run-all-tests))

     (let [test-out-string (with-java-out-str (-main))]
        (is (.contains test-out-string "<DESCRIBE::>testGreet(MyTestCase)"))
        (is (.contains test-out-string "Lets sum"))
        (is (.contains test-out-string "<PASSED::>Test Passed<:LF:>"))
     )

    )
  )
)

(ns codewars.runners.groovy-test
  (:require [clojure.test :refer :all]
            [cheshire.core :as json]
            [codewars.core :refer [-main] :as core]
            [codewars.utils :refer [with-java-out-str]]))

(deftest groovy-code-only
  (testing "-main can handle a groovy code with no fixture"
    (with-in-str
      (json/generate-string
       {:language "groovy"
        :code "1 + 1"})
      (is (= 2 (-main))))))

(deftest groovy-java-out
  (testing "-main can handle a groovy code with no setup code but no fixture"
    (with-in-str
      (json/generate-string
       {:language "groovy"
        :code "print 'Hello Groovy!'"})
      (is (= "Hello Groovy!" (with-java-out-str (-main)))))))

Revert "downgrade groovy runner version"


(ns herder.web.handler
  (:require
   [compojure.route :as route]
   [compojure.core :refer [defroutes GET POST PUT context] :as compojure]
   [ring.middleware.defaults :refer [wrap-defaults api-defaults]]
   [ring.util.response :refer [file-response content-type]]
   [ring.middleware.json :refer [wrap-json-response]]
   [ring.util.anti-forgery :refer [anti-forgery-field]]
   [korma.core :as d]
   [korma.db :as kd]
   [reloaded.repl :refer [system]]

   [herder.web.conventions :refer [convention-routes]]))

(defn index [params]
  (content-type (file-response "resources/herder/templates/index.html") "text/html"))

(defroutes core-routes
  (GET "/" [] index)
  (route/files "/resources/public/" {:root "target/resources/public/"})
  (route/not-found "Not found"))

(def routes (compojure/routes convention-routes core-routes))

(defn wrap-db [f]
  (fn [req]
    (if-let [sys-db (:db system)]
      (kd/with-db sys-db
        (f req))
      (f req))))

(def app
  (-> #'routes
      (wrap-defaults (assoc-in api-defaults [:params :nested] true))
      wrap-db
      wrap-json-response))

(ns herder.web.handler
  (:require
   [compojure.route :as route]
   [compojure.core :refer [defroutes GET POST PUT context] :as compojure]
   [ring.middleware.defaults :refer [wrap-defaults api-defaults]]
   [ring.util.response :refer [file-response content-type]]
   [ring.middleware.json :refer [wrap-json-response]]
   [ring.util.anti-forgery :refer [anti-forgery-field]]
   [korma.core :as d]
   [korma.db :as kd]
   [reloaded.repl :refer [system]]

   [herder.web.conventions :refer [convention-routes]]))

(defn index [params]
  (content-type (file-response "resources/herder/templates/index.html") "text/html"))

(defroutes core-routes
  (GET "/" [] index)
  (route/files "/resources/public/" {:root "target/resources/public/"})
  (route/not-found "Not found"))

(def routes (compojure/routes convention-routes core-routes))

(defn wrap-db [f]
  (fn [req]
    (if-let [sys-db-spec (:db-spec (:db system))]
      (kd/with-db (kd/create-db sys-db-spec)
        (f req))
      (f req))))

(def app
  (-> #'routes
      (wrap-defaults (assoc-in api-defaults [:params :nested] true))
      wrap-db
      wrap-json-response))

Make db connection actually work each time


(defn hello
  ([] "Hello World!")
  ([a] (str "Hello, you silly " a "."))
  ([a & more] (str "Hello to this group: "
                   (apply str
                          (interpose ", " (concat (list a) more)))
                   "!")))

(defmulti diet (fn [x] (:eater x)))
(defmethod diet :herbivore [a] __)
(defmethod diet :carnivore [a] __)
(defmethod diet :default [a] __)

(meditations
  "Some functions can be used in different ways - with no arguments"
  (= __ (hello))

  "With one argument"
  (= __ (hello "world"))

  "Or with many arguments"
  (= __
     (hello "Peter" "Paul" "Mary"))

  "Multimethods allow more complex dispatching"
  (= "Bambi eats veggies."
     (diet {:species "deer" :name "Bambi" :age 1 :eater :herbivore}))

  "Different methods are used depending on the dispatch function result"
  (= "Simba eats animals."
     (diet {:species "lion" :name "Simba" :age 1 :eater :carnivore}))

  "You may use a default method when no others match"
  (= "I don't know what Rich Hickey eats."
     (diet {:name "Rich Hickey"})))

(defn hello
  ([] "Hello World!")
  ([a] (str "Hello, you silly " a "."))
  ([a & more] (str "Hello to this group: "
                   (apply str
                          (interpose ", " (concat (list a) more)))
                   "!")))

(defmulti diet (fn [x] (:eater x)))
(defmethod diet :herbivore [a] (str (:name a) " eats veggies."))
(defmethod diet :carnivore [a] (str (:name a) " eats animals."))
(defmethod diet :default [a] (str "I don't know what " (:name a) " eats."))

(meditations
  "Some functions can be used in different ways - with no arguments"
  (= "Hello World!" (hello))

  "With one argument"
  (= "Hello, you silly world." (hello "world"))

  "Or with many arguments"
  (= "Hello to this group: Peter, Paul, Mary!"
     (hello "Peter" "Paul" "Mary"))

  "Multimethods allow more complex dispatching"
  (= "Bambi eats veggies."
     (diet {:species "deer" :name "Bambi" :age 1 :eater :herbivore}))

  "Different methods are used depending on the dispatch function result"
  (= "Simba eats animals."
     (diet {:species "lion" :name "Simba" :age 1 :eater :carnivore}))

  "You may use a default method when no others match"
  (= "I don't know what Rich Hickey eats."
     (diet {:name "Rich Hickey"})))

Complete runtime polymorphism koans test


#!/usr/bin/env boot
(set-env!
 :dependencies '[[org.clojure/clojure "1.7.0-RC1" :scope "provided"]
                 [funcool/catacumba "0.2.0-SNAPSHOT"]])

(require '[catacumba.core :as ct])

(defn home-page
  [content]
  "Hello world")

(def app
  (ct/routes [[:get home-page]]))

(defn -main
  "The main entry point to your application."
  [& args]
  (let [lt (java.util.concurrent.CountDownLatch. 1)]
    (ct/run-server app {:port 5050 :basedir "."})
    (.await lt)))

#!/usr/bin/env boot
(set-env!
 :dependencies '[[org.clojure/clojure "1.7.0-RC1"]
                 [funcool/catacumba "0.2.0"]])

(require '[catacumba.core :as ct])

(defn home-page
  [content]
  "Hello world")

(def app
  (ct/routes [[:get home-page]]))

(defn -main
  "The main entry point to your application."
  [& args]
  (let [lt (java.util.concurrent.CountDownLatch. 1)]
    (ct/run-server app {:port 5050 :basedir "."})
    (.await lt)))

Update catacumba version on single-file example.


;-
; Copyright 2011 (c) Meikel Brandmeyer.
; All rights reserved.
;
; Permission is hereby granted, free of charge, to any person obtaining a copy
; of this software and associated documentation files (the "Software"), to deal
; in the Software without restriction, including without limitation the rights
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
; copies of the Software, and to permit persons to whom the Software is
; furnished to do so, subject to the following conditions:
;
; The above copyright notice and this permission notice shall be included in
; all copies or substantial portions of the Software.
;
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
; THE SOFTWARE.

(ns vimclojure.core)

(defn init-server
  []
  ; Check for doc macro. 1.2 in c.core, 1.3 in c.repl
  (when-not (ns-resolve 'clojure.core 'doc)
    (binding [*ns* *ns*]
      (in-ns 'user)
      (refer-clojure)
      (use 'clojure.repl))))

;-
; Copyright 2011 (c) Meikel Brandmeyer.
; All rights reserved.
;
; Permission is hereby granted, free of charge, to any person obtaining a copy
; of this software and associated documentation files (the "Software"), to deal
; in the Software without restriction, including without limitation the rights
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
; copies of the Software, and to permit persons to whom the Software is
; furnished to do so, subject to the following conditions:
;
; The above copyright notice and this permission notice shall be included in
; all copies or substantial portions of the Software.
;
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
; THE SOFTWARE.

(ns vimclojure.core)

(defn init-server
  []
  (binding [*ns* *ns*]
    (in-ns 'user)
    (refer-clojure)
    ; Check for doc macro. 1.2 in c.core, 1.3 in c.repl
    (when-not (ns-resolve 'clojure.core 'doc)
      (use 'clojure.repl))
    (when (io/resource "user.clj")
      (load "user"))))

Load user.clj if present on classpath

Load user.clj if present on classpath