Drop debug output.

Drop debug output.

--- src/cavm/h2.clj
+++ src/cavm/h2.clj
@@ -560,7 +560,6 @@
            files (map fmt-time files)]
        (when (or force
                  (not (= (set files) (set (related-sources experiments exp)))))
-         (println "loading data")
          (clear-by-exp exp)
          (load-related-sources
            experiment_sources :experiments_id exp files)


(TK-5) Add new tests

(TK-5) Add new tests

Add new tests to test omitting the --config arg. The tests
will make sure that the cli args and the config data can
be successfully parsed.

--- test/puppetlabs/trapperkeeper/core_test.clj
+++ test/puppetlabs/trapperkeeper/core_test.clj
@@ -77,21 +77,13 @@
           (reset! got-expected-exception true)))
       (is (true? @got-expected-exception))))

-  (testing "Fails if config CLI arg is not specified"
-    ;; looks like `thrown-with-msg?` can't be used with slingshot. :(
-    (let [got-expected-exception (atom false)]
-      (try+
-        (parse-cli-args! [])
-        (catch map? m
-          (is (contains? m :type))
-          (is (= :cli-error (without-ns (:type m))))
-          (is (= :puppetlabs.kitchensink.core/cli-error (:type m)))
-          (is (contains? m :message))
-          (is (re-find
-                #"Missing required argument '--config'"
-                (m :message)))
-          (reset! got-expected-exception true)))
-      (is (true? @got-expected-exception)))))
+  (testing "TK should allow the user to omit the --config arg"
+    ;; Make sure args will be parsed if no --config arg is provided; will throw an exception if not
+    (parse-cli-args! []))
+
+  (testing "TK should use an empty config if none is specified"
+    ;; Make sure data will be parsed if no path is provided; will throw an exception if not.
+    (config/parse-config-data {})))

 (deftest test-cli-args
   (testing "debug mode is off by default"


Sparkles!

Sparkles!

--- Clojure/clojuroids.clj
+++ Clojure/clojuroids.clj
@@ -14,6 +14,9 @@
 (def player-efficiency 0.7)
 (def bullet-efficiency 0.5)
 (def bullet-acceleration 200)
+(def sparkle-efficiency 0.3)
+(def sparkle-velocity 0.25)
+(def sparkle-amount 0.3)

 (def width 640)
 (def height 480)
@@ -32,9 +35,9 @@
 (defn bullet-shape []
     (doto
         (new Polygon)
-        (.addPoint 2 0)
-        (.addPoint -2 1)
-        (.addPoint -2 -1)))
+        (.addPoint 3 0)
+        (.addPoint -3 1.5)
+        (.addPoint -3 -1.5)))

 (defn draw-player [player g]
     (do
@@ -80,6 +83,14 @@
             (.fill g (bullet-shape))
             (.setTransform g old-transform))))

+(defn draw-sparkle [sparkle g]
+    (do
+        (.setColor g (:sparkle-color sparkle))
+        (let [old-transform (.getTransform g)]
+            (.translate g (:x sparkle) (:y sparkle))
+            (.fillRect g 0 0 1 1)
+            (.setTransform g old-transform))))
+
 (defn game-render [state g]
     (do
         (.setRenderingHint g
@@ -91,9 +102,11 @@
         (.setColor g (Color/BLACK))
         (let [rect (.getClipBounds g)]
             (.fillRect g (.x rect) (.y rect) (.width rect) (.height rect)))
-        (draw-player (:player state) g))
+        (doseq [s (:sparkles state)] (draw-sparkle s g))
         (doseq [a (:asteroids state)] (draw-asteroid a g))
-        (doseq [b (:bullets state)] (draw-bullet b g)))
+        (doseq [b (:bullets state)] (draw-bullet b g))
+        (draw-player (:player state) g)
+))

 (defn create-component [game-state]
     (doto
@@ -172,7 +185,8 @@
         :a 0.0
         :av 0.0
         :acc 0.0
-        :eff player-efficiency }
+        :eff player-efficiency
+        :sparkle-color Color/RED}
     :next-fire-time (now)
     :asteroids (take 10 (repeatedly generate-asteroid))
     :sparkles []
@@ -205,7 +219,28 @@
     (assoc player
         :eff bullet-efficiency
         :acc bullet-acceleration
+        :sparkle-color Color/PINK
 ))
+
+(defn make-new-sparkles [objects time-step]
+    (map
+        (fn [o]
+            (let [
+                a (rand (* 2.0 Math/PI))
+                v (rand sparkle-velocity)]
+                (assoc o
+                    :acc 0.0
+                    :eff sparkle-efficiency
+                    :xv (+ (:xv o) (* v (:acc o) (Math/cos a)))
+                    :yv (+ (:yv o) (* v (:acc o) (Math/sin a))))))
+        (filter
+            (fn [o] (> (* (:acc o) time-step sparkle-amount) (rand)))
+            objects)))
+
+(defn mag [x y] (Math/sqrt (+ (* x x) (* y y))))
+
+(defn sparkle-is-alive [sparkle]
+    (> (mag (:xv sparkle) (:yv sparkle)) 2.0))

 (defn game-step [state keys-pressed]
     (let [
@@ -228,7 +263,12 @@
                 :next-fire-time
                     (if spawn-new-bullet
                         (+ new-time fire-delay)
-                        (:next-fire-time state)))
+                        (:next-fire-time state))
+                :sparkles
+                    (doall (map (fn [s] (step-thing s time-step))
+                        (concat
+                            (make-new-sparkles (cons (:player state) (:bullets state)) time-step)
+                            (filter sparkle-is-alive (:sparkles state))))))
         [fb fa]
             (filter-collisions (:bullets state) (:asteroids state))
         state


Add support for nested directories to doc-site

--- pro.juxt.edge.doc-site/src/pro/juxt/edge/doc_site.clj
+++ pro.juxt.edge.doc-site/src/pro/juxt/edge/doc_site.clj
@@ -9,7 +9,8 @@
   [["" (merge
          (yada/redirect ::doc-resource {:route-params {:name "index"}})
          {:id ::doc-index})]
-   [[:name ".html"]
+   [[;; regex derived from bidi's default, but adding / to allow directories
+     [#"[A-Za-z0-9\\-\\_\\.\/]+" :name] ".html"]
     (yada/resource
       {:id ::doc-resource
        :methods


Rewrote powerit pca to take last-components (ans named args)

--- src/pca.clj
+++ src/pca.clj
@@ -77,20 +77,20 @@

 ; Will eventually also want to add last-pcs
-(defn powerit-pca [data n-comps & [iters]]
+(defn powerit-pca [data n-comps & {:keys [iters start-vectors]}]
   "Find the first n-comps principal components of the data matrix; iters defaults to iters of
   power-iteration"
   (let [data-cntr (ic.core/trans (mean-vector data))
-        ;shit (trace data-cntr)
-        cntrd-data (mapv #(ic.core/minus % data-cntr) data)]
-    (loop [data' cntrd-data n-comps' n-comps pcs []]
-      (let [pc (power-iteration data' iters) ; may eventually want to return eigenvals...
+        cntrd-data (mapv #(ic.core/minus % data-cntr) data)
+        start-vectors (or start-vectors [])]
+    (loop [data' cntrd-data n-comps' n-comps pcs [] start-vectors start-vectors]
+      (let [pc (power-iteration data' iters (first start-vectors)) ; may eventually want to return eigenvals...
             pcs (conj pcs pc)]
         (if (= n-comps' 1)
           pcs ; return if done
           (let [data' (factor-matrix data' pc)
                 n-comps' (dec n-comps')]
-            (recur data' n-comps' pcs)))))))
+            (recur data' n-comps' pcs (rest start-vectors))))))))

 (defn pca-project [data pcs]


(maint) Fix failure message in unit tests

This commit uses the correct response maps if a unit test fails.

--- test/integration/puppetlabs/services/master/environment_modules_int_test.clj
+++ test/integration/puppetlabs/services/master/environment_modules_int_test.clj
@@ -97,12 +97,12 @@
            (is (= 404 (:status notreal-response))
                (str
                  "unexpected status code for response, response: "
-                 (ks/pprint-to-string response))))
+                 (ks/pprint-to-string notreal-response))))
          (testing "a failed status code is returned"
            (is (= 400 (:status emptyenv-response))
                (str
                  "unexpected status code for response, response: "
-                 (ks/pprint-to-string response))))
+                 (ks/pprint-to-string emptyenv-response))))
          (testing "the expected response body is returned"
            (is (= expected-response
                   (response->module-info-map response))))
@@ -110,7 +110,7 @@
            (is (= 200 (:status all-response))
                (str
                  "unexpected status code for response, response: "
-                 (ks/pprint-to-string response))))
+                 (ks/pprint-to-string all-response))))
          (testing "the expected response body is returned"
            (is (= expected-all-response
                   (response->module-info-map all-response)))))))))


Add color to default reports

Add color to default reports

--- src/main/clojure/com/stuartsierra/lazytest/report.clj
+++ src/main/clojure/com/stuartsierra/lazytest/report.clj
@@ -1,5 +1,6 @@
 (ns com.stuartsierra.lazytest.report
   (:use [com.stuartsierra.lazytest :only (success?)]
+        [com.stuartsierra.lazytest.color :only (colorize)]
         [clojure.stacktrace :only (print-cause-trace)])
   (:import (java.io File)))

@@ -20,9 +21,9 @@
   number, doc string, and stack trace if applicable."
   [r]
   (println
-   (cond (success? r) "SUCCESS"
-         (:throwable r) "ERROR"
-         :else "FAIL"))
+   (cond (success? r) (colorize "SUCCESS" :fg-green)
+         (:throwable r) (colorize "ERROR" :fg-red)
+         :else (colorize "FAIL" :fg-red)))
   (let [m (details r)]
     (when-let [n (:name m)] (println "Name:" n))
     (when-let [d (:doc m)] (println "Doc: " d))
@@ -59,16 +60,22 @@
 (defn print-summary [r]
   (let [{:keys [assertions pass fail error]} (summary r)]
     (println "Ran" assertions "assertions.")
-    (println fail "failures," error "errors.")))
+    (print (colorize (str fail " failures")
+                     (if (zero? fail) :fg-green :fg-red)))
+    (print ", ")
+    (print (colorize (str error " errors")
+                     (if (zero? error) :fg-green :fg-red)))
+    (newline)))

 (defn dot-report
   "Simple spec report.  Prints a dot for each passed assertion; prints
   details for each failure."
   [r]
-  (println "Running" (:name (details r)))
+  (println "Running" (:name (details r))
+           "at" (str (java.util.Date.)))
   (doseq [c (assertion-results r)]
     (if (success? c)
-      (do (print ".") (flush))
+      (do (print (colorize "." :fg-green)) (flush))
       (do (newline) (print-details c))))
   (newline)
   (print-summary r))
