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

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

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

(deftest app-specific-codes
  (is (false? (multihash/app-code? 0x00)))
  (doseq [code (range 0x01 0x10)]
    (is (true? (multihash/app-code? code))
        (str "Algorithm code " code " is app-specific")))
  (doseq [code (range 0x10 0x100)]
    (is (false? (multihash/app-code? code))
        (str "Algorithm code " code " is not app-specific"))))

(def examples
  "Test case examples."
  {"11140beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"
   [0x11 :sha1 20 "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"]

   "11040beec7b8"
   [0x11 :sha1 4 "0beec7b8"]

   "12202c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"
   [0x12 :sha2-256 32 "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"]

   "12042c26b46b"
   [0x12 :sha2-256 4 "2c26b46b"]

   "40042c26b46b"
   [0x40 :blake2b 4 "2c26b46b"]})

(deftest example-decoding
  (doseq [[encoded [code algorithm length digest]] examples]
    (let [mhash (multihash/decode encoded)]
      (is (= code (:code mhash)))
      (is (= algorithm (:algorithm mhash)))
      (is (= length (:length mhash)))
      (is (= digest (:digest mhash))))))

(deftest example-encoding
  (doseq [[encoded [code algorithm length digest]] examples]
    (let [mhash (multihash/create algorithm digest)]
      (is (= encoded (multihash/encode mhash))))))

Add initial round of tests.

Add initial round of tests.


(defproject todomvc-re-frame "0.10.5"
  :dependencies [[org.clojure/clojure        "1.10.0"]
                 [org.clojure/clojurescript  "1.10.439"]
                 [reagent "0.8.1"]
                 [re-frame "0.10.5"]
                 [binaryage/devtools "0.9.10"]
                 [secretary "1.2.3"]
                 [day8.re-frame/tracing "0.5.1"]]

  :plugins [[lein-cljsbuild "1.1.7"]
            [lein-figwheel  "0.5.18"]]

  :hooks [leiningen.cljsbuild]

  :profiles {:dev  {:cljsbuild
                    {:builds {:client {:compiler {:asset-path           "js"
                                                  :optimizations        :none
                                                  :source-map           true
                                                  :source-map-timestamp true
                                                  :main                 "todomvc.core"}
                                       :figwheel {:on-jsload "todomvc.core/main"}}}}}

             :prod {:cljsbuild
                    {:builds {:client {:compiler {:optimizations :advanced
                                                  :elide-asserts true
                                                  :pretty-print  false}}}}}}

  :figwheel {:server-port 3450
             :repl        true}

  :clean-targets ^{:protect false} ["resources/public/js" "target"]

  :cljsbuild {:builds {:client {:source-paths ["src" "../../src"]
                                :compiler     {:output-dir "resources/public/js"
                                               :output-to  "resources/public/js/client.js"}}}})

(defproject todomvc-re-frame "0.10.5"
  :dependencies [[org.clojure/clojure        "1.10.0"]
                 [org.clojure/clojurescript  "1.10.439"]
                 [reagent "0.8.1"]
                 [re-frame "0.10.5"]
                 [binaryage/devtools "0.9.10"]
                 [clj-commons/secretary "1.2.4"]
                 [day8.re-frame/tracing "0.5.1"]]

  :plugins [[lein-cljsbuild "1.1.7"]
            [lein-figwheel  "0.5.18"]]

  :hooks [leiningen.cljsbuild]

  :profiles {:dev  {:cljsbuild
                    {:builds {:client {:compiler {:asset-path           "js"
                                                  :optimizations        :none
                                                  :source-map           true
                                                  :source-map-timestamp true
                                                  :main                 "todomvc.core"}
                                       :figwheel {:on-jsload "todomvc.core/main"}}}}}

             :prod {:cljsbuild
                    {:builds {:client {:compiler {:optimizations :advanced
                                                  :elide-asserts true
                                                  :pretty-print  false}}}}}}

  :figwheel {:server-port 3450
             :repl        true}

  :clean-targets ^{:protect false} ["resources/public/js" "target"]

  :cljsbuild {:builds {:client {:source-paths ["src" "../../src"]
                                :compiler     {:output-dir "resources/public/js"
                                               :output-to  "resources/public/js/client.js"}}}})

Update secretary dependency in todomvc

Update secretary dependency in todomvc

Fixes #530


(defproject hello-world "0.23.1"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.10.0"]
                 [uncomplicate/neanderthal "0.23.1"]]
  :exclusions [[org.jcuda/jcuda-natives :classifier "apple-x86_64"]
               [org.jcuda/jcublas-natives :classifier "apple-x86_64"]])

(defproject hello-world "0.23.1"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.10.0"]
                 [uncomplicate/neanderthal "0.23.1"]]
  :exclusions [[org.jcuda/jcuda-natives :classifier "apple-x86_64"]
               [org.jcuda/jcublas-natives :classifier "apple-x86_64"]]
  :jvm-opts ^:replace ["-Dclojure.compiler.direct-linking=true"
                       #_"--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED"])

Add JDK 9+ module example.

Add JDK 9+ module example.


(ns discuss.integration
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [goog.events :as events]
            [cljs.core.async :refer [put! chan <!]]
            [discuss.lib :as lib]
            [discuss.extensions]))

(defn selected-text []
  (let [selection (str (.getSelection js/window))]
    (when (> (count selection) 0)
      (lib/update-state-item! :user :selection (fn [_] selection))
      (lib/log selection))))

(defn get-selection
  "Return the stored selection of the user."
  []
  (get-in @lib/app-state [:user :selection]))

(defn listen [el type]
  (let [out (chan)]
    (events/listen el type
                   (fn [e] (put! out e)))
    out))

(let [clicks (listen (.getElementById js/document "discuss-text") "click")]
  (go (while true
        (<! clicks)
        (selected-text))))

;; http://www.thesoftwaresimpleton.com/blog/2014/12/30/core-dot-async-dot-mouse-dot-down/

(ns discuss.integration
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [goog.events :as events]
            [cljs.core.async :refer [put! chan <!]]
            [discuss.lib :as lib]
            [discuss.extensions]))

(defn get-selection
  "Return the stored selection of the user."
  []
  (get-in @lib/app-state [:user :selection]))

(defn selected-text []
  (let [selection (str (.getSelection js/window))]
    (when (and (> (count selection) 0)
               (not= selection (get-selection)))
      (lib/update-state-item! :user :selection (fn [_] selection))
      (lib/log selection))))

(defn listen [el type]
  (let [out (chan)]
    (events/listen el type
                   (fn [e] (put! out e)))
    out))

(let [clicks (listen (.getElementById js/document "discuss-text") "click")]
  (go (while true
        (<! clicks)
        (selected-text))))

;; http://www.thesoftwaresimpleton.com/blog/2014/12/30/core-dot-async-dot-mouse-dot-down/

Check if selection has changed before changing the atom


{:foreign-libs [{:file "js/fuse/fuse.min.js"
                 :provides ["cljsjs.fuse"]}]
 :externs "js/fuse/fuse.ext.js"}

{:foreign-libs [{:file "js/fuse/fuse.min.js"
                 :provides ["cljsjs.fuse"]}]
 :externs ["js/fuse/fuse.ext.js"]}

Correct expected data structure for externs


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

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

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

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

Change version to snapshot again

Change version to snapshot again


(defproject org.onyxplatform/onyx-datomic "0.7.12"
  :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.12"]]
  :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-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}
             :circle-ci {:jvm-opts ["-Xmx4g"]}})

(defproject org.onyxplatform/onyx-datomic "0.7.13-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.12"]]
  :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-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}
             :circle-ci {:jvm-opts ["-Xmx4g"]}})

Prepare for next release cycle.

Prepare for next release cycle.


(defproject
	li.elmnt/datapump "0.6.0"
	:description "FIXME: write description"
	:url "http://example.com/FIXME"
	:license {:name "Eclipse Public License"
						:url  "http://www.eclipse.org/legal/epl-v10.html"}
	:dependencies [[org.clojure/clojure "1.6.0"]
								 [prismatic/schema "0.4.0"]]
	:profiles {:dev {:dependencies [[junit/junit "4.11"]]}}
	:plugins [[lein-junit "1.1.8"]
						[lein-localrepo "0.5.3"]]
	:source-paths ["src/clojure"]
	:java-source-paths ["src/java"]
	:test-paths ["test/clojure"]
	:java-test-paths ["test/java"]
	:junit ["test/java"])

(defproject
  li.elmnt/datapump "0.7.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url  "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [prismatic/schema "0.4.0"]]
  :profiles {:dev {:dependencies [[junit/junit "4.11"]
                                  [midje "1.6.3"]]}}
  :plugins [[lein-junit "1.1.8"]
            [lein-localrepo "0.5.3"]
            [lein-midje "3.1.3"]
            [lein-marginalia "0.8.0"]]
  :source-paths ["src/clojure"]
  :java-source-paths ["src/java"]
  :test-paths ["test/clojure"]
  :java-test-paths ["test/java"]
  :junit ["test/java"])

Prepare 0.7.0: add marginalia and midje.

Signed-off-by: Stanislas Nanchen <b54ae7893982d10f03c27dbc889098ce04898c8b@hood.ch>


(defproject clj-chrome-devtools "20190529"
  :description "Clojure API for Chrome DevTools remote"
  :license {:name "MIT License"}
  :url "https://github.com/tatut/clj-chrome-devtools"
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [http-kit "2.3.0"]
                 [cheshire "5.8.1"]
                 [stylefruits/gniazdo "1.1.1"]
                 [org.clojure/core.async "0.4.490"]
                 [com.taoensso/timbre "4.10.0"]]
  :plugins [[lein-codox "0.10.3"]]
  :codox {:output-path "docs/api"
          :metadata {:doc/format :markdown}})

(defproject clj-chrome-devtools "20190530-SNAPSHOT"
  :description "Clojure API for Chrome DevTools remote"
  :license {:name "MIT License"}
  :url "https://github.com/tatut/clj-chrome-devtools"
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [http-kit "2.3.0"]
                 [cheshire "5.8.1"]
                 [stylefruits/gniazdo "1.1.1"]
                 [org.clojure/core.async "0.4.490"]
                 [com.taoensso/timbre "4.10.0"]]
  :plugins [[lein-codox "0.10.3"]]
  :codox {:output-path "docs/api"
          :metadata {:doc/format :markdown}})

Update to snapshot version before release


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

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

Prepare for next release cycle.

Prepare for next release cycle.


(defproject onyx-app/lein-template "0.8.11.2"
  :description "Onyx Leiningen application template"
  :url "https://github.com/onyx-platform/onyx-template"
  :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}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

(defproject onyx-app/lein-template "0.8.11.3-SNAPSHOT"
  :description "Onyx Leiningen application template"
  :url "https://github.com/onyx-platform/onyx-template"
  :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}}
  :plugins [[lein-set-version "0.4.1"]]
  :profiles {:dev {:plugins [[lein-set-version "0.4.1"]
                             [lein-update-dependency "0.1.2"]
                             [lein-pprint "1.1.1"]]}}
  :eval-in-leiningen true)

Prepare for next release cycle.

Prepare for next release cycle.


(defproject io.aviso/rook "0.1.2"
  :description "Ruby on Rails-style resource mapping for Clojure/Compojure web apps"
  :url "https://github.com/AvisoNovate/rook"
  :license {:name "Apache Sofware Licencse 2.0"
            :url  "http://www.apache.org/licenses/LICENSE-2.0.html"}
  ;; Normally we don't AOT compile; only when tracking down reflection warnings.
  :profiles {:reflection-warnings {:aot         :all
                                   :global-vars {*warn-on-reflection* true}}}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/tools.logging "0.2.6"]
                 [compojure "1.1.6"]
                 [org.clojure/core.memoize "0.5.6"]]
  :profiles {:dev {:dependencies [[ring-mock "0.1.5"]]}}
  :plugins [[test2junit "1.0.1"]])

(defproject io.aviso/rook "0.1.3-SNAPSHOT"
  :description "Ruby on Rails-style resource mapping for Clojure/Compojure web apps"
  :url "https://github.com/AvisoNovate/rook"
  :license {:name "Apache Sofware Licencse 2.0"
            :url  "http://www.apache.org/licenses/LICENSE-2.0.html"}
  ;; Normally we don't AOT compile; only when tracking down reflection warnings.
  :profiles {:reflection-warnings {:aot         :all
                                   :global-vars {*warn-on-reflection* true}}}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/tools.logging "0.2.6"]
                 [compojure "1.1.6"]
                 [org.clojure/core.memoize "0.5.6"]]
  :profiles {:dev {:dependencies [[ring-mock "0.1.5"]]}}
  :plugins [[test2junit "1.0.1"]])

Advance version number to 0.1.3-SNAPSHOT


(set-env!
 :source-paths #{"src"}
 :dependencies '[[radicalzephyr/boot-junit "0.1.1" :scope "test"]
                 [jeluard/boot-notify "0.1.2"      :scope "test"]
                 [net.sf.jopt-simple/jopt-simple "4.9"]])

(def +version+ "0.1.0-SNAPSHOT")

(require '[radicalzephyr.boot-junit :refer [junit]]
         '[jeluard.boot-notify      :refer [notify]])

(task-options!
 pom {:project 'http-server
      :version +version+
      :description "A Java HTTP server."
      :url "https://github.com/RadicalZephyr/http-server"
      :scm {:url "https://github.com/RadicalZephyr/http-server.git"}
      :licens {"MIT" "http://opensource.org/licenses/MIT"}}
 jar {:file "server.jar"
      :manifest {"Main-Class" "net.zephyrizing.http_server.HttpServer"}})

;;; This prevents a name collision WARNING between the test task and
;;; clojure.core/test, a function that nobody really uses or cares
;;; about.
(if ((loaded-libs) 'boot.user)
  (ns-unmap 'boot.user 'test))

(deftask test
  "Compile and run my jUnit tests."
  []
  (comp (javac)
        (junit)))

(deftask build
  "Build my http server."
  []
  (comp (javac)
        (pom)
        (jar)))

(set-env!
 :source-paths #{"src"}
 :dependencies '[[radicalzephyr/boot-junit "0.2.0-SNAPSHOT" :scope "test"]
                 [jeluard/boot-notify "0.1.2"      :scope "test"]
                 [net.sf.jopt-simple/jopt-simple "4.9"]])

(def +version+ "0.1.0-SNAPSHOT")

(require '[radicalzephyr.boot-junit :refer [junit]]
         '[jeluard.boot-notify      :refer [notify]])

(task-options!
 pom {:project 'http-server
      :version +version+
      :description "A Java HTTP server."
      :url "https://github.com/RadicalZephyr/http-server"
      :scm {:url "https://github.com/RadicalZephyr/http-server.git"}
      :licens {"MIT" "http://opensource.org/licenses/MIT"}}
 jar {:file "server.jar"
      :manifest {"Main-Class" "net.zephyrizing.http_server.HttpServer"}})

;;; This prevents a name collision WARNING between the test task and
;;; clojure.core/test, a function that nobody really uses or cares
;;; about.
(if ((loaded-libs) 'boot.user)
  (ns-unmap 'boot.user 'test))

(deftask test
  "Compile and run my jUnit tests."
  []
  (comp (javac)
        (junit)))

(deftask build
  "Build my http server."
  []
  (comp (javac)
        (pom)
        (jar)))

Update to 0.2.0-SNAPSHOT of boot-junit

Update to 0.2.0-SNAPSHOT of boot-junit


{:dev
 {:aliases {"test-all" ["with-profile" "dev,1.8:dev,1.6:dev,1.5:dev" "test"]}
  :codeina {:sources ["src"]
            :reader :clojure
            :target "doc/dist/latest/api"
            :src-uri "http://github.com/funcool/buddy-core/blob/master/"
            :src-uri-prefix "#L"}
  :plugins [[funcool/codeina "0.3.0"]
            [lein-ancient "0.6.7"]]}
 :1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
 :1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]}
 :1.8 {:dependencies [[org.clojure/clojure "1.8.0-beta2"]]}}

{:dev
 {:aliases {"test-all" ["with-profile" "dev,1.8:dev,1.6:dev,1.5:dev" "test"]}
  :codeina {:sources ["src"]
            :reader :clojure
            :target "doc/dist/latest/api"
            :src-uri "http://github.com/funcool/buddy-core/blob/master/"
            :src-uri-prefix "#L"}
  :plugins [[funcool/codeina "0.3.0"]
            [lein-ancient "0.6.7"]]}
 :1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
 :1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]}
 :1.8 {:dependencies [[org.clojure/clojure "1.8.0-RC4"]]}}

Update clj compiler to 1.8.0-RC4 in :1.8 profile.


(ns uxbox.util.data
  "A collection of data transformation utils.")

