;; Copyright © 2014 JUXT LTD.

;; We call this project modular to make the invocation: lein new modular appname
(defproject modular/lein-template "0.6.13"
  :description "Leiningen template for a full-featured component based app using modular extensions."
  :license {:name "The MIT License"
            :url "http://opensource.org/licenses/MIT"}
  :dependencies [[org.clojure/clojure "1.7.0-alpha4"]
                 ;; EDN reader with location metadata
                 [org.clojure/tools.reader "0.8.3"]
                 [org.clojure/tools.logging "0.2.6"]]
  :eval-in-leiningen true)

;; Copyright © 2014 JUXT LTD.

;; We call this project modular to make the invocation: lein new modular appname
(defproject modular/lein-template "0.6.13"
  :description "Leiningen template for a full-featured component based app using modular extensions."
  :url "http://modularity.org/"
  :license {:name "The MIT License"
            :url "http://opensource.org/licenses/MIT"}
  :dependencies [[org.clojure/clojure "1.7.0-alpha4"]
                 ;; EDN reader with location metadata
                 [org.clojure/tools.reader "0.8.3"]
                 [org.clojure/tools.logging "0.2.6"]]
  :eval-in-leiningen true)

Add url to silence Leiningen

Add url to silence Leiningen


(ns robot-kata.server-test
  (:require [clojure.test :refer :all]
            [robot-kata.server :refer :all]))

(deftest robot-kata-routes-test
         (testing "Routes work as expected"
                  (testing "Default route"
                           (let [resp (robot-kata-routes {:request-method :get :uri "/"})]
                             (is (= 302 (:status resp)) "Default route redirects")
                             (is (= "/robot-kata.html" ((:headers resp) "Location")) "Default route redirects to '/robot-kata.html'") ) )
                  (testing "Resource route"
                           (let [resp (robot-kata-routes {:request-method :get :uri "/robot-kata.html" :headers {"if-modified-since" "Sat, 29 Oct 1994 19:43:31 GMT"}})]
                             (is (= 200 (:status resp)) "GET of '/robot-kata.html' returns 200 status")
                             (is (= "text/html" ((:headers resp) "Content-Type")) "GET of '/robot-kata.html' returns content type 'text/html'")
                             (is (> ((:headers resp) "Content-Length") 0) "GET of '/robot-kata.html' returns content of length > 0") ) )
                  (testing "Page not found"
                           (is (= 0 1) "Implement page not found tests!") ) ) )

(ns robot-kata.server-test
  (:require [clojure.test :refer :all]
            [robot-kata.server :refer :all]))

(deftest robot-kata-routes-test
         (testing "Routes work as expected"
                  (testing "Default route"
                           (let [resp (robot-kata-routes {:request-method :get :uri "/"})]
                             (is (= 302 (:status resp)) "Default route redirects")
                             (is (= "/robot-kata.html" ((:headers resp) "Location")) "Default route redirects to '/robot-kata.html'") ) )
                  (testing "Resource route"
                           (let [resp (robot-kata-routes {:request-method :get :uri "/robot-kata.html" :headers {"if-modified-since" "Sat, 29 Oct 1994 19:43:31 GMT"}})]
                             (is (= 200 (:status resp)) "GET of '/robot-kata.html' returns 200 status")
                             (is (= "text/html" ((:headers resp) "Content-Type")) "GET of '/robot-kata.html' returns content type 'text/html'")
                             (is (> (Integer. ((:headers resp) "Content-Length")) 0) "GET of '/robot-kata.html' returns content of length > 0") ) )
                  (testing "Page not found"
                           (is (= 0 1) "Implement page not found tests!") ) ) )

Fix bug in robot-kata-routes test

Fix bug in robot-kata-routes test


(ns time-tracker.core
  (:gen-class)
  (:require [time-tracker.web.service :as web-service]
            [time-tracker.db :as db]
            [time-tracker.logging :as log]
            [org.httpkit.server :as httpkit]
            [time-tracker.util :as util]))

(defn init! []
  (log/configure-logging!)
  (db/init-db!))

(defn teardown! []
  (log/teardown-logging!))

(defn start-server!
  ([] (start-server! (web-service/app)))
  ([app-handler]
   (init!)
   (log/info {:event ::server-start})
   (let [stop-fn (httpkit/run-server app-handler
                                     {:port (Integer/parseInt (util/from-config :port))})]
     (fn []
       (stop-fn)
       (log/info {:event ::server-stop})
       (teardown!)))))

(defn -main
  [& args]
  (start-server!))

(ns time-tracker.core
  (:gen-class)
  (:require [org.httpkit.server :as httpkit]
            [time-tracker.migration :refer [migrate-db rollback-db]]
            [time-tracker.db :as db]
            [time-tracker.logging :as log]
            [time-tracker.util :as util]
            [time-tracker.web.service :as web-service]))

(defn init! []
  (log/configure-logging!)
  (db/init-db!))

(defn teardown! []
  (log/teardown-logging!))

(defn start-server!
  ([] (start-server! (web-service/app)))
  ([app-handler]
   (init!)
   (log/info {:event ::server-start})
   (let [stop-fn (httpkit/run-server app-handler
                                     {:port (Integer/parseInt (util/from-config :port))})]
     (fn []
       (stop-fn)
       (log/info {:event ::server-stop})
       (teardown!)))))

(defn -main
  [& args]
  (condp = (first args)
    "migrate"  (migrate-db)
    "rollback" (rollback-db)
    (start-server!)))

Allow uberjar to run migration/rollback

Allow uberjar to run migration/rollback


(defproject kukui "0.1.0-pre"
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/clojurescript "0.0-2227"]]
  :profiles {:dev {:plugins [[lein-cljsbuild "1.0.3"]
                             [com.cemerick/clojurescript.test "0.3.1"]]
                   :hooks        [leiningen.cljsbuild]}}
  :cljsbuild {:builds
              {:whitespace {:source-paths ["test"]
                            :compiler
                            {:output-to "target/cljsbuild/whitespace/kukui.js"
                             :optimizations :whitespace
                             :pretty-print true}}
               :advanced {:source-paths ["test"]
                          :compiler
                          {:output-to "target/cljsbuild/advanced/kukui.js"
                           :pretty-print  false
                           :optimizations :advanced}}}
              :test-commands {"whitespace" ["phantomjs" :runner
                                            "target/cljsbuild/whitespace/kukui.js"]
                              "advanced" ["phantomjs" :runner
                                          "target/cljsbuild/advanced/kukui.js"]}})

(defproject kukui "0.1.0-pre"
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/clojurescript "0.0-2227"]]
  :profiles {:dev {:plugins [[lein-cljsbuild "1.0.3"]
                             [com.cemerick/clojurescript.test "0.3.1"]]
                   :hooks        [leiningen.cljsbuild]}}
  :cljsbuild {:builds
              {:whitespace {:source-paths ["test"] ;; can't include src because of LT
                            :compiler
                            {:output-to "target/cljsbuild/whitespace/kukui.js"
                             :optimizations :whitespace
                             :pretty-print true}}
               ;; avoid advanced recompilation when testing
               ;; :advanced {:source-paths ["src" "test"]
               ;;            :compiler
               ;;            {:output-to "target/cljsbuild/advanced/kukui.js"
               ;;             :pretty-print  false
               ;;             :optimizations :advanced}}
               }
              :test-commands {"whitespace" ["phantomjs" :runner
                                            "target/cljsbuild/whitespace/kukui.js"]
                              "advanced" ["phantomjs" :runner
                                          "target/cljsbuild/advanced/kukui.js"]}})

Disable advanced target to speed up "lein cljsbuild test whitespace"


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

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

Update compojure from 1.3.3 to 1.4.0

Update compojure from 1.3.3 to 1.4.0


(ns metrics.counters
  (:use [metrics.utils :only (metric-name)])
  (:import (com.yammer.metrics Metrics))
  (:import (com.yammer.metrics.core Counter)))

; Create ----------------------------------------------------------------------
(defn counter
  "Create and return a new Counter metric with the given title.

  Title can be a plain string like \"foo\" or a vector of three strings (group,
  type, and title) like:

      [\"myapp\" \"webserver\" \"connections\"]

  "
  [title]
  (Metrics/newCounter (metric-name title)))

(defmacro defcounter
  "Define a new Counter metric with a given title, or group, type and title."
  ([title]
     `(def ~title (counter ~(str title))))

  ([group type title]
     `(def ~title (counter ~(vec (map str [group type title]))))))

; Read ------------------------------------------------------------------------
(defn value
  "Return the current value of the counter."
  [^Counter c]
  (.count c))

; Write -----------------------------------------------------------------------
(defn inc!
  "Increment the counter by the given amount (or 1 if not specified)."
  ([^Counter c] (inc! c 1))
  ([^Counter c n]
   (.inc c n)
   c))

(defn dec!
  "Decrement the counter by the given amount (or 1 if not specified)."
  ([^Counter c] (dec! c 1))
  ([^Counter c n]
   (.dec c n)
   c))

(defn clear!
  "Clear the given counter, resetting its value to zero."
  [^Counter c]
  (.clear c)
  c)

Make some indentation more Clojurey.

Make some indentation more Clojurey.


(ns telegenic.core
  (:import [org.jcodec.api FrameGrab]))

(ns telegenic.core
  (:import [org.jcodec.api FrameGrab])
  (:import [java.io File])
  (:import [java.awt.image BufferedImage])
  (:import [org.jcodec.common.model Picture])
  )

(set! *warn-on-reflection* true)
(set! *unchecked-math* true)

(defprotocol PGetFrame
  (get-frame [video frame-number]))

(extend-protocol PGetFrame
  String
    (get-frame [s frame-number] (get-frame (File. s) frame-number))
  File
    (get-frame [file frame-number]
      (let [^Picture nf (FrameGrab/getNativeFrame file (int frame-number))
            bi (.toBufferedImage nf)]
        bi)))

Work on frame grab code

Work on frame grab code


(defproject asystant "0.1.1-SNAPSHOT"
  :description "A simple, flexible helper for building modular systems with clojure/core.async"
  :url "https://github.com/monteithpj/asystant"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/core.async "0.1.346.0-17112a-alpha"]
                 [org.clojure/core.match "0.3.0-alpha4"]
                 [aysylu/loom "0.5.4"]]
  :aliases
  {"repl" ["with-profile" "+test" "repl"]}
  :profiles
  {:test
   {:dependencies [[org.clojure/test.check "0.8.2"]
                   [com.gfredericks/test.chuck "0.2.0"]
                   [com.velisco/herbert "0.7.0-alpha1"]]}}
  :plugins [[codox "0.8.15"]]
  :codox {:src-dir-uri "https://github.com/monteithpj/asystant/blob/master"})

(defproject asystant "0.1.1-SNAPSHOT"
  :description "A simple, flexible helper for building modular systems with clojure/core.async"
  :url "https://github.com/monteithpj/asystant"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/core.async "0.1.346.0-17112a-alpha"]
                 [org.clojure/core.match "0.3.0-alpha4"]]
  :aliases
  {"repl" ["with-profile" "+test" "repl"]}
  :profiles
  {:test
   {:dependencies [[org.clojure/test.check "0.8.2"]
                   [com.gfredericks/test.chuck "0.2.0"]
                   [com.velisco/herbert "0.7.0-alpha1"]
                   [aysylu/loom "0.5.4"]]}}
  :plugins [[codox "0.8.15"]]
  :codox {:src-dir-uri "https://github.com/monteithpj/asystant/blob/master"})

Move loom dependency to tests

Move loom dependency to tests


(defproject org.onyxplatform/onyx-datomic "0.7.2.0"
  :description "Onyx plugin for Datomic"
  :url "https://github.com/MichaelDrogalis/onyx-datomic"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}}
                 [org.onyxplatform/onyx "0.7.3-20150901_140443-g6e4750b"]]
  :profiles {:dev {:dependencies [[midje "1.7.0"]
                                  [com.datomic/datomic-free "0.9.5153"]]
                   :plugins [[lein-midje "3.1.3"]]}
             :circle-ci {:jvm-opts ["-Xmx4g"]}})