@@ -78,7 +85,7 @@
     (doseq [c (:children r)]
       (spec-report* c (conj parents r)))
     (if (success? r)
-      (do (print ".") (flush))
+      (do (print (colorize "." :fg-green)) (flush))
       (do (newline)
           (print-details
            (assoc r :source
@@ -91,7 +98,8 @@
 (defn spec-report
   "Like dot-report but concatenates :doc strings for nested specs."
   [r]
-  (println "Running" (:name (details r)))
+  (println "Running" (:name (details r))
+           "at" (str (java.util.Date.)))
   (spec-report* r [])
   (newline)
   (print-summary r))


Fixed external link

Fixed external link


CMR-5973: Fixed ci build.

CMR-5973: Fixed ci build.

--- search-app/test/cmr/search/test/site/routes.clj
+++ search-app/test/cmr/search/test/site/routes.clj
@@ -91,9 +91,15 @@
       (is (string/includes?
            (:body response)
            "Documentation for CMR Search"))
-      (is (string/includes?
-           (:body response)
-           "v dev"))
+      (is (or
+           ;; local build
+           (string/includes?
+            (:body response)
+            "v dev")
+           ;; ci build
+           (string/includes?
+            (:body response)
+            "v %CMR-RELEASE-VERSION%")))
       (is (string/includes?
            (:body response)
            "site/docs/search/api"))


filter by namespace works (#556)

filter by namespace works (#556)

(in methods repo -- gawb 1254)

--- src/cljs/org/broadinstitute/firecloud_ui/page/method_repo/method_config_importer.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/method_repo/method_config_importer.cljs
@@ -249,7 +249,6 @@
                   {:header "Namespace" :starting-width 160
                    :sort-by (fn [m] (clojure.string/lower-case (m "namespace")))
                    :sort-initial :asc
-                   :filter-by :text
                    :as-text (fn [m] (m "namespace"))
                    :content-renderer (fn [item]
                                        (if (:in-workspace? props)


Removing dead code.

Removing dead code.

--- src-cljs/frontend/components/build_timings.cljs
+++ src-cljs/frontend/components/build_timings.cljs
@@ -46,15 +46,6 @@
                            top-axis-height))
       (.append "g") ;move everything over to see the axis
         (.attr "transform" (gstring/format "translate(%d,%d)" left-axis-width top-axis-height))))
-
-(defn time-axis-tick-formatter [ms-value]
-  (let [m (js/Math.floor (/ ms-value 1000 60))
-        s (js/Math.floor (- (/ ms-value 1000) (* m 60)))]
-    (if (<= m 0)
-      (if (= s 0)
-        (gstring/format "%ds" s)
-        (gstring/format "%02ds" s))
-      (gstring/format "%d:%02dm" m s))))

 (defn create-y-axis [number-of-containers]
   (let [range-start (+ bar-height (/ container-bar-height 2))


review chapter 2

review chapter 2

--- clojure-programming/src/clojure_programming/chp02.clj
+++ clojure-programming/src/clojure_programming/chp02.clj
@@ -30,15 +30,16 @@
     (let [a 5]
       (+ a 3)
       (= a 5))
-    => true))
+    => true) )
 "
 In almost all languages, number are immutable so they can be trusted.
 Strings in most languages are immutable so they can be trusted as key in hash-tables.
 "

+
 [[:subsection {:title "A Critical Choice -- page: 58"}]]
 "
-Immutable object state means that:
+Mutable object state means that:
 - Mutable objects can't be passed safely to methods.
 - Mutable objects can't be reliably used as hash keys.
 - Mutable objects can't be safely cached.
@@ -68,6 +69,9 @@
 123
 123
 "
+(fact
+  (call-twice inc 123)
+  => 124)

 "
 Java functions are complicated to use because they are tied to classes and objects:
@@ -89,7 +93,7 @@
 "
 (require 'clojure.string)

-(facts "clojures versions are easy to call separate functions"
+(facts "clojures versions are easy to call as  objectless functions"
   (fact
     (max 5 6)
     => 6)
@@ -104,18 +108,22 @@
 page: 62
 Map - takes a function and one or more collections returning collections with the
 functions applied to each unit:
-(map f [a b c]) => [(f a) (f b) (f c)]
-"
-
-(fact (map inc [1 2 3 4])
-  => '(2 3 4 5))
-
-(fact (map clojure.string/lower-case ["Java" "Imperative" "Weeping"
-                                      "Clojure" "Leaning" "Peace"])
-  => '("java" "imperative" "weeping" "clojure" "leaning" "peace"))
-
-(fact (map * [1 2 3 4] [5 6 7 8])
-  => '(5 12 21 32))
+(map f [a b c]) => [(f a) (f b) (f c)] and
+(map f [a b c] [x y z]) => [(f a x) (f b y) (f c z)]
+"
+(facts "a few examples of map"
+  (fact
+    (map inc [1 2 3 4])
+    => '(2 3 4 5))
+
+  (fact
+    (map clojure.string/lower-case ["Java" "Imperative" "Weeping"
+                                    "Clojure" "Leaning" "Peace"])
+    => '("java" "imperative" "weeping" "clojure" "leaning" "peace"))
+
+  (fact
+    (map * [1 2 3 4] [5 6 7 8])
+    => '(5 12 21 32)) )

 "
 Differences between map and 'toLowercase':
@@ -124,13 +132,15 @@
 i  and type of collection. Map aways returns a sequence.
 - We would have to worry about the imperative flow of control.

-Reduce  applies a function to a collection producing a single value
-"
-(fact (reduce max [0 -3 10 48])
-  => 48)
+Reduce  applies a function (taking two values) to a collection producing a single value
+"
+(fact
+  (reduce max [0 -3 10 48])
+  => 48 )
 "similar to:"
-(fact (max (max (max 0 -3) 10) 48)
-  => 48)
+(fact
+  (max (max (max 0 -3) 10) 48)
+  => 48 )

 (fact "initial seed value"
   (reduce + 50 [1 2 3 4])
@@ -146,7 +156,7 @@
      (assoc m v (* v v)))
    {}
    [1 2 3 4])
-  => {4 16, 3 9, 2 4, 1 1})
+  => {4 16, 3 9, 2 4, 1 1} )

 (fact "using a function literal"
   (reduce
@@ -173,15 +183,17 @@

 (fact "prefix with a number of arguments"
   (apply * 0.5 3 args)
-  => -60.0)
+  => -60.0 )

 "
 'apply' applies a function to all arguments in a sequence, 'partial' only applies
 some of the arguments returning a new function that applies to the rest.
+
+partial ::  fun args -> fun
 "
 (def only-strings (partial filter string?))

-(fact "partial application"
+(fact "partial application in clojure"
   (only-strings ["a" 5 "b" 6])
   => '("a" "b"))

@@ -189,46 +201,54 @@
   (#(filter string? %) ["a" 5 "b" 6])
   => '("a" "b"))

-(facts "not just limited to initial arguments"
+(facts "function literals are not just limited to initial arguments"
   (fact (#(filter % ["a" 5 "b" 6]) number?)
     => '(5 6))
   (fact (#(filter % ["a" 5 "b" 6]) string?)
     => '("a" "b")))

 (facts "But function literals require all arguments to be fully specified"
+
   (fact "must account for number of arguments"
     (#(map *) [1 2 3] [4 5 6] [7 8 9])
-    => (throws clojure.lang.ArityException))
+    => (throws clojure.lang.ArityException) )
+
   (fact "enumerating arguments"
     (#(map * %1 %2 %3) [1 2 3] [4 5 6] [7 8 9])
-    => '(28 80 162))
+    => '(28 80 162) )
+
   (fact "must align with passed arguments"
     (#(map * %1 %2 %3) [1 2 3] [4 5 6])
-    => (throws clojure.lang.ArityException))
+    => (throws clojure.lang.ArityException) )
+
   (fact "apply using 'rest' arguments"
     (#(apply map * %&) [1 2 3] [4 5 6] [7 8 9])
-    => '(28 80 162))
+    => '(28 80 162) )
+
   (fact "still works but duplicates what 'partial' does better"
     (#(apply map * %&) [1 2 3])
-    => '(1 2 3))
-  (fact "much better"
+    => '(1 2 3) )
+
+  (fact "much better without syntatic dificulties"
     ((partial map *) [1 2 3] [4 5 6] [7 8 9])
-    => '(28 80 162)))
+    => '(28 80 162)) )

 [[:section {:title "Composition of Functionality --  page: 68"}]]

 "
-Compositionality is the ability to build more complex things out of smaller simpler parts. Different programming languages use different methods of composition. Functional languages us functions.
+Compositionality is the ability to build more complex things out of smaller simpler parts. Different programming languages use different methods of composition. Functional languages use functions.
 "
 (defn negated-sum-str
-  "negate a sum of some given numbers"
+  "negate a sum of some given numbers, return a string"
   [& numbers]
   (str (- (apply + numbers))))

-(fact (negated-sum-str 10 12 3.4)
-  => "-25.4")
-
+(fact
+  (negated-sum-str 10 12 3.4)
+  => "-25.4" )
+
+"using 'comp' we can produce the same result but more concisely:"
 (def comp-negated-sum-str (comp str - +))

 (fact "composed version:"
@@ -236,14 +256,15 @@
   => "-25.4")

 " (comp f g h) acts like a pipeline passing arguments from h to g to f
-
-"
-
-(fact "the resulting type of each function must be compatible with the next function"
+"
+
+(fact "the resulting type of each function must be compatible with the
+       input of next function"
   ((comp + - str) 5 10)
   => (throws java.lang.ClassCastException))

-"Another example:"
+
+"A non toy example:"

 (require '[clojure.string :as str])

@@ -253,19 +274,26 @@
                           (partial map str/lower-case)
                           #(str/split % #"(?<=[a-z])(?=[A-Z])")))

-(fact (camel->keyword "CamelCase")
+(fact
+  (camel->keyword "CamelCase")
   => :camel-case)

-(fact (camel->keyword "lowerCamelCase")
+(fact
+  (camel->keyword "lowerCamelCase")
   => :lower-camel-case)

-(def camel-pairs->map (comp (partial apply hash-map)
-                            (partial map-indexed (fn [i x]
-                                                   (if (odd? i)
-                                                     x
-                                                     (camel->keyword x))))))
-
-(fact (camel-pairs->map ["CamelCase" 5 "lowerCamelcase" 3])
+"
+use the 'camel->keyword' function in another composition:"
+
+(def camel-pairs->map
+  (comp (partial apply hash-map)
+        (partial map-indexed (fn [i x]
+                               (if (odd? i)
+                                 x
+                                 (camel->keyword x))))))
+
+(fact "now shove the camel case key into a map"
+  (camel-pairs->map ["CamelCase" 5 "lowerCamelcase" 3])
   => {:camel-case 5, :lower-camelcase 3})

@@ -275,27 +303,32 @@
 is higher-order functions
 "
 (defn adder
-  "produce a function that add a given number to it's result"
+  "produce a function that adds a given number to it's argument"
   [n]
   (fn [x] (+ n x)))

-(fact ((adder 5) 18)
-  => 23)
-
+(fact "return and apply a 5 adding function"
+  ((adder 5) 18)
+  => 23 )
+
+"as a stored value:"
 (def add5 (adder 5))
-
-(fact (add5 18)
-  => 23)
-
+(fact
+  (add5 18)
+  => 23 )
+
+"
+a less tivial example:"
 (defn doubler
-  "doubles the result of the given function"
+  "doubles the result of calling the given function"
   [f]
   (fn [& args]
     (* 2 (apply f args))))

-(def double-+ (doubler +))
-
-(fact (double-+ 1 2 3)
+(def double-+ (doubler +)) ;; adds then doubles
+
+(fact
+  (double-+ 1 2 3)
   => 12)

 [[:subsection {:title "Primitive Logging System Example -- page: 72"}]]
@@ -311,7 +344,8 @@
   "a logger that prints to standard output"
   (print-logger *out*))

-(fact (*out*-logger "hello")
+(fact
+  (*out*-logger "hello")
   ; hello
   => nil)

@@ -327,9 +361,12 @@
   (print-logger writer))

 (facts
-  (fact (retained-logger "hello") => nil)
-  (fact (str writer)
-    => #"hello\r\n"))   ;test for only one "hello\n"
+  (fact
+    (retained-logger "hello")
+    => nil )
+  (fact
+    (str writer)
+    => #"hello\r\n") )   ;test for only one "hello\n"

 "
 logging to a file:"
@@ -400,15 +437,15 @@
 (require 'clojure.xml)

 (defn twitter-followers
-[username]
-(->> (str "https://api.twitter.com/1/users/show.xml?screen_name=" username)
-clojure.xml/parse
-:content
-(filter (comp #{:followers_count} :tag))
-first
-:content
-first
-Integer/parseInt))
+  [username]
+  (->> (str "https://api.twitter.com/1/users/show.xml?screen_name=" username)
+       clojure.xml/parse
+       :content
+       (filter (comp #{:followers_count} :tag))
+       first
+       :content
+       first
+       Integer/parseInt))

 ;; (twitter-followers "ClojureBook") ;;outdated.


Update chapter 3

Update chapter 3

--- clojure-programming/src/clojure_programming/chp03.clj
+++ clojure-programming/src/clojure_programming/chp03.clj
@@ -389,8 +389,87 @@
 Code defining lazy sequences should minimize side effects.
 "

-
 [[:subsection {:title "Associative --  page: 99"}]]
+"
+The associative abstraction is used by collections that link keys to values.
+
+It is defined by four functions:
+
+- 'assoc' creates new associations between keys and values in a collection.
+- 'dissoc' drops association for keys in the collection.
+- 'get' looks up a value in a collection.
+- 'contains?' a predicate that returns whether a key is in the collection.
+
+The most used structure is the 'map'."
+
+(def m {:a 1, :b 2, :c 3})
+
+(facts "'assoc' and 'dissoc' are a more natural fit then 'conj' ans 'seq'"
+  (fact (get m :b)
+    => 2)
+  (fact (get m :d)
+    => nil)
+  (fact (get m :d "not-found")
+    => "not-found")
+  (fact (assoc m :d 4)
+    => {:c 3, :b 2, :d 4, :a 1})
+  (fact (dissoc m :b)
+    => {:c 3, :a 1}))
+
+(facts "'assoc' and 'dissoc can be used for mutiple entries"
+  (fact
+    (assoc m
+      :x 4
+      :y 5
+      :z 6)
+    => {:y 5, :z 6, :c 3, :b 2, :x 4, :a 1})
+  (fact
+    (dissoc m :a :c)
+    => {:b 2}))
+
+
+(def v [1 2 3])
+
+(facts "'get' and 'assoc' are supported by vectors:"
+  (fact (get v 1)
+    => 2)
+  (fact (get v 10)
+    => nil)
+  (fact (get v 10 "not-found")
+    => "not-found")
+  (fact (assoc v
+          1 4
+          0 -12
+          2 :p)
+    => [-12 4 :p]))
+
+(fact "can add but need to remember what the new index will be:"
+  (assoc v 3 10)
+  => [1 2 3 10])
+
+(facts "'get' works on sets - the key is the value"
+  (fact (get #{1 2 3} 2)
+    => 2)
+  (fact (get #{1 2 3} 4)
+    => nil)
+  (fact (get #{1 2 3} 4 "not-found")
+    => "not-found"))
+
+
+(fact "sets can be used like a conditional\"\""
+  (when (get #{1 2 3} 2)
+    "it contains '2'!")
+  => "it contains '2'!")
+
+(facts "'contains?' is a predicate that returns 'true' if a collection contains a key"
+  (fact (contains? [1 2 3] 0)
+    => true)
+  (fact (contains? {:a 5 :b 6} :b)
+    => true)
+  (fact (contains? {:a 5 :b 6} 42)
+    => false)
+  (fact (contains? #{1 2 3} 1)
+    => true))

 [[:subsection {:title "Indexed --  page: 103"}]]


Process files before rendering

Process files before rendering

--- ui/src/bucket/routes.cljs
+++ ui/src/bucket/routes.cljs
@@ -1,14 +1,23 @@
 (ns bucket.routes
-  (:require [bucket.path :as path]
+  (:require [ajax.core :refer [GET]]
             [bucket.history :as history]
-            [ajax.core :refer [GET]]
+            [bucket.path :as path]
+            [cljs.core.async :refer [put! chan]]
             [secretary.core :as secretary :refer-macros [defroute]]))
+
+(defn process-files [files]
+  "Given a list of files, processes them according to our preferences."
+  (->> files
+       (filter #(not (:is_hidden %)))
+       (sort-by #(.toLowerCase (:name %))) ; case-insensitive name sort
+       (sort-by #(if (:is_directory %) 0 1)) ; dirs first, then files
+       (into [])))

 ;; TODO: refactor to not modify global state from here!
 (defn update-files! [path]
   "Update the app state's `:files` key to the files under `path`."
   (GET (path/join "/files/" path "/")
-       {:handler #(swap! bucket.core/app-state assoc :files %)
+       {:handler #(swap! bucket.core/app-state assoc :files (process-files %))
         :format :json
         :response-format :json
         :keywords? true
@@ -34,7 +43,7 @@
        (secretary/dispatch! path)))))

 ;; configure and start history
-(defn dispatch-current-path! []
+(defn- dispatch-current-path! []
   "Dispatch to the current window pathname."
   (secretary/dispatch! (history/current-path)))


updated cider-nrepl

updated cider-nrepl

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -15,6 +15,6 @@
    [criterium "0.4.3"]
    [org.clojure/tools.nrepl "0.2.12"]
    ]}
- :repl {:plugins [[refactor-nrepl "2.2.0-SNAPSHOT"]
-                  [cider/cider-nrepl "0.10.2"]
-                  ]}}
+ :repl {:plugins
+        [[refactor-nrepl "2.2.0-SNAPSHOT"]
+         [cider/cider-nrepl "0.11.0"]]}}


add leiningen :repl profile

add leiningen :repl profile

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -6,8 +6,9 @@
         }
  :woot {:plugins [[lein-ancient "0.6.7"]]}
  :cider-repl {:dependencies [[org.clojure/tools.nrepl "0.2.12"]]
-              :plugins [[cider/cider-nrepl "0.11.0"]]}
-
+              :plugins [[cider/cider-nrepl "0.12.0"]]}
+ :repl {:dependencies [[org.clojure/tools.nrepl "0.2.12"]]
+        :plugins [[cider/cider-nrepl "0.12.0"]]}
  :mavbozo {
            ;;:repl-options {:prompt (fn [ns] (str "[" *ns* "]" \newline "=> "))}
            :repl-options { ; for nREPL dev you really need to limit output


better comment

better comment

--- src-cljs/frontend/colors.cljs
+++ src-cljs/frontend/colors.cljs
@@ -1,8 +1,8 @@
 (ns frontend.colors
   (:require [clojure.string :as str]))

-;; nb these are ordered so that next-color will choose a
-;;    something that has high contrast with the previous
+;; Note that these are ordered so that next-color will choose
+;; a color with high contrast to the previous color
 (def color-idents
   [:color.name/red
    :color.name/cyan


parse-uri

parse-uri

--- src-cljs/frontend/routes.cljs
+++ src-cljs/frontend/routes.cljs
@@ -243,12 +243,17 @@
       (define-admin-routes! nav-ch))
     (define-spec-routes! nav-ch)))

+(defn parse-uri [uri]
+  (let [[uri-path fragment] (str/split (sec/uri-without-prefix uri) "#")
+        [uri-path query-string] (str/split uri-path  #"\?")
+        uri-path (sec/uri-with-leading-slash uri-path)]
+    [uri-path query-string fragment]))
+
 (defn dispatch!
   "Dispatch an action for a given route if it matches the URI path."
+  ;; Based on secretary.core: https://github.com/gf3/secretary/blob/579bc224f23e6c26a2299a2e5a48491fd3792faf/src/secretary/core.cljs#L314
   [uri]
-  (let [[uri-path fragment] (str/split (sec/uri-without-prefix uri) "#")
-        [uri-path query-string] (str/split uri-path  #"\?")
-        uri-path (sec/uri-with-leading-slash uri-path)
+  (let [[uri-path query-string fragment] (parse-uri uri)
         query-params (when query-string
                        {:query-params (sec/decode-query-params query-string)})
         {:keys [action params]} (sec/locate-route uri-path)


Simple implementation of expert-refuses?

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/contrib/dl/framework/interaction.clj
+++ src/conexp/contrib/dl/framework/interaction.clj
@@ -15,8 +15,14 @@
 (defn expert-refuses?
   "Asks an expert (the user) whether a given subsumption is to be refuted or not."
   [subsumption]
-  ;; stupid implementation for testing right now
-  false)
+  (let [answer (ask (str "Do you accept the subsumption \n\n"
+			 (print-str subsumption)
+			 "\n\n")
+		    '#{yes no}
+		    "Please enter yes or no.")]
+    (if (= answer 'yes)
+      false
+      true)))

 (defn extend-model-by-contradiction
   "Extends given model by asking an expert (the user) to extend model


Remove additional references to wrapper functions

--- modules/lazytest/src/main/clojure/lazytest/test_case.clj
+++ modules/lazytest/src/main/clojure/lazytest/test_case.clj
@@ -43,9 +43,8 @@
   (and (map? x) (isa? (type x) ::test-case-result)))

 (defn try-test-case
-  "Executes a test case function.  Does not execute before/after
-   metadata functions.  Catches all Throwables.  Returns a map with
-   the following key-value pairs:
+  "Executes a test case function.  Catches all Throwables.  Returns a
+   map with the following key-value pairs:

      :source - the input function
      :pass?  - true if the function ran without throwing


Fix with-sparql-bindings macro for clojure-1.9.0

Namespaced maps (introduced in clojure 1.9.0) break the associative
destructuring in with-sparql-bindings' let block, as syntax quoting
will turn `bindings` into a fully qualified name. We use the
quote/unquote to explicitly force an unqualified name in the expansion.

--- src/main/clojure/conexp/fca/applications/wikidata.clj
+++ src/main/clojure/conexp/fca/applications/wikidata.clj
@@ -53,7 +53,7 @@
        (sparql-query ~v)
        (get ~v :body)
        (json/read-str ~v)
-       (let [{{bindings "bindings"} "results"} ~v]
+       (let [{{~'bindings "bindings"} "results"} ~v]
          ~@body))))

 (defn- entity-add-sparql-prefix


Restore a few uses that are needed by the sensor script.

--- metlog-agent/src/metlog_agent/core.clj
+++ metlog-agent/src/metlog_agent/core.clj
@@ -7,7 +7,9 @@
             [clojure.java.io :as jio]
             [overtone.at-at :as at-at]
             [clj-http.client :as http]
-            [cognitect.transit :as transit]))
+            [cognitect.transit :as transit]
+            [clj-time.format :as time-format]
+            [clj-time.coerce :as time-coerce]))

 (defn pr-transit [ val ]
   (let [out (java.io.ByteArrayOutputStream. 4096)


bug #5154 - disabled default password autocapitalize in wallet send

--- src/status_im/ui/screens/wallet/send/views.cljs
+++ src/status_im/ui/screens/wallet/send/views.cljs
@@ -53,7 +53,8 @@
          :placeholder-text-color components.styles/color-gray4
          :on-change-text         #(re-frame/dispatch [:wallet.send/set-password (security/mask-data %)])
          :style                  styles/password
-         :accessibility-label    :enter-password-input}]
+         :accessibility-label    :enter-password-input
+         :auto-capitalize        :none}]
        (when wrong-password?
          [tooltip/tooltip (i18n/label :t/wrong-password)])]]]))


Point network to correct current-network

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

--- src/status_im/wallet/choose_recipient/core.cljs
+++ src/status_im/wallet/choose_recipient/core.cljs
@@ -90,8 +90,8 @@

 (fx/defn fill-request-from-url
   {:events [:wallet/fill-request-from-url]}
-  [{{:keys [network] :wallet/keys [all-tokens] :as db} :db} data origin]
-  (let [current-chain-id                       (get-in constants/default-networks [network :config :NetworkId])
+  [{{:networks/keys [current-network] :wallet/keys [all-tokens] :as db} :db} data origin]
+  (let [current-chain-id                       (get-in constants/default-networks [current-network :config :NetworkId])
         {:keys [address chain-id] :as details} (extract-details data current-chain-id all-tokens)
         valid-network?                         (boolean (= current-chain-id chain-id))
         previous-state                         (get-in db [:wallet :send-transaction])


Fix default color on fill options.

Fix default color on fill options.

--- src/uxbox/main/ui/workspace/sidebar/options/fill.cljs
+++ src/uxbox/main/ui/workspace/sidebar/options/fill.cljs
@@ -53,10 +53,10 @@
        [:span "Color"]
        [:div.row-flex.color-data
         [:span.color-th
-         {:style {:background-color (:fill shape)}
+         {:style {:background-color (:fill shape "#000000")}
           :on-click show-color-picker}]
         [:div.color-info
-         [:span (:fill shape)]]]
+         [:span (:fill shape "#000000")]]]

        [:div.row-flex
         [:input.input-text


truncate all tables before the tests

truncate all tables before the tests

--- test/clj_money/models/accounts_test.clj
+++ test/clj_money/models/accounts_test.clj
@@ -1,16 +1,29 @@
 (ns clj-money.models.accounts-test
   (:require [clojure.test :refer :all]
             [environ.core :refer [env]]
-            [clj-money.web :refer :all]
             [clojure.pprint :refer [pprint]]
-            [clojure.data :refer [diff]])
+            [clojure.data :refer [diff]]
+            [clojure.java.jdbc :as jdbc]
+            [clj-money.web :refer :all])
   (:use [clj-money.models.accounts :as accounts]))
+
+(def data-store (env :db))
+
+(defn reset-db
+  "Deletes all records from all tables in the database prior to test execution"
+  [f]
+  (jdbc/with-db-connection [db data-store]
+    (doseq [table ["accounts"]]
+      (jdbc/execute! db (str "truncate table " table ";"))))
+  (f))
+
+(use-fixtures :each reset-db)

 (deftest create-an-account
   (testing "After I add an account, I can retrieve it"
-    (accounts/create (env :db) {:name "Checking"
-                               :type :asset})
-    (let [accounts (->> (env :db)
+    (accounts/create data-store {:name "Checking"
+                                 :type :asset})
+    (let [accounts (->> data-store
                         (accounts/select)
                         (map #(select-keys % [:name :type])))
           expected [{:name "Checking"


code refactoring in scoped-counter demo

code refactoring in scoped-counter demo

--- test/duratom/scoped_counter_example.clj
+++ test/duratom/scoped_counter_example.clj
@@ -40,9 +40,13 @@

 (defn demo [n-services [start end :as scope]]
   (let [services (mock-services n-services)
-        service-ids (sort (map (comp str last :id) services))
-        init-scoped-ranges (map #(scoped-seq % end n-services)
-                                (take n-services (iterate inc start)))
+        service-ids (->> services
+                         (map (comp str last :id))
+                         sort)
+        init-scoped-ranges (->> start
+                                (iterate inc)
+                                (take n-services)
+                                (map #(scoped-seq % end n-services)))
         duratoms (map (fn [id init-range]
                         (core/duratom :postgres-db
                                       :db-config DB-SPEC
@@ -52,7 +56,7 @@
                       service-ids
                       init-scoped-ranges)
         generate (partial generate! scope n-services)]
-
+    ;; unleash them all!
     (dotimes [_ 15]
       (doall (pmap #(do (println (generate %))
                         (Thread/sleep (rand-int 1000)))


fix punctation

fix punctation

--- iwaswhere-web/src/cljs/iwaswhere_web/ui/markdown.cljs
+++ iwaswhere-web/src/cljs/iwaswhere_web/ui/markdown.cljs
@@ -11,13 +11,13 @@
   [show-hashtags?]
   (fn [acc hashtag]
     (let [f-hashtag (if show-hashtags? hashtag (subs hashtag 1))
-          with-link (str " " f-hashtag " ")]
+          with-link (str " " f-hashtag "")]
       (s/replace acc (re-pattern (str "[^*]" hashtag "(?!\\w)")) with-link))))

 (defn mentions-replacer
   "Replaces mentions in entry text."
   [acc mention]
-  (let [with-link (str " " mention " ")]
+  (let [with-link (str " " mention "")]
     (s/replace acc mention with-link)))

 (defn- reducer


Allow websocket fns to take kwargs.

Allow websocket fns to take kwargs.

--- web/src/immutant/websocket.clj
+++ web/src/immutant/websocket.clj
@@ -1,11 +1,11 @@
 ;; Copyright 2014 Red Hat, Inc, and individual contributors.
-;;
+;;
 ;; Licensed under the Apache License, Version 2.0 (the "License");
 ;; you may not use this file except in compliance with the License.
 ;; You may obtain a copy of the License at
-;;
+;;
 ;; http://www.apache.org/licenses/LICENSE-2.0
-;;
+;;
 ;; Unless required by applicable law or agreed to in writing, software
 ;; distributed under the License is distributed on an "AS IS" BASIS,
 ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -48,8 +48,10 @@
     :on-close   (fn [channel {:keys [code reason]}])
     :on-error   (fn [channel throwable])
     :fallback   (fn [request] (response ...))"
-  [{:keys [on-message on-open on-close on-error fallback] :as args}]
-  (undertow/create-websocket-handler args))
+  ([key value & key-values]
+     (create-handler (apply hash-map key value key-values)))
+  ([{:keys [on-message on-open on-close on-error fallback] :as args}]
+     (undertow/create-websocket-handler args)))

 (defn create-servlet
   "The same callbacks accepted by create-handler are supported, where
@@ -58,5 +60,7 @@

   In addition, a :path may be specified. It will be resolved relative
   to the path on which the returned servlet is mounted"
-  [{:keys [path on-message on-open on-close on-error fallback] :as args}]
-  (javax/create-endpoint-servlet (javax/create-endpoint args) args))
+  ([key value & key-values]
+     (create-servlet (apply hash-map key value key-values)))
+  ([{:keys [path on-message on-open on-close on-error fallback] :as args}]
+     (javax/create-endpoint-servlet (javax/create-endpoint args) args)))


add a few more helpers to the repl ns

add a few more helpers to the repl ns

--- src/pc/repl.clj
+++ src/pc/repl.clj
@@ -8,9 +8,13 @@
             [clojure.repl :refer :all]
             [datomic.api :as d]
             [pc.datomic :as pcd]
+            [pc.datomic.web-peer :as web-peer]
+            [pc.email :as email]
+            [pc.http.sente :as sente]
             [pc.models.chat :as chat-model]
             [pc.models.cust :as cust-model]
             [pc.models.doc :as doc-model]
+            [pc.models.flag :as flag-model]
             [pc.models.layer :as layer-model]
             [pc.models.permission :as permission-model]))


Added two tests into test-metadata-analyzer module

--- test/emender_jenkins/metadata_analyzer_test.clj
+++ test/emender_jenkins/metadata_analyzer_test.clj
@@ -27,3 +27,14 @@
 ; Tests for various function definitions
 ;

+(deftest test-data->csv-existence
+    "Check that the emender-jenkins.metadata-analyzer/data->csv definition exists."
+    (testing "if the emender-jenkins.metadata-analyzer/data->csv definition exists."
+        (is (callable? 'emender-jenkins.metadata-analyzer/data->csv))))
+
+
+(deftest test-select-results-existence
+    "Check that the emender-jenkins.metadata-analyzer/select-results definition exists."
+    (testing "if the emender-jenkins.metadata-analyzer/select-results definition exists."
+        (is (callable? 'emender-jenkins.metadata-analyzer/select-results))))
+


(MAINT) Remove classname/subprotocol from tests

This specifically removes the fields from our "call-with-pdb-instance"
tests which leads test output like:

  The [database] classname setting has been retired and will be ignored.
  The [database] subprotocol setting has been retired and will be ignored.

--- test/puppetlabs/puppetdb/testutils/services.clj
+++ test/puppetlabs/puppetdb/testutils/services.clj
@@ -73,6 +73,9 @@
    #'maint-mode-service
    #'config-service])

+(defn strip-retired-config [config]
+  (update config :database dissoc :classname :subprotocol))
+
 (defn call-with-puppetdb-instance
   "Stands up a puppetdb instance with the specified config, calls f,
   and then tears the instance down, binding *server* to the instance
@@ -94,6 +97,7 @@
    (when (zero? bind-attempts)
      (throw (RuntimeException. "Repeated attempts to bind port failed, giving up")))
    (let [config (-> config
+                    strip-retired-config
                     conf/adjust-and-validate-tk-config
                     assoc-open-port)
          port (or (get-in config [:jetty :port])


serve backend on port 8081 by default

serve backend on port 8081 by default

--- backend/src/lambdaui/core.clj
+++ backend/src/lambdaui/core.clj
@@ -18,8 +18,8 @@
   (try (Integer/parseInt port) (catch NumberFormatException e (default-fn e))))

 (defn -main [& [portArg]]
-  (let [port (try-parse-int portArg (fn [e] (when portArg (println "Port '" portArg "' is not a number. Using default port")) 80))]
+  (let [port (try-parse-int portArg (fn [e] (when portArg (println "Port '" portArg "' is not a number. Using default port")) 8081))]

     (println "Started Server on port " port ". CTRL+C to abort.")
     (new-api/start-server port))
-  )+  )


Add clj-diff

Add clj-diff

--- roles/clojure/files/profiles.clj
+++ roles/clojure/files/profiles.clj
@@ -2,6 +2,7 @@

         :dependencies [[acyclic/squiggly-clojure "0.1.2-SNAPSHOT"]
                        [alembic "0.2.1"]
+                       [clj-diff "1.0.0-SNAPSHOT"]
                        [clj-stacktrace "0.2.7"]
                        [com.cemerick/pomegranate "0.3.0"]
                        [criterium "0.4.2"]
@@ -33,6 +34,7 @@
                        ^:lazy cemerick.pomegranate/add-classpath
                        ^:lazy cemerick.pomegranate/get-classpath
                        ^:lazy cemerick.pomegranate/resources
+                       ^:lazy clj-diff.core/diff
                        ^:lazy clojure.java.shell/sh
                        ^:lazy clojure.pprint/pp
                        ^:lazy clojure.pprint/pprint


add java-methods-for and pster

add java-methods-for and pster

--- user.clj
+++ user.clj
@@ -35,6 +35,10 @@
     (when-not (empty? unresolved)
       (println (str "\n" "Unable to resolve these symbols: " (string/join ", " unresolved))))))

+(defn pster "Print full error stack"
+  ([] (pster *e))
+  ([err] (->> err .getStackTrace (map clojure.repl/stack-element-str) display)))
+
 (def ^:dynamic *display* :table)

 (defn display
@@ -50,6 +54,9 @@

 (defn java-methods "List of methods for a java class" [klass]
   (sort (distinct (map #(.getName %) (seq (.getMethods klass))))))
+
+(defn java-methods-for "List of methods for java object" [obj]
+  (java-methods (class obj)))

 ; mtable 'doc
 (defn var-meta "Prints meta of a symbol" [sym]


need to require clojure.java.javadoc to access it

--- user.clj
+++ user.clj
@@ -2,6 +2,7 @@
   (:require clojure.pprint
             table.core
             clojure.java.io
+            clojure.java.javadoc
             [clojure.java.shell :as sh]
             [clojure.string :as string]))


Tweak dispatcher-spec in anticipation of changes to the dispatcher

--- spec/rook/dispatcher_spec.clj
+++ spec/rook/dispatcher_spec.clj
@@ -53,6 +53,12 @@
         (:request-method request)))))

+(defn wrap-with-incrementer [handler atom]
+  (fn [request]
+    (swap! atom inc)
+    (handler request)))
+
+
 (create-ns 'example.foo)

 (binding [*ns* (the-ns 'example.foo)]
@@ -66,12 +72,12 @@
            (defn create [x]
              (resp/response (str "Created " x))))))

-(def ^:dynamic *default-middleware* identity)
+(def default-middleware identity)

 (def simple-dispatch-table
-  [[:get  ["foo"]     'example.foo/index  `*default-middleware*]
-   [:post ["foo"]     'example.foo/create `*default-middleware*]
-   [:get  ["foo" :id] 'example.foo/show   `*default-middleware*]])
+  [[:get  ["foo"]     'example.foo/index  `default-middleware]
+   [:post ["foo"]     'example.foo/create `default-middleware]
+   [:get  ["foo" :id] 'example.foo/show   `default-middleware]])

 (describe "io.aviso.rook.dispatcher"

@@ -85,25 +91,25 @@
     (it "should correctly unnest DTs WITHOUT default middleware"

       (let [dt [(into [["api"]] simple-dispatch-table)]]
-        (should= [[:get  ["api" "foo"]     'example.foo/index  `*default-middleware*]
-                  [:post ["api" "foo"]     'example.foo/create `*default-middleware*]
-                  [:get  ["api" "foo" :id] 'example.foo/show   `*default-middleware*]]
+        (should= [[:get  ["api" "foo"]     'example.foo/index  `default-middleware]
+                  [:post ["api" "foo"]     'example.foo/create `default-middleware]
+                  [:get  ["api" "foo" :id] 'example.foo/show   `default-middleware]]
           (dispatcher/unnest-dispatch-table dt))))

     (it "should correctly unnest DTs WITH default middleware and empty context pathvec"

-      (let [dt [(into [[] `*default-middleware*]
+      (let [dt [(into [[] `default-middleware]
                   (mapv pop simple-dispatch-table))]]
         (should= simple-dispatch-table
           (dispatcher/unnest-dispatch-table dt))))

     (it "should correctly unnest DTs WITH default middleware and non-empty context pathvec"

-      (let [dt [(into [["api"] `*default-middleware*]
+      (let [dt [(into [["api"] `default-middleware]
                   (mapv pop simple-dispatch-table))]]
-        (should= [[:get  ["api" "foo"]     'example.foo/index  `*default-middleware*]
-                  [:post ["api" "foo"]     'example.foo/create `*default-middleware*]
-                  [:get  ["api" "foo" :id] 'example.foo/show   `*default-middleware*]]
+        (should= [[:get  ["api" "foo"]     'example.foo/index  `default-middleware]
+                  [:post ["api" "foo"]     'example.foo/create `default-middleware]
+                  [:get  ["api" "foo" :id] 'example.foo/show   `default-middleware]]
           (dispatcher/unnest-dispatch-table dt)))))

   (describe "compile-dispatch-table"
@@ -126,14 +132,14 @@

     (it "should inject the middleware"

-      (let [handler (dispatcher/compile-dispatch-table simple-dispatch-table)
-            a (atom 0)]
-        (binding [*default-middleware* (fn [handler]
-                                         (fn [request]
-                                           (swap! a inc)
-                                           (handler request)))]
-          (handler (mock/request :get "/foo"))
-          (should= 1 @a)))))
+      (let [a (atom 0)]
+        (with-redefs [default-middleware (fn [handler]
+                                           (fn [request]
+                                             (swap! a inc)
+                                             (handler request)))]
+          (let [handler (dispatcher/compile-dispatch-table simple-dispatch-table)]
+            (handler (mock/request :get "/foo"))
+            (should= 1 @a))))))

   (describe "namespace-dispatch-table"

@@ -141,7 +147,7 @@

       (let [dt (set (dispatcher/unnest-dispatch-table
                       (dispatcher/namespace-dispatch-table
-                        ["foo"] 'example.foo `*default-middleware*)))]
+                        ["foo"] 'example.foo `default-middleware)))]
         (should= (set simple-dispatch-table) dt))))

   (describe "compiled handlers"
@@ -184,7 +190,7 @@

       (let [handler (namespace-handler
                       {:apply-middleware-fn dispatcher/apply-middleware-async}
-                      [] 'barney `*default-middleware*)]
+                      [] 'barney `default-middleware)]
         (should= {:message "ribs!"}
           (-> (mock/request :get "/") handler async/<!! :body))))


(SERVER-1260) Add status endpoint metric tests

This commit adds a few extra tests to the jruby-metrics-service tests
which validate metrics content for borrowed and requested JRuby
instances.

--- test/integration/puppetlabs/services/jruby/jruby_metrics_service_test.clj
+++ test/integration/puppetlabs/services/jruby/jruby_metrics_service_test.clj
@@ -28,7 +28,8 @@
             [puppetlabs.testutils.task-coordinator :as coordinator]
             [puppetlabs.services.jruby.jruby-metrics-core :as jruby-metrics-core]
             [clojure.tools.logging :as log]
-            [schema.core :as schema])
+            [schema.core :as schema]
+            [cheshire.core :as json])
   (:import (com.puppetlabs.puppetserver JRubyPuppetResponse JRubyPuppet)
            (clojure.lang IFn Atom)
            (java.util.concurrent TimeUnit)))
@@ -88,6 +89,31 @@
   [coordinator request-id uri]
   (async-request coordinator request-id uri :request-complete)
   (coordinator/final-result coordinator request-id))
+
+(defn current-jruby-status-metrics
+  []
+  (-> (str "http://localhost:8140/status/v1/"
+           "services/jruby-metrics?level=debug")
+      http-get
+      :body
+      (json/parse-string true)
+      (get-in [:status :experimental :metrics])))
+
+(defn jruby-status-metric-counters
+  [jruby-status-metrics]
+  (-> jruby-status-metrics
+      (select-keys
+       [:borrow-count
+        :borrow-retry-count
+        :borrow-timeout-count
+        :num-free-jrubies
+        :num-jrubies
+        :requested-count
+        :return-count])
+      (assoc :current-borrowed-instances (count (:borrowed-instances
+                                                 jruby-status-metrics))
+             :current-requested-instances (count (:requested-instances
+                                                  jruby-status-metrics)))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Test services/mocks
@@ -287,7 +313,10 @@
                                  :borrow-count 2
                                  :return-count 2})

-        (is (= (expected-metrics-values) (current-metrics-values)))))))
+        (let [expected-metrics (expected-metrics-values)]
+          (is (= expected-metrics (current-metrics-values)))
+          (is (= expected-metrics (-> (current-jruby-status-metrics)
+                                      (jruby-status-metric-counters)))))))))

 (deftest ^:metrics borrowed-instances-test
   (with-metrics-test-env test-env default-test-config
@@ -305,18 +334,41 @@
                                  :requested-count 2
                                  :borrow-count 2
                                  :current-borrowed-instances 2})
-        (is (= (expected-metrics-values) (current-metrics-values)))
-
-        ;; let's take a peek at the info about the borrowed instances.
-        ;; the keys for `borrowed-instances` are the jruby instance ids.
-        (is (= #{1 2} (set (keys @borrowed-instances))))
-        (is (= #{"/foo/bar/async1" "/foo/baz/async2"}
-              (set (map #(get-in % [:reason :request :uri]) (vals @borrowed-instances)))))
-        (let [routes (set (map #(get-in % [:reason :request :route-info :route-id]) (vals @borrowed-instances)))]
-          (is (= #{"foo-baz-:baz" "foo-bar-:bar"} routes)))
-        (doseq [borrowed (vals @borrowed-instances)]
-          (is (= :get (get-in borrowed [:reason :request :request-method])))
-          (is (timestamp-after? start-time (:time borrowed))))
+
+        (let [expected-metrics (expected-metrics-values)
+              jruby-status-metrics (current-jruby-status-metrics)]
+          (is (= expected-metrics (current-metrics-values)))
+          (is (= expected-metrics (-> (current-jruby-status-metrics)
+                                      (jruby-status-metric-counters))))
+
+          ;; let's take a peek at the info about the borrowed instances.
+          ;; the keys for `borrowed-instances` are the jruby instance ids.
+          (is (= #{1 2} (set (keys @borrowed-instances))))
+          (let [expected-uris #{"/foo/bar/async1" "/foo/baz/async2"}
+                actual-uris #(set (map (fn [instance]
+                                         (get-in instance
+                                                 [:reason :request :uri])) %))]
+            (is (= expected-uris (actual-uris (vals @borrowed-instances))))
+            (is (= expected-uris (actual-uris (:borrowed-instances
+                                               jruby-status-metrics)))))
+
+          (let [expected-routes #{"foo-baz-:baz" "foo-bar-:bar"}
+                actual-routes #(set (map (fn [instance]
+                                           (get-in instance %1)) %2))]
+            (is (= expected-routes (actual-routes
+                                    [:reason :request :route-info :route-id]
+                                    (vals @borrowed-instances))))
+            (is (= expected-routes (actual-routes
+                                    [:reason :request :route-id]
+                                    (:borrowed-instances jruby-status-metrics)))))
+
+          (doseq [borrowed (vals @borrowed-instances)]
+            (is (= :get (get-in borrowed [:reason :request :request-method])))
+            (is (timestamp-after? start-time (:time borrowed))))
+
+          (doseq [borrowed (:borrowed-instances jruby-status-metrics)]
+            (is (= "get" (get-in borrowed [:reason :request :request-method])))
+            (is (timestamp-after? start-time (:time borrowed)))))

         ;; unblock both of our requests
         (coordinator/final-result coordinator 1)
@@ -368,7 +420,12 @@
                                  :requested-count 2
                                  :borrow-count 2
                                  :current-borrowed-instances 2})
-        (is (= (expected-metrics-values) (current-metrics-values)))
+
+        (let [expected-metrics (expected-metrics-values)
+              jruby-status-metrics (current-jruby-status-metrics)]
+          (is (= expected-metrics (current-metrics-values)))
+          (is (= expected-metrics (-> (current-jruby-status-metrics)
+                                      (jruby-status-metric-counters)))))

         ;; now we'll create a few more requests and tell them they may
         ;; try to proceed to the :borrowed-jruby phase; they won't
@@ -386,18 +443,38 @@

         (update-expected-values {:requested-count 2
                                  :current-requested-instances 2})
-        (is (= (expected-metrics-values) (current-metrics-values)))
-
-        ;; now, make sure we can see info about requests 3 and 4 in the
-        ;; metrics
-        (let [req-instances (vals @requested-instances)]
-          (is (= #{"/foo/bar/async3" "/foo/baz/async4"}
-                (set (map #(get-in % [:reason :request :uri]) req-instances))))
-          (let [routes (set (map #(get-in % [:reason :request :route-info :route-id]) req-instances))]
-            (is (= #{"foo-baz-:baz" "foo-bar-:bar"} routes)))
-          (doseq [requested req-instances]
-            (is (= :get (get-in requested [:reason :request :request-method])))
-            (is (timestamp-after? start-time (:time requested)))))
+
+        (let [expected-metrics (expected-metrics-values)
+              jruby-status-metrics (current-jruby-status-metrics)]
+          (is (= expected-metrics (current-metrics-values)))
+          (is (= expected-metrics (-> (current-jruby-status-metrics)
+                                      (jruby-status-metric-counters))))
+
+          ;; now, make sure we can see info about requests 3 and 4 in the
+          ;; metrics
+          (let [expected-uris #{"/foo/bar/async3" "/foo/baz/async4"}
+                actual-uris #(set (map (fn [instance]
+                                         (get-in instance
+                                                 [:reason :request :uri])) %))]
+            (is (= expected-uris (actual-uris (vals @requested-instances)))))
+
+          (let [expected-routes #{"foo-baz-:baz" "foo-bar-:bar"}
+                actual-routes #(set (map (fn [instance]
+                                           (get-in instance %1)) %2))]
+            (is (= expected-routes (actual-routes
+                                    [:reason :request :route-info :route-id]
+                                    (vals @requested-instances))))
+            (is (= expected-routes (actual-routes
+                                    [:reason :request :route-id]
+                                    (:requested-instances jruby-status-metrics)))))
+
+          (doseq [borrowed (vals @requested-instances)]
+            (is (= :get (get-in borrowed [:reason :request :request-method])))
+            (is (timestamp-after? start-time (:time borrowed))))
+
+          (doseq [borrowed (:requested-instances jruby-status-metrics)]
+            (is (= "get" (get-in borrowed [:reason :request :request-method])))
+            (is (timestamp-after? start-time (:time borrowed)))))

         ;; finish the first two requests
         (coordinator/final-result coordinator 1)


added mentir

added mentir

--- src/babel/espanol/lexicon.clj
+++ src/babel/espanol/lexicon.clj
@@ -342,6 +342,15 @@
                         :number :sing}
                   :sem {:pred :I}
                   :subcat '()}}
+   "mentir" {:espanol {:boot-stem1 "mient"
+                        :boot-stem2 "ment"}
+             :synsem {:cat :verb
+                      :sem {:pred :close}}}
+
+
+
+
+
    "mujer"
    (unify agreement-noun
           common-noun


Add "free" field to elevio user info

Add "free" field to elevio user info

--- src-cljs/frontend/elevio.cljs
+++ src-cljs/frontend/elevio.cljs
@@ -16,9 +16,17 @@
 (defn enable! []
   (class-list/add js/document.body "circle-elevio")
   (aset js/window "_elev" (or (aget js/window "_elev") #js {}))
-  (let [set-elev! (partial aset (aget js/window "_elev"))]
+  (let [set-elev! (partial aset (aget js/window "_elev"))
+        is-free (boolean (some-> js/window
+                                 (aget "ldUser")
+                                 (aget "custom")
+                                 (aget "free")))
+        user-info (aget js/window "elevSettings")
+        _ (-> user-info
+              (aget "traits")
+              (aset "free" is-free))]
     (set-elev! "account_id" account-id)
-    (set-elev! "user" (aget js/window "elevSettings"))
+    (set-elev! "user" user-info)
     (set-elev! "translations"
           #js {"loading"
                #js {"loading_ticket" "Loading support request"


update seed-data function  in seeddata

update seed-data function  in seeddata

--- src/bookmarks/db/seeddata.clj
+++ src/bookmarks/db/seeddata.clj
@@ -15,5 +15,5 @@
               bm (first (db/create-bookmark
                   {:title r :url (str "www."r".com")
                   :description r}))]]
-    (db/create-bookmark-tag (:bookmarkid bm) (:tagid t))))
+    (db/create-bookmark-tag {:bookmarkid (:id bm) :tagid (:id t)})))


Style embed backgrounds to have a fixed color based on the provider

--- src/braid/ui/views/embed.cljs
+++ src/braid/ui/views/embed.cljs
@@ -1,6 +1,7 @@
 (ns braid.ui.views.embed
   (:require [reagent.core :as r]
-            [chat.client.xhr :refer [edn-xhr]]))
+            [chat.client.xhr :refer [edn-xhr]]
+            [chat.client.views.helpers :refer [->color]]))

 (defn- arr->rgb [arr]
   ; until embedly provides color alpha, default to transparent background
@@ -11,7 +12,7 @@

 (defn- website-embed-view [content]
   [:div.content.loaded.website
-   {:style {:background-color (str "hsl(" (* 360 (rand)) ",70%,35%)")}}
+   {:style {:background-color (->color (content :provider_name))}}
    (if-let [img (get-in content [:images 0])]
      [:img.image {:src (img :url)
                   :style {:background-color


fix IT Department (pass correct number of args to ice-strength-bonus)

--- src/clj/game/cards-assets.clj
+++ src/clj/game/cards-assets.clj
@@ -250,7 +250,7 @@
               {:pre-ice-strength {:req (req (get-in card [:it-targets (keyword (str (:cid target)))]))
                                   :effect (effect (ice-strength-bonus
                                                     (* (get-in card [:it-targets (keyword (str (:cid target)))])
-                                                       (inc (:counter card)))))}
+                                                       (inc (:counter card))) target))}
                :runner-turn-ends it :corp-turn-ends it})}

    "Jackson Howard"


implement Social Engineering

implement Social Engineering

--- src/clj/game/cards-events.clj
+++ src/clj/game/cards-events.clj
@@ -511,6 +511,28 @@
                         :effect (req (doseq [c (get-in (:servers corp) (conj (:server run) :content))]
                                        (trash state side c)))}} card))}

+   "Social Engineering"
+   {:prompt "Choose an unrezzed piece of ICE"
+    :choices {:req #(and (= (last (:zone %)) :ices) (not (:rezzed %)) (= (:type %) "ICE"))}
+    :effect (req (let [ice target
+                       serv (cond
+                             (= (second (:zone ice)) :hq) "HQ"
+                             (= (second (:zone ice)) :rd) "R&D"
+                             (= (second (:zone ice)) :archives) "Archives"
+                             :else (join " " ["Server" (last (butlast (:zone ice)))]))]
+              (resolve-ability
+                 state :runner
+                 {:msg (msg "choose the ICE at position " (ice-index state ice) " of " serv)
+                  :effect (effect (register-events {:pre-rez-cost
+                                                    {:req (req (= target ice))
+                                                     :effect (req (let [cost (rez-cost state side (get-card state target))]
+                                                                    (gain state :runner :credit cost)))
+                                                     :msg (msg "gain " (rez-cost state side (get-card state target)) " [Credits]")}}
+                                  (assoc card :zone '(:discard))))}
+               card nil)))
+    :events {:pre-rez-cost nil}
+    :end-turn {:effect (effect (unregister-events card))}}
+
    "Special Order"
    {:prompt "Choose an Icebreaker"
     :effect (effect (system-msg (str "adds " (:title target) " to their Grip and shuffles their Stack"))


Client: Correct problems with scratch area

For some hysteric reason storing a map as an attribute value in
Datascript stopped working.
https://github.com/tonsky/datascript/issues/69 is the reason, I think,
but shouldn't it be fixed according to that discussion? And why did it
work before and doesn't now? It makes no sense.

(Yes, I did bump to Datascript 0.11.5, but when I debumped and cleaned
several times, it didn't start working again.)

Anyway, restructure some things, so that I don't need to store maps
anymore. Some refactorings strewn in as usual. Sorry for that.

--- src/cljs/theatralia/core.cljs
+++ src/cljs/theatralia/core.cljs
@@ -49,6 +49,12 @@
   [text-change-event]
   (-> text-change-event .-target .-value))

+(defn pull-single
+  "Same as (safe-get (pull db [attr] eid) attr), i. e. it saves you from typing
+  the extra map lookup and, especially, mistyping the second occurence of ATTR."
+  [db attr eid]
+  (safe-get (d/pull db [attr] eid) attr))
+

 ;;;; Event handlers

@@ -57,8 +63,7 @@
 (defn search-submitted
   "Send XHR searching for materials."
   [db [scratch-entid]]
-  (let [search-string (get-in (d/pull db [:scratch/val] scratch-entid)
-                              [:scratch/val "searchInput"])
+  (let [search-string (pull-single db :searchInput scratch-entid)
         url (str "/gq/" (th-utils/url-encode search-string))]
     (when search-string
       (ajax/GET url
@@ -88,19 +93,16 @@
   "Install scratch area with SCRATCH-KEY as its :scratch/key attribute's value."
   [_ [scratch-key]]
   [{:db/id -1
-    :scratch/key scratch-key
-    :scratch/val {}}])
+    :scratch/key scratch-key}])
 (th-utils/register-handler* new-scratch)

 (defn set-scratch-val
   "Set V as the value of key K in the scratch area indentified by
   SCRATCH-ENTID."
   [db [scratch-entid k v]]
-  {:pre [scratch-entid k v]}
-  (let [{m :scratch-val}
-        (d/pull db [:scratch/val] scratch-entid)]
-    [{:db/id scratch-entid
-      :scratch/val (assoc (or m {}) k v)}]))
+  {:pre [scratch-entid (keyword? k)]}
+  [{:db/id scratch-entid
+    k v}])
 (th-utils/register-handler* set-scratch-val)

@@ -108,20 +110,21 @@

 (defn get-scratch-entid
   "Entity ID of the scratch area with SCRATCH-KEY as the value of its
-  :scratch/key attribute."
+  :scratch/key attribute. Assumes that this scratch area already exists."
   [conn [_ scratch-key]]
-  (tsky/bind '[:find ?e .
-               :in $ ?key
-               :where [?e :scratch/key ?key]]
-             conn scratch-key))
+  (let [r (tsky/bind '[:find ?e .
+                       :in $ ?key
+                       :where [?e :scratch/key ?key]]
+                     conn scratch-key)]
+    (assert @r)
+    r))
 (th-utils/register-sub* get-scratch-entid)

-(defn get-scratch-val
-  "Scratch area with entity ID SCRATCH-ENTID."
+(defn get-scratch-contents
+  "Contents of scratch area with entity ID SCRATCH-ENTID."
   [conn [_ scratch-entid]]
-  (reaction
-    (safe-get (d/pull @conn [:scratch/val] scratch-entid) :scratch/val)))
-(th-utils/register-sub* get-scratch-val)
+  (reaction (d/pull @conn '[*] scratch-entid)))
+(th-utils/register-sub* get-scratch-contents)

 (defn search-result
   "Result of the material search."
@@ -138,16 +141,23 @@
 ;; and then a random number. Or just the provided scratch-key, but we'd have to
 ;; do check for collisions, which could be ugly.
 (defn get-scratch
-  "Adds a scratch area to the app-db and returns a pair [eid ratom]. eid is the
-  ID of an entity with two attributes: :scratch/key (a unique key identifying
-  this scratch area) and :scratch/val (a map, the scratch area itself). ratom is
-  a reactive atom holding the current value of :scratch/val."
+  "Adds a scratch entity to the app-db and returns a pair [eid ratom].
+
+  eid is the ID of the scratch entity. It has at least one attribute,
+  :scratch/key, a unique key which identifies it. Being a scratch space, you can
+  attach arbitrary other attributes to it. Their values should probably be
+  scalar, but you might try collections. I'm not sure about this. See also
+  https://github.com/tonsky/datascript/issues/69.
+
+  ratom is a reactive atom holding all the attributes of the scratch entity."
   []
   (let [scratch-key (uuid/make-random-squuid)]
     (rf/dispatch-sync [:new-scratch scratch-key])
     (let [scratch-entid @(rf/subscribe [:get-scratch-entid scratch-key])
-          scratch-val-ra (rf/subscribe [:get-scratch-val scratch-entid])]
-      [scratch-entid scratch-val-ra])))
+
+          scratch-contents-ra
+          (rf/subscribe [:get-scratch-contents scratch-entid])]
+      [scratch-entid scratch-contents-ra])))

 (defn dispatch-scratch
   "Convenience fn around rf/dispatch. Suppose s is what (get-scratch) returned.
@@ -166,7 +176,7 @@
   [[scratch-id scratch-ratom] & attrs]
   {:pre [(even? (count attrs))]}
   (fn [node]
-    (let [id (plumbing/safe-get-in node [:attrs :id])
+    (let [id (keyword (plumbing/safe-get-in node [:attrs :id]))
           default-attrs
           [:value (get @scratch-ratom id "")
            :onChange #(rf/dispatch [:set-scratch-val scratch-id id (value %)])]]


Clear REPL text when restarting

Clear REPL text when restarting

--- src/clojure/nightmod/repl.clj
+++ src/clojure/nightmod/repl.clj
@@ -44,6 +44,7 @@
   []
   (let [console (editors/create-console u/repl-name)
         run! (fn [& _]
+               (.setText (.getTextArea console) "")
                (run-repl! (ui/get-io! console))
                (s/request-focus! (.getTextArea console)))
         actions {:restart run!}


Forgot to bump the HTTP exchange timeout when handling the request head.

--- src/clojure/picard/server.clj
+++ src/clojure/picard/server.clj
@@ -367,6 +367,7 @@
         state         (atom current-state)]

     (reset! channel-state state)
+    (bump-timeout state current-state :exchange)

     (try
       (let [upstream-fn   (app (mk-downstream-fn state))


fixed JP daemon problem

fixed JP daemon problem

--- src/aristotle/templates/home.clj
+++ src/aristotle/templates/home.clj
@@ -37,7 +37,7 @@
        [:img {:src "imgs/home.png" :class "home-btn"}]]
       [:div {:class "container" :id "head-container"}
        [:div {:class "row"}
-        [:a {:href (str  (str "/" daemon-name)) :id "header-img-atag"}
+        [:a {:href "/" :id "header-img-atag"}
           [:img {:src (str "imgs/"
                            daemon-name
                            "/logo.jpg")


some additional descs

some additional descs

--- .desc.clj
+++ .desc.clj
@@ -90,4 +90,14 @@
   :desc "partial(fn *args): #(apply fn *args *&)"}
  {:name "clojure.core/fnil",
   :desc
-  "sets default for a function expecting non-nil args used in clojure prob 2 as (hash[:key] ||= {}) << 2"}]
+  "sets default for a function expecting non-nil args used in clojure prob 2 as (hash[:key] ||= {}) << 2"}
+ {:name "clojure.core/some->", :desc "try of the clojure world"}
+ {:name "clojure.core/re-matches",
+  :desc "same as re-find except it matches against whole string"}
+ {:name "clojure.core/cond->",
+  :desc "handy way to conditionally build up a seq or map of options"}
+ {:name "clojure.core/map-indexed",
+  :desc
+  "can be easily recreated by passing range as an additional arg to map"}
+ {:name "clojure.core/as->",
+  :desc "seems mainly for inlinining readable fns in threaded macros"}]


added attendre

added attendre

--- src/babel/francais/lexicon.clj
+++ src/babel/francais/lexicon.clj
@@ -28,6 +28,9 @@
    ;;  CONJUGATES LIKE TENIR
    "apprendre" {:synsem {:cat :verb
                          :sem {:pred :imparare}}}
+
+    "attendre" {:synsem {:cat :verb
+                         :sem {:pred :wait}}}
    "avoir"
    {:synsem {:essere false
              :sem {:pred :avere}


Change litedocx.unit package

Change litedocx.unit package

--- src/bakyeono/litedocx/unit.clj
+++ src/bakyeono/litedocx/unit.clj
@@ -1,76 +1,74 @@
 (ns bakyeono.litedocx.unit
-  "Thinchgs for unit conversion."
+  "Things for unit conversion."
   (:require [clojure.string :as str])
   (:use [bakyeono.litedocx.util])
   (:gen-class))

-;;; Length units
-;;; Base conversion
-(defconst cm-per-inch 2.54)
-(defconst inch-per-emu 1/914400)
-(defconst mm-per-cm 10)
-(defconst pt-per-dxa 1/20)
-(defconst pt-per-px 3/4)
-(defconst px-per-inch 96)
+;;; Conversion rate constants
+(defn- reverse-conversion-map
+  [m]
+  (into {}
+    (for [[k v] m]
+      [k (/ 1 (k m))])))

-;;; Reversion
-(defconst inch-per-cm (/ 1 cm-per-inch))
-(defconst emu-per-inch (/ inch-per-emu))
-(defconst cm-per-mm (/ 1 mm-per-cm))
-(defconst dxa-per-pt (/ pt-per-dxa))
-(defconst px-per-pt (/ 1 pt-per-px))
-(defconst inch-per-px (/ 1 px-per-inch))
+(defconst unit-per-inch
+  {:cm       2.54
+   :dxa      1440
+   :emu      914400
+   :inch     1
+   :km       0.0000254
+   :m        0.0254
+   :mm       25.4
+   :pt       72
+   :px       96
+   :twip     1440})

-;;; Combination
-(defconst cm-per-emu (* cm-per-inch inch-per-emu))
-(defconst cm-per-px (* cm-per-inch inch-per-px))
-(defconst cm-per-pt (* cm-per-px px-per-pt))
-(defconst cm-per-dxa (* cm-per-pt pt-per-dxa))
-(defconst inch-per-mm (* inch-per-cm cm-per-mm))
-(defconst inch-per-pt (* inch-per-px px-per-pt))
-(defconst inch-per-dxa (* inch-per-pt pt-per-dxa))
-(defconst mm-per-inch (* mm-per-cm cm-per-inch))
-(defconst mm-per-emu (* mm-per-inch inch-per-emu))
-(defconst mm-per-px (* mm-per-inch inch-per-px))
-(defconst mm-per-pt (* mm-per-px px-per-pt))
-(defconst mm-per-dxa (* mm-per-pt pt-per-dxa))
-(defconst pt-per-inch (* pt-per-px px-per-inch))
-(defconst pt-per-emu (* pt-per-inch inch-per-emu))
-(defconst pt-per-cm (* pt-per-inch inch-per-cm))
-(defconst pt-per-mm (* pt-per-cm cm-per-mm))
-(defconst dxa-per-px (* dxa-per-pt pt-per-px))
-(defconst dxa-per-inch (* dxa-per-px px-per-inch))
-(defconst dxa-per-emu (* dxa-per-inch inch-per-emu))
-(defconst dxa-per-cm (* dxa-per-inch inch-per-cm))
-(defconst dxa-per-mm (* dxa-per-cm cm-per-mm))
-(defconst px-per-emu (* px-per-inch inch-per-emu))
-(defconst px-per-cm (* px-per-inch inch-per-cm))
-(defconst px-per-mm (* px-per-cm cm-per-mm))
-(defconst px-per-dxa (* px-per-pt pt-per-dxa))
-(defconst emu-per-cm (* emu-per-inch inch-per-cm))
-(defconst emu-per-mm (* emu-per-cm cm-per-mm))
-(defconst emu-per-px (* emu-per-inch inch-per-px))
-(defconst emu-per-pt (* emu-per-px px-per-pt))
-(defconst emu-per-dxa (* emu-per-pt pt-per-dxa))
+(defconst inch-per-unit (reverse-conversion-map unit-per-inch))
+
+(defconst unit-per-m
+  {:cm       100
+   :dxa      (* (:m inch-per-unit) (inch-per-unit :dxa))
+   :emu      (* (:m inch-per-unit) (inch-per-unit :emu))
+   :inch     (:m inch-per-unit)
+   :km       1/1000
+   :m        1
+   :mm       1000
+   :pt       (* (:m inch-per-unit) (inch-per-unit :pt))
+   :px       (* (:m inch-per-unit) (inch-per-unit :px))
+   :twip     (* (:m inch-per-unit) (inch-per-unit :twip))})
+
+(defconst m-per-unit (reverse-conversion-map unit-per-m))
+
+;;; Conversion rate map selector
+(defconst metric-set #{:cm :km :m :mm})
+(defconst inch-set #{:dxa :emu :inch :pt :px :twip})

 ;;; Functions
-(defn parse-unit
+(defn- parse-unit
   "Takes a string expression of a number and returns it as a [number unit]
   vector."
   [s]
   (let [s (str/trim s)
         n (Double/parseDouble (re-find #"^-?\d+\.?\d*" s))
-        unit (re-find #"[a-z]+$" s)]
+        unit (-> (re-find #"[a-z]+$" s) clojure.string/lower-case keyword)]
     [n unit]))

+(defn- conversion-medium
+  "Takes a keyword of unit and returns its preffered conversion medium."
+  [u]
+  (cond (metric-set u) [unit-per-m m-per-unit]
+        (inch-set u) [unit-per-inch inch-per-unit]))
+
 (defn conversion-rate
-  "Returns conversion rate for 'from' unit -> 'to' unit."
+  "Returns conversion rate for 'from' unit -> 'to' unit. The parameters should
+  be keywords."
   [from to]
-  (let [sym (symbol (str "bakyeono.litedocx.unit/" to "-per-" from))]
-    (cond (resolve sym) (eval sym)
-          (= from to) 1
-          true (throw (Exception. (str "Unsupported unit conversion: "
-                                       from " -> " to))))))
+  (let [medium (conversion-medium from)
+        medium-per-from (from (first medium))
+        to-per-medium (to (second medium))]
+    (if (and medium-per-from to-per-medium)
+      (* medium-per-from to-per-medium)
+      (throw (Exception. (str "Unsupported unit conversion: " from " -> " to))))))

 (defn convert
   "Takes a string expression of a value and its unit and then converts it into
@@ -85,8 +83,8 @@
   - (convert \"29.7 cm\" :dxa)

   Supported Unit Types:
-  - Length Units: inch, cm, mm, px, pt, dxa, emu"
+  - Length Units: inch, cm, km, m, mm, px, pt, dxa, emu"
   [value to]
   (let [[n unit] (parse-unit value)
-        rate (conversion-rate unit (name to))]
+        rate (conversion-rate unit (keyword to))]
     (* n rate)))


Re-throw errors in Clojure, for easier debugging.

--- src/datomish/test_macros.cljc
+++ src/datomish/test_macros.cljc
@@ -31,9 +31,10 @@
                         (->
                           (datomish.pair-chan/go-pair ~@body)
                           (cljs.core.async/take! (fn [[v# e#]]
-                                                   (cljs.test/is (= e# nil))
+                                                   (cljs.test/is (= e# nil)) ;; Can't synchronously fail.
                                                    (done#))))))
      (clojure.test/deftest
        ~(with-meta name {:async true})
        (let [[v# e#] (clojure.core.async/<!! (datomish.pair-chan/go-pair ~@body))]
+         (when e# (throw e#)) ;; Assert nil just to be safe, even though we should always throw first.
          (clojure.test/is (= e# nil))))))


Cleanup the Eden Fragment ability test

Cleanup the Eden Fragment ability test

--- src/clj/test/cards-agendas.clj
+++ src/clj/test/cards-agendas.clj
@@ -116,10 +116,9 @@
     (take-credits state :runner)
     (take-credits state :runner)
     (take-credits state :runner)
-    (is (= 3 (get-in @state [:corp :click])) "It's the beginning of the corp's turn")
-    (let [hriscored (get-in @state [:corp :scored 0])
+    (let [efscored (get-in @state [:corp :scored 0])
           hqice (find-card "Ice Wall" (get-in @state [:corp :hand]))]
-      (card-ability state :corp hriscored 0)
+      (card-ability state :corp efscored 0)
       (prompt-select :corp hqice)
       (prompt-choice :corp "HQ")
       (is (not (nil? (get-ice state :hq 1))) "Corp has two ice installed on HQ")


Add stacktrace printing to failed simulation

--- src/clj_gatling/simulation.clj
+++ src/clj_gatling/simulation.clj
@@ -7,7 +7,8 @@
             [schema.core :refer [check validate]]
             [clj-time.local :as local-time]
             [clojure.set :refer [rename-keys]]
-            [clojure.core.async :as async :refer [go go-loop close! put! <!! alts! <! >!]]))
+            [clojure.core.async :as async :refer [go go-loop close! put! <!! alts! <! >!]]
+            [clojure.stacktrace :as stacktrace]))

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

@@ -24,7 +25,8 @@
           (if (instance? clojure.core.async.impl.channels.ManyToManyChannel result)
             (parse-response (<! result))
             (parse-response result)))
-        (catch Exception _
+        (catch Exception e
+          (stacktrace/print-cause-trace e)
           {:result false :end-time (now) :context ctx})))))

 (defn async-function-with-timeout [step timeout sent-requests user-id original-context]


Extract with-channels method to simplify running scenario or requests parallel using core.async channels

--- src/clj_gatling/simulation.clj
+++ src/clj_gatling/simulation.clj
@@ -7,14 +7,19 @@
   (let [[result c] (async/alts!! cs)]
     @result))

+(defn- with-channels [channel-count function]
+  (let [cs (repeatedly channel-count async/chan)
+        result (function cs)]
+    (dorun result) ;Lazy results must be evaluated before channels are closed
+    (doseq [c cs] (async/close! c))
+    result))
+
 (defn- run-parallel-and-collect-results [function times]
-  (let [cs (repeatedly times async/chan)
-        ps (map vector (iterate inc 0) cs)]
-    (doseq [[i c] ps] (go (>! c (function i))))
-    (let [results (repeatedly times (partial collect-result cs))]
-      (dorun results) ;Lazy results must be evaluated before channels are closed
-      (doseq [c cs] (async/close! c))
-      results)))
+  (with-channels times (fn [cs]
+    (let [ps (map vector (iterate inc 0) cs)]
+      (doseq [[i c] ps]
+        (go (>! c (function i))))
+      (repeatedly times (partial collect-result cs))))))

 (defn- collect-result-and-run-next [cs run]
   (let [[result c] (async/alts!! cs)
@@ -23,15 +28,13 @@
     ret))

 (defn- run-scenarios-in-parallel [scenario-runners parallel-count]
-  (let [cs (repeatedly parallel-count async/chan)
-        ps (map vector (iterate inc 0) cs)]
-    (doseq [[i c] ps] (go (>! c ((nth scenario-runners i)))))
-    (let [results-with-new-run (map (partial collect-result-and-run-next cs) (drop parallel-count scenario-runners))
-          results-rest (repeatedly parallel-count (partial collect-result cs))]
-      (dorun results-with-new-run) ;Lazy results must be evaluated before channels are closed
-      (dorun results-rest) ;Lazy results must be evaluated before channels are closed
-      (doseq [c cs] (async/close! c))
-      (concat results-with-new-run results-rest))))
+  (with-channels parallel-count (fn [cs]
+    (let [ps (map vector (iterate inc 0) cs)]
+      (doseq [[i c] ps]
+        (go (>! c ((nth scenario-runners i)))))
+      (let [results-with-new-run (map (partial collect-result-and-run-next cs) (drop parallel-count scenario-runners))
+            results-rest (repeatedly parallel-count (partial collect-result cs))]
+        (concat results-with-new-run results-rest))))))

 (defn- now [] (System/currentTimeMillis))


Fix typo.

Fix typo.

--- src/clojure/parkour/io/dux.clj
+++ src/clojure/parkour/io/dux.clj
@@ -118,7 +118,7 @@
                   add-rw (fn [rws]
                            (if rws
                              (if-let [rw (get-in rws rwkey)]
-                               rw
+                               rws
                                (assoc-in rws rwkey (delay (new-rw))))))]
               (-> rws (swap! add-rw) (get-in rwkey)))))))


Handle "dispatching" trial state properly when aggregate-state is satisfy-last

--- src/cider_ci/dispatcher/task.clj
+++ src/cider_ci/dispatcher/task.clj
@@ -80,8 +80,12 @@

 (defn- eval-new-state [task trial-states]
   (let [spec (-> task :task_specification_id get-task-spec-data)]
+    (logging/debug 'spec spec)
     (if (= "satisfy-last" (-> spec :aggregate_state))
-      (or (last trial-states) "defective")
+      (let [state (or (last trial-states) "defective")]
+        (case state
+          "dispatching" "executing"
+          state))
       (cond (empty? trial-states) "defective"
             (some #{"passed"} trial-states) "passed"
             (some #{"executing" "dispatching"} trial-states) "executing"


Update logger format config.

Update logger format config.

--- src/clj/clj_templates/logger.clj
+++ src/clj/clj_templates/logger.clj
@@ -1,9 +1,13 @@
 (ns clj-templates.logger
   (:require [integrant.core :as ig]
             [taoensso.timbre :as timbre]
-            [taoensso.timbre.appenders.core :as appenders]))
+            [taoensso.timbre.appenders.core :as appenders])
+  (:import (java.util Locale TimeZone)))

 (defmethod ig/init-key :logger/timbre [_ {:keys [appenders]}]
   (println (str "Initializing logging appenders: " (keys appenders)))
-  (timbre/merge-config! {:appenders {:println (when-let [opts (:println appenders)] (appenders/println-appender opts))
-                                     :spit    (when-let [opts (:spit appenders)] (appenders/spit-appender opts))}}))
+  (timbre/merge-config! {:appenders      {:println (when-let [opts (:println appenders)] (appenders/println-appender opts))
+                                          :spit    (when-let [opts (:spit appenders)] (appenders/spit-appender opts))}
+                         :timestamp-opts {:pattern  "yyyy-MM-dd HH:mm:ss"
+                                          :timezone (TimeZone/getDefault)
+                                          :locale   (Locale. "en")}}))


fix paranthesis

fix paranthesis

--- src/clj/hsm/controllers/coll.clj
+++ src/clj/hsm/controllers/coll.clj
@@ -97,7 +97,7 @@
                 [:p (:description proj)]
                 [:hr]
                 ]
-                  ))]
+                  ]))
         [:div.panel-footer
           [:a.green {:href "#" :onclick "$(this).parent().find('form').toggle()"} "Add New"]
           [:form {:method "POST" :action (format "/collections/%s/add" (:id c)) :style "display:none;"}