(defn index-by
  "Return a indexed map of the collection
  keyed by the result of executing the getter
  over each element of the collection."
  [coll getter]
  (let [data (transient {})]
    (run! #(assoc! data (getter %) %) coll)
    (persistent! data)))

(def ^:static index-by-id #(index-by % :id))

(defn remove-nil-vals
  "Given a map, return a map removing key-value
  pairs when value is `nil`."
  [data]
  (into {} (remove (comp nil? second) data)))

(ns uxbox.util.data
  "A collection of data transformation utils."
  (:require [cljs.reader :as r]))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Data structure manipulation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn index-by
  "Return a indexed map of the collection
  keyed by the result of executing the getter
  over each element of the collection."
  [coll getter]
  (let [data (transient {})]
    (run! #(assoc! data (getter %) %) coll)
    (persistent! data)))

(def ^:static index-by-id #(index-by % :id))

(defn remove-nil-vals
  "Given a map, return a map removing key-value
  pairs when value is `nil`."
  [data]
  (into {} (remove (comp nil? second) data)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Numbers Parsing
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn read-string
  [v]
  (r/read-string v))

(defn parse-int
  [v]
  (js/parseInt v 10))

Add helpers for the reader and int parsing.


(defproject spamscope "2.3.0-SNAPSHOT"
  :resource-paths ["_resources"]
  :target-path "_build"
  :min-lein-version "2.0.0"
  :jvm-opts ["-client"]
  :dependencies  [[org.apache.storm/storm-core "1.1.1"]
                  [org.apache.storm/flux-core "1.1.1"]]
  :jar-exclusions     [#"log4j\.properties" #"org\.apache\.storm\.(?!flux)" #"trident" #"META-INF" #"meta-inf" #"\.yaml"]
  :uberjar-exclusions [#"log4j\.properties" #"org\.apache\.storm\.(?!flux)" #"trident" #"META-INF" #"meta-inf" #"\.yaml"]
  )

(defproject spamscope "2.3.0-SNAPSHOT"
  :resource-paths ["_resources"]
  :target-path "_build"
  :min-lein-version "2.0.0"
  :jvm-opts ["-client"]
  :dependencies  [[org.apache.storm/storm-core "1.2.1"]
                  [org.apache.storm/flux-core "1.2.1"]]
  :jar-exclusions     [#"log4j\.properties" #"org\.apache\.storm\.(?!flux)" #"trident" #"META-INF" #"meta-inf" #"\.yaml"]
  :uberjar-exclusions [#"log4j\.properties" #"org\.apache\.storm\.(?!flux)" #"trident" #"META-INF" #"meta-inf" #"\.yaml"]
  )

Upgrade Apache Storm to 1.2.1

Upgrade Apache Storm to 1.2.1


(ns isla.talk
  (:use [clojure.pprint])
  (:require [clojure.string :as str])
  (:require [mrc.utils :as utils]))

(defn room-intro [room]
  (str "You are in the " (:name room) ". "
       (:summary room)))

(defn room-already [name] (str "You are already in the " name "."))
(defn room-not-allowed [name] (str "You cannot go into the " name "."))

(ns isla.talk
  (:use [clojure.pprint])
  (:require [clojure.string :as str])
  (:require [mrc.utils :as utils]))

(defn room-intro [room]
(declare list-rooms)
  (str "You are in the " (:name room) ". "
       (:summary room)))

(defn room-already [name] (str "You are already in the " name "."))
(defn room-not-allowed [name] (str "You cannot go into the " name "."))

(defmulti list-rooms (fn [rooms] (count rooms)))
(defmethod list-rooms 0 [rooms] "There is no way out of this room.")
(defmethod list-rooms 1 [rooms] (str "You can see a door to the " (:name (first rooms))))
(defmethod list-rooms :default [rooms]
  (let [all-room-list (reduce (fn [string x]
                                (str string ", the " (:name x)))
                              "" rooms)
        all-but-last-list (rest (butlast (str/split all-room-list #",")))
        final (str "You can see a door to"
                   (str/join "," all-but-last-list)
                   " and the " (:name (last rooms)) ".")]
  final))

Add fn to list rooms with nice commas and ands.


(ns bocko-ios.core
  (:require bocko.core))

(defn ^:export init
  [canvas-view-controller]
  (bocko.core/set-create-canvas
    (fn [color-map raster width height _ _]
      (add-watch raster :monitor
        (fn [_ _ old new]
          (when-not (= old new)
            (doseq [x (range width)]
              (let [old-col (nth old x)
                    new-col (nth new x)]
                (when-not (= old-col new-col)
                  (doseq [y (range height)]
                    (let [old-color (nth old-col y)
                          new-color (nth new-col y)]
                      (when-not (= old-color new-color)
                        (let [[r g b] (new-color color-map)]
                          (.plotXYRedGreenBlue canvas-view-controller x y r g b))))))))))))))

(ns bocko-ios.core
  (:require bocko.core))

(defn run-app
  []
  (comment "Code here will be run when app launches"))

(defn ^:export init
  [canvas-view-controller]
  (bocko.core/set-create-canvas
    (fn [color-map raster width height _ _]
      (add-watch raster :monitor
        (fn [_ _ old new]
          (when-not (= old new)
            (doseq [x (range width)]
              (let [old-col (nth old x)
                    new-col (nth new x)]
                (when-not (= old-col new-col)
                  (doseq [y (range height)]
                    (let [old-color (nth old-col y)
                          new-color (nth new-col y)]
                      (when-not (= old-color new-color)
                        (let [[r g b] (new-color color-map)]
                          (.plotXYRedGreenBlue canvas-view-controller x y r g b)))))))))))))
  (run-app))

Add a run-app entry point

Add a run-app entry point


(defproject scrabble "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [thinktopic/cortex "0.1.0-SNAPSHOT"]]
  :main scrabble.core)

(defproject scrabble "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [thinktopic/cortex "0.1.0-SNAPSHOT"]]
  :main scrabble.core)

Update to newer version of clojure.

[examples/scrabble] Update to newer version of clojure.


(defproject java-s3-tests/java-s3-tests "0.0.1"
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [com.reiddraper/clj-aws-s3 "0.4.2"]
                 [clj-http "0.7.1"]
                 [cheshire "5.1.0"]]
  :profiles {:dev {:dependencies [[midje "1.5.1"]]}}
  :min-lein-version "2.0.0"
  :plugins [[lein-midje "3.0.1"]]
  :description "integration tests for Riak CS using the offical Java SDK")

(defproject java-s3-tests/java-s3-tests "0.0.2"
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/tools.logging "0.3.1"]
                 ;; aws-sdk-java deps
                 [com.amazonaws/aws-java-sdk "1.10.8" :exclusions [joda-time]]
                 [joda-time "2.8.1"]
                 [com.fasterxml.jackson.core/jackson-core "2.5.3"]
                 [com.fasterxml.jackson.core/jackson-databind "2.5.3"]
                 ;; user_creation deps
                 [clj-http "2.0.0"]
                 [cheshire "5.1.0"]]
  ;; :jvm-opts ["-verbose:class"]
  :profiles {:dev {:dependencies [[midje "1.7.0"]]}}
  :min-lein-version "2.0.0"
  :plugins [[lein-midje "3.1.3"]]
  :description "integration tests for Riak CS using the offical Java SDK")

Update aws-sdk-java and other library versions


(defproject clj-fst "0.1.0"
  :description "Finite State Transducers (FST) for Clojure"
  :url "https://github.com/structureddynamics/clj-fst"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.apache.lucene/lucene-core "4.10.2"]
                 [org.apache.lucene/lucene-misc "4.10.2"]
                 [lein-marginalia "0.8.0"]]
  :source-paths      ["src/clojure"]
  :java-source-paths ["src/java"]
  :target-path "target/%s"
  :marginalia {:exclude ["utils.clj"]})

(defproject clj-fst "0.1.1"
  :description "Finite State Transducers (FST) for Clojure"
  :url "https://github.com/structureddynamics/clj-fst"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.apache.lucene/lucene-core "4.10.4"]
                 [org.apache.lucene/lucene-misc "4.10.4"]
                 [lein-marginalia "0.8.0"]]
  :source-paths      ["src/clojure"]
  :java-source-paths ["src/java"]
  :target-path "target/%s"
  :marginalia {:exclude ["utils.clj"]})

Update to the latest version of Lucene 4.x


(defproject io.aviso/twixt "0.1.6"
  :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.1"]
                 [org.mozilla/rhino "1.7R4"]
                 [com.github.sommeri/less4j "1.2.1"]
                 [de.neuland-bfi/jade4j "0.4.0"]
                 [io.aviso/pretty "0.1.8"]
                 [hiccup "1.0.4"]]
  :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.7"
  :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.1"]
                 [org.mozilla/rhino "1.7R4"]
                 [com.github.sommeri/less4j "1.2.1"]
                 [de.neuland-bfi/jade4j "0.4.0"]
                 [io.aviso/pretty "0.1.8"]
                 [hiccup "1.0.4"]]
  :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"]]}})

Advance version number to 0.1.7

Advance version number to 0.1.7


(ns clj-templates.config.main-config
  (:require [integrant.core :as ig]
            [environ.core :refer [env]]))

(def main-config
  {:handler/main        {:db (ig/ref :db/postgres)}
   :server/jetty        {:handler (ig/ref :handler/main)
                         :opts    {:port 3000 :join? false}}
   :db/postgres         {:jdbc-url          (env :database-url)
                         :driver-class-name "org.postgresql.Driver"}
   :logger/timbre       {:appenders {:println {:stream :auto}}}
   :jobs/scheduled-jobs {:hours-between-jobs 1
                         :db                 (ig/ref :db/postgres)
                         :es-client          (ig/ref :search/elastic)}
   :search/elastic      {:hosts           ["http://127.0.0.1:9200"]
                         :default-headers {:content-type "application/json"}}})

(ns clj-templates.config.main-config
  (:require [integrant.core :as ig]
            [environ.core :refer [env]]))

(def main-config
  {:handler/main        {:db (ig/ref :db/postgres)}
   :server/jetty        {:handler (ig/ref :handler/main)
                         :opts    {:port 3000 :join? false}}
   :db/postgres         {:jdbc-url          (env :database-url)
                         :driver-class-name "org.postgresql.Driver"}
   :logger/timbre       {:appenders {:println {:stream :auto}}}
   :jobs/scheduled-jobs {:hours-between-jobs 1
                         :db                 (ig/ref :db/postgres)
                         :es-client          (ig/ref :search/elastic)}
   :search/elastic      {:hosts           [(env :elastic-url)]
                         :default-headers {:content-type "application/json"}}})

Use env for elastic url.

Use env for elastic url.


(defproject ohpauleez/cmma "0.1.0-SNAPSHOT"
  :description "Clojure + Make Managed Applications"
  :url "https://github.com/ohpauleez/cmma"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 ;; Try nrepl 0.2.5 and reply 0.3.5 - :(
                 [org.clojure/tools.nrepl "0.2.3"]
                 [reply "0.3.4" :exclusions [[ring/ring-core]]]
                 [com.cemerick/pomegranate "0.3.0" :exclusions [[org.apache.httpcomponents/httpclient]
                                                                [org.codehaus.plexus/plexus-utils]
                                                                [commons-codec]]]
                 [pedantic "0.2.0"]
                 [org.eclipse.jgit/org.eclipse.jgit.java7 "3.4.1.201406201815-r"]

                 ;; Patch up deps
                 [org.apache.httpcomponents/httpclient "4.1.3"]
                 [org.codehaus.plexus/plexus-utils "3.0"]
                 [commons-codec "1.5"]]
  :global-vars  {*warn-on-reflection* true
                 *assert* true}
  :pedantic? :abort)

(defproject ohpauleez/cmma "0.1.0-SNAPSHOT"
  :description "Clojure + Make Managed Applications"
  :url "https://github.com/ohpauleez/cmma"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/tools.nrepl "0.2.5"]
                 [reply "0.3.5" :exclusions [[ring/ring-core]]]
                 [com.cemerick/pomegranate "0.3.0" :exclusions [[org.apache.httpcomponents/httpclient]
                                                                [org.codehaus.plexus/plexus-utils]
                                                                [commons-codec]]]
                 [pedantic "0.2.0"]
                 [org.eclipse.jgit/org.eclipse.jgit.java7 "3.4.1.201406201815-r"]

                 ;; Patch up deps
                 [org.apache.httpcomponents/httpclient "4.1.3"]
                 [org.codehaus.plexus/plexus-utils "3.0"]
                 [commons-codec "1.5"]]
  :global-vars  {*warn-on-reflection* true
                 *assert* true}
  :pedantic? :abort)

Fix reply and nREPL versions

Fix reply and nREPL versions


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

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

Remove broken test generated by project template


(ns such.random
  "Random numbers and crypographic hashes"
  (:import org.apache.commons.codec.digest.DigestUtils))

(defn guid
  "A random almost-certainly-unique identifier"
  []
  (str (java.util.UUID/randomUUID)))

(def uuid "Synonym for `guid`" guid)

(defn form-hash
  "Returns a SHA-1 hash (encoded as a hex string) from the `prn` representation of the input.
   Use for collision avoidance when the highest security is not needed."
  [form]
  (DigestUtils/sha1Hex (pr-str form)))

(ns such.random
  "Random numbers and crypographic hashes"
  (:import org.apache.commons.codec.digest.DigestUtils))

(defn guid
  "A random almost-certainly-unique identifier"
  []
  (str (java.util.UUID/randomUUID)))

(def uuid "Synonym for `guid`" guid)

(defn form-hash
  "Returns a SHA-1 hash (encoded as a hex string) from the `prn` representation of the input.
   Use for collision avoidance when the highest security is not needed."
  [form]
  ;; Note: this is deprecated in later versions of commons.codec. However,
  ;; we're using an old version for compatibility with Compojure.
  ;; When compojure updates, we can use sha1Hex.
  (DigestUtils/shaHex (pr-str form)))

Revert to older version of commons-codec for compatibility with compojure


(defproject inlein/client "0.1.0-SNAPSHOT"
  :description "Inlein your dependencies."
  :url "https://github.com/hyPiRion/inlein"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies []
  :source-paths []
  :java-source-paths ["src"]
  :javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
  :main inlein.client.Main
  :scm {:dir ".."}
  :aliases {"javadoc" ["shell" "javadoc" "-d" "javadoc/inlein-${:version}"
                       "-sourcepath" "src" "inlein.client"]}
  :plugins [[lein-shell "0.5.0"]]
  :uberjar-name "inlein-%s.jar"
  ;; to avoid complaints from Leiningen
  :profiles {:uberjar {:aot :all}
             :dev {:dependencies [[org.clojure/clojure "1.8.0"]]}})

(defproject inlein/client "0.1.0-SNAPSHOT"
  :description "Inlein your dependencies."
  :url "https://github.com/hyPiRion/inlein"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies []
  :source-paths []
  :java-source-paths ["src"]
  :javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
  :main inlein.client.Main
  :scm {:dir ".."}
  :aliases {"javadoc" ["shell" "javadoc" "-d" "javadoc/inlein-${:version}"
                       "-sourcepath" "src" "inlein.client"]}
  :plugins [[lein-shell "0.5.0"]]
  :jar-name "inlein-no-deps-%s.jar"
  :uberjar-name "inlein-%s.jar"
  ;; to avoid complaints from Leiningen
  :profiles {:uberjar {:aot :all}
             :dev {:dependencies [[org.clojure/clojure "1.8.0"]]}})

Make it easier to separate between jar and uberjar


(ns formlogic.db
  (:require [yesql.core :refer [defqueries]]))

(def db-spec {:classname "org.postgresql.Driver"
              :subprotocol "postgresql"
              :subname "//localhost:5432/formlogic"
              :user "formlogic"})

(defqueries "sql/get.sql" {:connection db-spec})
(defqueries "sql/insert.sql" {:connection db-spec})

(ns formlogic.db
  (:require [yesql.core :refer [defqueries]]
            [formlogic.config :refer [cget]]))

(def db-spec {:classname "org.postgresql.Driver"
              :subprotocol "postgresql"
              :subname (format "//%s:%d/%s"
                               (cget :db :host)
                               (cget :db :port)
                               (cget :db :database))
              :user (cget :db :user)})

(defqueries "sql/get.sql" {:connection db-spec})
(defqueries "sql/insert.sql" {:connection db-spec})

Use DB connection configuration from config.edn


(defproject todomvc-re-frame "0.10.5"
  :dependencies [[org.clojure/clojure        "1.10.0"]
                 [org.clojure/clojurescript  "1.10.439"]
                 [reagent "0.8.1"]
                 [re-frame "0.10.5"]
                 [binaryage/devtools "0.9.10"]
                 [secretary "1.2.3"]
                 [day8.re-frame/tracing "0.5.1"]

  :plugins [[lein-cljsbuild "1.1.7"]
            [lein-figwheel  "0.5.18"]]

  :hooks [leiningen.cljsbuild]

  :profiles {:dev  {:cljsbuild
                    {:builds {:client {:compiler {:asset-path           "js"
                                                  :optimizations        :none
                                                  :source-map           true
                                                  :source-map-timestamp true
                                                  :main                 "todomvc.core"}
                                       :figwheel {:on-jsload "todomvc.core/main"}}}}}

             :prod {:cljsbuild
                    {:builds {:client {:compiler {:optimizations :advanced
                                                  :elide-asserts true
                                                  :pretty-print  false}}}}}}

  :figwheel {:server-port 3450
             :repl        true}

  :clean-targets ^{:protect false} ["resources/public/js" "target"]

  :cljsbuild {:builds {:client {:source-paths ["src" "../../src"]
                                :compiler     {:output-dir "resources/public/js"
                                               :output-to  "resources/public/js/client.js"}}}})

(defproject todomvc-re-frame "0.10.5"
  :dependencies [[org.clojure/clojure        "1.10.0"]
                 [org.clojure/clojurescript  "1.10.439"]
                 [reagent "0.8.1"]
                 [re-frame "0.10.5"]
                 [binaryage/devtools "0.9.10"]
                 [secretary "1.2.3"]
                 [day8.re-frame/tracing "0.5.1"]]

  :plugins [[lein-cljsbuild "1.1.7"]
            [lein-figwheel  "0.5.18"]]

  :hooks [leiningen.cljsbuild]

  :profiles {:dev  {:cljsbuild
                    {:builds {:client {:compiler {:asset-path           "js"
                                                  :optimizations        :none
                                                  :source-map           true
                                                  :source-map-timestamp true
                                                  :main                 "todomvc.core"}
                                       :figwheel {:on-jsload "todomvc.core/main"}}}}}

             :prod {:cljsbuild
                    {:builds {:client {:compiler {:optimizations :advanced
                                                  :elide-asserts true
                                                  :pretty-print  false}}}}}}

  :figwheel {:server-port 3450
             :repl        true}

  :clean-targets ^{:protect false} ["resources/public/js" "target"]

  :cljsbuild {:builds {:client {:source-paths ["src" "../../src"]
                                :compiler     {:output-dir "resources/public/js"
                                               :output-to  "resources/public/js/client.js"}}}})

Fix missing trailing ] in todomvc :dependencies


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

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

Prepare for next release cycle.

Prepare for next release cycle.


(defproject jnanomsg "0.1.0"
  :description "Nanomsg clojure/java wrapper/"
  :url "https://github.com/niwibe/jnanomsg"
  :license {:name "Apache 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0.txt"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/core.async "0.1.267.0-0d7780-alpha"]
                 [net.java.dev.jna/jna "4.0.0"]]
  :jvm-opts ["-server" "-Xmx2g" "-XX:+UseG1GC"]
  :source-paths ["src/clojure"]
  :java-source-paths ["src/java"]
  :plugins [[lein-javadoc "0.1.1"]]
  :javadoc-opts {:output-dir "docs/_build/javadoc"
                 :package-names ["nanomsg" "nanomsg.jna" "nanomsg.pubsub"
                                 "nanomsg.reqrep" "nanomsg.bus" "nanomsg.pair"]}
  :main nanomsg.benchmark
  :profiles {:uberjar {:aot :all}})