(defproject org.onyxplatform/onyx-datomic "0.7.2.0"
  :description "Onyx plugin for Datomic"
  :url "https://github.com/MichaelDrogalis/onyx-datomic"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}}
                 [org.onyxplatform/onyx "0.7.3-20150901_142736-gd0de107"]]
  :profiles {:dev {:dependencies [[midje "1.7.0"]
                                  [com.datomic/datomic-free "0.9.5153"]]
                   :plugins [[lein-midje "3.1.3"]]}
             :circle-ci {:jvm-opts ["-Xmx4g"]}})

Update dependency org.onyxplatform/onyx to version 0.7.3-20150901_142736-gd0de107.

Automatic commit by lein-unison.


(defproject com.draines/postal "1.12-SNAPSHOT"
  :repositories {"java.net" "http://download.java.net/maven/2"}
  :dependencies [[commons-codec "1.9"]
                 [javax.mail/mail "1.4.4"
                  :exclusions [javax.activation/activation]]]
  :profiles {:dev {:dependencies [[org.clojure/clojure "1.5.1"]]}
             :1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]}
             :1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}})

(defproject com.draines/postal "1.12-SNAPSHOT"
  :description "JavaMail on Clojure"
  :url "https://github.com/drewr/postal"
  :license {:name "MIT"
            :url "http://en.wikipedia.org/wiki/MIT_License"
            :distribution :repo
            :comments "Use at your own risk"}
  :repositories {"java.net" "http://download.java.net/maven/2"}
  :dependencies [[commons-codec "1.9"]
                 [javax.mail/mail "1.4.4"
                  :exclusions [javax.activation/activation]]]
  :profiles {:dev {:dependencies [[org.clojure/clojure "1.5.1"]]}
             :1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]}
             :1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}})

Add metadata to appease clojars

Add metadata to appease clojars

Conflicts:
	project.clj


(defproject org.onyxplatform/onyx-datomic "0.7.4"
  :description "Onyx plugin for Datomic"
  :url "https://github.com/MichaelDrogalis/onyx-datomic"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}}
                 [org.onyxplatform/onyx "0.7.4-20150916_205458-gf33df5b"]]
  :profiles {:dev {:dependencies [[midje "1.7.0"]
                                  [com.datomic/datomic-free "0.9.5153"]]
                   :plugins [[lein-midje "3.1.3"]
                             [lein-set-version "0.4.1"]
                             [lein-pprint "1.1.1"]]}
             :circle-ci {:jvm-opts ["-Xmx4g"]}})

(defproject org.onyxplatform/onyx-datomic "0.7.5-SNAPSHOT"
  :description "Onyx plugin for Datomic"
  :url "https://github.com/MichaelDrogalis/onyx-datomic"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :repositories {"snapshots" {:url "https://clojars.org/repo"
                              :username :env
                              :password :env
                              :sign-releases false}
                 "releases" {:url "https://clojars.org/repo"
                             :username :env
                             :password :env
                             :sign-releases false}}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 ^{:voom {:repo "git@github.com:onyx-platform/onyx.git" :branch "master"}}
                 [org.onyxplatform/onyx "0.7.4-20150916_205458-gf33df5b"]]
  :profiles {:dev {:dependencies [[midje "1.7.0"]
                                  [com.datomic/datomic-free "0.9.5153"]]
                   :plugins [[lein-midje "3.1.3"]
                             [lein-set-version "0.4.1"]
                             [lein-pprint "1.1.1"]]}
             :circle-ci {:jvm-opts ["-Xmx4g"]}})

Prepare for next release cycle.

Prepare for next release cycle.


(defproject se.haleby/stub-http "0.2.8"
  :description "A client library agonistic way to stub HTTP responses"
  :url "https://github.com/johanhaleby/stub-http"
  :license {:name         "MIT License"
            :url          "http://www.opensource.org/licenses/mit-license.php"
            :distribution :repo}
  :lein-release {:deploy-via :clojars}
  :min-lein-version "2.0.0"
  :dependencies [[org.nanohttpd/nanohttpd "2.3.1"]]
  :profiles {:dev {:dependencies [[org.clojure/clojure "1.8.0"]
                                  [cheshire "5.5.0"]
                                  [clj-http-lite "0.3.0"]
                                  ;; needed for java>=11:
                                  [javax.xml.bind/jaxb-api "2.3.1"]
                                  ;; needed for clj-release
                                  [org.clojure/clojure-contrib "1.20"]]}}
  :repositories [["releases" {:url "http://clojars.org/repo" :creds :gpg}]]
  :plugins [[lein-codox "0.9.4"]])

(defproject se.haleby/stub-http "0.2.8"
  :description "A client library agonistic way to stub HTTP responses"
  :url "https://github.com/johanhaleby/stub-http"
  :license {:name         "MIT License"
            :url          "http://www.opensource.org/licenses/mit-license.php"
            :distribution :repo}
  :lein-release {:deploy-via :clojars}
  :min-lein-version "2.0.0"
  :dependencies [[org.nanohttpd/nanohttpd "2.3.1"]]
  :profiles {:dev {:dependencies [[org.clojure/clojure "1.8.0"]
                                  [cheshire "5.5.0"]
                                  [clj-http-lite "0.3.0"]
                                  ;; needed for java>=11:
                                  [javax.xml.bind/jaxb-api "2.3.1"]]}}
  :repositories [["releases" {:url "http://clojars.org/repo" :creds :gpg}]]
  :plugins [[lein-codox "0.9.4"]])

Revert "Trying to add contrib dep to make lein-release work"

This reverts commit 73a2a0dfcc2468a48c352c5a1ca4ba4392d96301.


(defproject cadence "0.2.0-SNAPSHOT"
  :description "Use pattern recognition to match users with Cadence.js
               output."
  :min-lein-version "2.0.0"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.3.0"]
                 [net.tanesha.recaptcha4j/recaptcha4j "0.0.7"]
                 [com.novemberain/monger "1.0.0-beta4"]
                 ;[clauth "1.0.0-rc1"]
                 [amalloy/ring-gzip-middleware "0.1.1"]
                 [fuziontech/ring-json-params "0.2.0"]
                 [com.cemerick/friend "0.0.8"]
                 [svm-clj "0.0.1-SNAPSHOT"]
                 ;[ring-middleware-format "0.1.1"]
                 ;[noir-cljs "0.2.5"]
                 [noir "1.2.2"]]
  :main cadence.server)

(defproject cadence "0.2.0-SNAPSHOT"
  :description "Use pattern recognition to match users with Cadence.js
               output."
  :min-lein-version "2.0.0"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.3.0"]
                 [net.tanesha.recaptcha4j/recaptcha4j "0.0.7"]
                 [com.novemberain/monger "1.0.0-beta4"]
                 ;[clauth "1.0.0-rc1"]
                 [amalloy/ring-gzip-middleware "0.1.1"]
                 [fuziontech/ring-json-params "0.2.0"]
                 [com.cemerick/friend "0.0.8"]
                 ;[com.ml/libsvm "2.89"]
                 ;[svm-clj "0.0.1-SNAPSHOT"]
                 ;[edu.berkely.compbio/jlibsvm "0.902"]
                 ;[clj-ml "0.0.3-SNAPSHOT"]
                 [com.leadtune/clj-ml "0.2.1"]
                 ;[ring-middleware-format "0.1.1"]
                 ;[noir-cljs "0.2.5"]
                 [noir "1.2.2"]]
  :main cadence.server)

Add clj-ml dependency for patrec.

Add clj-ml dependency for patrec.


(ns hyphen-keeper.util
  (:require [clojure.string :as string]))

(defn hyphenation-valid?
  "Return true if the `hyphenation` is not blank, is equal to
  `word` (modulo the hyphenation marks) and contains at least one of
  the letters 'a-z', '\u00DF-\u00FF' or '-'. Also each '-' in the
  hyphenation should be surrounded by letters."
  [hyphenation word]
  (and (not (string/blank? hyphenation))
       (= word (string/replace hyphenation "-" ""))
       (not (string/starts-with? hyphenation "-"))
       (not (string/ends-with? hyphenation "-"))
       (not (string/includes? hyphenation "--"))
       ;; only allow chars in the unicode range of Basic Latin (a-z),
       ;; Latin-1 Supplement (the printable chars in 00C0-00FF) and
       ;; Latin Extended-A (0100—017F), see
       ;; https://unicode-table.com/en/blocks/basic-latin,
       ;; https://unicode-table.com/en/blocks/latin-1-supplement and
       ;; https://unicode-table.com/en/blocks/latin-extended-a

       ;; Exclude Latin Small Letter Dotless I (0131) because it seems
       ;; to cause libhyphen to crash
       (some? (re-matches #"[a-z\xC0-\xFF\u0100-\u0130\u0132-\u017F-]+" hyphenation))))

(ns hyphen-keeper.util
  (:require [clojure.string :as string]))

(defn hyphenation-valid?
  "Return true if the `hyphenation` is not blank, is equal to
  `word` (modulo the hyphenation marks) and contains at least one of
  the letters 'a-z', '\u00DF-\u00FF' or '-'. Also each '-' in the
  hyphenation should be surrounded by letters."
  [hyphenation word]
  (and (not (string/blank? hyphenation))
       (= word (string/replace hyphenation "-" ""))
       (not (string/starts-with? hyphenation "-"))
       (not (string/ends-with? hyphenation "-"))
       (not (string/includes? hyphenation "--"))
       (some? (re-matches #"[a-z\xC0-\xFF\u0100-\u017F-]+" hyphenation))))

Revert "Exclude Latin Small Letter Dotless I from valid hyphenations"

This reverts commit a25365bd10dac9aef84ea6bc948d460242ace13f.

They want Latin Small Letter Dotless I after all.


(ns desdemona.launcher.utils
  (:require
   [clojure.core.async :as a]))

(defn block-forever!
  []
  (a/<!! (a/chan)))

(ns desdemona.launcher.utils
  (:require
   [clojure.core.async :as a]))

(defn block-forever!
  "Blocks forever."
  []
  (a/<!! (a/chan)))

Add a docstring for block-forever!

Add a docstring for block-forever!


;; Copyright © 2014 JUXT LTD.

(defproject juxt.modular/clostache "0.6.0"
  :description "A modular extension that provides a Clostache templater for juxt.modular/template"
  :url "https://github.com/juxt/modular/tree/master/modules/clostache"
  :license {:name "The MIT License"
            :url "http://opensource.org/licenses/MIT"}
  :dependencies [[com.stuartsierra/component "0.2.1"]
                 [de.ubercode.clostache/clostache "1.3.1"]
                 [juxt.modular/template "0.6.0"]
                 ])

;; Copyright © 2014 JUXT LTD.

(defproject juxt.modular/clostache "0.6.1"
  :description "A modular extension that provides a Clostache templater for juxt.modular/template"
  :url "https://github.com/juxt/modular/tree/master/modules/clostache"
  :license {:name "The MIT License"
            :url "http://opensource.org/licenses/MIT"}
  :dependencies [[com.stuartsierra/component "0.2.2"]
                 [de.ubercode.clostache/clostache "1.4.0"]
                 [juxt.modular/template "0.6.2"]
                 ])

Update library dependencies and release clostache


(ns oc.storage.util.sort)

(defn- activity-sort
  "
  Compare function to sort 2 entries and/or activity by their `created-at` or `published-at` order respectively,
  in the order (:asc or :desc) provided.
  "
  [order x y]
  (let [order-flip (if (= order :desc) -1 1)]
    (* order-flip (compare (or (:published-at x) (:created-at x))
                           (or (:published-at y) (:created-at y))))))

(defn sort-activity
  "Given a set of entries, return up to the default limit of them, intermixed and sorted."
  [entries order limit]
  (take limit (sort (partial activity-sort order) entries)))

(ns oc.storage.util.sort
  (:require [clojure.pprint :as pp]
            [clj-time.core :as t]
            [clj-time.format :as f]))

(defn- max-comment-timestamp
  "Return a map {entry-uuid most-recent-comment-timestap} excluding the user authored comments"
  [user-id entry]
  (let [all-comments (filterv #(and (:body %) (not= (-> % :author :user-id) user-id)) (:interactions entry))
        sorted-comments (sort-by :updated-at all-comments)]
    (when (seq sorted-comments)
      (hash-map (:uuid entry) (-> sorted-comments last :updated-at)))))

(defn sort-activity
  "Given a set of entries, return up to the default limit of them, intermixed and sorted."
  [entries sorting order limit user-id]
  (let [all-published-at (apply merge (map #(hash-map (:uuid %) (:published-at %)) entries))
        sorting-by-most-recent? (= sorting :most-recent)
        all-comments (if sorting-by-most-recent?
                       (apply merge (remove nil? (map (partial max-comment-timestamp user-id) entries)))
                       {})
        to-sort-map (merge all-published-at all-comments)
        order-flip (if (= order :desc) -1 1)
        sorted-map (into (sorted-map-by (fn [key1 key2]
                          (* order-flip (compare [(get to-sort-map key1) key1]
                                                 [(get to-sort-map key2) key2]))))
                    to-sort-map)
        limited-uuids (take limit (keys sorted-map))]
    (remove nil? (map (fn [entry-uuid] (first (filter #(= (:uuid %) entry-uuid) entries))) limited-uuids))))

Sort posts by updated-at or the most recent comment updated-at, return only the first tot posts.


{:user {:plugins [[lein-marginalia "0.7.1"]
                  [cider/cider-nrepl "0.7.0-SNAPSHOT"]
                  [lein-try "0.4.1"]
                  [lein-clojars "0.9.1"]
                  [lein-ancient  "0.5.5"]
                  [lein-pprint "1.1.1"]]
        :dependencies [[com.gfredericks/clj-usage-graph "0.1.3"]] }}

{:user {:plugins [[lein-marginalia "0.7.1"]
                  [cider/cider-nrepl "0.7.0-SNAPSHOT"]
                  [lein-try "0.4.1"]
                  [lein-clojars "0.9.1"]
                  [lein-ancient  "0.5.5"]
                  [lein-exec "0.3.4"]
                  [lein-pprint "1.1.1"]]
        :dependencies [[com.gfredericks/clj-usage-graph "0.1.3"]
                       [org.clojure/tools.trace "0.7.8"]]}}

Add more stuff to my .lein.

Add more stuff to my .lein.


(ns app.analysis
  "GitHub releases URL analysis"
  (:require
    [taoensso.timbre :as timbre :refer-macros [info]]))

(defn get-os
  [url]
  (cond
    (boolean (re-find #"windows" url)) "Windows"
    (boolean (re-find #"linux" url)) "Linux"
    (boolean (re-find #".dmg" url)) "Mac OS X"
    :else "Other"))

(defn get-word-size
  [url]
  (cond
    (boolean (re-find #"x86_64" url)) "64-bit"
    (boolean (re-find #"x64" url)) "64-bit"
    (boolean (re-find #"x86" url)) "32-bit"
    :else ""))

(defn get-file-type
  [url]
  (cond
    (boolean (re-find #".zip" url)) "Portable"
    (boolean (re-find #".tar.gz" url)) "Portable"
    (boolean (re-find #".dmg" url)) "Disk Image"
    :else "Installer"))

(defn analyze-download-url
  [asset-info]
  (let [{url :browser-download-url} asset-info]
    {:os (get-os url) :word-size (get-word-size url)
     :file-type (get-file-type url) :url url}))

(defn build-download-map
  [asset-info-vector]
  (group-by :os (map analyze-download-url asset-info-vector)))

(ns app.analysis
  "GitHub releases URL analysis"
  (:require
    [taoensso.timbre :as timbre :refer-macros [info]]))

(defn get-os
  [url]
  (cond
    (boolean (re-find #"windows" url)) "Windows"
    (boolean (re-find #"linux" url)) "Linux"
    (boolean (re-find #"mac|.dmg" url)) "Mac OS X"
    :else "Other"))

(defn get-word-size
  [url]
  (cond
    (boolean (re-find #"x86_64" url)) "64-bit"
    (boolean (re-find #"x64" url)) "64-bit"
    (boolean (re-find #"x86" url)) "32-bit"
    :else ""))

(defn get-file-type
  [url]
  (cond
    (boolean (re-find #".zip" url)) "Portable"
    (boolean (re-find #".tar.gz" url)) "Portable"
    (boolean (re-find #".dmg" url)) "Disk Image"
    :else "Installer"))

(defn analyze-download-url
  [asset-info]
  (let [{url :browser-download-url} asset-info]
    {:os (get-os url) :word-size (get-word-size url)
     :file-type (get-file-type url) :url url}))

(defn build-download-map
  [asset-info-vector]
  (group-by :os (map analyze-download-url asset-info-vector)))

Update Mac file name possibilities

Update Mac file name possibilities


;; See: https://github.com/kumarshantanu/lein-localrepo
{:user {:plugins [;; Try new api quickly using the repl
                  [lein-try "0.4.3"]

                  ;;[lein-localrepo "0.5.4"]

                  ;; Convert pom.xml to project.clj
                  ;; Note: from https://github.com/thickey/lein-nevam
                  [lein-nevam "0.1.2"]

                  ;; A Leiningen plugin for a superior development environment
                  ;; See: [Introduction Blog Post](https://blog.venanti.us/ultra/)
                  ;; https://github.com/venantius/ultra
                  ;;[venantius/ultra "0.5.2"]

                  ;; Pretty-print a representation of the project map
                  [lein-pprint "1.2.0"]
                  ;; Keep adding more stuff here
                  ]
        ;; Experimental
        :dependencies [[pjstadig/humane-test-output "0.8.3"]
                       ;; See: https://github.com/pallet/alembic
                       [alembic "0.3.2"]]
        :injections [(require 'pjstadig.humane-test-output)
                     (pjstadig.humane-test-output/activate!)]}}

;; See: https://github.com/kumarshantanu/lein-localrepo
{:user {:plugins [;; Try new api quickly using the repl
                  [lein-try "0.4.3"]
                  ;;[lein-localrepo "0.5.4"]

                  ;; Convert pom.xml to project.clj
                  ;; Note: from https://github.com/thickey/lein-nevam
                  [lein-nevam "0.1.2"]

                  ;; A Leiningen plugin for a superior development environment
                  ;; See: [Introduction Blog Post](https://blog.venanti.us/ultra/)
                  ;; https://github.com/venantius/ultra
                  ;;[venantius/ultra "0.5.2"]

                  ;; Pretty-print a representation of the project map
                  [lein-pprint "1.2.0"]

                  ;; For quick typing
                  [com.palletops/lein-shorthand "0.4.0"]]

        ;; See: https://github.com/pallet/alembic
        :shorthand {. [alembic.still/distill alembic.still/lein]}

        ;; Experimental
        :dependencies [[pjstadig/humane-test-output "0.8.3"]
                       ;; See: https://github.com/pallet/alembic
                       [alembic "0.3.2"]]
        :injections [(require 'pjstadig.humane-test-output)
                     (pjstadig.humane-test-output/activate!)]}}

Add more setup for alembic

Add more setup for alembic


(ns icecap.handlers.delay
  (:require [clojure.core.async :refer [timeout]]
            [icecap.handlers.core :refer [defstep]]
            [schema.core :as sc]))

(defstep :delay
  {:amount (sc/both sc/Int (sc/pred #(< 0 % 60)'(< 0 delay 60)))}
  [step]
  (timeout (:amount step)))

(ns icecap.handlers.delay
  (:require [clojure.core.async :refer [timeout]]
            [icecap.handlers.core :refer [defstep]]
            [schema.core :as sc]))

(defstep :delay
  {:amount (sc/conditional #(< 0 % 60) sc/Int)}
  [step]
  (timeout (:amount step)))

Use conditional instead of both

Use conditional instead of both


(ns mathom.toolbar)

(def tool (atom {}))

(defn clean
  []
  (let [prev (.getElementById js/document "mathom_toolbar")]
    (if (not (nil? prev))
      (.remove prev))))

(defn set-content
  [content]
  (set! (.-innerHTML (:bar @tool)) content))

(def content "

Mithril ClojureScript Toolbar

<button id=\"mathom_toolbar_prev\">Previous state</button>
<button id=\"mathom_toolbar_next\">Next state</button>

")

(defn setup
  []
  (let [body (aget (.getElementsByTagName js/document "body") 0)
        tb (.createElement js/document "div")]
    (clean)
    (.setAttribute tb "id" "mathom_toolbar")
    (.appendChild body tb)
    (set-content content)
    (swap! tool #(assoc @tool :bar tb)) ; To get access to generated node
    ))

(defn handle-event
  [eib])

(defn attach-listener
  []
  (.addEventListener (:bar @tool)
                     "click"
                     #(handle-event (aget (.-target %) "id"))))

(ns mathom.toolbar)

(def tool (atom {}))

(defn clean
  []
  (let [prev (.getElementById js/document "mathom_toolbar")]
    (if (not (nil? prev))
      (.remove prev))))

(defn set-content
  [content]
  (set! (.-innerHTML (:bar @tool)) content))

(def content "

Mithril ClojureScript Toolbar

<button id=\"mathom_toolbar_prev\">Previous state</button>
<button id=\"mathom_toolbar_next\">Next state</button>

")

(defn setup
  []
  (let [body (aget (.getElementsByTagName js/document "body") 0)
        tb (.createElement js/document "div")]
    (clean)
    (.setAttribute tb "id" "mathom_toolbar")
    (.appendChild body tb)
    (set-content content)
    (swap! tool #(assoc @tool :bar tb)))) ; To get access to generated node

(defn handle-event
  [eib])

(defn attach-listener
  []
  (.addEventListener (:bar @tool)
                     "click"
                     #(handle-event (aget (.-target %) "id"))))

(defn d-to-s
  "Returns stringified version
  of given map in HTML/XML
  attribute style"
  [d]
  (clojure.string/join " "
                       (for [[k v] d]
                         (str (name k) "=\"" v "\""))))

(defn h
  "Returns a string resembling
  HTML tag, attributes and children"
  [tag attrs children]
  (str "<" tag
       (if (not(empty? attrs)) (str " " (d-to-s attrs))) ">"
       (if (not(empty? children)) (clojure.string/join " " children))
       "</" tag ">"))

Add simple Cljs to HTML helpers

Add simple Cljs to HTML helpers


;; Copyright 2008-2014 Red Hat, Inc, and individual contributors.
;;
;; This is free software; you can redistribute it and/or modify it
;; under the terms of the GNU Lesser General Public License as
;; published by the Free Software Foundation; either version 2.1 of
;; the License, or (at your option) any later version.
;;
;; This software is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Lesser General Public License for more details.
;;
;; You should have received a copy of the GNU Lesser General Public
;; License along with this software; if not, write to the Free
;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
;; 02110-1301 USA, or see the FSF site: http://www.fsf.org.

(ns no-clojure-jar.tests
  (:use clojure.test))

(deftest bundled-clojure-version
  (is (= "1.5.1" (clojure-version))))

;; Copyright 2008-2014 Red Hat, Inc, and individual contributors.
;;
;; This is free software; you can redistribute it and/or modify it
;; under the terms of the GNU Lesser General Public License as
;; published by the Free Software Foundation; either version 2.1 of
;; the License, or (at your option) any later version.
;;
;; This software is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Lesser General Public License for more details.
;;
;; You should have received a copy of the GNU Lesser General Public
;; License along with this software; if not, write to the Free
;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
;; 02110-1301 USA, or see the FSF site: http://www.fsf.org.

(ns no-clojure-jar.tests
  (:use clojure.test))

(deftest bundled-clojure-version
  (is (= "1.6.0" (clojure-version))))

Test for the correct clojure version.

Test for the correct clojure version.


(ns webdev.core
  (:use [org.httpkit.server :only [run-server]])
  (:require [webdev.item.migration :as migration]
            [webdev.item.routes :refer [item-routes]]
            [webdev.common.routes :refer [common-routes]]
            [webdev.common.middleware :refer [wrap-db
                                              wrap-simulated-methods]])
  (:require [ring.middleware.reload :refer [wrap-reload]]
            [ring.middleware.params :refer [wrap-params]]
            [ring.middleware.resource :refer [wrap-resource]]
            [ring.middleware.file-info :refer [wrap-file-info]]
            [compojure.core :refer [routes]]
            [environ.core :refer [env]]))

(def db (env :database-url))

(def app
  (wrap-file-info
    (wrap-resource
      (wrap-db
        (wrap-params
          (wrap-simulated-methods (routes item-routes common-routes))))
      "static")))

(defn -main [port]
  (migration/create-table db)
  (run-server app {:port (Integer. port)}))

(defn -dev-main [port]
  (migration/create-table db)
  (run-server (wrap-reload #'app) {:port (Integer. port)}))

(ns webdev.core
  (:require [webdev.item.migration :as migration]
            [webdev.item.routes :refer [item-routes]]
            [webdev.common.routes :refer [common-routes]]
            [webdev.common.middleware :refer [wrap-db
                                              wrap-simulated-methods]])
  (:require [org.httpkit.server :refer [run-server]]
            [ring.middleware.reload :refer [wrap-reload]]
            [ring.middleware.params :refer [wrap-params]]
            [ring.middleware.resource :refer [wrap-resource]]
            [ring.middleware.file-info :refer [wrap-file-info]]
            [compojure.core :refer [routes]]
            [environ.core :refer [env]]))

(def db (env :database-url))

(def app-routes
  (routes
    item-routes
    common-routes))

(def app
  (-> app-routes
      (wrap-simulated-methods)
      (wrap-params)
      (wrap-db)
      (wrap-resource "static")
      (wrap-file-info)))

(defn -main [port]
  (migration/create-table db)
  (run-server app {:port (Integer. port)}))

(defn -dev-main [port]
  (migration/create-table db)
  (run-server (wrap-reload #'app) {:port (Integer. port)}))

Use threading macro for app setup.

Use threading macro for app setup.


(defproject {{ project_name }} "0.0.1-SNAPSHOT"
  :source-paths ["topologies"]
  :resource-paths ["_resources"]
  :aot :all
  :target-path "_build"
  :min-lein-version "2.0.0"
  :dependencies [[org.apache.storm/storm-core "0.9.1-incubating"]
                 [com.parsely/streamparse "0.0.1-SNAPSHOT"]
                 [org.clojure/clojure "1.5.1"]
                 [org.clojure/data.json "0.2.4"]
                 [org.clojure/tools.cli "0.3.1"]
                 ]
  )

(defproject {{ project_name }} "0.0.1-SNAPSHOT"
  :source-paths ["topologies"]
  :resource-paths ["_resources"]
  :aot :all
  :target-path "_build"
  :min-lein-version "2.0.0"
  :jvm-opts ["-client"]
  :dependencies [[org.apache.storm/storm-core "0.9.1-incubating"]
                 [com.parsely/streamparse "0.0.1-SNAPSHOT"]
                 [org.clojure/clojure "1.5.1"]
                 [org.clojure/data.json "0.2.4"]
                 [org.clojure/tools.cli "0.3.1"]]
  )

Add "-client" to JVM opts for quickstart projects.


(ns little-clojurer.chapter5
  (:require [little-clojurer.chapter4 :refer :all]))

(defn rember*
  [a l]
  nil)

(defn insertR*
  [new old l]
  nil)

(defn occur*
  [a l]
  nil)

(defn subst*
  [new old l]
  nil)

(defn insertL*
  [new old l]
  nil)

(defn member*
  [a l]
  nil)

(defn leftmost
  [l]
  nil)

(ns little-clojurer.chapter5
  (:require [little-clojurer.chapter4 :refer :all]))

(defn rember*
  "find all occurrances of a in l deeply recursively and remove them"
  [a l]
  nil)

(defn insertR*
  "find all occurrances of old in l deeply recursively and append new to the right of the occurrances"
  [new old l]
  nil)

(defn occur*
  "count the number of times a occurs in l deeply recursively"
  [a l]
  nil)

(defn subst*
  "find all occurrances of a in l deeply recursively and replace them with new"
  [new old l]
  nil)

(defn member*
  "check if a occurs in l deeply recursively"
  [a l]
  nil)

(defn leftmost
  "finds the leftmost atom in l deeply recursively. l cannot be empty and cannot contain empty lists."
  [l]
  nil)

Add docstrings to chapter 5 stubs.

Add docstrings to chapter 5 stubs.


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

(defn data-table-cell-input
  [columns data nth-row nth-col state]
  (let [k (:key (nth columns nth-col))]
    [:input {:type "text"
             :auto-focus true
             :value (get (get-in @state [:edit :updated]) k)
             :on-change #(swap! state
                                assoc-in
                                [:edit :updated k]
                                (-> % .-target .-value))}]))

(defn data-table-cell
  [columns data v nth-row nth-col state]
  (let [selected? (= (:selected @state) [nth-row nth-col])
        edit? (:edit @state)]
    [:td {:class (if selected? "selected")
          :on-click #(util/set-selected! state nth-row nth-col)}
     (if (and selected? edit?)
       [data-table-cell-input columns data nth-row nth-col state]
       [:span v])]))

(defn data-table-row
  [columns data row-data nth-row state]
  [:tr
   ;; TODO: run map-indexed to columns only once
   (for [[nth-col {:keys [key value]}] (map-indexed vector columns)]
     ^{:key nth-col}
     [data-table-cell columns data (get row-data key) nth-row nth-col state])])

(defn data-table-headers
  [columns]
  [:thead
   [:tr
    (for [{:keys [key value]} columns]
      ^{:key key} [:th value])]])

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

(defn data-table-cell-input
  [cursor]
  [:input {:type "text"
           :auto-focus true
           :value @cursor
           :on-change #(reset! cursor (-> % .-target .-value))}])

(defn data-table-cell
  [columns data v nth-row nth-col state]
  (let [selected? (= (:selected @state) [nth-row nth-col])
        edit? (:edit @state)
        key (:key (nth columns nth-col))
        cursor (reagent/cursor state [:edit :updated key])]
    [:td {:class (if selected? "selected")
          :on-click #(util/set-selected! state nth-row nth-col)}
     (if (and selected? edit?)
       [data-table-cell-input cursor]
       [:span v])]))

(defn data-table-row
  [columns data row-data nth-row state]
  [:tr
   ;; TODO: run map-indexed to columns only once
   (for [[nth-col {:keys [key value]}] (map-indexed vector columns)]
     ^{:key nth-col}
     [data-table-cell columns data (get row-data key) nth-row nth-col state])])

(defn data-table-headers
  [columns]
  [:thead
   [:tr
    (for [{:keys [key value]} columns]
      ^{:key key} [:th value])]])

Simplify arguments the editing component gets from the cell component


(ns interop.Sample
  (:gen-class))

(defn -main []
  (throw (UnsupportedOperationException. "Not yet implemented")))

(ns interop.Sample
  (:gen-class))

(defn -main [& _]
  (throw (UnsupportedOperationException. "Not yet implemented")))

Fix arity of interop call

Fix arity of interop call


(ns leiningen.pallet-release
  "Pallet release commands to support the PalletOps release workflow."
  (:require
   [leiningen.pallet-release.core :refer [fail]]
   [leiningen.pallet-release.release :as release]
   [leiningen.pallet-release.travis :as travis]))

(defn pallet-release
  "Pallet release commands to support the PalletOps release workflow."
  ^{:subtasks
    [#'release/init #'release/start #'release/finish
     #'travis/push #'release/publish]}
  [project & [cmd & args]]
  (case cmd
    "init" (release/init project args)
    "start" (release/start project args)
    "finish" (release/finish project args)
    "push" (travis/push project args)
    "publish" (release/publish project args)
    (fail "Known cmds are init, start, finish, and push")))

(ns leiningen.pallet-release
  "Pallet release commands to support the PalletOps release workflow."
  (:require
   [leiningen.pallet-release.core :refer [fail]]
   [leiningen.pallet-release.release :as release]
   [leiningen.pallet-release.travis :as travis]))

(defn pallet-release
  "Pallet release commands to support the PalletOps release workflow."
  ^{:subtasks
    [#'release/init #'release/start #'release/finish
     #'travis/push #'release/publish]}
  [project & [cmd & args]]
  (case cmd
    "init" (release/init project args)
    "start" (release/start project args)
    "finish" (release/finish project args)
    "push" (travis/push project args)
    "publish" (release/publish project args)
    (fail "Known cmds are init, start, finish, and publish.")))

Fix list of known commands in help message


(ns onyx.types)

<<<<<<< HEAD
(defrecord Message [id payload])

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

(defn leaf
  ([message]
     (->Leaf message nil nil nil nil nil nil nil nil)))
>>>>>>> ba78b0e... Read vpeer-id separately to rest of buffer so that

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

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

(defrecord Results [tree acks segments])

(defrecord Result [root leaves])

(defrecord Link [link timestamp])

(ns onyx.types)

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

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

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

(defrecord Results [tree acks segments])

(defrecord Result [root leaves])

(defrecord Link [link timestamp])

Fix merge issue in last commit.

Fix merge issue in last commit.


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

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

(deftest RequestSpecTests
  (testing "Correct request specs validate"
    (are [example] (s/validate RequestSpec example)
         simple-http-request
         simple-https-request
         #{simple-http-request simple-https-request}))
  (testing "Request specs with unknown/unsupported schemes don't validate"
    (are [example] (thrown? Throwable (s/validate RequestSpec example))
         simple-ftp-request)))

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

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

(deftest RequestSpecTests
  (testing "Correct request specs validate"
    (are [example] (s/validate RequestSpec example)
         simple-http-request
         simple-https-request
         #{simple-http-request simple-https-request}))
  (testing "Request specs with unknown/unsupported schemes don't validate"
    (are [example reason] (= (s/check RequestSpec example) reason)
         simple-ftp-request {:target (not ("supported-scheme?" "ftp://example.test"))})))

Test allegedly better error reporting

Test allegedly better error reporting

Refs #1.


(ns lcmap.clownfish.system
  (:require [again.core :as again]
            [clojure.tools.logging :as log]
            ;; requiring this ensures the server component will start
            [lcmap.clownfish.server :as server]
            [lcmap.clownfish.setup.cassandra]
            [lcmap.clownfish.setup.rabbitmq]
            [mount.core :refer [defstate] :as mount]))

(defstate hook
  :start (do
           (log/debugf "registering shutdown handler")
           (.addShutdownHook (Runtime/getRuntime)
                             (Thread. #(mount/stop) "shutdown-handler"))))

(def default-retry-strategy
  (again/max-retries 10 (again/constant-strategy 5000)))

(defn start
  ([environment]
   (start default-retry-strategy))

  ([environment startup-retry-strategy]
   (again/with-retries startup-retry-strategy
     (do (log/info "Stopping mount components")
         (mount/stop)
         (log/info "Starting mount components...")
         ;; insulation to make sure these states do not get accidentally
         ;; started
         (mount/start-without #'lcmap.clownfish.setup.cassandra/setup
                              #'lcmap.clownfish.setup.cassandra/teardown
                              #'lcmap.clownfish.setup.rabbitmq/setup
                              (mount/with-args {:environment environment}))))))
(defn stop []
  (mount/stop))

(ns lcmap.clownfish.system
  (:require [again.core :as again]
            [clojure.tools.logging :as log]
            ;; requiring this ensures the server component will start
            [lcmap.clownfish.server :as server]
            [lcmap.clownfish.setup.cassandra]
            [lcmap.clownfish.setup.rabbitmq]
            [mount.core :refer [defstate] :as mount]))

(defstate hook
  :start (do
           (log/debugf "registering shutdown handler")
           (.addShutdownHook (Runtime/getRuntime)
                             (Thread. #(mount/stop) "shutdown-handler"))))

(def default-retry-strategy
  (again/max-retries 10 (again/constant-strategy 5000)))

(defn start
  ([environment]
   (start environment default-retry-strategy))

  ([environment startup-retry-strategy]
   (again/with-retries startup-retry-strategy
     (do (log/info "Stopping mount components")
         (mount/stop)
         (log/info "Starting mount components...")
         ;; insulation to make sure these states do not get accidentally
         ;; started
         (mount/start-without #'lcmap.clownfish.setup.cassandra/setup
                              #'lcmap.clownfish.setup.cassandra/teardown
                              #'lcmap.clownfish.setup.rabbitmq/setup
                              (mount/with-args {:environment environment}))))))
(defn stop []
  (mount/stop))

Fix stack overflow during startup

Fix stack overflow during startup


(ns de.otto.tesla.example.example-system
  (:require [de.otto.tesla.system :as system]
            [de.otto.tesla.example.calculating :as calculating]
            [de.otto.tesla.example.example-page :as example-page]
            [com.stuartsierra.component :as c])
  (:gen-class))

(defn example-calculation-function [input]
  (.toUpperCase input))

(defn example-system [runtime-config]
  (-> (system/empty-system runtime-config)
      (assoc :calculator
             (c/using (calculating/new-calculator example-calculation-function) [:metering :app-status]))
      (assoc :example-page
             (c/using (example-page/new-example-page) [:routes :calculator :app-status]))))

(defn -main
  "starts up the production system."
  [& args]
  (system/start-system (example-system{})))

(ns de.otto.tesla.example.example-system
  (:require [de.otto.tesla.system :as system]
            [de.otto.tesla.example.calculating :as calculating]
            [de.otto.tesla.example.example-page :as example-page]
            [com.stuartsierra.component :as c])
  (:gen-class))

(defn example-calculation-function [input]
  (.toUpperCase input))

(defn example-system [runtime-config]
  (-> (system/empty-system runtime-config)
      (assoc :calculator
             (c/using (calculating/new-calculator example-calculation-function) [:metering :app-status]))
      (assoc :example-page
             (c/using (example-page/new-example-page) [:routes :calculator :app-status]))
      (c/system-using {:server [:example-page]})))

(defn -main
  "starts up the production system."
  [& args]
  (system/start-system (example-system{})))

Example: Make sure page component is started before server

In the system definition from the example code, an explicit dependency
from the :server component to the :example-page component is introduced
to make sure the routes for example-page are registered before the
server is started.


(ns uxbox.locales
  "A i18n foundation."
  (:require [hodgepodge.core :refer [local-storage]]
            [cuerdas.core :as str]
            [uxbox.locales.en :as locales-en]))

(defonce +locales+
  {:en locales-en/+locales+})

(defonce +locale+
  (get local-storage ::locale :en))

(deftype C [val]
  IDeref
  (-deref [o] val))

(defn c
  [x]
  (C. x))

(defn ^boolean c?
  [r]
  (instance? C r))

(defn tr
  "Translate the string."
  ([t]
   (let [default (name t)
         value (get-in +locales+ [+locale+ t] default)]
     (if (vector? value)
       (or (second value) default)
       value)))
  ([t & args]
   (let [value (get-in +locales+ [+locale+ t] (name t))
         plural (first (filter c? args))
         args (mapv #(if (c? %) @% %) args)
         value (if vector?
                 (if (= @plural 1) (first value) (second value))
                 value)]
     (apply str/format value args))))

(ns uxbox.locales
  "A i18n foundation."
  (:require [hodgepodge.core :refer [local-storage]]
            [cuerdas.core :as str]
            [uxbox.locales.en :as locales-en]))

(defonce +locales+
  {:en locales-en/+locales+})

(defonce +locale+
  (get local-storage ::locale :en))

(deftype C [val]
  IDeref
  (-deref [o] val))

(defn c
  [x]
  (C. x))

(defn ^boolean c?
  [r]
  (instance? C r))

(defn tr
  "Translate the string."
  ([t]
   (let [default (name t)
         value (get-in +locales+ [+locale+ t] default)]
     (if (vector? value)
       (or (second value) default)
       value)))
  ([t & args]
   (let [value (get-in +locales+ [+locale+ t] (name t))
         plural (first (filter c? args))
         args (mapv #(if (c? %) @% %) args)
         value (cond
                 (and (vector? value)
                      (= 3 (count value)))
                 (nth value (min 2 @plural))

                 (vector? value)
                 (if (= @plural 1) (first value) (second value))

                 :else
                 value)]
     (apply str/format value args))))

Support 0, 1 or more in plural translations


(defproject lean-map "0.3.2-SNAPSHOT"
  :description "Lean Hash Array Mapped Trie implementation in ClojureScript"

  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :clean-targets ^{:protect false} ["resources/out"]

  :source-paths  ["src/main"]

  :jvm-opts ^:replace ["-Xms512m" "-Xmx512m" "-server"]

  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/clojurescript "1.7.228"]]

  :profiles {:test {:dependencies [[collection-check "0.1.7-SNAPSHOT"]]}}

  :plugins [[lein-doo "0.1.6-rc.1"]]

  :cljsbuild {:builds
              [{:id "test"
                :source-paths ["src/main" "test"]
                :compiler {:output-to "resources/public/js/testable.js"
                           :main cljs.lean-map.test.runner
                           :optimizations :none}}
               {:id "node-test"
                :source-paths ["src/main" "test"]
                :compiler {:output-to "resources/public/js/testable.js"
                           :main cljs.lean-map.test.runner
                           :output-dir "target"
                           :target :nodejs
                           :optimizations :none}}]})

(defproject lean-map "0.3.2-SNAPSHOT"
  :description "Lean Hash Array Mapped Trie implementation in ClojureScript"

  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :clean-targets ^{:protect false} ["resources/out"]

  :source-paths  ["src/main"]

  :jvm-opts ^:replace ["-Xms512m" "-Xmx512m" "-server"]

  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/clojurescript "1.8.51"]]

  :profiles {:test {:dependencies [[collection-check "0.1.7-SNAPSHOT"]]}}

  :plugins [[lein-doo "0.1.6"]]

  :cljsbuild {:builds
              [{:id "test"
                :source-paths ["src/main" "test"]
                :compiler {:output-to "resources/public/js/testable.js"
                           :main cljs.lean-map.test.runner
                           :optimizations :none}}
               {:id "node-test"
                :source-paths ["src/main" "test"]
                :compiler {:output-to "resources/public/js/testable.js"
                           :main cljs.lean-map.test.runner
                           :output-dir "target"
                           :target :nodejs
                           :optimizations :none}}]})

Bump dependencies for ClojureScript and lein doo


(defproject shurly "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://shurly.herokuapp.com"
  :license {:name "FIXME: choose"
            :url "http://example.com/FIXME"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [compojure "1.1.8"]
                 [ring/ring-jetty-adapter "1.2.2"]
                 [ring/ring-devel "1.2.2"]
                 [ring-basic-authentication "1.0.5"]
                 [environ "0.5.0"]
                 [com.cemerick/drawbridge "0.0.6"]]
  :min-lein-version "2.0.0"
  :plugins [[environ/environ.lein "0.2.1"]]
  :hooks [environ.leiningen.hooks]
  :uberjar-name "shurly-standalone.jar"
  :profiles {:production {:env {:production true}}})

(defproject shurly "1.0.0-SNAPSHOT"
  :description "A URL shortener"
  :url "http://shurly.herokuapp.com"
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [compojure "1.1.8"]
                 [ring/ring-jetty-adapter "1.2.2"]
                 [ring/ring-devel "1.2.2"]
                 [environ "0.5.0"]]
  :min-lein-version "2.0.0"
  :plugins [[environ/environ.lein "0.2.1"]]
  :hooks [environ.leiningen.hooks]
  :uberjar-name "shurly-standalone.jar"
  :ring {:handler shurly.web/app}
  :profiles {:production {:env {:production true}}})

Remove useless stuff and set ring handler


(defproject nasa-cmr/cmr-system-trace-lib "0.1.0-SNAPSHOT"
  :description "Provides library functions for tracing requests throughout the CMR system. Built on
               Twitter Zipkin and clj-zipkin."
  :url "***REMOVED***projects/CMR/repos/cmr-system-trace-lib/browse"
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [nasa-cmr/cmr-common-lib "0.1.1-SNAPSHOT"]

                ;; clj-zipkin macros don't work very well. It's included mostly for some utility
                ;; functions, and the thrift handling.
                [clj-zipkin "0.1.3" :exclusions [ch.qos.logback/logback-classic
                                                 log4j
                                                 org.slf4j/slf4j-log4j12]]
                ;; Turn off the logging noise
                [com.dadrox/quiet-slf4j "0.1"]
                [clj-time "0.7.0"]]

  :plugins [[lein-test-out "0.3.1"]]

  :profiles
  {:dev {:dependencies [[org.clojure/tools.namespace "0.2.4"]
                        [org.clojars.gjahad/debug-repl "0.3.3"]]
         :source-paths ["src" "dev" "test"]}})

(defproject nasa-cmr/cmr-system-trace-lib "0.1.0-SNAPSHOT"
  :description "Provides library functions for tracing requests throughout the CMR system. Built on
               Twitter Zipkin and clj-zipkin."
  :url "***REMOVED***projects/CMR/repos/cmr-system-trace-lib/browse"
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [nasa-cmr/cmr-common-lib "0.1.1-SNAPSHOT"]

                ;; clj-zipkin macros don't work very well. It's included mostly for some utility
                ;; functions, and the thrift handling.
                [clj-zipkin "0.1.3" :exclusions [ch.qos.logback/logback-classic
                                                 log4j
                                                 org.slf4j/slf4j-log4j12]]
                ;; Turn off the logging noise
                [com.dadrox/quiet-slf4j "0.1"]]

  :plugins [[lein-test-out "0.3.1"]]

  :profiles
  {:dev {:dependencies [[org.clojure/tools.namespace "0.2.4"]
                        [org.clojars.gjahad/debug-repl "0.3.3"]]
         :source-paths ["src" "dev" "test"]}})

Move clj-time dependency to cmr-common-lib


(defproject io.aviso/twixt "0.1.5"
  :description "An extensible asset pipeline for Clojure web applications"
  :url "https://github.com/AvisoNovate/twixt"
  :license {:name "Apache Sofware Licencse 2.0"
            :url  "http://www.apache.org/licenses/LICENSE-2.0.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/tools.logging "0.2.6"]
                 [ring/ring-core "1.2.0"]
                 [org.mozilla/rhino "1.7R4"]
                 [com.github.sommeri/less4j "1.1.2"]
                 [de.neuland/jade4j "0.3.15"]
                 [io.aviso/pretty "0.1.5"]
                 [hiccup "1.0.4"]]
  :repositories [["jade4j" "https://raw.github.com/neuland/jade4j/master/releases"]]
  :codox {:src-dir-uri               "https://github.com/AvisoNovate/twixt/blob/master/"
          :src-linenum-anchor-prefix "L"}
  :profiles {:dev {:dependencies [[log4j "1.2.17"]
                                  [ring/ring-jetty-adapter "1.2.0"]]}})

(defproject io.aviso/twixt "0.1.5"
  :description "An extensible asset pipeline for Clojure web applications"
  :url "https://github.com/AvisoNovate/twixt"
  :license {:name "Apache Sofware Licencse 2.0"
            :url  "http://www.apache.org/licenses/LICENSE-2.0.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/tools.logging "0.2.6"]
                 [ring/ring-core "1.2.0"]
                 [org.mozilla/rhino "1.7R4"]
                 [com.github.sommeri/less4j "1.1.2"]
                 [de.neuland/jade4j "0.3.15"]
                 [io.aviso/pretty "0.1.6"]
                 [hiccup "1.0.4"]]
  :repositories [["jade4j" "https://raw.github.com/neuland/jade4j/master/releases"]]
  :codox {:src-dir-uri               "https://github.com/AvisoNovate/twixt/blob/master/"
          :src-linenum-anchor-prefix "L"}
  :profiles {:dev {:dependencies [[log4j "1.2.17"]
                                  [ring/ring-jetty-adapter "1.2.0"]]}})

Update pretty dependency to 0.1.6

Update pretty dependency to 0.1.6


(ns leiningen.clean-tokyo
  (:use [clojure.java.shell :only [sh]]
        [clojure.java.io :only [file]]))

(defn clean [srcdir]
  (when (.exists (file srcdir "Makefile"))
    (println (:out (sh "make" "distclean" :dir (file srcdir))))))

(defn clean-tokyo []
  (clean (file "src/tokyocabinet"))
  (clean (file "src/tokyocabinet-java")))

(ns leiningen.clean-tokyo
  (:use [clojure.java.io :only [file]])
  (:require [conch.core :as sh]))

(defn clean [srcdir]
  (when (.exists (file srcdir "Makefile"))
    (sh/stream-to-out (sh/proc "make" "distclean" :dir (file srcdir)) :out)))

(defn clean-tokyo []
  (clean (file "src/tokyocabinet"))
  (clean (file "src/tokyocabinet-java")))

Make clean-tokyo task also use conch.

Make clean-tokyo task also use conch.


(ns jest.arithmetic-test
  (:require [clojure.test :refer :all]
            [jest.utils :refer :all]
            :verbose))

(deftest product-test-1
  (test-code
   "val x = 1 * 2;"
   ["(def x (* 1 2))"]))

(deftest product-test-2
  (test-code
   "val x = 1 * 2 * 3;"
   ["(def x (* (* 1 2) 3))"]))

(deftest quotent-test-1
  (test-code
   "val x = 1 / 2;"
   ["(def x (/ 1 2))"]))

(deftest quotent-test-2
  (test-code
   "val x = 1 / 2 / 3;"
   ["(def x (/ (/ 1 2) 3))"]))

(deftest multiply-divide-test
  (test-code
   "val x = 1 * 2 / 3;"
   ["(def x (/ (* 1 2) 3))"]))

(ns jest.arithmetic-test
  (:require [clojure.test :refer :all]
            [jest.utils :refer :all]
            :verbose))

(deftest sum-test-1
  (test-code
   "val x = 1 + 2;"
   ["(def x (+ 1 2))"]))

(deftest sum-test-2
  (test-code
   "val x = 1 + 2 + 3;"
   ["(def x (+ (+ 1 2) 3))"]))

(deftest product-test-1
  (test-code
   "val x = 1 * 2;"
   ["(def x (* 1 2))"]))

(deftest product-test-2
  (test-code
   "val x = 1 * 2 * 3;"
   ["(def x (* (* 1 2) 3))"]))

(deftest quotent-test-1
  (test-code
   "val x = 1 / 2;"
   ["(def x (/ 1 2))"]))

(deftest quotent-test-2
  (test-code
   "val x = 1 / 2 / 3;"
   ["(def x (/ (/ 1 2) 3))"]))

(deftest multiply-divide-test
  (test-code
   "val x = 1 * 2 / 3;"
   ["(def x (/ (* 1 2) 3))"]))

Add sum and diff tests

Add sum and diff tests


(ns buddy.crypto.keys
  (:import java.security.Key))

(defn make-secret-key
  "Generates a Key instance from given raw string key."
  [^String skey]
  (let [rawkey (.getBytes skey "UTF-8")]
    (proxy [Key] []
      (getFormat [] nil)
      (getEncoded [] rawkey)
      (toString [] skey))))

(ns buddy.crypto.keys
  (:require [buddy.crypto.core :refer [str->bytes]])
  (:import java.security.Key))

(defn make-secret-key
  "Generates a Key instance from given raw string key."
  [^String skey]
  (let [rawkey (str->bytes skey)]
    (proxy [Key] []
      (getFormat [] nil)
      (getEncoded [] rawkey)
      (toString [] skey))))

Use byddy.crypto utils function for get a byte array from string on make-secret-key function.


(ns reabledit.cells.read-only
  (:require [reabledit.util :as util]))

(defn read-only-cell
  [{:keys [row-data column-key]}]
  (let [v (get row-data column-key)]
    [:div.reabledit-read-only-cell
     {:title v}
     [:input.reabledit-read-only-cell__input.reabledit-focused
      {:type "text"
       :value ""
       :on-key-down #(if (= (.-keyCode %) 13) (.stopPropagation %))
       :on-copy #(util/set-clipboard-data % v)}]
     [:span.reabledit-read-only-cell__view v]]))

(ns reabledit.cells.read-only
  (:require [reabledit.util :as util]))

(defn read-only-cell
  [{:keys [row-data column-key]}]
  (let [v (get row-data column-key)]
    [:div.reabledit-read-only-cell
     {:title v}
     [:input.reabledit-read-only-cell__input.reabledit-focused
      {:type "text"
       :value ""
       :on-key-down #(if (= (.-keyCode %) 13) (.stopPropagation %))
       :on-copy #(util/set-clipboard-data % v)
       :on-cut #(util/set-clipboard-data % v)}]
     [:span.reabledit-read-only-cell__view v]]))

Add cut handler to read-only cell

Add cut handler to read-only cell


 (ns silly-image-store.handler
  (:require [silly-image-store.store :as store]
            [environ.core :refer [env]]
            [compojure.core :refer :all]
            [ring.middleware.json :refer :all]
            [compojure.handler :as handler]
            [compojure.route :as route]))

(def images-dir
  (env :base-store-dir))

(defn image-not-found [image]
  (route/not-found (str "No image '" image "' found")))

(defn serve-image [image]
  (let [image-file (store/load-image images-dir image)]
    (or image-file (image-not-found image))))

(defroutes app-routes
  (GET "/blah" [] {:status 200 :body {:def [123 456 789]}})
  (GET "/images/:image" [image] (serve-image image))
  (route/resources "/")
  (route/not-found "Not Found"))

(def app
  (-> (handler/site app-routes)
      (wrap-json-response)))

 (ns silly-image-store.handler
  (:require [silly-image-store.store :as store]
            [environ.core :refer [env]]
            [compojure.core :refer :all]
            [ring.middleware.json :refer :all]
            [compojure.handler :as handler]
            [compojure.route :as route]))

(def images-dir
  (env :base-store-dir))

(defn image-not-found [image]
  (route/not-found (str "No image '" image "' found")))

(defn serve-image [image]
  (let [image-file (store/load-image images-dir image)]
    (or image-file (image-not-found image))))

(defroutes app-routes
  (GET "/images" [] "nothing")
  (GET "/images/:image" [image] (serve-image image))
  (route/resources "/")
  (route/not-found "Not Found"))

(def app
  (-> (handler/site app-routes)
      (wrap-json-response)))

Replace fake json route by /images route


(ns desdemona.query
  (:require [clojure.core.logic :as l]))

(defn ^:private gen-query
  [n-answers query events]
  `(l/run ~n-answers [results#]
     (l/fresh [~'x]
       (l/membero ~'x results#)
       (l/everyg #(l/membero % results#) ~events)
       ~query)))

(defn run-query
  ([query events]
   (run-query 1 query events))
  ([n-answers query events]
   (eval (gen-query n-answers query events))))

(ns desdemona.query
  (:require [clojure.core.logic :as l]))

(defn ^:private gen-query
  [n-answers query events]
  `(l/run ~n-answers [results#]
     (l/fresh [~'x]
       (l/everyg #(l/membero % results#) ~events)
       (l/== [~'x] results#)
       ~query)))

(defn run-query
  ([query events]
   (run-query 1 query events))
  ([n-answers query events]
   (eval (gen-query n-answers query events))))

Use unification to constrain results

Use unification to constrain results


(ns clojuresque.tasks.repl
  (:require
    [clojuresque.cli :as cli]
    [clojuresque.util :as util]
    [clojure.tools.nrepl.server :as repl]))

(def barrier (promise))
(def server nil)

(cli/deftask start-repl
  "Start a nrepl server on the given port. An optional handler
  may be given as fully-qualified symbol. The repl server may
  be stopped via clojuresque.tasks.repl/stop-server."
  [[port     p "server port"]
   [handler  h "handler function" nil]]
  (let [p (Long/parseLong port)
        h (if handler
            (let [custom-handler (util/resolve-required handler)]
              (when-not custom-handler
                (throw (Exception. (str "Unknown handler Var: " handler))))
              (custom-handler))
            (repl/default-handler))
        s (repl/start-server :port p :handler h)]
    (println "Repl started on port" port)
    (alter-var-root #'server (constantly s)))
  @barrier)

(defn stop-repl
  []
  (when server
    (repl/stop-server server)
    (deliver barrier true)))

(ns clojuresque.tasks.repl
  (:require
    [clojuresque.cli :as cli]
    [clojuresque.util :as util]
    [clojure.tools.nrepl.server :as repl]))

(def barrier (promise))
(def server nil)

(cli/deftask start-repl
  "Start a nrepl server on the given port. An optional handler
  may be given as fully-qualified symbol. The repl server may
  be stopped via clojuresque.tasks.repl/stop-server."
  [[port     p "server port"]
   [handler  h "handler function" nil]]
  (let [p (Long/parseLong port)
        h (if handler
            (let [custom-handler (binding [*warn-on-reflection* *warn-on-reflection*]
                                   (util/resolve-required handler))]
              (when-not custom-handler
                (throw (Exception. (str "Unknown handler Var: " handler))))
              (custom-handler))
            (repl/default-handler))
        s (repl/start-server :port p :handler h)]
    (println "Repl started on port" port)
    (alter-var-root #'server (constantly s)))
  @barrier)

(defn stop-repl
  []
  (when server
    (repl/stop-server server)
    (deliver barrier true)))

Add workaround to fix ClojureScript

Add workaround to fix ClojureScript


(ns cglossa.core
  (:require [reagent.core :as reagent :refer [atom]]
            [plumbing.core :as plumbing :refer [map-vals]]
            [cglossa.centre :as centre]))

(def state {:showing-results false})
; avoid "not resolved" messages in Cursive
(declare getElementById)

(def data {:categories ["ku" "hest"]
           :users      ["per" "kari"]})

(defonce app-state (into {} (map-vals atom state)))
(defonce app-data (into {} (map-vals atom data)))

(defn header []
  [:div.navbar.navbar-fixed-top [:div.navbar-inner [:div.container [:span.brand "Glossa"]]]])

(defn app [s d]
  [:div
   [header]
   [:div.container-fluid
    [centre/top s d]
    [centre/bottom s d]]
   [:div.app-footer
    [:img.textlab-logo {:src "img/tekstlab.gif"}]]])

(defn ^:export main []
  (reagent/render-component
    (fn []
      [app app-state app-data])
    (. js/document (getElementById "app"))))

(ns cglossa.core
  (:require [reagent.core :as reagent :refer [atom]]
            [plumbing.core :as plumbing :refer [map-vals]]
            [cglossa.centre :as centre]))

; avoid "not resolved" messages in Cursive
(declare getElementById)

(def state {:showing-results? false
            :showing-sidebar? false})

(def data {:corpus {:name "LBK"
                    :search-engine :cwb-speech}})

(defonce app-state (into {} (map-vals atom state)))
(defonce app-data (into {} (map-vals atom data)))

(defn header []
  [:div.navbar.navbar-fixed-top [:div.navbar-inner [:div.container [:span.brand "Glossa"]]]])

(defn app [s d]
  [:div
   [header]
   [:div.container-fluid
    [centre/top s d]
    [centre/bottom s d]]
   [:div.app-footer
    [:img.textlab-logo {:src "img/tekstlab.gif"}]]])

(defn ^:export main []
  (reagent/render-component
    (fn []
      [app app-state app-data])
    (. js/document (getElementById "app"))))

Use some more authentic test data

Use some more authentic test data


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

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

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

(defn fetch-list [{:keys [url selector normalize]}]
  (when (every? (complement nil?) [url selector normalize])
    (map normalize (html/select (fetch-url url) selector))))

(defn enlive->hiccup [{:keys [tag attrs content]}]
  (if (nil? content)
    [tag attrs]
    [tag attrs content]))

(defn fetch-image-tag [url]
  (-> (fetch-url url)
      (html/select [:div#imgholder :a :img#img])
      first
      enlive->hiccup))

Add function for getting a hiccup image tag


(ns my-money.routes.upload
  (:require [my-money.op-csv :refer :all]
            [compojure.core :refer [defroutes POST]]
            [ring.util.http-response :as response]))

(defroutes upload-routes
  (POST "/upload" [file]
    (let [data (read-csv (slurp (:tempfile file)))]
      (-> (response/ok (-> data
                           (remove-column-by-name "Arkistointitunnus")))))))

(ns my-money.routes.upload
  (:require [my-money.op-csv :refer :all]
            [compojure.core :refer [defroutes POST]]
            [ring.util.http-response :as response]))

(defroutes upload-routes
  (POST "/upload" [file]
    (let [data (read-csv (slurp (:tempfile file) :encoding "ISO-8859-1"))]
      (-> (response/ok (-> data
                           (remove-column-by-name "Arvopäivä")
                           (remove-column-by-name "Laji")
                           (remove-column-by-name "Arkistointitunnus")))))))

Fix character encodings for the data read from the csv. Remove columns from the response.


(ns theatralia.welcome-page
  (:require [net.cgrand.enlive-html :as html]
            [garden.core :refer [css]]
            [clojure.java.io :as io]))
;;; Credits:
;;;  - https://github.com/cgrand/enlive
;;;  - https://github.com/swannodette/enlive-tutorial/
;;;  - http://clojurewebdev.com/workshop/slides/

(def ^:private main-html (io/resource "templates/around.html"))
(def ^:private welcome-html (io/resource "templates/welcome.html"))

(html/defsnippet welcome-snippet
  welcome-html
  [:body :> html/any-node]
  [] identity)

(html/deftemplate index main-html
  []
  [:title] (html/content "Welcome to Theatralia!")
  [:#main-content] (html/content (welcome-snippet)))

(def css-data [[:html {:font-family "sans-serif"}]
               [:#theatralia {:font-family "fancy"}]
               [:#login {:float "right"}]])

(defn main-css []
  {:status 200
   :headers {"Content-Type" "text/css"}
   :body (css css-data)})

(ns theatralia.welcome-page
  (:require [net.cgrand.enlive-html :as html]
            [garden.core :refer [css]]
            [clojure.java.io :as io]))
;;; Credits:
;;;  - https://github.com/cgrand/enlive
;;;  - https://github.com/swannodette/enlive-tutorial/
;;;  - http://clojurewebdev.com/workshop/slides/

(def ^:private main-html (io/resource "templates/around.html"))
(def ^:private welcome-html (io/resource "templates/welcome.html"))

(html/defsnippet welcome-snippet
  welcome-html
  [:#main]
  [] identity)

(html/defsnippet login-snippet
  welcome-html
  [:#login]
  [] identity)

(html/deftemplate index main-html
  []
  [:title] (html/content "Welcome to Theatralia!")
  [:#main-content] (html/content (welcome-snippet))
  [:#global-tools] (html/content (login-snippet)))

(def css-data [[:html {:font-family "sans-serif"}]
               [:#theatralia {:font-family "fancy"}]
               [:#login {:float "right"}]])

(defn main-css []
  {:status 200
   :headers {"Content-Type" "text/css"}
   :body (css css-data)})

Adjust the deftemplates and defsnippets

Adjust the deftemplates and defsnippets

In bc87d96 I had made an adjustment to the HTML. Change the Enlive code
to take advantage of that. That means putting the login form into the
right column and the main text in the middle.


(ns oc.storage.lib.email
  (:require [amazonica.aws.sqs :as sqs]
            [taoensso.timbre :as timbre]
            [schema.core :as schema]
            [oc.storage.config :as config]
            [oc.storage.resources.common :as common-res]))

(def EmailTrigger
  {:to [schema/Str]
   :subject schema/Str
   :note schema/Str
   :reply-to (schema/maybe schema/Str)
   :org-slug schema/Str
   :origin-url schema/Str
   :entries [common-res/UpdateEntry]})

(defn ->trigger [org-slug update origin-url user]
  {:to (vec (:to update))
   :subject (:subject update)
   :note (:note update)
   :reply-to (:email user)
   :org-slug org-slug
   :origin-url origin-url
   :entries (:entries update)})

(defn send-trigger! [trigger]
  (timbre/info "Email request to:" config/aws-sqs-email-queue "\n" (dissoc trigger :entries))
  (schema/validate EmailTrigger trigger)
  (timbre/info "Sending request to:" config/aws-sqs-email-queue)
  (sqs/send-message
   {:access-key config/aws-access-key-id
    :secret-key config/aws-secret-access-key}
   config/aws-sqs-email-queue
   trigger)
  (timbre/info "Request sent to:" config/aws-sqs-email-queue))

(ns oc.storage.lib.email
  (:require [amazonica.aws.sqs :as sqs]
            [taoensso.timbre :as timbre]
            [schema.core :as schema]
            [oc.storage.config :as config]
            [oc.storage.resources.common :as common-res]))

(def EmailTrigger
  {:to [schema/Str]
   :subject schema/Str
   :note schema/Str
   :reply-to (schema/maybe schema/Str)
   :org-slug schema/Str
   :org-name schema/Str
   :logo-url (schema/maybe schema/Str)
   :origin-url schema/Str
   :currency schema/Str
   :entries [common-res/UpdateEntry]})

(defn ->trigger [org-slug update origin-url user]
  {:to (vec (:to update))
   :subject (:subject update)
   :note (:note update)
   :reply-to (:email user)
   :org-slug org-slug
   :origin-url origin-url
   :org-name (:org-name update)
   :logo-url (:logo-url update)
   :currency (:currency update)
   :entries (:entries update)})

(defn send-trigger! [trigger]
  (timbre/info "Email request to:" config/aws-sqs-email-queue "\n" (dissoc trigger :entries))
  (schema/validate EmailTrigger trigger)
  (timbre/info "Sending request to:" config/aws-sqs-email-queue)
  (sqs/send-message
   {:access-key config/aws-access-key-id
    :secret-key config/aws-secret-access-key}
   config/aws-sqs-email-queue
   trigger)
  (timbre/info "Request sent to:" config/aws-sqs-email-queue))

Add some missing update props to the update SQS trigger.


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

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

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

(deftest fizzbuzz-val-test
  (testing "Returns fizz for multiple of 3"
    (is (= "fizz" (fizzbuzz-val 9))))
  (testing "Returns buzz for multiple of 5"
    (is (= "buzz" (fizzbuzz-val 10))))
  (testing "Returns fizzbuzz for multiple of 15"
    (is (= "fizzbuzz" (fizzbuzz-val 15))))
  (testing "Returns stringified number for other values")
    (is (= "13" (fizzbuzz-val 13))))

(deftest generic-fizzbuzz-test
  (testing "Returns vector of fizzbuzz results"
    (is (= ["1" "2" "fizz" "4" "buzz" "fizz" "7" "8" "fizz"]
           (generic-fizzbuzz 9)))))

(deftest fizzbuzz-test
  (testing "Returns vector of 100 fizzbuzz results"
    (is (= 100 (count (fizzbuzz))))))

Update the clojure fizzbuzz tests.

Update the clojure fizzbuzz tests.


(defproject io.aviso/tracker "0.1.0"
  :description "Track per-thread operations when exceptions occur"
  :url "https://github.com/AvisoNovate/tracker"
  :license {:name "Apache Sofware Licencse 2.0"
            :url  "http://www.apache.org/licenses/LICENSE-2.0.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/tools.logging "0.2.6"]
                 [io.aviso/pretty "0.1.8"]]
  :codox {:src-dir-uri               "https://github.com/AvisoNovate/tracker/blob/master/"
          :src-linenum-anchor-prefix "L"}
  :profiles {:dev {:dependencies [[log4j "1.2.17"]]}})

(defproject io.aviso/tracker "0.1.1"
  :description "Track per-thread operations when exceptions occur"
  :url "https://github.com/AvisoNovate/tracker"
  :license {:name "Apache Sofware Licencse 2.0"
            :url  "http://www.apache.org/licenses/LICENSE-2.0.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/tools.logging "0.2.6"]
                 [io.aviso/pretty "0.1.8"]]
  :codox {:src-dir-uri               "https://github.com/AvisoNovate/tracker/blob/master/"
          :src-linenum-anchor-prefix "L"}
  :profiles {:dev {:dependencies [[log4j "1.2.17"]]}})

Advance version number to 0.1.1

Advance version number to 0.1.1


(def project-version "0.1.0-SNAPSHOT")

(defproject whitman project-version
  :description "Samples web APIs for fun and profit"
  :url "https://github.com/mdippery/whitman"
  :license {:name "3-Clause BSD"
            :url "http://opensource.org/licenses/BSD-3-Clause"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/data.json "0.2.6"]]
  :main ^:skip-aot whitman.core
  :target-path "target/%s"
  :jar-name "whitman.jar"
  :uberjar-name "whitman-standalone.jar"
  :manifest {"Implementation-Version" ~project-version}
  :profiles {:uberjar {:aot :all}})

(def project-version "0.1.0-SNAPSHOT")

(defproject whitman project-version
  :description "Samples web APIs for fun and profit"
  :url "https://github.com/mdippery/whitman"
  :license {:name "3-Clause BSD"
            :url "http://opensource.org/licenses/BSD-3-Clause"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/data.json "0.2.6"]
                 [com.novemberain/monger "2.0.0"]]
  :main ^:skip-aot whitman.core
  :target-path "target/%s"
  :jar-name "whitman.jar"
  :uberjar-name "whitman-standalone.jar"
  :manifest {"Implementation-Version" ~project-version}
  :profiles {:uberjar {:aot :all}})

Include monger 2.0.0 as a dependency

Include monger 2.0.0 as a dependency


(ns emulator-4917.core)

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

(ns emulator-4917.core
  (:require #?(:cljs [cljs.nodejs :as nodejs])
            #?(:cljs [goog.crypt :as gcrypt])
            [clojure.string :as str]))

;; enable *print-fn* in clojurescript
#?(:cljs (enable-console-print!))

(defn to-4bit-array
  "Convert 0xf4 to [f 4]"
  [s]
  (let [h (bit-shift-right s 4) ;; 0xf4 >> 4   => f
        l (bit-and s 0x0f)]     ;; 0xf4 & 0x0f => 4
    [h l]))

(defn parse-rom
  "Parse binary file and convert contents to vector."
  [file]
  (flatten
   (map to-4bit-array
        #?(:clj
           (.getBytes (slurp file) "ascii")
           :cljs
           (->  (nodejs/require "fs")
                (.readFileSync file "ascii")
                .toString
                gcrypt/stringToUtf8ByteArray)
           ))))

(defn -main [& args]
  (let [arg1 (nth args 0)]
    (if arg1
      (println (parse-rom arg1))
      (println "Error: Please specify filename."))))

;; setup node.js starter point
#?(:cljs (set! *main-cli-fn* -main))

Implement binary reader for clj/cljs

Implement binary reader for clj/cljs

The funtion parse-rom will read from binary and convert it to 4-bit
array.

For example, the binary form is

	(79 FB 68 05 F2 00 00 05)

the parse-rom will convert it to

	(7 9 7 11 6 8 0 5 7 2 0 0 0 0 0 5)

Signed-off-by: Yen-Chin Lee <082d453d72dce940e12089a4ad48b97cfe1f3ec4@gmail.com>


(ns comic-reader.api
  (:require [ajax.core :refer [GET POST]]))

(defn error-handler [{:keys [status status-text]}]
  (.log js/console (str "something bad happened: " status " " status-text)))

(defn get-sites [callback]
  (GET "/api/v1/sites" {:handler callback
                        :error-handler error-handler
                        :response-format :edn}))

(ns comic-reader.api
  (:require [re-frame.core :refer [dispatch]]
            [ajax.core :refer [GET POST]]))

(defn error-handler [{:keys [status status-text]}]
  (.log js/console (str "something bad happened: " status " " status-text)))

(defn get-sites []
  (GET "/api/v1/sites" {:handler #(dispatch [:site-list %])
                        :error-handler error-handler
                        :response-format :edn}))

Rewrite API call to dispatch a re-frame event


{:user {
          :dependencies [[cider/cider-nrepl "0.12.0-SNAPSHOT"] ; Emnacs
                         [acyclic/squiggly-clojure "0.1.5"] ; Emacs
                         ^:replace [org.clojure/tools.nrepl "0.2.12"] ; Emacs
                         ]
        :singing {:gpg-key "matthew.russell@wormbase.org"}}
 ;; VisualVM profiling opts
 :jvm-opts ["-Dcom.sun.management.jmxremote"
            "-Dcom.sun.management.jmxremote.ssl=false"
            "-Dcom.sun.management.jmxremote.authenticate=false"
            "-Dcom.sun.management.jmxremote.port=43210"]}

{:user {:plugin-repositories [["private-plugins" {:url "private repo url"}]]
        :singing {:gpg-key "matthew.russell@wormbase.org"}
        :dependencies [[clojure-ini "0.0.2"]
                       [me.raynes/fs "1.4.6"]]
        :plugins [[cider/cider-nrepl "0.8.2"]
                  [refactor-nrepl "0.2.2"]
                  [jonase/eastwood "0.2.3"]
                  [lein-ancient "0.6.8"]
                  [lein-bikeshed "0.3.0"]
                  [lein-kibit "0.1.2"]
                  [lein-ns-dep-graph "0.1.0-SNAPSHOT"]]}
 :repl {:dependencies [[acyclic/squiggly-clojure "0.1.6"]
                       [datomic-schema-grapher "0.0.1"]
                       [org.clojure/tools.nrepl "0.2.12"]]}
 ;; VisualVM profiling opts
 :jvm-opts ["-Dcom.sun.management.jmxremote"
            "-Dcom.sun.management.jmxremote.ssl=false"
            "-Dcom.sun.management.jmxremote.authenticate=false"
            "-Dcom.sun.management.jmxremote.port=43210"]}

Fix up global deps and plugins.

Fix up global deps and plugins.


(ns obb-rules-api.deploy-test
  (:require [obb-rules-api.simulator-test :as sim])
  (:use clojure.test
        obb-rules-api.routes
        ring.mock.request))

(deftest test-deploy
  (let [[result response]
        (sim/turn-ok :p1
                     {:game {:state "deploy"
                             :stash {:p1 {:kamikaze 1}
                                     :p2 {:kamikaze 1}}
                             :width 8
                             :height 8
                             :elements {}}
                      :actions [[:deploy 1 :kamikaze [8 8]]]})]
    (is (= :deploy (get-in result [:board :state])))))

(deftest test-invalid-deploy
  (let [[result response]
        (sim/turn-fail :p2
                     {:game {:state "deploy"
                             :stash {:p1 {:kamikaze 1}
                                     :p2 {:kamikaze 1}}
                             :width 8
                             :height 8
                             :elements {}}
                      :actions [[:deploy 1 :kamikaze [8 8]]]})]
    (is (= "ActionFailed" (get-in result [:message])))
    (is (= :deploy (get-in result [:board :state])))))

(ns obb-rules-api.deploy-test
  (:require [obb-rules-api.simulator-test :as sim])
  (:use clojure.test
        obb-rules-api.routes
        ring.mock.request))

(deftest test-deploy
  (let [[result response]
        (sim/turn-ok :p1
                     {:game {:state "deploy"
                             :stash {:p1 {:kamikaze 1}
                                     :p2 {:kamikaze 1}}
                             :width 8
                             :height 8
                             :elements {}}
                      :actions [[:deploy 1 :kamikaze [8 8]]]})]
    (is (= :deploy (get-in result [:board :state])))))

(deftest test-finish-deploy
  (let [[result response]
        (sim/turn-ok :p1
                     {:game {:state "deploy"
                             :stash {:p1 {:kamikaze 1}
                                     :p2 {}}
                             :width 8
                             :height 8
                             :elements {}}
                      :actions [[:deploy 1 :kamikaze [8 8]]]})]
    (is (not= :deploy (get-in result [:board :state])))))

(deftest test-invalid-deploy
  (let [[result response]
        (sim/turn-fail :p2
                     {:game {:state "deploy"
                             :stash {:p1 {:kamikaze 1}
                                     :p2 {:kamikaze 1}}
                             :width 8
                             :height 8
                             :elements {}}
                      :actions [[:deploy 1 :kamikaze [8 8]]]})]
    (is (= "ActionFailed" (get-in result [:message])))
    (is (= :deploy (get-in result [:board :state])))))

Test auto start battle after deploy

Test auto start battle after deploy


(ns useful.datatypes-test
  (:use clojure.test useful.datatypes))

(defrecord Test [a b c])
(record-accessors Test)

(deftest test-record
  (let [init (Test. 1 2 3)
        second (Test. 1 5 4)]
    (is (= init (make-record Test :b 2 :a 1 :c 3)))
    (is (= second (assoc-record init :b 5 :c 4)))
    (is (= second (update-record init (+ b 3) (inc c))))
    (is (= (:a init) (a init)))
    (testing "Preserves metadata"
      (let [m {:test 1}
            r (Test. 1 2 3 m {})]
        (is (= m (meta (assoc-record r :b 10))))))
    (testing "Inline typehinting"
      (is (= second (assoc-record ^Test (assoc init :b 5) :c 4))))))

(ns useful.datatypes-test
  (:use clojure.test useful.datatypes))

(defrecord Test [a b c])
(record-accessors Test)

(deftest test-record
  (let [init (Test. 1 2 3)
        second (Test. 1 5 4)]
    (is (= init (make-record Test :b 2 :a 1 :c 3)))
    (is (= second (assoc-record init :b 5 :c 4)))
    (is (= second (update-record init (+ b 3) (inc c))))
    (is (= (:a init) (a init)))
    (testing "Preserves metadata"
      (let [m {:test 1}
            r (Test. 1 2 3 m {})]
        (is (= m (meta (assoc-record r :b 10))))))
    (testing "Inline typehinting"
      (is (= second (assoc-record ^Test (assoc init :b 5) :c 4))))

    (testing "Don't eval more than once"
      (let [times-evaled (atom 0)
            r (Test. 1 2 3)]
        (assoc-record ^Test (do (swap! times-evaled inc) r) :a :x :b :y :c :z)
        (is (= 1 @times-evaled))))))

Test that the record expr is only eval'd once


(ns clojournal.db
  (:require [monger.core :as mg]
            [monger.collection :as mc]
            [environ.core :as env]))

(defonce db
  (let [uri (:mongo-url env/env)
        {:keys [conn db]} (mg/connect-via-uri uri)]
    db))

(defn create-indexes []
  (mc/ensure-index db "articles" (array-map :title 1) {:name "by-title"})
  (mc/ensure-index db "articles" (array-map :content 1) {:name "by-content"})
  (mc/ensure-index db "articles" (array-map :author 1) {:name "by-author"})
  (mc/ensure-index db "articles" (array-map :tags 1) {:name "by-tags"}))

(ns clojournal.db
  (:require [monger.core :as mg]
            [monger.collection :as mc]
            [environ.core :as env]))

(defonce db
  (let [uri (:mongo-url env/env)
        {:keys [conn db]} (mg/connect-via-uri uri)]
    db))

(defn create-indexes []
  (mc/ensure-index db "articles" (array-map :title 1) {:name "by-title"})
  (mc/ensure-index db "articles" (array-map :author 1) {:name "by-author"})
  (mc/ensure-index db "articles" (array-map :tags 1) {:name "by-tags"}))

Remove index from article content, which caused some errors


(ns lt.objs.notifos
  (:require [lt.object :as object]
            [lt.objs.statusbar :as statusbar]
            [lt.objs.command :as cmd]
            [lt.util.js :refer [wait]]
            [crate.binding :refer [map-bound bound deref?]])
  (:require-macros [lt.macros :refer [defui]]))

(def standard-timeout 10000)

(defn working [msg]
  (when msg
    (set-msg! msg))
  (statusbar/loader-inc))

(defn done-working [msg]
  (when msg
    (set-msg! msg))
  (statusbar/loader-dec))

(defn msg* [m opts]
  (object/merge! statusbar/statusbar-loader (merge {:message m :class ""} opts)))

(defn set-msg! [msg opts]
  (msg* msg opts)
  (js/clearTimeout cur-timeout)
  (set! cur-timeout (wait standard-timeout #(msg* ""))))

(cmd/command {:command :reset-working
              :desc "Statusbar: Reset working indicator"
              :exec (fn []
                      (statusbar/loader-set 0)
                      )})

(ns lt.objs.notifos
  (:require [lt.object :as object]
            [lt.objs.statusbar :as statusbar]
            [lt.objs.command :as cmd]
            [lt.util.js :refer [wait]]
            [crate.binding :refer [map-bound bound deref?]])
  (:require-macros [lt.macros :refer [defui]]))

(def standard-timeout 10000)

(defn working [msg]
  (when msg
    (set-msg! msg))
  (statusbar/loader-inc))

(defn done-working
  ([]
   (statusbar/loader-dec))
  ([msg]
   (set-msg! msg)
   (statusbar/loader-dec)))

(defn msg* [m opts]
  (object/merge! statusbar/statusbar-loader (merge {:message m :class ""} opts)))

(defn set-msg! [msg opts]
  (msg* msg opts)
  (js/clearTimeout cur-timeout)
  (set! cur-timeout (wait standard-timeout #(msg* ""))))

(cmd/command {:command :reset-working
              :desc "Statusbar: Reset working indicator"
              :exec (fn []
                      (statusbar/loader-set 0)
                      )})

Add a zero-arg version of done-working

Add a zero-arg version of done-working


(ns pinpointer.trace-test
  (:require [clojure.test :refer [deftest are]]
            [clojure.spec.alpha :as s]
            [pinpointer.trace :as trace]))

(deftest trace-test
  (are [spec input expected]
      (= expected (trace/traces (s/explain-data spec input)))
    (s/map-of keyword? (s/coll-of (s/spec integer?)))
    {:a [1 2] :b ["3"]}
    [[[{:spec `(s/map-of keyword? (s/coll-of (s/spec integer?)))
        :val {:a [1 2] :b ["3"]}
        :steps [:b 1]}
       {:spec `(s/coll-of (s/spec integer?)) :val ["3"] :steps [0]}
       {:spec `(s/spec integer?) :val "3" :steps []}
       {:spec `integer? :val "3" :steps []}]]]))

(ns pinpointer.trace-test
  (:require [clojure.test :refer [deftest are]]
            [clojure.spec.alpha :as s]
            [pinpointer.trace :as trace]))

(deftest trace-test
  (are [spec input expected]
      (= expected (trace/traces (s/explain-data spec input)))
    (s/map-of keyword? (s/coll-of (s/spec integer?)))
    {:a [1 2] :b ["3"]}
    [[[{:spec `(s/map-of keyword? (s/coll-of (s/spec integer?)))
        :val {:a [1 2] :b ["3"]}
        :steps [:b 1]}
       {:spec `(s/coll-of (s/spec integer?)) :val ["3"] :steps [0]}
       {:spec `(s/spec integer?) :val "3" :steps []}
       {:spec `integer? :val "3" :steps []}]]]

    (s/cat :first integer? :second integer?)
    [1]
    [[[{:spec `(s/cat :first integer? :second integer?) :val [1] :steps []}
       {:spec `integer? :val [1] :steps [] :reason "Insufficient input"}]]]

    (s/cat :first integer? :second integer?)
    [1 2 3]
    [[[{:spec `(s/cat :first integer? :second integer?)
        :val [1 2 3]
        :steps [2]
        :reason "Extra input"}]]]))

Add more test cases for insufficient/extra input