Add [riemann.victorops :only [victorops]] to config.clj. This does something

--- src/riemann/config.clj
+++ src/riemann/config.clj
@@ -51,6 +51,7 @@
         [riemann.twilio :only [twilio]]
         [riemann.boundary :only [boundary]]
         [riemann.pushover :only [pushover]]
+        [riemann.victorops :only [victorops]]
         riemann.streams))

 (def core "The currently running core."


log test

log test

--- src/s7p/slave/core.clj
+++ src/s7p/slave/core.clj
@@ -84,16 +84,16 @@
             :price (+ 1 second-price)
             :isClick (click? result response)}})

-(defn log-winnotice-option [data]
+(defn log-winnotice-option [test data]
   (if data
     (let [{dsp :dsp notice :notice} data]
-      (winnotice/log (assoc notice :status "auction" :dspId (:id dsp))))
-    (winnotice/log {:status "no auction"})))
+      (winnotice/log (assoc notice :status "auction" :dspId (:id dsp) :test test)))
+    (winnotice/log {:status "no auction" :test test})))

 (defn winnotice [{dsp :dsp notice :notice}]
   (http/post (:winnotice dsp) (json-request-option notice)))

-(defn work [req result]
+(defn work [test req result]
   (->> @dsps
        (sequence (comp
                   (map (fn [dsp] {:dsp dsp :response (http/post (:url dsp) (json-request-option req))}))
@@ -105,22 +105,12 @@
                   (filter #(over-floor? (:floorPrice req) %))))
        (auction (:floorPrice req))
        (non-nil #(to-winnotice result %))
-       (log-winnotice-option)
+       (log-winnotice-option false)
        (non-nil winnotice)))
-
-(defn test-run [req]
-  (->> @dsps
-   (sequence (comp
-              (map (fn [dsp] {:dsp dsp :response (http/post (:url dsp) (json-request-option req))}))
-              (map destruct)
-              (map validate)
-              (map #(log-validated true %))))))

 (defn worker [c]
   (thread
     (loop []
       (when-let [{:keys [req result]} (<!! c)]
-        (if (= 1 (:test req))
-          (test-run req)
-          (work req result))
+        (work (= 1 (:test req)) req result)
         (recur)))))


Add :vault.entity/id key back to entity-state result.

--- src/vault/entity/datom.clj
+++ src/vault/entity/datom.clj
@@ -77,4 +77,7 @@
   "Given a sequence of datoms, return a map giving the 'current' state of some
   entity."
   [root-id datoms]
-  (reduce apply-datom {} datoms))
+  (reduce
+    apply-datom
+    {:vault.entity/id root-id}
+    datoms))


formatting, logging, error-checking

formatting, logging, error-checking

--- src/babel/directory.cljc
+++ src/babel/directory.cljc
@@ -104,21 +104,20 @@
         numbers [:sing :plur]]
     (doall
      (map (fn [root-verb]
-            (do (println (str "verb: " root-verb))
+            (do (println (str "" root-verb))
                 (let [root-verb-spec (get root-verb-specs root-verb)]
                   (doall (map (fn [tense]
-                                (println (str "tense:" tense))
+                                (println (str " " tense))
                                 (doall (map (fn [number]
                                               (let [number-spec {:comp {:synsem {:agr {:number number}}}}]
                                                 (doall (map (fn [person]
                                                               (let [person-spec {:comp {:synsem {:agr {:person person}}}}]
-                                                                (println (generate language (unify root-verb-spec
-                                                                                (get tenses tense)
-                                                                                number-spec
-                                                                                person-spec)))))
+                                                                (println (str "  " (generate language (unify root-verb-spec
+                                                                                (get tenses tense)
+                                                                                number-spec
+                                                                                person-spec))))))
                                                             persons))))
-                                            numbers))
-                                (println))
+                                            numbers)))
                               (sort (keys tenses)))))
                 (println)))
           (sort (keys root-verb-specs))))))
@@ -127,9 +126,17 @@
   (let [model @((-> models language))
         generate-fn (:generate-fn model)
         morph-fn (:morph model)]
-    (morph-fn (generate-fn spec))))
+    (log/debug (str "generating with spec: " spec))
+    (let [result (generate-fn spec)]
+      (when (nil? result)
+        (let [err (str "could not generate an expression for spec: " spec " in language:" language)]
+          (log/error err)
+          (throw (Exception. err))))
+      (morph-fn result))))

+
+


Fix content-type for CSV responses

Fix content-type for CSV responses

--- src/buildviz/handler.clj
+++ src/buildviz/handler.clj
@@ -26,16 +26,27 @@
     (@test-results job)
     {}))

+(defn- respond-with-json [content]
+  {:body content})
+
+(defn- respond-with-csv [content]
+  {:body content
+   :headers {"Content-Type" "text/csv;charset=UTF-8"}})
+
+(defn- respond-with-xml [content]
+  {:body content
+   :headers {"Content-Type" "application/xml;charset=UTF-8"}})
+
 (defn- store-build! [job build build-data]
   (let [entry (job-entry job)
         updated-entry (assoc entry build build-data)]
     (swap! builds assoc job updated-entry)
-    {:body build-data}))
+    (respond-with-json build-data)))

 (defn- get-build [job build]
   (if (contains? @builds job)
     (if-let [build-data ((@builds job) build)]
-      {:body build-data}
+      (respond-with-json build-data)
       {:status 404})
     {:status 404}))

@@ -50,11 +61,13 @@
   (if-let [job-results (@test-results job)]
     (if-let [content (job-results build)]
       (if (= (:mime accept) :json)
-        {:body (testsuites/testsuites-for content)}
-        {:body content
-         :headers {"Content-Type" "application/xml;charset=UTF-8"}})
+        (respond-with-json (testsuites/testsuites-for content))
+        (respond-with-xml content))
       {:status 404})
     {:status 404}))
+
+(defn- serialize-nested-testsuites [testsuite-id]
+  (join ": " testsuite-id))

 ;; jobs

@@ -85,14 +98,15 @@
         buildSummaries (map summary-for jobNames)
         buildSummary (zipmap jobNames buildSummaries)]
     (if (= (:mime accept) :json)
-      {:body buildSummary}
-      {:body (csv/export-table ["job" "averageRuntime" "totalCount" "failedCount" "flakyCount"]
-                               (map (fn [[job-name job]] [job-name
-                                                          (csv/format-duration (:averageRuntime job))
-                                                          (:totalCount job)
-                                                          (:failedCount job)
-                                                          (:flakyCount job)])
-                                    buildSummary))})))
+      (respond-with-json buildSummary)
+      (respond-with-csv
+       (csv/export-table ["job" "averageRuntime" "totalCount" "failedCount" "flakyCount"]
+                         (map (fn [[job-name job]] [job-name
+                                                    (csv/format-duration (:averageRuntime job))
+                                                    (:totalCount job)
+                                                    (:failedCount job)
+                                                    (:flakyCount job)])
+                              buildSummary))))))

 ;; fail phases

@@ -105,13 +119,14 @@
   (let [annotated-builds-in-order (sort-by :end (all-builds-in-order))
         fail-phases (pipelineinfo/pipeline-fail-phases annotated-builds-in-order)]
     (if (= (:mime accept) :json)
-      {:body fail-phases}
-      {:body (csv/export-table ["start" "end" "culprits"]
-                               (map (fn [{start :start end :end culprits :culprits}]
-                                      [(csv/format-timestamp start)
-                                       (csv/format-timestamp end)
-                                       (join "|" culprits)])
-                                    fail-phases))})))
+      (respond-with-json fail-phases)
+      (respond-with-csv
+       (csv/export-table ["start" "end" "culprits"]
+                         (map (fn [{start :start end :end culprits :culprits}]
+                                [(csv/format-timestamp start)
+                                 (csv/format-timestamp end)
+                                 (join "|" culprits)])
+                              fail-phases))))))

 ;; failures

@@ -122,9 +137,6 @@
       (let [build-data-entries (vals (@builds job))]
         {job (merge {:children failed-tests}
                     (failed-count-for build-data-entries))}))))
-
-(defn- serialize-nested-testsuites [testsuite-id]
-  (join ": " testsuite-id))

 (defn- failures-as-list [job]
   (when-let [test-results (@test-results job)]
@@ -141,9 +153,9 @@
   (let [jobs (keys @builds)]
     (if (= (:mime accept) :json)
       (let [failures (map failures-for jobs)]
-        {:body (into {} (apply merge failures))})
-      (csv/export-table ["failedCount" "job" "testsuite" "classname" "name"]
-                        (mapcat failures-as-list jobs)))))
+        (respond-with-json (into {} (apply merge failures))))
+      (respond-with-csv (csv/export-table ["failedCount" "job" "testsuite" "classname" "name"]
+                                          (mapcat failures-as-list jobs))))))

 ;; testsuites

@@ -169,10 +181,10 @@
 (defn- get-testsuites [accept]
   (let [job-names (filter has-testsuites? (keys @builds))]
     (if (= (:mime accept) :json)
-      {:body (zipmap job-names (map testsuites-for job-names))}
-      {:body (csv/export-table ["averageRuntime" "job" "testsuite" "classname" "name"]
-                               (mapcat flat-test-runtimes
-                                       job-names))})))
+      (respond-with-json (zipmap job-names (map testsuites-for job-names)))
+      (respond-with-csv (csv/export-table
+                         ["averageRuntime" "job" "testsuite" "classname" "name"]
+                         (mapcat flat-test-runtimes job-names))))))

 ;; app

@@ -203,5 +215,5 @@
                            "application/xml" "text/xml" :as :xml
                            "text/plain" :as :plain]})
       (wrap-resource "public")
-      (wrap-content-type)
-      (wrap-not-modified)))
+      wrap-content-type
+      wrap-not-modified))


Stylistic fixes. There's also a bug with `parse-squares` which I will fix later.

--- src/chessground/fen.cljs
+++ src/chessground/fen.cljs
@@ -7,12 +7,17 @@

 (def role-names {"p" "pawn" "r" "rook" "n" "knight" "b" "bishop" "q" "queen" "k" "king"})

-(defn- pos-to-key [pos] (str (get "abcdefgh" (mod pos 8)) (- 8 (int (/ pos 8)))))
+(defn- pos-to-key [pos]
+  (str (get "abcdefgh" (mod pos 8))
+       (- 8 (int (/ pos 8)))))

 (defn- parse-squares [fen-chars]
-  (loop [pieces {} pos 0 [current & next] fen-chars]
+  (loop [pieces {}
+         pos 0
+         [current & next] fen-chars]
     (let [as-int (js/parseInt current)
-          spaces (when (not (js/isNaN as-int)) as-int)]
+          spaces (when-not (js/isNaN as-int) as-int)]
+      (println (str "pos: " pos ", current: " current ", as-int: " as-int "\n"))
       (cond
         (nil? current) pieces
         (not (nil? spaces)) (recur pieces (+ pos spaces) next)
@@ -23,6 +28,8 @@
                     piece {:role role :color color}]
                 (recur (assoc pieces key piece) (inc pos) next))))))