(defproject jnanomsg "0.1.0"
  :description "Nanomsg clojure/java wrapper/"
  :url "https://github.com/niwibe/jnanomsg"
  :license {:name "Apache 2.0"
            :url "http://www.apache.org/licenses/LICENSE-2.0.txt"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/core.async "0.1.267.0-0d7780-alpha"]
                 [net.java.dev.jna/jna "4.0.0"]]
  :jvm-opts ["-server" "-Xmx2g" "-XX:+UseG1GC"]
  :source-paths ["src/clojure"]
  :java-source-paths ["src/java"]
  :plugins [[lein-javadoc "0.1.1"]]
  :javadoc-opts {:output-dir "docs/javadoc"
                 :package-names ["nanomsg" "nanomsg.jna" "nanomsg.pubsub" "nanomsg.exceptions"
                                 "nanomsg.reqrep" "nanomsg.bus" "nanomsg.pair"]}
  :main nanomsg.benchmark
  :profiles {:uberjar {:aot :all}})

Add more new nanomsg.exceptions package to javadoc.


(defproject {{app-name}} "0.1.0-SNAPSHOT"
  :description ""
  :url ""
  :license {:name ""
            :url ""}
  :dependencies [[aero "1.0.0-beta2"]
                 [org.clojure/clojure "1.8.0"]
                 [org.clojure/tools.cli "0.3.5"]
                 [org.onyxplatform/onyx "{{onyx-version}}{{onyx-version-post}}"]
                 [org.onyxplatform/lib-onyx "{{onyx-version}}.{{lib-onyx-minor}}"]]
  :source-paths ["src"]

  :profiles {:dev {:jvm-opts ["-XX:-OmitStackTraceInFastThrow"]
                   :global-vars {*assert* false}}
             :dependencies [[org.clojure/tools.namespace "0.2.11"]
                            [lein-project-version "0.1.0"]]
             :uberjar {:aot [lib-onyx.media-driver
                             {{app-name}}.core]
                       :uberjar-name "peer.jar"
                       :global-vars {*assert* false}}})

(defproject {{app-name}} "0.1.0-SNAPSHOT"
  :description ""
  :url ""
  :license {:name ""
            :url ""}
  :dependencies [[aero "1.0.0-beta2"]
                 [org.clojure/clojure "1.8.0"]
                 [org.clojure/tools.cli "0.3.5"]
                 [org.onyxplatform/onyx "{{onyx-version}}{{onyx-version-post}}"]
                 [org.onyxplatform/lib-onyx "{{onyx-version}}.{{lib-onyx-minor}}"]]
  :source-paths ["src"]

  :profiles {:dev {:jvm-opts ["-XX:-OmitStackTraceInFastThrow"]
                   :global-vars {*assert* true}}
             :dependencies [[org.clojure/tools.namespace "0.2.11"]
                            [lein-project-version "0.1.0"]]
             :uberjar {:aot [lib-onyx.media-driver
                             {{app-name}}.core]
                       :uberjar-name "peer.jar"
                       :global-vars {*assert* false}}})

Enable assertions in development mode

Enable assertions in development mode


(ns onyx.static.default-vals)

(def defaults
  {; input task defaults
   :onyx/input-retry-timeout 1000
   :onyx/pending-timeout 60000
   :onyx/max-pending 10000

   ; task defaults
   :onyx/batch-timeout 1000

   ; zookeeper defaults
   :onyx.peer/zookeeper-timeout 50000

   ; peer defaults
   :onyx.peer/inbox-capacity 1000
   :onyx.peer/outbox-capacity 1000
   :onyx.peer/drained-back-off 400
   :onyx.peer/sequential-back-off 2000
   :onyx.peer/job-not-ready-back-off 500

   ; messaging defaults
   :onyx.messaging.aeron/embedded-driver? true
   :onyx.messaging.netty/thread-pool-sizes 1
   :onyx.messaging.netty/connect-timeout-millis 1000
   :onyx.messaging.netty/pending-buffer-size 10000
   :onyx.messaging/completion-buffer-size 50000
   :onyx.messaging/release-ch-buffer-size 10000
   :onyx.messaging/retry-ch-buffer-size 10000})

(ns onyx.static.default-vals)

(def defaults
  {; input task defaults
   :onyx/input-retry-timeout 1000
   :onyx/pending-timeout 60000
   :onyx/max-pending 10000

   ; task defaults
   :onyx/batch-timeout 1000

   ; zookeeper defaults
   :onyx.peer/zookeeper-timeout 6000

   ; peer defaults
   :onyx.peer/inbox-capacity 1000
   :onyx.peer/outbox-capacity 1000
   :onyx.peer/drained-back-off 400
   :onyx.peer/sequential-back-off 2000
   :onyx.peer/job-not-ready-back-off 500

   ; messaging defaults
   :onyx.messaging.aeron/embedded-driver? true
   :onyx.messaging.netty/thread-pool-sizes 1
   :onyx.messaging.netty/connect-timeout-millis 1000
   :onyx.messaging.netty/pending-buffer-size 10000
   :onyx.messaging/completion-buffer-size 50000
   :onyx.messaging/release-ch-buffer-size 10000
   :onyx.messaging/retry-ch-buffer-size 10000})

Reduce ZK timeout back to default for zookeeper-clj


(ns org.knotation.editor.line-map
  (:require [clojure.set :as set]

            [org.knotation.state :as st]

            [org.knotation.editor.util :as util]))

(def empty {})

(defn compiled->line-map
  ([compiled] (compiled->line-map empty compiled))
  ([line-map compiled]
   (let [modified
         (fn [m ed in out]
           (if (and in out)
             (update-in
              (update-in m [ed in] #(conj (or % #{}) [:out (dec out)]))
              [:out (dec out)] #(conj (or % #{})  [ed in]))
             m))]
     (:map
      (reduce
       (fn [memo elem]
         (let [ed (if (= ::st/graph-end (::st/event elem)) (+ 1 (:ed memo)) (:ed memo))
               in (::st/line-number (::st/input elem))
               out (::st/line-number (::st/output elem))
               lns (count (::st/lines (::st/input elem)))
               comp (:compensate memo)
               m (:map memo)]
           {:ed ed
            :compensate (if (> lns 1) (+ (dec lns) comp) comp)
            :map (reduce (fn [m delta] (modified m ed (+ delta in) (+ delta comp out))) m (range lns))}))
       {:ed 0 :compensate 0 :map line-map}
       compiled)))))

(defn lookup
  [line-map editor-ix line-ix]
  (get-in line-map [editor-ix line-ix] #{}))

(ns org.knotation.editor.line-map
  (:require [clojure.set :as set]

            [org.knotation.state :as st]

            [org.knotation.editor.util :as util]))

(def empty {})

(defn compiled->line-map
  ([compiled] (compiled->line-map empty compiled))
  ([line-map compiled]
   (let [modified
         (fn [m ed in out]
           (if (and in out)
             (update-in
              (update-in m [ed (dec in)] #(conj (or % #{}) [:out out]))
              [:out out] #(conj (or % #{}) [ed (dec in)]))
             m))]
     (:map
      (reduce
       (fn [memo elem]
         (let [ed (if (= ::st/graph-end (::st/event elem)) (+ 1 (:ed memo)) (:ed memo))
               in (::st/line-number (::st/input elem))
               out (::st/line-number (::st/output elem))
               lns (count (::st/lines (::st/input elem)))
               m (:map memo)]
           {:ed ed
            :map (reduce (fn [m delta] (modified m ed (+ delta in) (+ delta out))) m (range lns))}))
       {:ed 0 :map line-map}
       compiled)))))

(defn lookup
  [line-map editor-ix line-ix]
  (get-in line-map [editor-ix line-ix] #{}))

Update highlighting to accomodate new knotation-cljs


(ns audio-utils.mp3-encoder
  (:require [cljsjs.lamejs]
            [audio-utils.worker :as w]))

(defrecord MP3Encoder [bit-rate sample-rate next]
  w/IWorkerAudioNode
  (connect [this destination]
    (reset! next destination))

  (disconnect [this]
    (reset! next nil))

  (process-audio [this data]
    (let [int-data (mapv (fn [samples]
                           (into-array (map #(* 32768 %) samples)))
                         data)
          encoder  (js/lamejs.Mp3Encoder. (count data) sample-rate
                                          bit-rate)
          encoded  #js []]
      (doto encoded
        (.push (apply (aget encoder "encodeBuffer") int-data))
        (.push (.flush encoder)))
      (some-> @next (w/process-audio encoded)))))

(defn mp3-encoder
  [{:keys [bit-rate
           sample-rate]
    :or   {bit-rate    128
           sample-rate 44100}}]
  (map->MP3Encoder {:bit-rate    bit-rate
                    :sample-rate sample-rate
                    :next        (atom nil)}))

(ns audio-utils.mp3-encoder
  (:require [cljsjs.lamejs]
            [audio-utils.util :as u]
            [audio-utils.worker :as w]))

(defrecord MP3Encoder [bit-rate sample-rate next]
  w/IWorkerAudioNode
  (connect [this destination]
    (reset! next destination))

  (disconnect [this]
    (reset! next nil))

  (process-audio [this data]
    (let [int-data (u/amap (fn [samples]
                             (u/amap #(* 32768 %) samples))
                           data)
          encoder  (js/lamejs.Mp3Encoder. (u/acount data) sample-rate
                                          bit-rate)
          encoded  #js []]
      (doto encoded
        (.push (apply (.-encodeBuffer encoder) int-data))
        (.push (.flush encoder)))
      (some-> @next (w/process-audio encoded)))))

(defn mp3-encoder
  [{:keys [bit-rate
           sample-rate]
    :or   {bit-rate    128
           sample-rate 44100}}]
  (map->MP3Encoder {:bit-rate    bit-rate
                    :sample-rate sample-rate
                    :next        (atom nil)}))

Update MP3 encoder to operate on JS arrays/data


(ns om-tut.core
  (:require [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true]))

(enable-console-print!)

(println "A new developer message. Pay attention, dev guy!")

;; define your app data so that it doesn't get over-written on reload

(defonce app-state (atom {:list ["Lion" "Zebra" "Buffalo" "Antelope"]}))

(om/root
 (fn [data owner]
   (om/component
    (apply dom/ul nil
           (map (fn [text] (dom/li nil text)) (:list data)))))
 app-state
 {:target (. js/document (getElementById "app0"))})

(defn on-js-reload []
  ;; optionally touch your app-state to force rerendering depending on
  ;; your application
  ;; (swap! app-state update-in [:__figwheel_counter] inc)
)

(ns om-tut.core
  (:require [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true]))

(enable-console-print!)

(println "A new developer message. Pay attention, dev guy!")

;; define your app data so that it doesn't get over-written on reload

(defonce app-state (atom {:list ["Lion" "Zebra" "Buffalo" "Antelope"]}))

(om/root
 (fn [data owner]
   (om/component
    (apply dom/ul #js {:className "animals"}
           (map (fn [text] (dom/li nil text)) (:list data)))))
 app-state
 {:target (. js/document (getElementById "app0"))})

(defn on-js-reload []
  ;; optionally touch your app-state to force rerendering depending on
  ;; your application
  ;; (swap! app-state update-in [:__figwheel_counter] inc)
)

Implement code to render a list of things.


(ns leiningen.new.vdom-app
  (:use [leiningen.new.templates :only [renderer name-to-path ->files]]))

(def render (renderer "vdom-app"))

(defn vdom-app [name]
  (let [data {:name name
              :path (name-to-path name)}]
    (->files data
      ["index.html" (render "index.html" data)]
      ["dev.html" (render "dev.html" data)]
      ["project.clj" (render "project.clj" data)]
      "externs"
      ["externs/vdom.js" (render "externs/vdom.js" data)]
      "src/{{path}}"
      ["src/{{path}}/core.cljs" (render "src/vdom_app/core.cljs" data)]
      "resources/public/js"
      ["resources/public/js/vdom.js" (render "resources/public/js/vdom.js" data)]
      "resources/public/css"
      "resources/public/css/{{path}}.css" (render "resources/public/css/styles.css" data))))

(ns leiningen.new.vdom-app
  (:use [leiningen.new.templates :only [renderer name-to-path ->files]]))

(def render (renderer "vdom-app"))

(defn vdom-app [name]
  (let [data {:name name
              :path (name-to-path name)}]
    (->files data
      ["index.html" (render "index.html" data)]
      ["dev.html" (render "dev.html" data)]
      ["project.clj" (render "project.clj" data)]
      "externs"
      ["externs/vdom.js" (render "externs/vdom.js" data)]
      "src/{{path}}"
      ["src/{{path}}/core.cljs" (render "src/vdom_app/core.cljs" data)]
      "resources/public/js"
      ["resources/public/js/vdom.js" (render "resources/public/js/vdom.js" data)]
      "resources/public/css"
      ["resources/public/css/{{path}}.css" (render "resources/public/css/styles.css" data)])))

Fix creating directory instead of file.

Fix creating directory instead of file.


(ns quil-site.core
  (:require [compojure.core :refer [defroutes GET]]
            [compojure.handler :refer [site]]
            [compojure.route :refer [files]]
            [ring.middleware.json :as json]
            [ring.adapter.jetty :refer [run-jetty]]
            [ring.middleware.stacktrace :as stacktrace]
            [quil-site.sketches :as sketches]
            [quil-site.views.about :refer [about-page]]))

(defroutes app
  (GET "/" [] (about-page))
  sketches/routes
  (files "/"))

(defn dump-request [handler]
  (fn [req]
    (clojure.pprint/pprint req)
    (handler req)))

(def handler
  (-> #'app
      dump-request
      site
      (json/wrap-json-body {:keywords? true})
      json/wrap-json-response
      stacktrace/wrap-stacktrace))

(comment

 (def server (run-jetty #(handler %) {:port 8080 :join? false}))

 (.stop server)

)

(ns quil-site.core
  (:require [compojure.core :refer [defroutes GET]]
            [compojure.handler :refer [site]]
            [compojure.route :refer [files]]
            [ring.middleware.json :as json]
            [ring.adapter.jetty :refer [run-jetty]]
            [ring.middleware.stacktrace :as stacktrace]
            [quil-site.sketches :as sketches]
            [quil-site.views.about :refer [about-page]]))

(defroutes app
  (GET "/" [] (about-page))
  sketches/routes
  (files "/"))

(defn dump-request [handler]
  (fn [req]
    (clojure.pprint/pprint req)
    (handler req)))

(def handler
  (-> #'app
      dump-request
      site
      (json/wrap-json-body {:keywords? true})
      json/wrap-json-response
      stacktrace/wrap-stacktrace))

(defn run []
  (run-jetty handler {:port 8080}))

(comment

 (def server (run-jetty #(handler %) {:port 8080 :join? false}))

 (.stop server)

)

Add method for running server.

Add method for running server.


(ns braid.search.ui.search-bar
  (:require
   [reagent.core :as r]
   [re-frame.core :refer [subscribe dispatch]]
   [braid.core.client.routes :as routes]
   [braid.lib.color :as color]))

(defn search-bar-view
  []
  (r/with-let [search-query (r/atom @(subscribe [:braid.search/query]))]
    [:div.search-bar
     [:input {:type "text"
              :placeholder "Search..."
              :value @search-query
              :on-change
              (fn [e]
                (reset! search-query (.. e -target -value))
                (dispatch [:braid.search/update-query! (.. e -target -value)]))}]
     (if (and @search-query (not= "" @search-query))
       [:a.action.clear
        {:on-click (fn [] (reset! search-query ""))
         :href (routes/group-page-path {:group-id @(subscribe [:open-group-id])
                                        :page-id "inbox"})
         :style {:color (color/->color @(subscribe [:open-group-id]))}}]
       [:div.action.search])]))

(ns braid.search.ui.search-bar
  (:require
   [reagent.core :as r]
   [re-frame.core :refer [subscribe dispatch]]
   [braid.core.client.routes :as routes]
   [braid.lib.color :as color]))

(defn search-bar-view
  []
  (r/with-let [search-query (r/atom @(subscribe [:braid.search/query]))
               prev-page (r/atom (:type @(subscribe [:page])))]
    (let [current-page (:type @(subscribe [:page]))]
      (when (not= @prev-page current-page)
        (when (= @prev-page :search)
          (reset! search-query ""))
        (reset! prev-page current-page)))
    [:div.search-bar
     [:input {:type "text"
              :placeholder "Search..."
              :value @search-query
              :on-change
              (fn [e]
                (reset! search-query (.. e -target -value))
                (dispatch [:braid.search/update-query! (.. e -target -value)]))}]
     (if (and @search-query (not= "" @search-query))
       [:a.action.clear
        {:on-click (fn [] (reset! search-query ""))
         :href (routes/group-page-path {:group-id @(subscribe [:open-group-id])
                                        :page-id "inbox"})
         :style {:color (color/->color @(subscribe [:open-group-id]))}}]
       [:div.action.search])]))

[search] Make leaving the search page clear the search bar


(ns discuss.test.lib
  (:require [cljs.pprint :as pprint]
            [cljs.test :refer-macros [is]]))

(defn- summarize-results' [spec-check]
  (doall (map #(-> % :clojure.test.check/ret pprint/pprint) spec-check)))

(defn check' [spec-check]
  (summarize-results' spec-check)
  (is (nil? (-> spec-check first :failure))))

(ns discuss.test.lib
  (:require [cljs.pprint :as pprint]
            [cljs.test :refer-macros [is]]))

(defn- summarize-results' [spec-check]
  (doall (map #(-> %
                   (select-keys [:clojure.test.check/ret :sym])
                   vals
                   pprint/pprint) spec-check)))

(defn check' [spec-check]
  (summarize-results' spec-check)
  (is (nil? (-> spec-check first :failure))))

Add name of fn which was automatically tested


(ns rill.event-store.psql-test
  (:require [rill.event-store.psql :refer [psql-event-store]]
            [rill.event-store.psql.tools :as tools]
            [rill.event-store.generic-test-base :refer [test-store]]
            [clojure.test :refer :all]))

(def config {:user (System/getenv "RILL_POSTGRES_USER")
             :password (System/getenv "RILL_POSTGRES_PASSWORD")
             :hostname (System/getenv "RILL_POSTGRES_HOST")
             :port (System/getenv "RILL_POSTGRES_PORT")
             :database (System/getenv "RILL_POSTGRES_DATABASE")})

(defn get-clean-psql-store! [config]
  (tools/clear-db! config)
  (psql-event-store (tools/connection config)))

(deftest test-psql-store
  (if (System/getenv "RILL_POSTGRES_DATABASE")
    (do (tools/load-schema! config)
        (test-store #(get-clean-psql-store! config)))
    (println "Skipped tests for rill postgres backend. Set at least RILL_POSTGRES_DATABASE environment variable to configure and enable tests")))

(ns rill.event-store.psql-test
  (:require [rill.event-store.psql :refer [psql-event-store]]
            [rill.event-store.psql.tools :as tools]
            [rill.event-store.generic-test-base :refer [test-store]]
            [clojure.test :refer :all]))

(def config {:user (System/getenv "RILL_POSTGRES_USER")
             :password (System/getenv "RILL_POSTGRES_PASSWORD")
             :hostname (System/getenv "RILL_POSTGRES_HOST")
             :port (System/getenv "RILL_POSTGRES_PORT")
             :database (System/getenv "RILL_POSTGRES_DB")})

(defn get-clean-psql-store! [config]
  (tools/clear-db! config)
  (psql-event-store (tools/connection config)))

(deftest test-psql-store
  (if (System/getenv "RILL_POSTGRES_DB")
    (do (tools/load-schema! config)
        (test-store #(get-clean-psql-store! config)))
    (println "Skipped tests for rill postgres backend. Set at least RILL_POSTGRES_DB environment variable to configure and enable tests")))

Fix accidental rename of environment variable


(ns continuo.postgresql-spec
  (:require [clojure.test :as t]
            [continuo.postgresql.schema :as schema]))

(t/deftest schema-internal-tests
  (let [schema [[:db/add :user/username {:type :continuo/string}]
                [:db/add :user/fullname {:type :continuo/string}]
                [:db/drop :user/name]]
        cschema (schema/compile-schema schema)]
    (cschema (fn [sql]
               (println "Executing:" sql)))))

(ns continuo.postgresql-spec
  (:require [clojure.test :as t]
            [suricatta.core :as sc]
            [continuo.core :as co]
            [continuo.impl :as impl]
            [continuo.executor :as exec]
            [continuo.postgresql.connection :as conn]
            [continuo.postgresql.schema :as schema])
  (:import java.net.URI))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Fixtures & Initialization
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(def +ctx+)
(def dbspec {:subprotocol "postgresql"
             :subname "//127.0.0.1/test"})

(defn transaction-fixture
  [continuation]
  (with-open [ctx (sc/context dbspec)]
    (sc/atomic ctx
      (alter-var-root #'+ctx+ (constantly ctx))
      (continuation)
      (sc/set-rollback! ctx))))

(deftype Transactor [schema]
  conn/ITrasactor
  (-get-connection [_] +ctx+)
  (-get-schema [_] schema))

(defmethod impl/connect :pgtest
  [_ _]
  (exec/submit (fn [] (Transactor. (atom nil)))))

(t/use-fixtures :each transaction-fixture)

(def ^:static uri "pgtest://localhost/test")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Tests
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(t/deftest facked-connect-tests
  (let [tx @(impl/connect (URI. uri) {})]
    (t/is (instance? Transactor tx))))

;; (t/deftest schema-internal-tests
;;   (let [schema [[:db/add :user/username {:type :continuo/string}]
;;                 [:db/add :user/fullname {:type :continuo/string}]
;;                 [:db/drop :user/name]]
;;         cschema (schema/compile-schema schema)]
;;     (cschema (fn [sql]
;;                (println "Executing:" sql)))))

Add first test for fake transactor creation process.


(ns fhofherr.clj-db-util.jdbc-template-test
  (:require [clojure.test :refer :all]
            [fhofherr.clj-db-util.support.test-db :as test-db]
            [fhofherr.clj-db-util.jdbc-template :as t]
            [fhofherr.clj-db-util.dialect :refer [h2]]))

(deftest named-parameters
  (let [stmt "SELECT 1 AS result FROM dual WHERE 1 = :number"]
    (is (= {:result 1}
         (t/query-str h2
                      (test-db/h2-private-in-memory)
                      stmt
                      :params {:number 1}
                      :result-set-fn first)))
    (is (nil?
         (t/query-str h2
                      (test-db/h2-private-in-memory)
                      stmt
                      :params {:number 2}
                      :result-set-fn first)))))

(ns fhofherr.clj-db-util.jdbc-template-test
  (:require [clojure.test :refer :all]
            [fhofherr.clj-db-util.support.test-db :as test-db]
            [fhofherr.clj-db-util.jdbc-template :as t]
            [fhofherr.clj-db-util.dialect :refer [h2]]))

(deftest named-parameters
  (testing "simple statements"
    (let [stmt "SELECT 1 AS result FROM dual WHERE 1 = :number"]
      (is (= {:result 1}
             (t/query-str h2
                          (test-db/h2-private-in-memory)
                          stmt
                          :params {:number 1}
                          :result-set-fn first)))
      (is (nil?
            (t/query-str h2
                         (test-db/h2-private-in-memory)
                         stmt
                         :params {:number 2}
                         :result-set-fn first)))))
  (testing "subselects"
    (let [stmt "SELECT 1 AS result
                FROM dual
                WHERE 1 = :number
                  AND EXISTS (SELECT 1 FROM DUAL WHERE 2 = :another-number)"]
      (is (= {:result 1}
             (t/query-str h2
                          (test-db/h2-private-in-memory)
                          stmt
                          :params {:number 1
                                   :another-number 2}
                          :result-set-fn first))))))

Test subselects with named parameters.

Test subselects with named parameters.


(ns pangram-test
  (:require [clojure.test :refer [is deftest]]
            [pangram :refer [pangram?]]))

(deftest empty-sentence
  (is (false? (pangram? ""))))

(deftest lowercase-pangram
  (is (pangram? "the quick brown fox jumps over the lazy dog")))

(deftest missing-character-x
  (is
   (false?
    (pangram? "a quick movement of the enemy will jeopardize five gunboats"))))

(deftest another-missing-character-x
  (is
   (false?
    (pangram? "the quick brown fish jumps over the lazy dog"))))

(deftest with-underscores
  (is (pangram? "the_quick_brown_fox_jumps_over_the_lazy_dog")))

(deftest with-numbers
  (is (pangram? "the 1 quick brown fox jumps over the 2 lazy dogs")))

(deftest missing-letters-replaced-by-numbers
  (is
   (false?
    (pangram? "7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog"))))

(deftest mixed-case-and-punctuation
  (is (pangram? "\"Five quacking Zephyrs jolt my wax bed.\"")))

(deftest non-ascii-characters
  (is (pangram?
       "Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.")))

(ns pangram-test
  (:require [clojure.test :refer [is deftest]]
            [pangram :refer [pangram?]]))

(deftest empty-sentence
  (is (false? (pangram? ""))))

(deftest lowercase-pangram
  (is (pangram? "the quick brown fox jumps over the lazy dog")))

(deftest missing-character-x
  (is
   (false?
    (pangram? "a quick movement of the enemy will jeopardize five gunboats"))))

(deftest another-missing-character-x
  (is
   (false?
    (pangram? "the quick brown fish jumps over the lazy dog"))))

(deftest with-underscores
  (is (pangram? "the_quick_brown_fox_jumps_over_the_lazy_dog")))

(deftest with-numbers
  (is (pangram? "the 1 quick brown fox jumps over the 2 lazy dogs")))

(deftest missing-letters-replaced-by-numbers
  (is
   (false?
    (pangram? "7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog"))))

(deftest mixed-case-and-punctuation
  (is (pangram? "\"Five quacking Zephyrs jolt my wax bed.\"")))

(deftest upper-and-lower-not-counted-separately
  (is
    (false?
      (pangram? "the quick brown fox jumps over with lazy FX"))))

Update tests to reflect master problem spec


(ns dragon.generator
  (:require [dragon.config :as config]
            [dragon.web :as web]
            [stasis.core :as stasis]
            [taoensso.timbre :as log]))

(defn run
  [routes out-dir]
  (log/infof "Generating static content to %s ..." out-dir)
  (stasis/export-pages routes out-dir)
  (log/info "Static generation complete."))

(ns dragon.generator
  (:require [dragon.config :as config]
            [dragon.web :as web]
            [stasis.core :as stasis]
            [taoensso.timbre :as log]))

(defn run
  [routes out-dir]
  (log/infof "Generating static content to '%s' ..." out-dir)
  (stasis/export-pages routes out-dir)
  (log/info "Static generation complete."))

Add quote marks to log message.

Add quote marks to log message.


(ns airhead-cljs.core
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [reagent.core :as r]
            [ajax.core :refer [GET POST]]))

(def state (r/atom {:server "http://localhost:8080"}))

(defn change-server! [event]
  (swap! state
         assoc :server
         (-> event .-target .-value)))

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

(defn server-form []
  [:div
   [:input {:type "text"
            :value (:server @state)
            :on-change change-server!}]])

(defn playlist-div []
  (let [playlist (r/atom [])
        handler #(reset! playlist (% "items"))]
    (GET "http://localhost:8080/api/queue"
         {:handler handler
          :response-format :json})
    (fn []
      [:div [:h2 "Playlist"]
       [:ul (for [track @playlist]
              [:li (track "title")])]])))

(defn home-page []
  [:div [:h1 "Airhead"]
   [server-form]
   [playlist-div]
   ])

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

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

(defn init! []
  (mount-root))

(ns airhead-cljs.core
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [reagent.core :as r]
            [ajax.core :refer [GET POST]]))

(def state (r/atom {:server "http://localhost:8080"
                    :playlist []}))

(defn update-state! [k value]
  (swap! state assoc k value))

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

(defn server-form []
  [:div
   [:input {:type "text"
            :value (@state :server)
            :on-change #(update-state! :server
                                       (-> % .-target .-value))}]])

(defn playlist-div []
  (GET "http://localhost:8080/api/queue"
       {:handler #(update-state! :playlist (% "items"))
        :response-format :json})
  (fn []
    [:div [:h2 "Playlist"]
     [:ul (for [track (@state :playlist)]
            [:li (track "title")])]]))

(defn home-page []
  [:div [:h1 "Airhead"]
   [server-form]
   [playlist-div]
   ])

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

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

(defn init! []
  (mount-root))

Move playlist in state atom

Move playlist in state atom


(ns leipzig-live.core
  (:require
    [leipzig-live.processing] ; Import action defs.
    [leipzig-live.eval :as eval]
    [leipzig-live.views :as view]
    [leipzig-live.framework :as framework]
    [reagent.core :as reagent]))

(def initial-text
  "(->> (phrase [1 1 1 1] [0 1 2 0])
       (where :time (bpm 90))
       (where :duration (bpm 90))
       (where :pitch (comp equal-temperament B major)))")

(defonce state-atom
  (reagent/atom
    {:looping? false
     :error nil
     :text initial-text
     :music (-> initial-text eval/uate :value)}))

(defn reload! []
  (swap! state-atom identity))

(defn mount-root []
  (reagent/render
    [view/home-page (framework/handler-for state-atom) state-atom]
    js/document.body))

(defn main []
  (mount-root))

(main)

(ns leipzig-live.core
  (:require
    [leipzig-live.processing] ; Import action defs.
    [leipzig-live.eval :as eval]
    [leipzig-live.views :as view]
    [leipzig-live.framework :as framework]
    [reagent.core :as reagent]))

(def initial-text
  "(->> (phrase [1 1/2 1/2 1 1 2 2] [0 1 0 2 -3 -10 -10])
     (where :time (bpm 180))
     (where :duration (bpm 180))
     (where :pitch (comp equal-temperament C sharp major)))")

(defonce state-atom
  (reagent/atom
    {:looping? false
     :error nil
     :text initial-text
     :music (-> initial-text eval/uate :value)}))

(defn reload! []
  (swap! state-atom identity))

(defn mount-root []
  (reagent/render
    [view/home-page (framework/handler-for state-atom) state-atom]
    js/document.body))

(defn main []
  (mount-root))

(main)

Use a more visually pleasing starting melody.


{:user {:dependencies [[org.clojure/tools.namespace "0.3.0-alpha4"]
                       [eftest "0.5.2"]]
        :repl-options {:color false}
        :plugins [[lein-cljfmt "0.4.1" :exclusions [org.clojure/clojure]]
                  [lein-cloverage "1.0.6" :exclusions [org.clojure/clojure]]
                  [lein-kibit "0.1.3" :exclusions [org.clojure/clojure]]
                  [lein-eftest "0.5.2" :exclusions [org.clojure/clojure]]
                  [lein-ancient "0.6.15", :exclusions [org.clojure/clojure]]]}}

{:user {:dependencies [[org.clojure/tools.namespace "0.3.0-alpha4"]
                       [com.cemerick/pomegranate "1.0.0"]
                       [eftest "0.5.2"]]
        :repl-options {:color false}
        :plugins [[lein-cljfmt "0.4.1" :exclusions [org.clojure/clojure]]
                  [lein-cloverage "1.0.6" :exclusions [org.clojure/clojure]]
                  [lein-kibit "0.1.3" :exclusions [org.clojure/clojure]]
                  [lein-eftest "0.5.2" :exclusions [org.clojure/clojure]]
                  [lein-ancient "0.6.15", :exclusions [org.clojure/clojure]]]}}

Add pomegranate to global dependencies

[clojure] Add pomegranate to global dependencies


(ns {{namespace}}
  (:import [com.badlogic.gdx Game Gdx Graphics Screen]
           [com.badlogic.gdx.graphics Color GL20]
           [com.badlogic.gdx.graphics.g2d BitmapFont]
           [com.badlogic.gdx.scenes.scene2d Stage]
           [com.badlogic.gdx.scenes.scene2d.ui Label Label$LabelStyle]))

(declare ^Stage stage)

(def main-screen
  (proxy [Screen] []
    (show []
      (def stage (Stage.))
      (let [style (Label$LabelStyle. (BitmapFont.) (Color. 1.0 1.0 1.0 1.0))
            label (Label. "Hello world!" style)]
        (.addActor stage label)))
    (render [delta]
      (.glClearColor (Gdx/gl) 0 0 0 0)
      (.glClear (Gdx/gl) GL20/GL_COLOR_BUFFER_BIT)
      (doto stage
        (.act delta)
        (.draw)))
    (dispose[])
    (hide [])
    (pause [])
    (resize [w h])
    (resume [])))

(gen-class
  :name {{namespace}}.Game
  :extends com.badlogic.gdx.Game)
(defn -create [^Game this]
  (.setScreen this main-screen))

(ns {{namespace}}
  (:import [com.badlogic.gdx Game Gdx Graphics Screen]
           [com.badlogic.gdx.graphics Color GL20]
           [com.badlogic.gdx.graphics.g2d BitmapFont]
           [com.badlogic.gdx.scenes.scene2d Stage]
           [com.badlogic.gdx.scenes.scene2d.ui Label Label$LabelStyle]))

(def main-screen
  (let [stage (atom nil)]
    (proxy [Screen] []
      (show []
        (reset! stage (Stage.))
        (let [style (Label$LabelStyle. (BitmapFont.) (Color. 1 1 1 1))
              label (Label. "Hello world!" style)]
          (.addActor @stage label)))
      (render [delta]
        (.glClearColor (Gdx/gl) 0 0 0 0)
        (.glClear (Gdx/gl) GL20/GL_COLOR_BUFFER_BIT)
        (doto @stage
          (.act delta)
          (.draw)))
      (dispose [])
      (hide [])
      (pause [])
      (resize [w h])
      (resume []))))

(gen-class
  :name {{namespace}}.Game
  :extends com.badlogic.gdx.Game)
(defn -create [^Game this]
  (.setScreen this main-screen))

Make Clojure LibGDX code more idiomatic

Make Clojure LibGDX code more idiomatic


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

(ns vimclojure.core)

(defn init-server
  []
  )

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

(ns vimclojure.core)

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

Load repl namespace when running on 1.3

Load repl namespace when running on 1.3


(ns clojure.lang.apersistent-map
  (:refer-clojure :only [bit-and defmacro defn let loop +])
  (:require [clojure.lang.counted   :refer [count]]
            [clojure.lang.hash      :refer [hash]]
            [clojure.lang.lookup    :refer [contains? get]]
            [clojure.lang.map-entry :refer [key val]]
            [clojure.lang.operators :refer [and =]]
            [clojure.lang.seq       :refer [first next seq]]))

(defmacro map-hash [-seq]
  `(loop [entries# ~-seq
          acc#     0]
     (if entries#
       (let [entry# (first entries#)]
         (recur
           (next entries#)
           (+ acc# (bit-and (hash (key entry#))
                            (hash (val entry#))))))
      acc#)))

(defn map-equals? [m1 m2]
  (if (= (count m1) (count m2))
    (loop [m1-seq (seq m1)]
      (if m1-seq
        (let [first-entry (first m1-seq)
              k (key first-entry)
              v (val first-entry)]
          (if (and (contains? m2 k)
                   (= v (get m2 k)))
            (recur (next m1-seq))
            false))
        true))
    false))

(ns clojure.lang.apersistent-map
  (:refer-clojure :only [bit-and defmacro defn let loop +])
  (:require [clojure.lang.counted   :refer [count]]
            [clojure.lang.hash      :refer [hash]]
            [clojure.lang.lookup    :refer [contains? get]]
            [clojure.lang.map-entry :refer [key val]]
            [clojure.lang.operators :refer [and =]]
            [clojure.lang.seq       :refer [first next seq]]))

(defn map-hash [-seq]
  (loop [entries -seq
         acc     0]
    (if entries
      (let [entry (first entries)]
        (recur
          (next entries)
          (+ acc (bit-and (hash (key entry))
                          (hash (val entry))))))
      acc)))

(defn map-equals? [m1 m2]
  (if (= (count m1) (count m2))
    (loop [m1-seq (seq m1)]
      (if m1-seq
        (let [first-entry (first m1-seq)
              k (key first-entry)
              v (val first-entry)]
          (if (and (contains? m2 k)
                   (= v (get m2 k)))
            (recur (next m1-seq))
            false))
        true))
    false))

Change map-hash from macro to fn

Change map-hash from macro to fn


; https://projecteuler.net/problem=3

(ns euler.003
  (:require [clojure.math.numeric-tower :as math]))

(defmulti prime?
  "Returns true if a number is divisible by only 1 and itself, false otherwise."
  (fn [n] (cond
            (> 2 n) :not
            (= 2 n) :is)))

(defmethod prime? :not [_] false)

(defmethod prime? :is [_] true)

(defmethod prime? :default [n]
  (empty? (filter #(zero? (mod n %))
                  (range 2 (+ 1 (math/sqrt n))))))

(defn primes-below [n]
  "Returns a lazy seq of all possible primes below n."
  (filter prime? (range (int (math/floor n)) 1 -1)))

(defn possible-prime-factors-of [n]
  "Returns a lazy seq of all possible prime factors of n in order of largest to smallest."
  (primes-below (math/floor (math/sqrt n))))

(defn biggest-prime-divisor-of-n [n]
  "Lazily retrieves the first prime divisor "
  (let [possible-primes (possible-prime-factors-of n)]
    (first (drop-while #(not (zero? (mod n %)))
                       possible-primes))))

; https://projecteuler.net/problem=3

(ns euler.003
  (:require [clojure.math.numeric-tower :as math]))

(defmulti prime?
  "Returns true if a number is divisible by only 1 and itself, false otherwise."
  (fn [n] (cond
            (> 2 n) :not
            (= 2 n) :is)))

(defmethod prime? :not [_] false)

(defmethod prime? :is [_] true)

(defmethod prime? :default [n]
  (empty? (filter #(zero? (mod n %))
                  (range 2 (+ 1 (math/sqrt n))))))

(defn primes-below [n]
  "Returns a lazy seq of all possible primes less than n."
  ; Use `int` to cast and floor n, subtract 1 so it's exclusive of `n`
  (filter prime? (range (dec (int n)) 1 -1)))

(defn possible-prime-factors-of [n]
  "Returns a lazy seq of all possible prime factors of n in order of largest to smallest."
  ; Add 1 so `primes-below` results includes `sqrt(n)`
  (primes-below (inc (math/floor (math/sqrt n)))))

(defn biggest-prime-divisor-of-n [n]
  "Returns the first prime divisor of n, or `nil` if ."
  (let [possible-primes (possible-prime-factors-of n)]
    (first (drop-while #(not (zero? (mod n %)))
                       possible-primes))))

Clean up with comments, semantic fix

Clean up with comments, semantic fix


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

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

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

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

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

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

Add route for getting card info

Add route for getting card info


(ns cmr.common.test.util
  (:require [clojure.test :refer :all]
            [cmr.common.util :as util]))

(deftest test-sequence->fn
  (testing "vector of values"
    (let [f (util/sequence->fn [1 2 3])]
      (is (= 1 (f)))
      (is (= 2 (f)))
      (is (= 3 (f)))
      (is (= nil (f)))
      (is (= nil (f)))))
  (testing "list of values"
    (let [f (util/sequence->fn '(1 2 3))]
      (is (= 1 (f)))
      (is (= 2 (f)))
      (is (= 3 (f)))
      (is (= nil (f)))))
  (testing "empty vector"
    (let [f (util/sequence->fn [])]
      (is (= nil (f)))
      (is (= nil (f)))))
  (testing "empty list"
    (let [f (util/sequence->fn '())]
      (is (= nil (f)))
      (is (= nil (f)))))
  (testing "infinite sequence of values"
    (let [f (util/sequence->fn (iterate inc 1))]
      (is (= 1 (f)))
      (is (= 2 (f)))
      (is (= 3 (f)))
      (is (= 4 (f)))
      (is (= 5 (f))))))

(deftest this-should-fail
  (is (= 5 4)))

Revert "Adding failing test to test ci."

This reverts commit 788e5af5fbec49f0b77ea36b05831145dd610c23.


(ns lab-notebook.core
  (:require [om.core :as om]
            [om.dom :as dom]))

(defonce appstate (atom {}))

(defn item-view [cursor component]
  (reify
    om/IRender
    (render [this]
      (dom/div nil
        (dom/div nil (:summary cursor))
        (dom/div nil (:date-time cursor))
        (dom/div nil (:notes cursor))))))

(defn app-container [cursor component]
  (reify
    om/IRender
    (render [this]
      (apply dom/div nil
        (dom/h1 nil "Lab notebook")
        nil
        (for [entry (:entries cursor)]
          (om/build item-view entry))))))

(om/root app-container appstate
  {:target (. js/document (getElementById "app"))})

(ns lab-notebook.core
  (:require [om.core :as om]
            [om.dom :as dom]))

(defonce appstate (atom {}))

(defn item-view [cursor component]
  (reify
    om/IRender
    (render [this]
      (dom/div #js {:style #js {:marginTop "2em"}}
        (dom/div nil (:summary cursor))
        (dom/div nil (:date-time cursor))
        (dom/div nil (:notes cursor))))))

(defn app-container [cursor component]
  (reify
    om/IRender
    (render [this]
      (apply dom/div nil
        (dom/h1 nil "Lab notebook")
        nil
        (for [entry (:entries cursor)]
          (om/build item-view entry))))))

(om/root app-container appstate
  {:target (. js/document (getElementById "app"))})

Add our first style, just a bit of margin


(ns example.core
  (:require [clojure.string :as str]
            [example.lib :as lib]))

(defn collatz [n]
  (lazy-seq
    (cons n
          (if (lib/even? n)
            (collatz (/ n 2))
            (collatz (+ (* 3 n) 1))))))

(defmacro let1 [name expr & body]
  `(let [~name ~expr]
     ~@body))

(def x 42)

(defn f []
  (let1 x (* x x)
    (+ x x)))

(->> (str/split "hoge\nfuga\npiyo" #"\n")
     (map #(str "[" % "]"))
     (str/join \newline))

(ns example.core
  (:require [clojure.java.io :as io]
            [clojure.string :as str]
            [example.lib :as lib]))

(defn collatz [n]
  (lazy-seq
    (cons n
          (if (lib/even? n)
            (collatz (/ n 2))
            (collatz (+ (* 3 n) 1))))))

(defmacro let1 [name expr & body]
  `(let [~name ~expr]
     ~@body))

(def x 42)

(defn f []
  (let1 x (* x x)
    (+ x x)))

(->> (str/split "hoge\nfuga\npiyo" #"\n")
     (map #(str "[" % "]"))
     (str/join \newline))

(defmacro aif [test then else]
  `(let [~'it ~test]
     ~then
     ~else))

(defn g [x]
  (aif (:k x)
    (inc it)
    0))

(let [x 0]
  (let [[x & y] [1 2 3]]
    (let [x x]
      x)))

(defn f [x]
  (with-open [x (io/reader "hoge")]
    x))

Update example code demonstrating some features


(ns clj-chrome-devtools.automation-test
  (:require [clj-chrome-devtools.automation :as a]
            [clj-chrome-devtools.automation.fixture :refer [create-chrome-fixture]]
            [clojure.spec.test.alpha :as stest]
            [clojure.test :as t :refer [deftest is testing]]))

(stest/instrument)

(defonce chrome-fixture (create-chrome-fixture))
(t/use-fixtures :each chrome-fixture)

(deftest evaluate
  (testing "a call that takes longer than the default timeout should throw an exception"
    (let [[prior-default-timeout _] (reset-vals! a/default-timeout-ms 100)]
      (is (thrown-with-msg?
           RuntimeException
           #"^Timeout!.+"
           (a/evaluate "Array(1024 ** 3).fill().map(Math.random).length")))
      (reset! a/default-timeout-ms prior-default-timeout)))
  (testing "a call that takes longer than the supplied timeout should throw an exception"
    (is (thrown-with-msg?
         RuntimeException
         #"^Timeout!.+"
         (a/evaluate @a/current-automation
                    "Array(1024 ** 3).fill().map(Math.random).length"
                    100)))))

(ns clj-chrome-devtools.automation-test
  (:require [clj-chrome-devtools.automation :as a]
            [clj-chrome-devtools.automation.fixture :refer [create-chrome-fixture]]
            [clojure.spec.test.alpha :as stest]
            [clojure.test :as t :refer [deftest is testing]]
            [clojure.string :as str]))

(stest/instrument)

(defonce chrome-fixture (create-chrome-fixture))
(t/use-fixtures :each chrome-fixture)

(deftest evaluate
  (testing "a call that takes longer than the default timeout should throw an exception"
    (let [[prior-default-timeout _] (reset-vals! a/default-timeout-ms 100)]
      (is (thrown-with-msg?
           RuntimeException
           #"^Timeout!.+"
           (a/evaluate "Array(1024 ** 3).fill().map(Math.random).length")))
      (reset! a/default-timeout-ms prior-default-timeout)))
  (testing "a call that takes longer than the supplied timeout should throw an exception"
    (is (thrown-with-msg?
         RuntimeException
         #"^Timeout!.+"
         (a/evaluate @a/current-automation
                    "Array(1024 ** 3).fill().map(Math.random).length"
                    100)))))

(deftest pdf-print-test
  (a/to "http://example.com")
  (a/print-pdf @a/current-automation "example.pdf")
  (let [pdf (slurp "example.pdf")]
    (is (str/starts-with? pdf "%PDF-1.4")) ; file exists and starts with proper PDF header
    (is (> (count pdf) 50000)))) ; file should be little over 50k

Add test that prints example.com site to PDF


(ns doctopus.test-utilities
  (:require [clojure.test :refer :all]
            [doctopus.test-utilities :refer :all])
  (:import [org.joda.time DateTime]
           [org.joda.time.format DateTimeFormat]))

(def iso-formatter (DateTimeFormat/forPattern "yyyy-MM-dd"))

(defn make-today
  []
  (let [today (DateTime.)]
    (.print iso-formatter today)))

(ns doctopus.test-utilities
  (:require [clojure.test :refer :all]
            [doctopus.storage :refer [remove-from-storage backend]]
            [doctopus.test-utilities :refer :all])
  (:import [org.joda.time DateTime]
           [org.joda.time.format DateTimeFormat]))

(def iso-formatter (DateTimeFormat/forPattern "yyyy-MM-dd"))

(defn make-today
  []
  (let [today (DateTime.)]
    (.print iso-formatter today)))

(defn clean-up-test-html
  [k]
  (remove-from-storage backend k))

Add a test cleanup util

Add a test cleanup util