-(defn parse [fen] (parse-squares (->> (or fen default)
-                                      (remove #(= "/" %))
-                                      (take-while #(not= \space %)))))
+(defn parse [fen]
+  (parse-squares
+    (->> (or fen default)
+      (remove #(= "/" %))
+      (take-while #(not= \space %)))))


added doc on borders to static.clj

added doc on borders to static.clj

--- src/clj/forma/static.clj
+++ src/clj/forma/static.clj
@@ -48,7 +48,11 @@
    vcf :: vegetation continuous field index, derived from MODIS
    products for the year 2000, found [here](http://goo.gl/KW8y1), and
    used to define the extent of the sample area, given by the Forest
-   Cover Loss Hotspots training data set."}
+   Cover Loss Hotspots training data set.
+
+   border :: distance in meters to a coastline, defined by the border
+   of land and large body of water.  Projected in MODIS coordinates
+   (927m resolution)." }
   static-datasets
   {:precl  {:corner [0 -90]
             :travel [+ +]


add-cookie-to-cookie-store and clear-cookies-from-cookie-store added

--- src/clj_http/cookies.clj
+++ src/clj_http/cookies.clj
@@ -135,3 +135,15 @@
   [^CookieStore cookie-store]
   (when cookie-store
     (into {} (map to-cookie (.getCookies cookie-store)))))
+
+(defn add-cookie-to-cookie-store
+  "Add a ClientCookie to a cookie-store"
+  [^CookieStore cookie-store ^ClientCookie cookie]
+  (.addCookie cookie-store cookie)
+  )
+
+(defn clear-cookies-from-cookie-store
+  "Clears all cookies from cookie-store"
+  [^CookieStore cookie-store]
+  (.clear cookie-store)
+  )


improved ui

improved ui

--- src/clj_shoutcast/ui.clj
+++ src/clj_shoutcast/ui.clj
@@ -16,7 +16,7 @@
   (list* "open" (map #(.getPath %) (get-songs))))

 (defn get-song [prefix]
-  (some #(if (.startsWith (.getName %) prefix) %) (get-songs)))
+  (some #(if (.startsWith (.toLowerCase (.getName %)) prefix) %) (get-songs)))

 (defn open [command player]
   (let [
@@ -30,8 +30,21 @@

 (defn ls []
   (println "***saved songs***")
-  (println (apply str (interpose "\n" (map #(.getName %) (get-songs))))))
+  (println (apply str (interpose "\n" (map #(.getName %) (get-songs)))))
+  (println "***"))

+(defn rm [command]
+  (when-let [song (get-song (second (.split command " ")))]
+    (println (format "Delete %s? " (.getName song)))
+    (.flush *out*)
+    (if (= "y" (.trim (read-line))) (.delete song))))
+
+(let [
+      command "rm A"
+      [_ prefix] (.split command " ")
+      song (get-song prefix)
+      ]
+  song)

 (defn -main [& args]
   (let [
@@ -45,6 +58,7 @@
       (let [
             input (-> (read-line) .trim .toLowerCase)
             val (try (Double/parseDouble input) (catch NumberFormatException e))
+            starts-with? (fn [a b] (.startsWith b a))
             ]
         (if val
           (.setGain player (/ val 9))
@@ -56,7 +70,8 @@
             "cancel" (do (println "cancelling save...") (reset! recorder/save? false))
             "size" (-> recorder/os .size println)
             "ls" (ls)
-            (if (.startsWith input "open")
-              (open input player)
+            (condp starts-with? input
+              "rm" (rm input)
+              "open" (open input player)
               (println "command not recognized"))
             ))))))


Remove js->clj which was useless

Remove js->clj which was useless

--- src/cljs/klang/core.cljs
+++ src/cljs/klang/core.cljs
@@ -898,14 +898,14 @@
    (.highlight js/hljs "clojure" msg true)))

 (defn msg->str
-  "Converts a message to a string. Also calls js->clj."
+  "Converts a message to a string."
   [msg]
-  (as-> (pr-str (js->clj msg)) s
+  (as-> (pr-str msg) s
     (.substr s 1 (- (.-length s) 2))))

 (defn register-highlighter!
   "Registeres a transducer :highlight-msg that highlights the :msg of
-  log. Uses js->clj to ensure the :msg is cojure.
+  log.
   TODO: We should highlight functions as javascript and not clojure!"
   [db]
   @inject-highlightjs-css


Hack more

Hack more

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -623,7 +623,7 @@
                                              sum (reduce + (mapv * improvements weights))]
                                          (- sum)))))))
                           ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
-                          (if (not (:print-history argmap))
+                          #_(if (not (:print-history argmap))
                             (throw
                               (Exception.
                                 ":print-history must be true for :case-stagnation"))
@@ -638,6 +638,27 @@
                                                                     (if (= newer-error older-error)
                                                                       0.0
                                                                       -1.0)))
+                                                                (partition 2 1 case-history))
+                                             weights (take (count improvements)
+                                                           (iterate (partial * (- 1 improvement-discount)) 1))
+                                             sum (reduce + (mapv * improvements weights))]
+                                         (- sum)))))))
+                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;HACKED STABILITY
+                          (if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :case-stagnation"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (if (zero? (first case-history))
+                                       -100000  ;; solved, improvement doesn't matter
+                                       (let [improvements (mapv (fn [[newer-error older-error]]
+                                                                  (if (< newer-error older-error)
+                                                                    1.0
+                                                                    (if (= newer-error older-error)
+                                                                      -0.1
+                                                                      0.0)))
                                                                 (partition 2 1 case-history))
                                              weights (take (count improvements)
                                                            (iterate (partial * (- 1 improvement-discount)) 1))
@@ -777,3 +798,4 @@
             me (calculate-meta-errors new-ind argmap)]
         (assoc new-ind :meta-errors me)))))

+


Omits "PRs" field if it's empty.

Omits "PRs" field if it's empty.

--- frontend/components/build_head.cljs
+++ frontend/components/build_head.cljs
@@ -371,14 +371,16 @@
                        :href (build-model/path-for-parallelism build)}
                    (str (:parallel build) "x")]
                   [:span (:parallel build) "x"])]
-               [:th "PRs"]
-               [:td
-                (interpose
-                 ", "
-                 (map (fn [url] [:a {:href url} "#"
-                                 (let [n (re-find #"/\d+$" url)]
-                                   (if n (subs n 1) "?"))])
-                      (:pull_request_urls build)))]]]]
+               (let [urls (:pull_request_urls build)]
+                 (when (seq urls)
+                   (list [:th "PRs"]
+                         [:td
+                          (interpose
+                           ", "
+                           (map (fn [url] [:a {:href url} "#"
+                                           (let [n (re-find #"/\d+$" url)]
+                                             (if n (subs n 1) "?"))])
+                                urls))])))]]]
             [:div.build-actions
              [:div.actions
               (forms/stateful-button


PR comment.

PR comment.

--- src/cljs/wombats_web_client/panels/game_play.cljs
+++ src/cljs/wombats_web_client/panels/game_play.cljs
@@ -74,7 +74,8 @@
   ;; The first 3 seconds of a round ending, show transition text
   (let [time-since-round-end (- round-intermission
                                 millis-left)
-        transition-time-left (- 3000 time-since-round-end)]
+        transition-time-left (- transition-time
+                                time-since-round-end)]
     (if (and (> round-number 1)
              (pos? transition-time-left))
       (do


Add note about clj http implementation of http

--- src/com/wsscode/pathom/diplomat/http/clj_http.clj
+++ src/com/wsscode/pathom/diplomat/http/clj_http.clj
@@ -2,6 +2,8 @@
   (:require [clj-http.client :as client]
             [com.wsscode.pathom.diplomat.http :as http]
             [clojure.spec.alpha :as s]))
+
+; TODO not working at this point, will be implemented later

 (defn request [req]
   (s/assert ::http/request req)


clearing debug

clearing debug

--- src/celestial/jobs.clj
+++ src/celestial/jobs.clj
@@ -32,7 +32,6 @@

 (defn job-exec [f {:keys [identity args tid] :as spec}]
   "Executes a job function tries to lock identity first (if used)"
-  (debug tid)
   (set-tid tid
     (try
       (if identity


clearing redundant log

clearing redundant log

--- src/celestial/jobs.clj
+++ src/celestial/jobs.clj
@@ -137,11 +137,11 @@
   Lifecyle
   (setup [this])
   (start [this]
-     (info "Starting job workers" (job* :reset-on))
-     (when (= (job* :reset-on) :start)
-       (clear-queues)
-       (clear-locks))
-       (initialize-workers))
+    (info "Starting job workers")
+    (when (= (job* :reset-on) :start)
+      (clear-queues)
+      (clear-locks))
+      (initialize-workers))
   (stop [this]
     (info "Stopping job workers")
     (shutdown-workers)


Fix syntax from merge conflict

Fix syntax from merge conflict

--- src/cfpb/qu/loader.clj
+++ src/cfpb/qu/loader.clj
@@ -17,7 +17,6 @@
     [query :as q]
     [collection :as coll]
     [joda-time]]
-    [collection :as coll]]
    [cfpb.qu.util :refer [->int ->num]]
    [cfpb.qu.query.where :as where]
    [cfpb.qu.data :refer :all])


filter options allow value 'all'

filter options allow value 'all'

--- src/wb_es/web/core.clj
+++ src/wb_es/web/core.clj
@@ -7,17 +7,21 @@
     (handler (update-in request [:params :q] #(some-> % clojure.string/lower-case)))))

-(defn get-filter [options]
-  (->> []
-       (cons (when-let [type-value (:type options)]
-               {:term {:page_type type-value}}))
-       (cons (when-let [species-value (some->> (:species options)
-                                               (clojure.string/lower-case))]
-               {:term {:species.key species-value}}))
-       (cons (when-let [species-value (some->> (:paper_type options)
-                                               (clojure.string/lower-case))]
-               {:term {:paper_type species-value}}))
-       (filter identity)))
+(defn get-filter [options-raw]
+  (let [options (->> options-raw
+                     (filter (fn [[key value]]
+                               (not= value "all")))
+                     (into {}))]
+    (->> []
+         (cons (when-let [type-value (:type options)]
+                 {:term {:page_type type-value}}))
+         (cons (when-let [species-value (some->> (:species options)
+                                                 (clojure.string/lower-case))]
+                 {:term {:species.key species-value}}))
+         (cons (when-let [species-value (some->> (:paper_type options)
+                                                 (clojure.string/lower-case))]
+                 {:term {:paper_type species-value}}))
+         (filter identity))))

 (declare autocomplete)


Improve tests by incorporating inputs and expected outputs into the characteristic name

--- spec/rook/dispatcher_spec.clj
+++ spec/rook/dispatcher_spec.clj
@@ -1,7 +1,6 @@
 (ns rook.dispatcher-spec
   (:use speclj.core
-        clojure.pprint
-        [clojure.template :only [do-template]])
+        clojure.pprint)
   (:require [io.aviso.rook.dispatcher :as dispatcher]
             [io.aviso.rook.client :as client]
             [io.aviso.rook.utils :as utils]
@@ -241,56 +240,60 @@

   (describe "compiled handlers using map traversal"

-    (it "should return the expected responses"
-        (do-template [method path namespace-name extra-params expected-value]
-                     (do
-                       (should= expected-value
-                                (let [mw (fn [handler metadata]
-                                           (-> handler
-                                               ring.middleware.keyword-params/wrap-keyword-params
-                                               ring.middleware.params/wrap-params))
-                                      dt (dispatcher/namespace-dispatch-table
-                                           [[] namespace-name mw])
-                                      handler (dispatcher/compile-dispatch-table nil dt)
-                                      body #(:body % %)]
-                                  (-> (mock/request method path)
-                                      (update-in [:params] merge extra-params)
-                                      handler
-                                      ;; TODO: fix rook-spec and rook-test/activate (the
-                                      ;; latter should return a response map rather than a
-                                      ;; string) and switch back to :body
-                                      body))))
-
-                     :get "/?limit=100" 'rook-test {} "limit=100"
-                     :get "/" 'rook-test {} "limit="
-                     :get "/123" 'rook-test {} "id=123"
-                     :get "/123/activate" 'rook-test {} nil
-                     :put "/" 'rook-test {} nil
-                     :put "/123" 'rook-test {} nil
-
-                     :post "/123/activate" 'rook-test
-                     {:test1 "foo" :test2 "bar"}
-                     "test1=foo,id=123,test2=bar,test3=TEST#,test4=test$/123/activate,meth=:post")))
-
-  (describe "argument resolution"
-
-    (it "supports overriding default arg resolvers"
-
-        (let [override ^:replace-resolvers {'magic-value (constantly "**magic**")}
-              handler (rook/namespace-handler {:arg-resolvers override}
-                                              [["magic"] 'magic])]
-          (-> (mock/request :get "/magic")
-              handler
-              (should= "**magic**"))))
-
-    (it "supports overriding default arg resolver factories"
-        (let [override ^:replace-factories {:magic (fn [sym]
-                                                     (constantly (str "**presto[" sym "]**")))}
-              handler (rook/namespace-handler {:arg-resolvers override}
-                                              [["presto"] 'presto])]
-          (-> (mock/request :get "/presto/42")
-              handler
-              (should= "42 -- **presto[extra]**")))))
+    (for [[method path extra-params expected-value]
+          (partition 4 [:get "/?limit=100" {} "limit=100"
+                        :get "/" {} "limit="
+                        :get "/123" {} "id=123"
+                        :get "/123/activate" {} nil
+                        :put "/" {} nil
+                        :put "/123" {} nil
+
+                        :post "/123/activate"
+                        {:test1 "foo" :test2 "bar"}
+                        "test1=foo,id=123,test2=bar,test3=TEST#,test4=test$/123/activate,meth=:post"])]
+      (it (format "should return %s from %s %s%s"
+                  (pr-str expected-value)
+                  (-> method name .toUpperCase)
+                  path
+                  (if-not (empty? extra-params)
+                    (str " with " (pr-str extra-params))
+                    ""))
+          (should= expected-value
+                   (let [mw (fn [handler metadata]
+                              (-> handler
+                                  ring.middleware.keyword-params/wrap-keyword-params
+                                  ring.middleware.params/wrap-params))
+                         dt (dispatcher/namespace-dispatch-table
+                              [[] 'rook-test mw])
+                         handler (dispatcher/compile-dispatch-table nil dt)
+                         body #(:body % %)]
+                     (-> (mock/request method path)
+                         (update-in [:params] merge extra-params)
+                         handler
+                         ;; TODO: fix rook-spec and rook-test/activate (the
+                         ;; latter should return a response map rather than a
+                         ;; string) and switch back to :body
+                         body)))))
+
+    (describe "argument resolution"
+
+      (it "supports overriding default arg resolvers"
+
+          (let [override ^:replace-resolvers {'magic-value (constantly "**magic**")}
+                handler (rook/namespace-handler {:arg-resolvers override}
+                                                [["magic"] 'magic])]
+            (-> (mock/request :get "/magic")
+                handler
+                (should= "**magic**"))))
+
+      (it "supports overriding default arg resolver factories"
+          (let [override ^:replace-factories {:magic (fn [sym]
+                                                       (constantly (str "**presto[" sym "]**")))}
+                handler (rook/namespace-handler {:arg-resolvers override}
+                                                [["presto"] 'presto])]
+            (-> (mock/request :get "/presto/42")
+                handler
+                (should= "42 -- **presto[extra]**"))))))

   (describe "async handlers"


Fix formating

Fix formating

--- src/stl_collector/reader.clj
+++ src/stl_collector/reader.clj
@@ -1,6 +1,6 @@
 (ns stl-collector.reader
   (:require
-    [clojure.core.matrix :as mx]
+   [clojure.core.matrix :as mx]
    [stl-collector.model :as m]
    [stl-collector.file :as stl-file]
    [nio.core :as nio]


Rename compile -> compile-cljs

Rename compile -> compile-cljs

--- src/clj/inky/entry.clj
+++ src/clj/inky/entry.clj
@@ -128,7 +128,7 @@
          "SyntaxHighlighter.defaults.gutter=true;"
          "SyntaxHighlighter.all();")]]]))

-(def compile comp/compile-cljs)
+(def compile-cljs comp/compile-cljs)

 (defn parse-meta [source]
   (let [forms (read-string (str "[" source "]"))
@@ -233,7 +233,7 @@
                                                 (.mkdirs (java.io.File. dir))
                                                 (spit filename source)
                                                 (spit html-filename (render-compiled hash))
-                                                (compile hash filename)
+                                                (compile-cljs hash filename)
                                                 (s3/upload-hash hash (str "/tmp/inky/" hash))
                                                 (println "done compiling" hash)
                                                 (catch Exception e


refactor(webgl): update recur handling in gl-context

- ...to allow compilation w/ cljs 1.10.*

--- src/thi/ng/geom/gl/core.cljc
+++ src/thi/ng/geom/gl/core.cljc
@@ -514,13 +514,16 @@
      ([canvas attribs]
       (let [canvas (if (string? canvas) (.getElementById js/document canvas) canvas)
             attribs (clj->js (merge context-default-attribs attribs))
+            getctx #(try
+                      (let [ctx (.getContext canvas % attribs)]
+                        (set! (.-onselectstart canvas) (constantly false))
+                        ctx)
+                      (catch js/Error e nil))
             ctx (loop [ids ["webgl" "experimental-webgl" "webkit-3d" "moz-webgl"]]
                   (when ids
-                    (try
-                      (let [ctx (.getContext canvas (first ids) attribs)]
-                        (set! (.-onselectstart canvas) (constantly false))
-                        (if ctx ctx (recur (next ids))))
-                      (catch js/Error e (recur (next ids))))))]
+                    (if-let [ctx (getctx (first ids))]
+                      ctx
+                      (recur (next ids)))))]
         (or ctx (err/unsupported! "WebGL not available"))))))

 ;; Context manipulation functions


Removed commas and quotes from title normalization

--- src/video_server/library.clj
+++ src/video_server/library.clj
@@ -49,7 +49,7 @@
                    (str/replace " - " " ")
                    (str/replace "_" " ")
                    (str/replace "(Unrated)" ""))]
-    (apply str (re-seq #"[A-Za-z0-9,'&\-\(\) ]" simple))))
+    (apply str (re-seq #"[A-Za-z0-9&\-\(\) ]" simple))))

 (defn norm-key
   "Returns the map with normalized values."


Added copyright header to compojure.json

--- src/compojure/json.clj
+++ src/compojure/json.clj
@@ -1,11 +1,19 @@
-;; compojure.json
-;;
-;; Small library for formatting standard Clojure datatype as a JSON string.
+;; Copyright (c) James Reeves. All rights reserved.
+;; The use and distribution terms for this software are covered by the Eclipse
+;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which
+;; can be found in the file epl-v10.html at the root of this distribution. By
+;; using this software in any fashion, you are agreeing to be bound by the
+;; terms of this license. You must not remove this notice, or any other, from
+;; this software.
+
+;; compojure.json:
+;;
+;; A library for outputting basic Clojure types in JSON.

 (ns compojure.json
-  (:use (clojure.contrib str-utils)))
+  (:use clojure.contrib.str-utils))

-(def json)
+(declare json)

 (defn- json-array
   [coll]


getting closer... correct for n=3 but not 2

--- statspop/src/statspop/detection.cljs
+++ statspop/src/statspop/detection.cljs
@@ -40,9 +40,12 @@
          cur-idx (first indices)
          remaining (rest indices)]
     (do
-      (println {:stage "in" :all all-regions :active active-region :item cur-idx :rest remaining})
+      (println (str "INCOMING item " cur-idx))
       (cond
-        (= 0 (count remaining)) all-regions
+        (= 0 (count remaining))
+        (if (>= (count active-region) minsize)
+          (conj all-regions active-region)
+          all-regions)
         (= active-region [])
         (do
           (println {:stage "appending to empty region" :all all-regions :active active-region :item cur-idx :rest remaining})
@@ -56,7 +59,7 @@
                   (println {:stage "run broken, appending to all-regions" :all all-regions :active active-region :item cur-idx :rest remaining})
                   (recur (conj all-regions active-region) [] (first remaining) (rest remaining)))
                 (do (println {:stage "run-broken, not appending (too small)" :all all-regions :active active-region :item cur-idx :rest remaining})
-                    (recur active-region [] (first remaining) (rest remaining))))))))
+                    (recur all-regions [] (first remaining) (rest remaining))))))))

 (def test-lines "123 abc
   foo bar baa


fixing build

fixing build

--- src-cljs/complico/prices.cljs
+++ src-cljs/complico/prices.cljs
@@ -2,9 +2,9 @@
   (:require
     [dommy.utils :as utils]
     [dommy.core :as dommy]
+    [hipo.interpreter :as hipo]
     [complico.conversion-funcs :as funcs]
     [complico.dom-helper :as dom-helper])
-    [hipo.interpreter :as hipo]
   (:use-macros
     [dommy.macros :only [sel sel1]]))


Minimal change to start `all` channel

Minimal change to start `all` channel

--- src-cljs/frontend/pusher.cljs
+++ src-cljs/frontend/pusher.cljs
@@ -44,16 +44,21 @@
   (str "private-" (:login user)))

 (defn build-channel-from-parts
-  [{:keys [project-name build-num vcs-type]}]
+  [{:keys [project-name build-num vcs-type container-index]}]
   (let [project-prefix (-> (str "private-" project-name)
                            (string/replace "/" "@"))
-        vcs-suffix (str "vcs-" vcs-type)]
-    (str project-prefix "@" build-num "@" vcs-suffix)))
+        vcs-part (str "vcs-" vcs-type)
+        suffix (or container-index "all")]
+    (str project-prefix "@" build-num "@" vcs-suffix "@" suffix)))

-(defn build-channel [build]
-  (build-channel-from-parts {:project-name (vcs-url/project-name (:vcs_url build))
-                             :build-num (:build_num build)
-                             :vcs-type (name (:vcs_type build))}))
+(defn build-channel
+  ([build]
+   (build-channel build nil))
+  ([build container-index]
+   (build-channel-from-parts {:project-name (vcs-url/project-name (:vcs_url build))
+                              :build-num (:build_num build)
+                              :vcs-type (name (:vcs_type build))
+                              :container-index container-index})))

 (def build-messages [:build/new-action
                      :build/update-action


allow separate tests added to an excel report

--- src/clojure/zensols/model/eval_classifier.clj
+++ src/clojure/zensols/model/eval_classifier.clj
@@ -204,7 +204,10 @@
            (apply concat)
            doall))))

-(defn- run-tests [classifier-sets feature-set-key]
+(defn run-tests
+  "Create result sets useful to functions like [[eval-and-write]].  This
+  package was designed for most use cases to not have to use this function."
+  [classifier-sets feature-set-key]
   (let [test-fn (case *default-set-type*
                   :cross-validation cross-validate-results
                   :train-test train-test-results)
@@ -347,19 +350,21 @@

   * **feature-sets-key** identifies what feature set (see
   **:feature-sets-set** in [[with-model-conf]])"
-  [classifier-sets set-key]
-  (letfn [(output-file [name]
-            (let [model-conf (model-config)]
-              (io/file (cl/analysis-report-resource)
-                       (format "%s-%s.xls" (:name model-conf) name))))]
-    (let [output-file (output-file "classification")
-          model-conf (model-config)]
-      (cl/excel-results
-       [{:sheet-name (format "%s Classification" (str/capitalize (:name model-conf)))
-         :results (run-tests classifier-sets set-key)}]
-       output-file)
-      (log/infof "wrote results file: %s" output-file)
-      output-file)))
+  ([classifier-sets set-key]
+   (eval-and-write (run-tests classifier-sets set-key)))
+  ([results]
+   (letfn [(output-file [name]
+             (let [model-conf (model-config)]
+               (io/file (cl/analysis-report-resource)
+                        (format "%s-%s.xls" (:name model-conf) name))))]
+     (let [output-file (output-file "classification")
+           model-conf (model-config)]
+       (cl/excel-results
+        [{:sheet-name (format "%s Classification" (str/capitalize (:name model-conf)))
+          :results results}]
+        output-file)
+       (log/infof "wrote results file: %s" output-file)
+       output-file))))

 (defn train-test-series
   "Test and train with different rations and return the results.  The return


Updated docs.

Updated docs.

--- src/fx_clj/core/pset.clj
+++ src/fx_clj/core/pset.clj
@@ -191,10 +191,10 @@
   instance of ObservableValue (or is converted to one),
   it will be bound to the property.

-  content-or-children* (zeror more): element or elements to be bound to the
+  content-or-children* (zero or more): element or elements to be bound to the
   JavaFX element's DefaultProperty. If the DefaultProperty is a list property
   then multiple children elements can be bound, otherwise only a single
-  'content' element  can be bound."
+  'content' element or can be bound."
   {:arglists '([element id-class-kw? property-map? & content-or-children*])}
   [element & args]
   (fx-clj.core.pset/pset!* element args))


CMR-4389 - updated version of preview gem (#231)

--- collection-renderer-lib/project.clj
+++ collection-renderer-lib/project.clj
@@ -14,7 +14,7 @@
    the hardcoded commit id during dev integration with cmr_metadata_preview project.
    The hardcoded commit id should be updated when MMT releases a new version of the gem."
   (or (System/getenv "CMR_METADATA_PREVIEW_COMMIT")
-      "ab477bd"))
+      "0ad880b09ce"))

 (def gem-install-path
   "The directory within this library where Ruby gems are installed."


killed-by-k8s? predicate should match kill and term signals (#610)

--- waiter/src/waiter/scheduler/kubernetes.clj
+++ waiter/src/waiter/scheduler/kubernetes.clj
@@ -162,8 +162,9 @@
   "Determine whether a pod was killed (restarted) by its corresponding Kubernetes liveness checks."
   [{:keys [exitCode reason] :as pod-terminated-info}]
   ;; TODO (#351) - Look at events for messages about liveness probe failures.
-  ;; Currently, we assume any SIGKILL (137) with the default "Error" reason was a livenessProbe kill.
-  (and (= 137 exitCode)
+  ;; Currently, we assume any SIGKILL (137) or SIGTERM (143) exit code
+  ;; with the default "Error" reason string indicates a livenessProbe kill.
+  (and (contains? #{137 143} exitCode)
        (= "Error" reason)))

 (defn- track-failed-instances!


Add clj support for path->ns

Add clj support for path->ns

--- src/adzerk/boot_cljs/util.clj
+++ src/adzerk/boot_cljs/util.clj
@@ -7,7 +7,7 @@
   Google Closure namespace name for goog.provide() or goog.require()."
   [path]
   (-> path
-      (string/replace #"\.clj[s|c]$" "")
+      (string/replace #"\.clj([s|c])?$" "")
       (string/replace #"[/\\]" ".")))

 (defn path->ns


s/map/pmap/

s/map/pmap/

--- src/babel/francais/writer.clj
+++ src/babel/francais/writer.clj
@@ -16,7 +16,7 @@
   (write-lexicon "fr" lexicon))

 (defn tout [ & [count]]
-  (let [use-map-fn map
+  (let [use-map-fn pmap
         count (if count (Integer. count) 10)
         root-verbs
         (zipmap


Adds Apocalypse - Memory from Console test.

--- src/clj/test/cards-events.clj
+++ src/clj/test/cards-events.clj
@@ -64,6 +64,30 @@
       (is (:facedown (refresh tmc)) "Tri-maf Contact is facedown")
       (is (= 3 (count (:hand (get-runner))))
           "No meat damage dealt by Tri-maf's leave play effect"))))
+
+(deftest apocalypse-in-play-ability
+  "Apocalypse - Turn Runner cards facedown and reduce memory and hand-size gains"
+  (do-game
+    (new-game (default-corp [(qty "Launch Campaign" 2) (qty "Ice Wall" 1)])
+              (default-runner [(qty "Logos" 3) (qty "Apocalypse" 3)]))
+    (play-from-hand state :corp "Ice Wall" "New remote")
+    (play-from-hand state :corp "Launch Campaign" "New remote")
+    (play-from-hand state :corp "Launch Campaign" "New remote")
+    (take-credits state :corp)
+    (play-from-hand state :runner "Logos")
+    (is (= 1 (:hand-size-modification (get-runner))) "Hand-size increased from Logos")
+    (is (= 5 (:memory (get-runner))) "Memory increased from Logos")
+    (core/gain state :runner :click 1 :credit 2)
+    (run-empty-server state "Archives")
+    (run-empty-server state "R&D")
+    (run-empty-server state "HQ")
+    (play-from-hand state :runner "Apocalypse")
+    (is (= 0 (count (core/all-installed state :corp))) "All installed Corp cards trashed")
+    (is (= 3 (count (:discard (get-corp)))) "3 Corp cards in Archives")
+    (let [logos (get-in @state [:runner :rig :facedown 0])]
+      (is (:facedown (refresh logos)) "Logos is facedown")
+      (is (= 0 (:hand-size-modification (get-runner))) "Hand-size reset with Logos facedown")
+      (is (= 4 (:memory (get-runner))) "Memory reset with Logos facedown"))))

 (deftest blackmail
   "Prevent rezzing of ice for one run"


Drop el dep

Drop el dep

--- src/cljs/threed/renderer.cljs
+++ src/cljs/threed/renderer.cljs
@@ -51,7 +51,7 @@
 (defprotocol IRender
   (render [this]))

-(defrecord RenderContext [el positions events
+(defrecord RenderContext [positions events
                           width height
                           scene camera renderer
                           geometry texture
@@ -70,7 +70,6 @@
     (set! (.. light -position -z) 130)

     (.setSize renderer width height)
-    (.appendChild el (.-domElement renderer))

     (doseq [pos positions]
       (add-block! scene pos))
@@ -119,12 +118,11 @@

         (.render renderer scene camera)))))

-(defn render-context [el positions events]
+(defn render-context [positions events]
   (let [width (.-innerWidth js/window)
         height (.-innerHeight js/window)]
     (map->RenderContext
-     {:el el
-      :positions positions
+     {:positions positions
       :events events

       :scene (reset! scene (js/THREE.Scene.))
@@ -144,10 +142,12 @@
 (defn start-renderer [el positions events]
   (reset! current-positions positions)

-  (let [context (render-context el positions events)
+  (let [context (render-context positions events)
         do-render (fn cb []
                     (js/requestAnimationFrame cb)
                     (render context))]

+    (.appendChild el (.-domElement (:renderer context)))
+
     (initialise! context)
     (do-render)))


Don't change home dir

Don't change home dir

--- src/clojure/nightmod/core.clj
+++ src/clojure/nightmod/core.clj
@@ -2,7 +2,6 @@
   (:require [clojure.java.io :as io]
             [nightcode.cli-args :as cli-args]
             [nightcode.editors :as editors]
-            [nightcode.sandbox :as nc-sandbox]
             [nightcode.shortcuts :as shortcuts]
             [nightcode.ui :as ui]
             [nightcode.utils :as nc-utils]
@@ -60,7 +59,6 @@
   [& args]
   (window/set-icon! "logo_launcher.png")
   (window/set-theme! (cli-args/parse-args args))
-  (nc-sandbox/set-home!)
   (sandbox/set-policy!)
   (add-watch u/project-dir :load-game (fn [_ _ _ path]
                                         (load-game! path)))


Added atom to mime-type definitions.

Added atom to mime-type definitions.

--- src/cmr/common/mime_types.clj
+++ src/cmr/common/mime_types.clj
@@ -12,7 +12,8 @@
    "application/iso:smap+xml" :iso-smap
    "application/iso19115+xml" :iso19115
    "application/dif+xml" :dif
-   "text/csv" :csv})
+   "text/csv" :csv
+   "application/atom+xml" :atom})

 (def format->mime-type
   {:json "application/json"
@@ -22,7 +23,8 @@
    :iso-smap "application/iso:smap+xml"
    :iso19115 "application/iso19115+xml"
    :dif "application/dif+xml"
-   :csv "text/csv"})
+   :csv "text/csv"
+   :atom "application/atom+xml"})

 (defn mime-type->format
   "Converts a mime-type into the format requested."


Updated in-memory configuration for the change to search app to embed the metadata db system.

--- src/cmr/dev_system/system.clj
+++ src/cmr/dev_system/system.clj
@@ -64,21 +64,23 @@
   ;; Sets a bit of global state for the application and system integration tests that will know how to talk to elastic
   (config/set-config-value! :elastic-port in-memory-elastic-port-for-connection)

-
-  ;; Memory DB configured to run in memory
-  {:apps {:metadata-db (assoc (mdb-system/create-system)
-                              :db (memory/create-db))
-          ;; Bootstrap is not enabled for in-memory dev system
-          :indexer (indexer-system/create-system)
-          :index-set (index-set-system/create-system)
-          :ingest (ingest-system/create-system)
-          :search (search-system/create-system)}
-   :components {:elastic-server (elastic-server/create-server
-                                  in-memory-elastic-port
-                                  (+ in-memory-elastic-port 10)
-                                  "es_data/dev_system")
-                ; :vdd-server (viz-helper/create-viz-server)
-                }})
+  (let [in-memory-db (memory/create-db)]
+    ;; Memory DB configured to run in memory
+    {:apps {:metadata-db (assoc (mdb-system/create-system)
+                                :db in-memory-db)
+            ;; Bootstrap is not enabled for in-memory dev system
+            :indexer (indexer-system/create-system)
+            :index-set (index-set-system/create-system)
+            :ingest (ingest-system/create-system)
+            :search (assoc-in (search-system/create-system)
+                              [:metadata-db :db]
+                              in-memory-db)}
+     :components {:elastic-server (elastic-server/create-server
+                                    in-memory-elastic-port
+                                    (+ in-memory-elastic-port 10)
+                                    "es_data/dev_system")
+                  ; :vdd-server (viz-helper/create-viz-server)
+                  }}))

 (defmethod create-system :external-dbs
   [type]


Ensure deepest exception is propagated

Ensure deepest exception is propagated

When an exception occurs on a system operation, ensure the returned
system map is from the deepest exception (and has the most correct
state).

--- src/com/palletops/leaven.cljx
+++ src/com/palletops/leaven.cljx
@@ -69,20 +69,27 @@
             res (try
                   (-> (update-in rec [c] f)
                       (cond-> post-f (post-f c)))
-                  (catch #+cljs js/Error #+clj Exception e
-                         (throw
-                          (ex-info
-                           (str "Exception while " operation-name
-                                " " c
-                                " system sub-component.")
-                           {:system rec
-                            :component c
-                            :sub-components sub-components
-                            :completed (subvec sub-components
-                                               0 (- (count sub-components)
-                                                    (count cs)))
-                            :uncompleted cs}
-                           e))))]
+                  (catch #+cljs js/Error #+clj Throwable e
+                         (let [d (ex-data e)]
+                           (throw
+                            (ex-info
+                             (str "Exception while " operation-name
+                                  " " c
+                                  " system sub-component.")
+                             (merge
+                              {:system rec
+                               :component c
+                               :sub-components sub-components
+                               :completed (subvec sub-components
+                                                  0 (- (count sub-components)
+                                                       (count cs)))
+                               :uncompleted cs
+                               :operation-name operation-name
+                               :type ::system-failed}
+                              (if (= ::system-failed (:type d))
+                                ;; ensure we report the most nested details
+                                d))
+                             e)))))]
         (recur res (rest cs)))
       rec)))


Remove another unnecessary symbol

Remove another unnecessary symbol

--- src/nightmod/sandbox.clj
+++ src/nightmod/sandbox.clj
@@ -23,7 +23,7 @@
        ns-resolve ns-publics ns-unmap ns-map ns-interns the-ns in-ns
        push-thread-bindings pop-thread-bindings future-call
        agent send send-off
-       pmap pvalues pcalls
+       pmap pcalls
        System/out System/in System/err
        set-screen! setScreen app! app})
    (jail-test/blacklist-nses '[clojure.main])


Fixes for Eastwood and kibit.

Fixes for Eastwood and kibit.

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -3,7 +3,6 @@
             [clojure.walk :refer (keywordize-keys)]
             [clj-time.format :as format]
             [hiccup.core :as h]
-            [oc.lib.text :as text]
             [oc.email.config :as config]))

 (def max-logo 32)
@@ -240,7 +239,7 @@
         org-name (:org-name digest)
         title (if weekly? (str org-name " Weekly Digest") (str org-name " Daily Digest"))
         boards (map posts-with-board-name (:boards digest))
-        posts (apply concat (map :posts boards))]
+        posts (mapcat :posts boards)]
     [:td
       (spacer 40)
       (when logo? (org-logo digest))


add more react keys

add more react keys

--- src-cljs/frontend/components/hud.cljs
+++ src-cljs/frontend/components/hud.cljs
@@ -226,16 +226,20 @@
                                                 [:show-viewers?]
                                                 [:client-id]
                                                 [:cust]
-                                                [:mouse-type]]))
+                                                [:mouse-type]])
+                  {:react-key "viewers"})
         (om/build menu (utils/select-in app [state/main-menu-learned-path
-                                             state/overlays-path]))
+                                             state/overlays-path])
+                  {:react-key "menu"})
         (om/build chat (utils/select-in app [state/chat-opened-path
                                              state/chat-button-learned-path
                                              state/browser-settings-path
-                                             [:document/id]]))
+                                             [:document/id]])
+                  {:react-key "chat"})

         ;; TODO finish this button once landing and outer are done
-        (om/build landing (utils/select-in app [state/info-button-learned-path]))
+        (om/build landing (utils/select-in app [state/info-button-learned-path])
+                  {:react-key "landing"})

         ;; deciding whether to get rid of this
         ;; (when-not (:cust app)


model refining incorporates corpus fix

model refining incorporates corpus fix

--- src/crawler/corpus.clj
+++ src/crawler/corpus.clj
@@ -182,32 +182,59 @@
   [model corpus]
   (map
    (fn [[action-seq count]]
-     [action-seq
-
-      :segments-to-fix
-      (refine-action-seq action-seq
-                         corpus)
-
-      :leaf-fix?
-      (leaf-fix? action-seq corpus)
-
-      :leaf-urls
-      (map
-       first
-       (filter
-        (fn [[u x]]
-          (and (:leaf? x)
-               (= (:src-xpath x)
-                  action-seq)))
-        corpus))
-
-      :fat
-      (map
-       first
-       (filter
-        (fn [[u x]]
-          (and (not (:leaf? x))
-               (= (:src-xpath x)
-                  action-seq)))
-        corpus))])
+     (let [leaf-fix-decision (leaf-fix? action-seq corpus)
+
+           leaf-muscle (map
+                        first
+                        (filter
+                         (fn [[u x]]
+                           (and (:leaf? x)
+                                (= (:src-xpath x)
+                                   action-seq)))
+                         corpus))
+
+           leaf-fat    (map
+                        first
+                        (filter
+                         (fn [[u x]]
+                           (and (not (:leaf? x))
+                                (= (:src-xpath x)
+                                   action-seq)))
+                         corpus))
+
+           leaf-src-urls (map
+                          (fn [[u x]]
+                            (:src-url x))
+                          (filter
+                           (fn [[u x]]
+                             (= (:src-xpath x)
+                                action-seq))
+                           corpus))
+
+           leaf-src-docs (map
+                          (fn [u]
+                            (:body (corpus u)))
+                          leaf-src-urls)]
+      [action-seq
+
+       :segments-to-fix
+       (refine-action-seq action-seq
+                          corpus)
+
+       :leaf-fix
+       (first
+        (first
+         (max-key
+          second
+          (frequencies
+           (map
+            (fn [[u b]]
+              (if leaf-fix-decision
+                (dom/refine-xpath-accuracy (first action-seq)
+                                           b
+                                           u
+                                           leaf-muscle
+                                           leaf-fat)
+                {}))
+            (map vector leaf-src-urls leaf-src-docs))))))]))
    model))


Adapt Locality validations to util no-missing

I centralized & generalized this for InternationalizedText, so this commit adapts the original validations to use the first version of the build-no-missing-validators fn.

--- src/vip/data_processor/validation/v5/locality.clj
+++ src/vip/data_processor/validation/v5/locality.clj
@@ -1,9 +1,8 @@
 (ns vip.data-processor.validation.v5.locality
   (:require [vip.data-processor.validation.v5.util :as util]
-            [vip.data-processor.validation.xml.spec :as spec]
-            [clojure.string :as str]
             [korma.core :as korma]
-            [vip.data-processor.db.postgres :as postgres]))
+            [vip.data-processor.db.postgres :as postgres]
+            [vip.data-processor.validation.xml.spec :as spec]))

 (def valid-types
   #{"city" "city-council" "congressional" "county" "county-concil" "judicial"
@@ -11,39 +10,19 @@
     "state-senate" "town" "township" "utility" "village" "ward" "water"
     "other"})

-(def locality-paths
-  (spec/type->simple-paths "Locality" "5.0"))
-
-(defn clojure-type->xml-type [type]
-  (let [components (-> type name (str/split #"-"))]
-    (str/join (map str/capitalize components))))
-
-(defn build-no-missing-validators [type import-id]
-  (let [path-element (clojure-type->xml-type type)]
-    (for [p locality-paths]
-      (util/build-xml-tree-value-query-validator
-       :errors :locality :missing (->> type name (str "missing-") keyword)
-       "SELECT xtv.path
-        FROM (SELECT DISTINCT subltree(path, 0, 4) || ? AS path
-              FROM xml_tree_values WHERE results_id = ?
-              AND subltree(simple_path, 0, 2) = text2ltree(?)) xtv
-        LEFT JOIN (SELECT path FROM xml_tree_values WHERE results_id = ?) xtv2
-        ON xtv.path = subltree(xtv2.path, 0, 5)
-        WHERE xtv2.path IS NULL"
-       (constantly [path-element import-id p import-id])))))
-
 (defn validate-no-missing-names [{:keys [import-id] :as ctx}]
-  (let [validators (build-no-missing-validators :name import-id)]
+  (let [validators (util/build-no-missing-validators :locality :name import-id)]
     (reduce (fn [ctx validator] (validator ctx)) ctx validators)))

 (defn validate-no-missing-state-ids [{:keys [import-id] :as ctx}]
-  (let [validators (build-no-missing-validators :state-id import-id)]
+  (let [validators (util/build-no-missing-validators :locality :state-id
+                                                     import-id)]
     (reduce (fn [ctx validator] (validator ctx)) ctx validators)))

 (defn valid-type? [type] (valid-types type))

 (defn validate-types [ctx]
-  (let [validators (for [p locality-paths]
+  (let [validators (for [p (spec/type->simple-paths "Locality" "5.0")]
                      (fn [{:keys [import-id] :as ctx}]
                        (let [type-path (str p ".Type")
                              types (korma/select postgres/xml-tree-values


Add type hints to remove reflection warnings

--- test/active/clojure/record_test.cljc
+++ test/active/clojure/record_test.cljc
@@ -138,7 +138,7 @@
   [^{:spec ::IntString} value container-value])

 (defn includes?
-  [e & subs]
+  [^Exception e & subs]
   (every? #(clojure.string/includes? (.getMessage e) %)
           subs))

@@ -198,6 +198,9 @@
   (hashCode [this] 3)
   (equals [this other] (= (first-important-a this) (first-important-a other))))

+(defn equals [^FirstImportant a ^FirstImportant b]
+  (.equals a b))
+
 (deftest providing-own-ihasheq-implementation-test
-  (is (.equals (make-first-important 1 1) (make-first-important 1 0)))
-  (is (not (.equals (make-first-important 1 1) (make-first-important 0 1)))))
+  (is (equals (make-first-important 1 1) (make-first-important 1 0)))
+  (is (not (equals (make-first-important 1 1) (make-first-important 0 1)))))


Test function test-assoc-in-if-not-nil-3

--- test/emender_jenkins/config_test.clj
+++ test/emender_jenkins/config_test.clj
@@ -115,3 +115,14 @@
             (assoc-in-if-not-nil {:first 1 :second 2} [:third] false) {:first 1 :second 2}
             (assoc-in-if-not-nil {:first 1 :second 2} [:third] true)  {:first 1 :second 2 :third true})))

+(deftest test-assoc-in-if-not-nil-3
+    "Check the behaviour of function emender-jenkins.config/assoc-in-if-not-nil."
+    (testing "the behaviour of function emender-jenkins.config/assoc-in-if-not-nil."
+        (are [x y] (= x y)
+            (assoc-in-if-not-nil {:first 1 :second 2} [:first] 3)        {:second 2 :first 3}
+            (assoc-in-if-not-nil {:first 1 :second 2} [:first] "string") {:second 2 :first "string"}
+            (assoc-in-if-not-nil {:first 1 :second 2} [:first] '())      {:second 2 :first ()}
+            (assoc-in-if-not-nil {:first 1 :second 2} [:first] [])       {:second 2 :first []}
+            (assoc-in-if-not-nil {:first 1 :second 2} [:first] '(1 2 3)) {:second 2 :first '(1 2 3)}
+            (assoc-in-if-not-nil {:first 1 :second 2} [:first] [1 2 3])  {:second 2 :first [1 2 3]})))
+


Test function test-assoc-in-if-not-nil-4

--- test/emender_jenkins/config_test.clj
+++ test/emender_jenkins/config_test.clj
@@ -126,3 +126,14 @@
             (assoc-in-if-not-nil {:first 1 :second 2} [:first] '(1 2 3)) {:second 2 :first '(1 2 3)}
             (assoc-in-if-not-nil {:first 1 :second 2} [:first] [1 2 3])  {:second 2 :first [1 2 3]})))

+(deftest test-assoc-in-if-not-nil-4
+    "Check the behaviour of function emender-jenkins.config/assoc-in-if-not-nil."
+    (testing "the behaviour of function emender-jenkins.config/assoc-in-if-not-nil."
+        (are [x y] (= x y)
+            (assoc-in-if-not-nil {:first 1 :second 2} [:second] 3)        {:first 1 :second 3}
+            (assoc-in-if-not-nil {:first 1 :second 2} [:second] "string") {:first 1 :second "string"}
+            (assoc-in-if-not-nil {:first 1 :second 2} [:second] '())      {:first 1 :second ()}
+            (assoc-in-if-not-nil {:first 1 :second 2} [:second] [])       {:first 1 :second []}
+            (assoc-in-if-not-nil {:first 1 :second 2} [:second] '(1 2 3)) {:first 1 :second '(1 2 3)}
+            (assoc-in-if-not-nil {:first 1 :second 2} [:second] [1 2 3])  {:first 1 :second [1 2 3]})))
+


Move default handler

Move default handler

--- src/discuss/utils/common.cljs
+++ src/discuss/utils/common.cljs
@@ -139,37 +139,6 @@
   (let [state (get-cursor key)]
     (om/transact! state (fn [] col))))

-
-;;;; References
-(defn get-references
-  "Returns a list of references which were received from the discussion system."
-  []
-  (get-in @app-state [:common :references]))
-
-(defn get-reference
-  "Returns a map matching a specific id. This id must be a number."
-  ([id col]
-   (first (filter #(= (str->int id) (:uid %)) col)))
-  ([id]
-   (get-reference id (get-references))))
-
-
-;;;; CSRF Token
-(defn get-csrf
-  "Return the user's csrf token for discussion system."
-  []
-  (get-in @app-state [:user :csrf]))
-
-(defn set-csrf!
-  "Set the newly received CSRF token."
-  [csrf]
-  (update-state-item! :user :csrf (fn [_] csrf)))
-
-(defn loading?
-  "Return boolean if app is currently loading content. Provide a boolean to change the app-state."
-  ([] (get-in @app-state [:layout :loading?]))
-  ([bool] (update-state-item! :layout :loading? (fn [_] bool))))
-
 (defn update-all-states!
   "Update item list with the data provided by the API.

@@ -184,6 +153,36 @@
     (update-state-map! :issues issues)
     (update-state-item! :user :avatar (fn [_] (get-in res [:extras :users_avatar])))))

+;;;; References
+(defn get-references
+  "Returns a list of references which were received from the discussion system."
+  []
+  (get-in @app-state [:common :references]))
+
+(defn get-reference
+  "Returns a map matching a specific id. This id must be a number."
+  ([id col]
+   (first (filter #(= (str->int id) (:uid %)) col)))
+  ([id]
+   (get-reference id (get-references))))
+
+
+;;;; CSRF Token
+(defn get-csrf
+  "Return the user's csrf token for discussion system."
+  []
+  (get-in @app-state [:user :csrf]))
+
+(defn set-csrf!
+  "Set the newly received CSRF token."
+  [csrf]
+  (update-state-item! :user :csrf (fn [_] csrf)))
+
+(defn loading?
+  "Return boolean if app is currently loading content. Provide a boolean to change the app-state."
+  ([] (get-in @app-state [:layout :loading?]))
+  ([bool] (update-state-item! :layout :loading? (fn [_] bool))))
+

 ;; Show error messages
 (defn error?


added home link to img banner

added home link to img banner

--- src/elliot/templates/home.clj
+++ src/elliot/templates/home.clj
@@ -1,6 +1,7 @@
 (ns elliot.templates.home
   (:require [garden.core :refer [css]]
-            [elliot.stylesheets.main :as style])
+            [elliot.stylesheets.main :as style]
+            [elliot.config-loader :as config])
   (:use hiccup.core))

 (defn render [search-component]
@@ -15,16 +16,17 @@
       [:div {:class "container" :id "search-container"}
        [:div {:class "row search-header"}
         [:div {:class "col-2"}
-         [:img {:src "imgs/small_elliot.png" :id "elliot-thumb"}]]
+         [:a {:href "/"}
+          [:img {:src "imgs/daemon_img.png" :id "daemon-img"}]]]
         [:div {:class "search-div col"}
          [:div {:class "search-div-contents"}
-          [:h1 "Yo Elliot...."]
+          [:h1 (str "Hey " (config/all :daemon-name) "....")]
           [:form {:method "GET"}
            [:div {:class "form-group"}
             [:input {:type "text"
                      :name "terms"
                      :class "form-control"
                      :id "search"
-                     :placeholder "...ask Elliot a question or search for wisdom"}]]]]]]
+                     :placeholder (str "...ask " (config/all :daemon-name) " a question or search for wisdom")}]]]]]]
         [:div {:id "results-div"}
          search-component]]]]))


Define specialized comparators in clj

Define specialized comparators in clj

Instead of letting a AFunction implement comparator, implement a
comparator which implements IFn, that way, the body is evaluated in the
context which lets the compiler work with primitives, never escaping
once to the heap on a call to .compare()

--- src/datascript/db.cljc
+++ src/datascript/db.cljc
@@ -7,6 +7,7 @@
     [datascript.lru :as lru]
     [me.tonsky.persistent-sorted-set :as set]
     [me.tonsky.persistent-sorted-set.arrays :as arrays])
+  #?(:clj (:import clojure.lang.IFn$OOL))
   #?(:cljs (:require-macros [datascript.db :refer [case-tree combine-cmp raise defrecord-updatable cond+]]))
   (:refer-clojure :exclude [seqable? #?(:clj update)]))

@@ -404,21 +405,39 @@
      [x y]
      `(long (Integer/compare ~x ~y))))

-(defn cmp-datoms-eavt ^long [^Datom d1, ^Datom d2]
+#?(:clj
+   (defmacro defcomp
+     [sym [arg1 arg2] & body]
+     (let [a1 (with-meta arg1 {})
+           a2 (with-meta arg2 {})]
+       `(def ~sym
+          (reify
+            java.util.Comparator
+            (compare [~'_ ~a1 ~a2]
+              (let [~arg1 ~arg1 ~arg2 ~arg2]
+                ~@body))
+            clojure.lang.IFn
+            (invoke [~'this ~a1 ~a2]
+              (.compare ~'this ~a1 ~a2))
+            IFn$OOL
+            (invokePrim [~'this ~a1 ~a2]
+              (.compare ~'this ~a1 ~a2)))))))
+
+(#?(:clj defcomp :cljfs defn) cmp-datoms-eavt ^long [^Datom d1, ^Datom d2]
   (combine-cmp
     (#?(:clj compare-int :cljs -) (.-e d1) (.-e d2))
     (cmp (.-a d1) (.-a d2))
     (value-cmp (.-v d1) (.-v d2))
     (#?(:clj compare-int :cljs -) (datom-tx d1) (datom-tx d2))))

-(defn cmp-datoms-aevt ^long [^Datom d1, ^Datom d2]
+(#?(:clj defcomp :cljfs defn) cmp-datoms-aevt ^long [^Datom d1, ^Datom d2]
   (combine-cmp
     (cmp (.-a d1) (.-a d2))
     (#?(:clj compare-int :cljs -) (.-e d1) (.-e d2))
     (value-cmp (.-v d1) (.-v d2))
     (#?(:clj compare-int :cljs -) (datom-tx d1) (datom-tx d2))))

-(defn cmp-datoms-avet ^long [^Datom d1, ^Datom d2]
+(#?(:clj defcomp :cljfs defn) cmp-datoms-avet ^long [^Datom d1, ^Datom d2]
   (combine-cmp
     (cmp (.-a d1) (.-a d2))
     (value-cmp (.-v d1) (.-v d2))
@@ -441,27 +460,27 @@
      :clj
      (.compareTo ^Comparable a1 a2)))

-(defn cmp-datoms-eav-quick ^long [^Datom d1, ^Datom d2]
+(#?(:clj defcomp :cljfs defn) cmp-datoms-eav-quick ^long [^Datom d1, ^Datom d2]
   (combine-cmp
     (#?(:clj compare-int :cljs -) (.-e d1) (.-e d2))
     (cmp-attr-quick (.-a d1) (.-a d2))
     (value-compare (.-v d1) (.-v d2))))

-(defn cmp-datoms-eavt-quick ^long [^Datom d1, ^Datom d2]
+(#?(:clj defcomp :cljfs defn) cmp-datoms-eavt-quick ^long [^Datom d1, ^Datom d2]
   (combine-cmp
     (#?(:clj compare-int :cljs -) (.-e d1) (.-e d2))
     (cmp-attr-quick (.-a d1) (.-a d2))
     (value-compare (.-v d1) (.-v d2))
     (#?(:clj compare-int :cljs -) (datom-tx d1) (datom-tx d2))))

-(defn cmp-datoms-aevt-quick ^long [^Datom d1, ^Datom d2]
+(#?(:clj defcomp :cljfs defn) cmp-datoms-aevt-quick ^long [^Datom d1, ^Datom d2]
   (combine-cmp
     (cmp-attr-quick (.-a d1) (.-a d2))
     (#?(:clj compare-int :cljs -) (.-e d1) (.-e d2))
     (value-compare (.-v d1) (.-v d2))
     (#?(:clj compare-int :cljs -) (datom-tx d1) (datom-tx d2))))

-(defn cmp-datoms-avet-quick ^long [^Datom d1, ^Datom d2]
+(#?(:clj defcomp :cljfs defn) cmp-datoms-avet-quick ^long [^Datom d1, ^Datom d2]
   (combine-cmp
     (cmp-attr-quick (.-a d1) (.-a d2))
     (value-compare (.-v d1) (.-v d2))


fixed a ton of things. added teensy weensy bit of unit testing

--- src/sciencefair/core.clj
+++ src/sciencefair/core.clj
@@ -32,11 +32,11 @@
 (defn pull-down-tracks-genres [genres pagesize offset date_to]
   (if
     (< empties 10)
-      (dorun (pmapcat #(tracks settings {"genres" %, "order" "created_at", "limit" pagesize, "offset" offset "created_at[to]" date_to}) genres))))
+      (doall (pmapcat #(tracks settings {"genres" %, "order" "created_at", "limit" pagesize, "offset" offset "created_at[to]" date_to}) genres))))

 (defn useful-format-tracks [tracks kees]
-  (test/is (> (count tracks) 0))
-  (map #(assoc (select-keys % kees) :comments (get-comments (% :id))) tracks))
+  ;(test/is (> (count tracks) 0))
+  (pmap #(assoc (select-keys % kees) :comments (get-comments (% :id))) tracks))

 (defn insert-batch-nodups [batch]


test cleanup

test cleanup

--- test/protobuf_test.clj
+++ test/protobuf_test.clj
@@ -182,7 +182,7 @@
   (is (= false (protodefault Foo :deleted)))
   (is (= {}    (protodefault clojure.protobuf.Test$Foo :groups))))

-(deftest use-underscores
+(deftest test-use-underscores
   (let [p (protobuf Foo {:tag_set ["odd"] :responses [:yes :not-sure :maybe :not-sure :no]})]
     (is (= '(:id :responses :tag-set :deleted)   (keys p)))
     (is (= [:yes :not-sure :maybe :not-sure :no] (:responses p)))
@@ -198,13 +198,15 @@

     (clojure.protobuf.PersistentProtocolBufferMap/setUseUnderscores false)))

-(deftest protobuf-nested-message
-  (let [p (protobuf Response :ok false :error (protobuf ErrorMsg :code -10 :data "abc"))]))
-
-(deftest protobuf-nil-field
-  (let [p (protobuf Response :ok true :error (protobuf ErrorMsg :code -10 :data nil))]))
-
-(deftest protobuf-seq-and-write-protobuf
+(deftest test-protobuf-nested-message
+  (let [p (protobuf Response :ok false :error (protobuf ErrorMsg :code -10 :data "abc"))]
+    (is (= "abc" (get-in p [:error :data])))))
+
+(deftest test-protobuf-nested-null-field
+  (let [p (protobuf Response :ok true :error (protobuf ErrorMsg :code -10 :data nil))]
+    (is (:ok p))))
+
+(deftest test-protobuf-seq-and-write-protobuf
   (let [in  (PipedInputStream.)
         out (PipedOutputStream. in)
         foo (protobuf Foo :id 1 :label "foo")


Rewrite login-form

Rewrite login-form

--- src/discuss/views.cljs
+++ src/discuss/views.cljs
@@ -83,28 +83,38 @@
                                     :onClick   #(lib/change-view! :login)}
                                "Login")))))

-(defn login-form []
-  (dom/div nil
-           (dom/h5 #js {:className "text-center"} "Login")
-           (dom/div #js {:className "input-group"}
-                    (dom/span #js {:className "input-group-addon"}
-                              (dom/i #js {:className "fa fa-user fa-fw"}))
-                    (dom/input #js {:id          (lib/prefix-name "login-nickname")
-                                    :className   "form-control"
-                                    :placeholder "nickname"}))
-           (dom/div #js {:className "input-group"}
-                    (dom/span #js {:className "input-group-addon"}
-                              (dom/i #js {:className "fa fa-key fa-fw"}))
-                    (dom/input #js {:id          (lib/prefix-name "login-password")
-                                    :className   "form-control"
-                                    :type        "password"
-                                    :placeholder "password"}))
-           (dom/button #js {:className "btn btn-default"
-                            :onClick   #(auth/login (lib/get-value-by-id "login-nickname") (lib/get-value-by-id "login-password"))}
-                       "Login")
-           (dom/div #js {:className "text-center text-muted pointer"
-                         :onClick   #(lib/change-view! :discussion)}
-                    "Back")))
+(defn login-form [_ owner]
+  (reify
+    om/IInitState
+    (init-state [_]
+      {:nickname ""
+       :password ""})
+    om/IRenderState
+    (render-state [_ {:keys [nickname password]}]
+      (dom/div nil
+               (dom/h5 #js {:className "text-center"} "Login")
+               (dom/div #js {:className "input-group"}
+                        (dom/span #js {:className "input-group-addon"}
+                                  (dom/i #js {:className "fa fa-user fa-fw"}))
+                        (dom/input #js {:id          (lib/prefix-name "login-nickname")
+                                        :className   "form-control"
+                                        :onChange    #(commit-target-value :nickname % owner)
+                                        :value       nickname
+                                        :placeholder "nickname"}))
+               (dom/div #js {:className "input-group"}
+                        (dom/span #js {:className "input-group-addon"}
+                                  (dom/i #js {:className "fa fa-key fa-fw"}))
+                        (dom/input #js {:className   "form-control"
+                                        :onChange    #(commit-target-value :password % owner)
+                                        :value       password
+                                        :type        "password"
+                                        :placeholder "password"}))
+               (dom/button #js {:className "btn btn-default"
+                                :onClick   #(auth/login nickname password)}
+                           "Login")
+               (dom/div #js {:className "text-center text-muted pointer"
+                             :onClick   #(lib/change-view! :discussion)}
+                        "Back")))))

 ;; Views
 (defn bubble-view [bubble]
@@ -201,7 +211,7 @@
                     (dom/div #js {:className "panel-body"}
                              (let [view (get-in data [:layout :template])]
                                (cond
-                                 (= view :login) (login-form)
+                                 (= view :login) (om/build login-form {})
                                  :else (discussion-elements data)))))
            (when (get-in data [:layout :add?])
              (om/build add-element {}))))


Restore cursor position when updating editor content

--- frontend/src-editor/editor/views/editor.cljs
+++ frontend/src-editor/editor/views/editor.cljs
@@ -39,8 +39,11 @@

 (defn set-codemirror-value! [value]
   (when-not (nil? *codemirror*)
-    (.call (aget *codemirror* "setValue") *codemirror* value)
-    (.call (aget *codemirror* "markClean") *codemirror*)))
+    (let [cursor (.call (aget *codemirror* "getCursor") *codemirror*)]
+      (.call (aget *codemirror* "setValue") *codemirror* value)
+      (when cursor
+        (.call (aget *codemirror* "setCursor") *codemirror* cursor))
+      (.call (aget *codemirror* "markClean") *codemirror*))))

 (defn apply-changes []
   (perform! *path* (codemirror-value)))


adding schema dep

adding schema dep

--- resources/leiningen/new/closp/project.clj
+++ resources/leiningen/new/closp/project.clj
@@ -59,7 +59,9 @@

                  [com.taoensso/tower "3.0.2"]

-                 [org.clojure/core.typed "0.3.11"]]
+                 [org.clojure/core.typed "0.3.11"]
+                 [prismatic/plumbing "0.5.0"]
+                 [prismatic/schema "1.0.3"]]

   :plugins [[de.sveri/closp-crud "0.1.4"]
             [lein-cljsbuild "1.0.5"]]


version updates minor refactoring

version updates
minor refactoring

--- resources/leiningen/new/closp/project.clj
+++ resources/leiningen/new/closp/project.clj
@@ -98,9 +98,7 @@
                                       [lein-figwheel "0.5.0-2"]
                                       [test2junit "1.1.1"]]

-                       :dependencies [[org.bouncycastle/bcprov-jdk15on "1.52"]
-
-                                      [org.apache.httpcomponents/httpclient "4.5.2"]
+                       :dependencies [[org.apache.httpcomponents/httpclient "4.5.2"]
                                       [clj-webdriver "0.7.2"]
                                       [org.seleniumhq.selenium/selenium-java "2.52.0"]


wrap session-request and session-response with cookies fns

--- ring-core/src/ring/middleware/session.clj
+++ ring-core/src/ring/middleware/session.clj
@@ -13,8 +13,7 @@
                         (if-let [root (options :root)]
                           {:path root}))})

-(defn session-request
-  "Reads current HTTP session map and adds it to :session key of the request."
+(defn- bare-session-request
   [request & [{:keys [store cookie-name]}]]
   (let [req-key  (get-in request [:cookies cookie-name :value])
         session  (store/read-session store req-key)
@@ -22,8 +21,14 @@
     (merge request {:session (or session {})
                     :session/key session-key})))

-(defn session-response
-  "Updates session based on :session key in response."
+(defn session-request
+  "Reads current HTTP session map and adds it to :session key of the request."
+  [request & [opts]]
+  (-> request
+      cookies/cookies-request
+      (bare-session-request opts)))
+
+(defn- bare-session-response
   [{session-key :session/key :as response} & [{:keys [store cookie-name cookie-attrs]}]]
   (let [new-session-key (when (contains? response :session)
                           (if-let [session (response :session)]
@@ -38,6 +43,13 @@
     (if (and new-session-key (not= session-key new-session-key))
       (assoc response :cookies (merge (response :cookies) cookie))
       response)))
+
+(defn session-response
+  "Updates session based on :session key in response."
+  [response & [opts]]
+  (-> response
+      (bare-session-response opts)
+      cookies/cookies-response))

 (defn wrap-session
   "Reads in the current HTTP session map, and adds it to the :session key on
@@ -65,12 +77,11 @@
      (wrap-session handler {}))
   ([handler options]
      (let [options (session-options options)]
-       (cookies/wrap-cookies
-        (fn [request]
-          (let [new-request (session-request request options)
-                session-key (:session/key new-request)
-                response (-> new-request
-                             handler
-                             (assoc :session/key session-key))]
-            (when (seq (dissoc response :session/key))
-              (session-response response options))))))))
+       (fn [request]
+         (let [new-request (session-request request options)
+               session-key (:session/key new-request)
+               response (-> new-request
+                            handler
+                            (assoc :session/key session-key))]
+           (when (seq (dissoc response :session/key))
+             (session-response response options)))))))


Use reading_metadata when parsing measurements.

--- src/kixi/hecuba/data/misc.clj
+++ src/kixi/hecuba/data/misc.clj
@@ -101,7 +101,11 @@
   "Takes measurements in the format returned from the database.
    Returns a list of maps, with all values parsed approprietly."
   [measurements]
-  (map (fn [m] (assoc-in m [:value] (let [value (:value m)] (if-not (empty? value) (edn/read-string value) nil)))) measurements))
+  (map (fn [m] (assoc-in m [:value]
+                         (if (metadata-is-number? m)
+                           (edn/read-string (:value m))
+                           nil)))
+       measurements))

 (defn find-broken-sensors
   "Finds sensors with bad metadata and label as broken.


Stop using deprecated macro

Stop using deprecated macro

--- src/expound/specs.cljc
+++ src/expound/specs.cljc
@@ -1,35 +1,57 @@
 (ns expound.specs
   (:require #?(:cljs [expound.alpha :as ex :include-macros true]
                :clj [expound.alpha :as ex])
-            ;; FIXME - remove this to expose
-            ;; https://github.com/bhb/expound/issues/123
             [clojure.spec.alpha :as s]))

 ;;;; public specs ;;;;;;

-(ex/def ::bool boolean? "should be either true or false")
-#?(:clj (ex/def ::bytes bytes? "should be an array of bytes"))
-(ex/def ::double double? "should be a double")
-(ex/def ::ident ident? "should be an identifier (a symbol or keyword)")
-(ex/def ::indexed indexed? "should be an indexed collection")
-(ex/def ::int int? "should be an integer")
-(ex/def ::kw keyword? "should be a keyword")
-(ex/def ::map map? "should be a map")
-(ex/def ::nat-int nat-int? "should be an integer equal to, or greater than, zero")
-(ex/def ::neg-int neg-int? "should be a negative integer")
-(ex/def ::pos-int pos-int? "should be a positive integer")
-(ex/def ::qualified-ident qualified-ident? "should be an identifier (a symbol or keyword) with a namespace")
-(ex/def ::qualified-kw qualified-keyword? "should be a keyword with a namespace")
-(ex/def ::qualified-sym qualified-symbol? "should be a symbol with a namespace")
-(ex/def ::seqable seqable? "should be a seqable collection")
-(ex/def ::simple-ident simple-ident? "should be an identifier (a symbol or keyword) with no namespace")
-(ex/def ::simple-kw simple-keyword? "should be a keyword with no namespace")
-(ex/def ::simple-sym simple-symbol? "should be a symbol with no namespace")
-(ex/def ::str string? "should be a string")
-(ex/def ::sym symbol? "should be a symbol")
-(ex/def ::uri uri? "should be a URI")
-(ex/def ::uuid uuid? "should be a UUID")
-(ex/def ::vec vector? "should be a vector")
+(s/def ::bool boolean?)
+#?(:clj (s/def ::bytes bytes?))
+(s/def ::double double?)
+(s/def ::ident ident?)
+(s/def ::indexed indexed?)
+(s/def ::int int?)
+(s/def ::kw keyword?)
+(s/def ::map map?)
+(s/def ::nat-int nat-int?)
+(s/def ::neg-int neg-int?)
+(s/def ::pos-int pos-int?)
+(s/def ::qualified-ident qualified-ident?)
+(s/def ::qualified-kw qualified-keyword?)
+(s/def ::qualified-sym qualified-symbol?)
+(s/def ::seqable seqable?)
+(s/def ::simple-ident simple-ident?)
+(s/def ::simple-kw simple-keyword?)
+(s/def ::simple-sym simple-symbol?)
+(s/def ::str string?)
+(s/def ::sym symbol?)
+(s/def ::uri uri?)
+(s/def ::uuid uuid?)
+(s/def ::vec vector?)
+
+(ex/defmsg ::bool "should be either true or false")
+#?(:clj (ex/defmsg ::bytes "should be an array of bytes"))
+(ex/defmsg ::double "should be a double")
+(ex/defmsg ::ident "should be an identifier (a symbol or keyword)")
+(ex/defmsg ::indexed "should be an indexed collection")
+(ex/defmsg ::int "should be an integer")
+(ex/defmsg ::kw "should be a keyword")
+(ex/defmsg ::map "should be a map")
+(ex/defmsg ::nat-int "should be an integer equal to, or greater than, zero")
+(ex/defmsg ::neg-int "should be a negative integer")
+(ex/defmsg ::pos-int "should be a positive integer")
+(ex/defmsg ::qualified-ident "should be an identifier (a symbol or keyword) with a namespace")
+(ex/defmsg ::qualified-kw "should be a keyword with a namespace")
+(ex/defmsg ::qualified-sym "should be a symbol with a namespace")
+(ex/defmsg ::seqable "should be a seqable collection")
+(ex/defmsg ::simple-ident "should be an identifier (a symbol or keyword) with no namespace")
+(ex/defmsg ::simple-kw "should be a keyword with no namespace")
+(ex/defmsg ::simple-sym "should be a symbol with no namespace")
+(ex/defmsg ::str "should be a string")
+(ex/defmsg ::sym "should be a symbol")
+(ex/defmsg ::uri "should be a URI")
+(ex/defmsg ::uuid "should be a UUID")
+(ex/defmsg ::vec "should be a vector")

 (def ^:no-doc public-specs
   [::bool #?(:clj ::bytes) ::double ::ident ::indexed ::int ::kw


pause now toggles

pause now toggles

--- src/frontend/core.cljs
+++ src/frontend/core.cljs
@@ -185,7 +185,9 @@
 (defn pause-upload [client-id]
   (println "Pausing:" client-id)
   (let [blob-stream ((:uploads @app-state) client-id)]
-    (.pause blob-stream)))
+    (if (.isPaused blob-stream)
+      (.resume blob-stream)
+      (.pause blob-stream))))

 (defn change-track [track-num]
   (.emit socket "change-track" track-num (.v4 js/uuid)))


delete upload on client

delete upload on client

--- src/frontend/core.cljs
+++ src/frontend/core.cljs
@@ -352,6 +352,12 @@
     (swap! app-state assoc :users (merge (:users @app-state)
                                          {socket-id (merge (get (:users @app-state) socket-id)
                                                            {"muted" false})}))))
+
+(.on socket "upload-cancelled"
+  (fn [id]
+    (swap! app-state assoc :current-uploads-info
+      (dissoc (:current-uploads-info @app-state) id))))
+
 (.onready js/soundManager
   (fn []
     (.createSound js/soundManager #js {


applied PR 30 with some indentation

applied PR 30 with some indentation

--- src/statuses/routing.clj
+++ src/statuses/routing.clj
@@ -36,8 +36,8 @@

 (defn next-uri [params request]
   (if (< (:offset params) (core/get-count @db))
-  (str (base-uri request) (:uri request) "?" (build-query-string params))
-  nil))
+    (str (base-uri request) (:uri request) "?" (build-query-string params))
+    nil))

 (defmacro with-etag
   "Ensures body is only evaluated if etag doesn't match. Try to do this in Java, suckers."


Updated call to forma-estimate to include est-map - was causing arity exception

--- src/clj/forma/hadoop/jobs/scatter.clj
+++ src/clj/forma/hadoop/jobs/scatter.clj
@@ -273,7 +273,8 @@
               ([]
                  "Apply beta vector"
                  (?- (hfs-seqfile out-path :sinkmode :replace)
-                     (forma/forma-estimate (hfs-seqfile beta-path)
+                     (forma/forma-estimate est-map
+                                           (hfs-seqfile beta-path)
                                            (hfs-seqfile final-path)
                                            (hfs-seqfile static-path))))


Fix field name in notabenoid crawler

Fix field name in notabenoid crawler

--- src/clj/subman/sources/notabenoid.clj
+++ src/clj/subman/sources/notabenoid.clj
@@ -91,7 +91,7 @@
      :name (get-episode-name title)
      :url (get-episode-url line)
      :version ""
-     :type const/type-notabenoid}))
+     :source const/type-notabenoid}))

 (defn- episodes-from-book
   "Get episodes from translation book"


add feedback to storage cleanup

add feedback to storage cleanup

--- src/cljs/lesezeichen/client/core.cljs
+++ src/cljs/lesezeichen/client/core.cljs
@@ -19,9 +19,9 @@
 (def ssl? (= (.getScheme uri) "https"))

 (def app-state (atom {:bookmarks []
-                      :user {:email nil
-                             :token-status nil}
+                      :user {:email nil :token-status nil}
                       :ws []}))
+
 (def socket-url (str (if ssl? "wss://" "ws://")
                      (.getDomain uri)
                      (when (= (.getDomain uri) "localhost")
@@ -90,7 +90,10 @@
                                                        (send-registry app owner))))))
    [:#modal-signup-btn] (listen :on-click (fn [e] (send-registry app owner)))
    [:#general-info] (content (om/get-state owner :info-text))
-   [:#clear-db-btn] (listen :on-click (fn [e] (.clear (.-localStorage js/window))))})
+   [:#clear-db-btn] (listen :on-click (fn [e] (do
+                                               (.clear (.-localStorage js/window))
+                                               (println "Info: Store cleared!"))))})
+

 ;; --- MAIN VIEW ---
@@ -112,8 +115,8 @@
                                                (when (= (.-which %) 13)
                                                  (when (.-ctrlKey %)
                                                    (send-bookmark app owner))))))
-   [:#search-input] (do-> (set-attr :value (:search-text state))
-                          (listen :on-change #(handle-text-change % owner :search-text)))
+   [:#search-input]  (do-> (set-attr :value (:search-text state))
+                           (listen :on-change #(handle-text-change % owner :search-text)))
    [:#url-list] (content (let [bms (if (blank? (:search-text state))
                                      (:bookmarks app)
                                      (remove
@@ -198,5 +201,3 @@
  bookmark-view
  app-state
  {:target (. js/document (getElementById "center-container"))})
-
-#_(.clear (.-localStorage js/window))


Revert "Pass context as nil"

Revert "Pass context as nil"

This reverts commit 40067942c2f14fed15f065e442ada0bc372af764.

--- src/clojure/nightcode/completions.clj
+++ src/clojure/nightcode/completions.clj
@@ -20,9 +20,19 @@
   [symbol-str ns]
   true)

+(defn get-completion-context
+  [text-area prefix]
+  (let [caretpos (.getCaretPosition text-area)
+        all-text (.getText text-area)
+        first-str (subs all-text 0 (- caretpos (count prefix)))
+        second-str (subs all-text caretpos)]
+    (str first-str "__prefix__" second-str)))
+
 (defn get-clojure-completions
-  [prefix ns]
-  (for [symbol-str (compliment/completions prefix ns nil)
+  [prefix ns context]
+  (for [symbol-str (try
+                     (compliment/completions prefix ns context)
+                     (catch Exception _))
         :when (and (some? symbol-str) (allow-symbol? symbol-str ns))]
     {:symbol-str symbol-str
      :doc-str (compliment/documentation symbol-str ns)}))
@@ -42,9 +52,10 @@
     (proxy [DefaultCompletionProvider] []
       (getCompletions [comp]
         (try
-          (let [prefix (.getAlreadyEnteredText this comp)]
+          (let [prefix (.getAlreadyEnteredText this comp)
+                context (get-completion-context text-area prefix)]
             (->> *namespaces*
-                 (map #(get-clojure-completions prefix %))
+                 (map #(get-clojure-completions prefix % context))
                  flatten
                  set
                  (map #(create-completion this (:symbol-str %) (:doc-str %)))


Add `atomic*` (alpha) low-level transactions util (#93)

--- src/taoensso/carmine.clj
+++ src/taoensso/carmine.clj
@@ -298,41 +298,9 @@
   :alpha, :asc, :desc."
   [key & sort-args] (apply sort key (parse-sort-args sort-args)))

-(defmacro atomic
-  "Alpha - subject to change!!
-  Tool to ease Redis transactions for fun & profit. Wraps body in a `wcar`
-  call that terminates with `exec`, cleans up reply, and supports automatic
-  retry for failed optimistic locking.
-
-  Body must contain a `multi` call and may contain calls to: `watch`, `unwatch`,
-  `discard`, etc. Ref. http://redis.io/topics/transactions for more info.
-
-  `return` and `parse` NOT supported after `multi` has been called.
-
-  Like `swap!` fn, body may be called multiple times so should avoid impure or
-  expensive ops.
-
-  ;;; Atomically increment integer key without using INCR
-  (atomic {} 100 ; Retry <= 100 times on failed optimistic lock, or throw ex
-
-    (watch  :my-int-key) ; Watch key for changes
-    (let [curr-val (-> (wcar {} ; Note additional connection!
-                         (get :my-int-key)) ; Use val of watched key
-                       (as-long)
-                       (or 0))]
-      (return curr-val)
-
-      (multi) ; Start the transaction
-        (set :my-int-key (inc curr-val))
-        (get :my-int-key)
-      ))
-  => [[\"OK\" nil \"OK\" \"QUEUED\" \"QUEUED\"] ; Prelude replies
-      [\"OK\" \"1\"] ; Transaction replies (`exec` reply)
-      ]
-
-  See also `lua` as alternative way to get transactional behaviour."
-  [conn-opts max-cas-attempts & body]
-  (assert (>= max-cas-attempts 1))
+(defmacro atomic* "Alpha - subject to change. Low-level transaction util."
+  [conn-opts max-cas-attempts on-success on-failure]
+    (assert (>= max-cas-attempts 1))
   `(let [conn-opts#  ~conn-opts
          max-idx#    ~max-cas-attempts
          prelude-result# (atom nil)
@@ -340,7 +308,7 @@
          (wcar conn-opts# ; Hold 1 conn for all attempts
            (loop [idx# 1]
              (try (reset! prelude-result#
-                    (protocol/with-replies* :as-pipeline ~@body))
+                    (protocol/with-replies* :as-pipeline (do ~on-success)))
                   (catch Exception e#
                     ;; Always return conn to normal state:
                     (protocol/with-replies* (discard))
@@ -350,9 +318,7 @@
                  ;; Was [] with < Carmine v3
                  (return r#)
                  (if (= idx# max-idx#)
-                   (throw (ex-info (format "`atomic` failed after %s attempt(s)"
-                                     idx#)
-                            {:nattempts idx#}))
+                   (do ~on-failure)
                    (recur (inc idx#)))))))]

      [@prelude-result#
@@ -361,6 +327,45 @@
         (if (next r#) r#
           (let [r# (nth r# 0)]
             (if (instance? Exception r#) (throw r#) r#))))]))
+
+(defmacro atomic
+  "Alpha - subject to change!
+  Tool to ease Redis transactions for fun & profit. Wraps body in a `wcar`
+  call that terminates with `exec`, cleans up reply, and supports automatic
+  retry for failed optimistic locking.
+
+  Body must contain a `multi` call and may contain calls to: `watch`, `unwatch`,
+  `discard`, etc. Ref. http://redis.io/topics/transactions for more info.
+
+  `return` and `parse` NOT supported after `multi` has been called.
+
+  Like `swap!` fn, body may be called multiple times so should avoid impure or
+  expensive ops.
+
+  ;;; Atomically increment integer key without using INCR
+  (atomic {} 100 ; Retry <= 100 times on failed optimistic lock, or throw ex
+
+    (watch  :my-int-key) ; Watch key for changes
+    (let [curr-val (-> (wcar {} ; Note additional connection!
+                         (get :my-int-key)) ; Use val of watched key
+                       (as-long)
+                       (or 0))]
+      (return curr-val)
+
+      (multi) ; Start the transaction
+        (set :my-int-key (inc curr-val))
+        (get :my-int-key)
+      ))
+  => [[\"OK\" nil \"OK\" \"QUEUED\" \"QUEUED\"] ; Prelude replies
+      [\"OK\" \"1\"] ; Transaction replies (`exec` reply)
+      ]
+
+  See also `lua` as alternative way to get transactional behaviour."
+  [conn-opts max-cas-attempts & body]
+  `(atomic* ~conn-opts ~max-cas-attempts (do ~@body)
+     (throw (ex-info (format "`atomic` failed after %s attempt(s)"
+                       ~max-cas-attempts)
+              {:nattempts ~max-cas-attempts}))))

 (comment
   ;; Error before exec (=> syntax, etc.)


Make base url configurable.

Make base url configurable.

--- src/hateoasql/core.clj
+++ src/hateoasql/core.clj
@@ -8,7 +8,7 @@
             [compojure.core :refer [defroutes ANY]]
             [clojure.string :as s]))

-(def ^:const serveraddress "http://localhost:3000/")
+(def ^:const serveraddress (or (System/getenv "BASE_URL") "http://localhost:3000/"))

 (def table-restresource-map
   (let [dbtorest (into {} (map (fn [table] {table (s/lower-case (inflec/plural table))}) dao/tablenames))]


reset

reset

--- src/launchpad/core.clj
+++ src/launchpad/core.clj
@@ -20,3 +20,5 @@

 (defn unlight [m x y]
   (light m x y 0))
+
+(defn reset [m] (midi-control m 0 0))


Appropriate error codes and improved message for command-not-found.

--- src/leiningen/core.clj
+++ src/leiningen/core.clj
@@ -28,7 +28,8 @@
 (def aliases {"--help" "help" "-h" "help" "-?" "help"})

 (defn command-not-found [command project & _]
-  (println (format "Command %s does not exist." command)))
+  (println command "is not a command. Use \"help\" to list all commands.")
+  (System/exit 1))

 (defn resolve-command [command]
   (let [command-ns (symbol (str "leiningen." command))
@@ -48,4 +49,4 @@
                                  (str (:root project) "/classes/"))]
       (apply (resolve-command command) project args))
     ;; In case tests or some other task started any:
-    (shutdown-agents))))
+    (shutdown-agents)))


implement loading of init-script specified in project.clj into REPL

--- src/leiningen/repl.clj
+++ src/leiningen/repl.clj
@@ -6,8 +6,11 @@
            [java.io OutputStreamWriter InputStreamReader]))

 (defn repl-server [project port]
-  (let [init-form (and (:main project)
-                       [:init `#(doto '~(:main project) require in-ns)])]
+  (let [init-form (and (or (:init-script project) (:main project))
+                       [:init `#(let [is# ~(:init-script project)
+                                      mn# '~(:main project)]
+                                  (when is# (load-file is#))
+                                  (when mn# (doto mn# require in-ns)))])]
     `(do (ns ~'user
            (:use [~'clojure.main :only [~'repl]])
            (:import [java.net ~'InetAddress ~'ServerSocket ~'Socket


Fix issue where we only ignored a single parent of a merge.

The syntax "^thisref^" will omit the parent and any ancestors of
"thisref". If this is a merge commit, it only excludes the first
parent (and ancestors).

It would seem, according to gitrevisions(7), that the proper way to do
this is "thisref^!" which excludes all parents and their ancestors.
However, this seems to cause other problems. The righter solution is
apparently "^thisref^@"... which /actually/ excludes all parents and
their ancestors.

Frankly, git can go @#$#^&$%^thisref...

--- src/leiningen/voom.clj
+++ src/leiningen/voom.clj
@@ -526,7 +526,7 @@
         ;; branch. Skip it.
         :when (seq tags-here)
         :let [tags-here-with-parents (remove #(.endsWith ^String % "--no-parent") tags-here)
-              neg-tags (map #(str "^" % "^") tags-here-with-parents)
+              neg-tags (map #(str "^" % "^@") tags-here-with-parents)
               ;; All commits on the current branch more recent than
               ;; (and including) the most recent tag matching our
               ;; version spec: