Remove library duplication

Remove library duplication

--- src/status_im/protocol/core.cljs
+++ src/status_im/protocol/core.cljs
@@ -6,7 +6,6 @@
             [status-im.protocol.web3.inbox :as inbox]
             [taoensso.timbre :refer-macros [debug] :as log]
             [status-im.protocol.validation :refer-macros [valid?]]
-            [status-im.protocol.web3.utils :as u]
             [status-im.protocol.web3.keys :as shh-keys]
             [status-im.protocol.chat :as chat]
             [status-im.protocol.group :as group]


🔊 Log all commands and events in dispatcher

Why:
- Makes it easy to see everything that is happening in the system.

--- src/territory_bro/dispatcher.clj
+++ src/territory_bro/dispatcher.clj
@@ -3,7 +3,8 @@
 ;; The license text is at http://www.apache.org/licenses/LICENSE-2.0

 (ns territory-bro.dispatcher
-  (:require [territory-bro.commands :as commands]
+  (:require [clojure.tools.logging :as log]
+            [territory-bro.commands :as commands]
             [territory-bro.config :as config]
             [territory-bro.congregation :as congregation]
             [territory-bro.db :as db]
@@ -59,9 +60,12 @@
     (call! db-admin/handle-command command state injections)))

 (defn command! [conn state command]
-  (let [command (commands/validate-command command)]
-    (case (namespace (:command/type command))
-      "congregation.command" (congregation-command! conn command state)
-      "gis-user.command" (gis-user-command! conn command state)
-      "db-admin.command" (db-admin-command! conn command state)
-      (throw (AssertionError. (str "Command handler not found: " (pr-str command)))))))
+  (log/info "Dispatch command:" (pr-str command))
+  (let [command (commands/validate-command command)
+        events (case (namespace (:command/type command))
+                 "congregation.command" (congregation-command! conn command state)
+                 "gis-user.command" (gis-user-command! conn command state)
+                 "db-admin.command" (db-admin-command! conn command state)
+                 (throw (AssertionError. (str "Command handler not found: " (pr-str command)))))]
+    (log/info "Produced events:" (pr-str events))
+    events))


Fix divide-by-zero error in #'overtone.sc.buffer/buffer-info when calculating :rate-scale and :duration.

--- src/overtone/sc/buffer.clj
+++ src/overtone/sc/buffer.clj
@@ -29,18 +29,20 @@
         prom   (recv "/b_info" (fn [msg]
                                  (= buf-id (first (:args msg)))))]
     (with-server-sync #(snd "/b_query" buf-id))
-    (let [msg                        (deref! prom)
-          [id n-frames n-chans rate] (:args msg)
-          num-samples                (* n-frames n-chans)
-          rate-scale                 (/ rate (server-sample-rate))
-          duration                   (/ n-frames rate)]
+    (let [[id n-frames n-chans rate] (:args (deref! prom))
+          server-rate                (server-sample-rate)
+          n-samples                  (* n-frames n-chans)
+          rate-scale                 (when (> server-rate 0)
+                                       (/ rate server-rate))
+          duration                   (when (> rate 0)
+                                       (/ n-frames rate))]

       (map->BufferInfo
        {:id id
         :size n-frames
         :n-channels n-chans
         :rate rate
-        :n-samples num-samples
+        :n-samples n-samples
         :rate-scale rate-scale
         :duration duration}))))


Fixed call to stiffness-task. say can now be used independently or in donao block

--- src/main/clojure/naojure/core.clj
+++ src/main/clojure/naojure/core.clj
@@ -3,6 +3,7 @@
              :refer [<! >! <!! timeout chan alts! alts!! put! go]]
             [naojure.util :refer :all]
             [naojure.motion-calc :refer :all]
+            [clojure.string :refer [join]]
             [clojure.pprint :refer [pprint]]))

 (def proxy-names {
@@ -100,6 +101,11 @@
   ([hostname port proxies]
      (add-proxies (attach-session {:hostname hostname :port port}) proxies)))

+(defn robot?
+  "Returns true if argument represents a robot"
+  [robot]
+  (not-nil? (:hostname robot)))
+
 (defn get-proxy
   "Gets a proxy from a robot, constructing it if necessary"
   [robot proxy]
@@ -556,10 +562,18 @@
    (.get)))

 ; text to speech
-(defn say
-  "Say something"
-  [robot text]
+(defmulti say (fn [tor & args]
+                (cond
+                 (robot? tor) :default
+                 :else :donao)))
+
+(defmethod say :default
+  [robot text & args]
   (call-service robot :tts "say" [text]))
+
+(defmethod say :donao
+  [text & args]
+  {:speech text})

 (defn get-language
   "Get the currently defined text-to-speech language"
@@ -735,7 +749,7 @@
        } action) angle1 angle2)))

 (defn- filter-actions
-  "Return only the values of joint actions"
+  "Return only the values of actions matching the selector"
   [selector actions]
   (->> actions
        (map selector)
@@ -785,10 +799,18 @@
                  (Float. execution-time-seconds)]))

 (defn- do-stiffness
-  "Takes a map of stiffness changes and a duration and builds tasks for"
+  "Takes a map of stiffness changes and a duration and builds tasks"
   [robot duration stiffness-changes]
   (if (seq stiffness-changes)
-    (map (fn [[c s]] (stiffness-task c s duration)) stiffness-changes)))
+    (map (fn [[c s]] (stiffness-task robot c s duration)) stiffness-changes)))
+
+(defn- do-speech
+  "Takes a map of speech actions and a duration and builds a single task since multiple words can't be said simultaneously"
+  [robot duration speech-changes]
+  (let [fulltext (if (string? speech-changes)
+                   speech-changes
+                   (join " " speech-changes))]
+    (list (call-service robot :tts "say" [fulltext]))))

 (defn-  parse-args
   "Parse an argument list and separate options from other params"
@@ -832,6 +854,7 @@
         is-blocking (and (nil? done-chan) (nil? callback))
         joint-changes (filter-actions :joints actions)
         stiffness-changes (filter-actions :stiffness actions)
+        speech-changes (filter-actions :speech actions)
         go-result-chan
         (go
          ;; wait to be triggered
@@ -846,7 +869,8 @@
          (let [stiffness-tasks (do-stiffness robot duration
                                              stiffness-changes)
                joint-tasks (do-joints robot duration joint-changes)
-               all-tasks (concat stiffness-tasks joint-tasks)]
+               speech-tasks (do-speech robot duration speech-changes)
+               all-tasks (concat stiffness-tasks joint-tasks speech-tasks)]
            (cond
             ;; send true on done-chan when all tasks done
             (not (nil? done-chan))


fixing 'day after [tomorrow 5pm]' vs '[day after tomororow] 5pm'

--- resources/languages/en/corpus/time.clj
+++ resources/languages/en/corpus/time.clj
@@ -199,8 +199,14 @@
   "the day after tomorrow"
   (datetime 2013 2 14)

+  "day after tomorrow 5pm"
+  (datetime 2013 2 14 17)
+
   "the day before yesterday"
   (datetime 2013 2 10)
+
+  "day before yesterday 8am"
+  (datetime 2013 2 10 8)

   "last Monday of March"
   (datetime 2013 3 25 :day-of-week 1)
@@ -271,9 +277,6 @@
   "3pm approximately"
   "at about 3pm"
   (datetime 2013 2 12 15 :hour 3 :meridiem :pm) ;; :precision "approximate"
-
-  "tomorrow 5pm sharp" ;; FIXME precision is lost
-  (datetime 2013 2 13 17 :hour 5 :meridiem :pm) ;; :precision "exact"

   "at 15 past 3pm"
   "a quarter past 3pm"
@@ -671,15 +674,8 @@
   "after 5 days"
   (datetime 2013 2 17 4 :direction :after)

-  "after tomorrow 2pm"
-  "tomorrow after 2pm" ;; FIXME this is actually not ambiguous it's 2pm - midnight.
-  (datetime 2013 2 13 14 :direction :after)
-
   "before 11 am"
   (datetime 2013 2 12 11 :direction :before)
-
-  "tomorrow before 11 am" ;; FIXME this is actually not ambiguous. it's midnight to 11 am
-  (datetime 2013 2 13 11 :direction :before)

   "in the afternoon"
   (datetime-interval [2013 2 12 12] [2013 2 12 19])


return string attrs in csv example

return string attrs in csv example

--- tutorial/csv_import.clj
+++ tutorial/csv_import.clj
@@ -42,9 +42,9 @@

 @(def db (d/db conn))

-(d/q '[:find ?sku ?count
-       :where [?e :inv/sku ?sku]
-              [?e :inv/count ?count]]
+(d/q '[:find (pull ?e [[:inv/sku :as "sku"]
+                       [:inv/count :as "count" :default 0]])
+       :where [?e :inv/sku ?sku]]
      db)

 (d/delete-database client {:db-name db-name})


remove debug repl

remove debug repl

--- src/polismath/clusters.clj
+++ src/polismath/clusters.clj
@@ -74,7 +74,6 @@
     #(assoc % :center (mean (matrix (:matrix (rowname-subset data (:members %))))))
     clusters)))

-(use 'alex-and-georges.debug-repl)
 (require '[clojure.tools.trace :as tr])
 (defnp safe-recenter-clusters [data clusters]
   "Replace cluster centers with a center computed from new positions"


Fix RE.

Fix RE.

--- src/org/spootnik/cyanite/util.clj
+++ src/org/spootnik/cyanite/util.clj
@@ -185,6 +185,6 @@

 (defn agg-fn-by-path
   [path]
-  (if-let [[_ method] (re-find #"^(sum|avg|mean|min|max|raw)\..*" path)]
+  (if-let [[_ method] (re-find #"^(sum|avg|mean|min|max|raw)(\.|\-).*" path)]
     (partial aggregate-with (keyword method))
     (partial aggregate-with :avg)))


Revert from using case since 1.2 breaks with nil test constants.

--- src/main/clojure/clojure/tools/logging.clj
+++ src/main/clojure/clojure/tools/logging.clj
@@ -49,11 +49,11 @@
   One can override the above by setting *force* to :direct or :agent; all
   subsequent writes will be direct or via an agent, respectively."
   [logger level throwable message]
-  (if (case *force*
-        :agent  true
-        :direct false
-        nil     (and (clojure.lang.LockingTransaction/isRunning)
-                     (*tx-agent-levels* level)))
+  (if (cond
+        (nil? *force*) (and (clojure.lang.LockingTransaction/isRunning)
+                            (*tx-agent-levels* level))
+        (= *force* :agent)  true
+        (= *force* :direct) false)
     (send-off *logging-agent*
       (fn [_#] (impl/write! logger level throwable message)))
     (impl/write! logger level throwable message)))


Validate token on incoming req from slack

--- src/mokkameister/slack_coffee_resource.clj
+++ src/mokkameister/slack_coffee_resource.clj
@@ -1,7 +1,13 @@
 (ns mokkameister.slack-coffee-resource
-  (:require [liberator.core :refer [resource defresource]]
+  (:require [environ.core :refer [env]]
+            [liberator.core :refer [resource defresource]]
             [mokkameister.slack :as slack]
             [mokkameister.util :refer [parse-int]]))
+
+(def ^:private slack-trigger-token
+  (or (env :slack-trigger-token)
+      (throw (Exception. "Missing SLACK_TRIGGER_TOKEN environment variable"))))
+

 (defn- coffee-message-starting [user minutes]
   (format "God nyhendnad folket! %s starta nett kaffitraktaren, kaffi om %d minuttar!" user minutes))
@@ -36,9 +42,14 @@
             time-ms (* time 1000 60)]
         (assoc event :coffee-type :regular, :time time, :time-ms time-ms)))))

+(defn valid-slack-token? [ctx]
+  (let [token (get-in ctx [:request :params :token])]
+    (= token slack-trigger-token)))
+
 (defresource slack-coffee
   :available-media-types ["text/plain"]
   :allowed-methods [:post]
+  :authorized? valid-slack-token?
   :post! (fn [{{:keys [params]} :request}]
            (-> params
                parse-slack-coffee-event


Clear up names

Clear up names

--- src/silly_image_store/handler.clj
+++ src/silly_image_store/handler.clj
@@ -17,9 +17,9 @@
   (str (name scheme) "://" host uri))

 (defn- list-images-route [request bucket]
-  (let [image-names (store/list-images images-dir bucket)
-        image-url (request-url request)
-        to-json (fn [n] {:name n :url (str image-url "/" n)})]
+  (let [base-image-url (request-url request)
+        image-names (store/list-images images-dir bucket)
+        to-json (fn [n] {:name n :url (str base-image-url "/" n)})]
     (map to-json image-names)))

 (defn- serve-image-route [{{image :image} :params}]


Don't recalculate faces every frame.

Don't recalculate faces every frame.

--- src/org/playasophy/wonderdome/geodesic.clj
+++ src/org/playasophy/wonderdome/geodesic.clj
@@ -131,6 +131,10 @@

 ;;;;; SKETCH CODE ;;;;;

+(def dome-faces
+  (split-faces icosahedron 3))
+
+
 (defn setup []
   (background 255)
   (stroke 00))
@@ -141,7 +145,7 @@
   (translate (/ (width) 2) (/ (height) 2) 0)
   (rotate-y (* (frame-count) 0.01))
   ;(rotate-x (* (frame-count) 0.04))
-  (doseq [face (split-faces icosahedron 3)]
+  (doseq [face dome-faces]
     (-> face
         (as-> points
           (map #(vec (map (partial * 100) %)) points)   ; scale the points


Update REPL notes.

Update REPL notes.

--- REPL_notes.clj
+++ REPL_notes.clj
@@ -86,14 +86,6 @@
       {:published-at "2017-10-27T19:12:40.644Z"}))
     (r/run c)))

-;; Provide a new slug for an org
-;; Insert a copy with the new slug
-(with-open [c (apply r/connect conn2)]
-  (-> (r/table "orgs")
-      (r/insert (assoc (org/get-org conn "old-slug") :slug "new-slug"))
-      (r/run c)))
-(org/delete-org! conn "old-slug")
-
 ;; for more RethinkDB help, see:
 ;; https://github.com/apa512/clj-rethinkdb
 ;; http://apa512.github.io/clj-rethinkdb/


Shorten function name

Shorten function name

--- src/play_clj/core_graphics.clj
+++ src/play_clj/core_graphics.clj
@@ -101,11 +101,11 @@
      :width (.get prop "width")
      :height (.get prop "height")}))

-(defn screen->isometric-map
+(defn screen->isometric
   "Returns a copy of the provided map with x/y values converted from screen
 to isometric map coordinates

-    (screen->isometric-map screen {:x 64 :y 32})"
+    (screen->isometric screen {:x 64 :y 32})"
   [screen {:keys [x y] :as entity}]
   (let [{:keys [unit-scale tile-width tile-height]} (tiled-map-prop screen)
         half-tile-width (/ (* tile-width unit-scale) 2)
@@ -118,11 +118,11 @@
                     (/ x half-tile-width))
                  2))))

-(defn isometric-map->screen
+(defn isometric->screen
   "Returns a copy of the provided map with x/y values converted from isometric
 map to screen coordinates

-    (isometric-map->screen screen {:x 2 :y 1})"
+    (isometric->screen screen {:x 2 :y 1})"
   [screen {:keys [x y] :as entity}]
   (let [{:keys [unit-scale tile-width tile-height]} (tiled-map-prop screen)
         half-tile-width (/ (* tile-width unit-scale) 2)
@@ -382,7 +382,7 @@
   [screen layer-name]
   (let [^TiledMapTileLayer l (tiled-map-layer screen layer-name)]
     (reduce (fn [layers {:keys [x y] :as map-tile}]
-              (let [screen-tile (isometric-map->screen screen map-tile)
+              (let [screen-tile (isometric->screen screen map-tile)
                     new-layer (or (->> layers (filter #(= y (:y %))) first)
                                   (assoc screen-tile :layer (create-layer l)))]
                 (->> (tiled-map-layer! l :get-cell x y)


Update example code demonstrating some features

--- examples/example/core.clj
+++ examples/example/core.clj
@@ -1,5 +1,6 @@
 (ns example.core
-  (:require [clojure.string :as str]
+  (:require [clojure.java.io :as io]
+            [clojure.string :as str]
             [example.lib :as lib]))

 (defn collatz [n]
@@ -22,3 +23,22 @@
 (->> (str/split "hoge\nfuga\npiyo" #"\n")
      (map #(str "[" % "]"))
      (str/join \newline))
+
+(defmacro aif [test then else]
+  `(let [~'it ~test]
+     ~then
+     ~else))
+
+(defn g [x]
+  (aif (:k x)
+    (inc it)
+    0))
+
+(let [x 0]
+  (let [[x & y] [1 2 3]]
+    (let [x x]
+      x)))
+
+(defn f [x]
+  (with-open [x (io/reader "hoge")]
+    x))


[#11384] Status Updates : Open profile when tapping on username or avatar

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

--- src/status_im/ui/screens/status/views.cljs
+++ src/status_im/ui/screens/status/views.cljs
@@ -71,16 +71,18 @@
                 :flex-direction     :row
                 :background-color   (when (and timeline? outgoing) colors/blue-light)
                 :padding-horizontal 16}
-    [react/view {:padding-top 2 :padding-right 8}
-     (if outgoing
-       [photos/member-identicon (multiaccounts/displayed-photo account)]
-       [photos/member-identicon identicon])]
+    [react/touchable-highlight {:on-press #(re-frame/dispatch [:chat.ui/show-profile-without-adding-contact from])}
+     [react/view {:padding-top 2 :padding-right 8}
+      (if outgoing
+        [photos/member-identicon (multiaccounts/displayed-photo account)]
+        [photos/member-identicon identicon])]]
     [react/view {:flex 1}
      [react/view {:flex-direction  :row
                   :justify-content :space-between}
-      (if outgoing
-        [message/message-my-name {:profile? true :you? false}]
-        [message/message-author-name from {:profile? true}])
+      [react/touchable-highlight {:on-press #(re-frame/dispatch [:chat.ui/show-profile-without-adding-contact from])}
+       (if outgoing
+         [message/message-my-name {:profile? true :you? false}]
+         [message/message-author-name from {:profile? true}])]
       [react/text {:style {:font-size 10 :color colors/gray}}
        (datetime/time-ago (datetime/to-date timestamp))]]
      (if (= content-type constants/content-type-image)


Handle "none" user case

Handle "none" user case

--- src-cljs/frontend/components/build_head.cljs
+++ src-cljs/frontend/components/build_head.cljs
@@ -546,8 +546,9 @@

 (defn link-to-user [build]
   (when-let [user (:user build)]
-    [:a {:href (vcs-url/profile-url user)}
-     (build-model/ui-user build)]))
+    (when (not (= "none" (:login user)))
+      [:a {:href (vcs-url/profile-url user)}
+       (build-model/ui-user build)])))

 (defn link-to-commit [build]
   [:a {:href (:compare build)}


added a kludge to print :ARGS binding in stress test

--- test/acceptance/stress_tests.clj
+++ test/acceptance/stress_tests.clj
@@ -186,6 +186,7 @@
                                     (str line "," (count (get-in s [:bindings k]))))
                                   "**"
                                   (:bindings s))
+                                ; "\n   " (get-in s [:bindings :ARGS])

                             ))
                   (recur (do


Add another pipeline test

Add another pipeline test

--- test/dataframe/pipeline_test.clj
+++ test/dataframe/pipeline_test.clj
@@ -20,3 +20,16 @@
                   (select (lte $a 2))
                   (assoc-col :c (add $a $b))
                   (sort-rows :c :b))))
+
+
+(expect (frame {:foo [8 8 14] :bar [0 -2 -3]} [:w :y :z])
+        (let [df (frame [[:w {:a 0 :b 8}]
+                         [:x {:a 1 :b 2}]
+                         [:y {:a 2 :b 4}]
+                         [:z {:a 3 :b 8}]])]
+          (with-> df
+                  (select (and (lte $a 2) (gte $b 4)))
+                  (assoc-col :c (add $a $b))
+                  (map-rows->df (fn [row] {:foo (+ (:a row) (:c row))
+                                           :bar (- (:b row) (:c row))}))
+                  head)))


Decoupled benchmark function with runner code.

--- src/validation_benchmark/core.clj
+++ src/validation_benchmark/core.clj
@@ -7,9 +7,6 @@
             [validation-benchmark.edn :refer [reader->seq
                                               resource-reader]])
   (:gen-class))
-
-
-(declare summarize)

 (def bench-out-path "target/criterium.output")
@@ -100,24 +97,19 @@
       (require [lib-ns])))

-(defn run-benchmarks [benchmarks quick?]
+(defn run-benchmarks [benchmarks bench-fn]
   (let [flattened (for [[lib-name lib-data] benchmarks
                         [test-name test-data] lib-data
                         [valid? {test-fn :fn inputs :inputs}] test-data]
-                    [[lib-name test-name valid?] [test-fn inputs]])
-        bench (if quick?
-                criterium/quick-benchmark*
-                criterium/benchmark*)
-        opts nil]
+                    [[lib-name test-name valid?] [test-fn inputs]])]
     (println "Running benchmarks.")
     (loop [benchmarks-with-results benchmarks
            [[k [test-fn test-data]] & r] flattened]
       (if (some? k)
         (do
           (println " " k)
-          (recur (->> (stdout->file bench-out-path
-                        (bench (fn [] (doall (map test-fn test-data))) opts))
-                      (summarize)
+          (recur (->> (fn [] (doall (map test-fn test-data)))
+                      (bench-fn)
                       (assoc-in benchmarks-with-results k))
                  r))
         benchmarks-with-results))))
@@ -179,7 +171,13 @@
                    (read-string (slurp results-path))
                    chart-path)
     (let [benchmarks (prepare-benchmarks alternatives inputs)
-          results (run-benchmarks benchmarks true)]
+          bench-fn (let [b (if quick?
+                             criterium/quick-benchmark*
+                             criterium/benchmark*)
+                         opts nil]
+                     #(stdout->file bench-out-path
+                                    (summarize (b % opts))))
+          results (run-benchmarks benchmarks bench-fn)]
       (save-results results results-path)
       (check-results alternatives inputs results)
       (final-summary groups results chart-path))))


Fixed issue where output test was passing embedded-kafka? parameter to mock-kafka as log-dir

--- test/onyx/plugin/output_test.clj
+++ test/onyx/plugin/output_test.clj
@@ -68,7 +68,7 @@
     (try
       (with-test-env [test-env [4 env-config peer-config]]
         (onyx.test-helper/validate-enough-peers! test-env job)
-        (reset! mock (test-utils/mock-kafka test-topic zk-address [] (:embedded-kafka? test-config)))
+        (reset! mock (test-utils/mock-kafka test-topic zk-address [] (str "/tmp/embedded-kafka" (java.util.UUID/randomUUID)) (:embedded-kafka? test-config)))
         (test-utils/create-topic zk-address other-test-topic)
         (pipe (spool test-data) in) ;; Pipe data from test-data to the in channel
         (->> (onyx.api/submit-job peer-config job)


Moved transaction transform into main transaction as that appears to work.

--- src/wealthpulse/parser.clj
+++ src/wealthpulse/parser.clj
@@ -2,16 +2,6 @@
 	(:require [instaparse.core :as insta]
 		[clojure.string :as string]))

-
-(defn transform-transaction-part-deux
-	"Hm, playing with transform now..."
-	[transaction]
-	(insta/transform
-		{:transaction (fn [header entries] (map (fn [entry] (concat entry [header])) (rest entries)))}
-		transaction))
-
-
-; Should use java.util.Date instead of java.text.SimpleDateFormat?

 (defn transform-transaction
 	"Transform a parsed transaction into a more usable form."
@@ -22,7 +12,8 @@
 		 :code (fn [x] [:code (string/trim x)])
 		 :payee (fn [x] [:payee (string/trim x)])
 		 :note (fn [x] [:note (string/trim x)])
-		 :quantity (fn [x] [:quantity (bigdec (string/replace x "," ""))])}
+		 :quantity (fn [x] [:quantity (bigdec (string/replace x "," ""))])
+		 :transaction (fn [header entries] (map (fn [entry] (concat entry [header])) (rest entries)))}
 		transaction))


Pull string instead of uuid object from db

--- src/clj/five_three_one/model/user.clj
+++ src/clj/five_three_one/model/user.clj
@@ -3,7 +3,9 @@
   (:require [five-three-one.model.queries :as queries]))

 (defn get-user-by-email [email]
-  (first (queries/get-user-by-email queries/spec email)))
+  (update-in (first (queries/get-user-by-email queries/spec email))
+             [:uuid]
+             str))

 (defn create-user! [{:keys [first-name last-name email]}]
   "creates new user and returns the created user"


remove unused wrap-edn

remove unused wrap-edn

--- src/clj/org/openforis/ceo/handler.clj
+++ src/clj/org/openforis/ceo/handler.clj
@@ -117,18 +117,6 @@
             {}
             keyvals)))

-(defn wrap-edn-params [handler]
-  (fn [{:keys [content-type request-method query-string body params] :as request}]
-    (if (= content-type "application/edn")
-      (let [get-params (when (and (= request-method :get)
-                                  (not (str/blank? query-string)))
-                         (parse-query-string query-string))
-            post-params (when (and (= request-method :post)
-                                   (not (nil? body)))
-                          (edn/read-string (slurp body)))]
-        (handler (assoc request :params (merge params get-params post-params))))
-      (handler request))))
-
 (def updatable-session-keys [:tokenKey])

 (defn wrap-persistent-session [handler]
@@ -161,7 +149,6 @@
       wrap-request-logging
       wrap-persistent-session
       wrap-keyword-params
-      wrap-edn-params
       wrap-json-params
       wrap-nested-params
       wrap-multipart-params


Add wrap to h-box containing symbols.

Add wrap to h-box containing symbols.

--- src/cljs/cljs_browser_repl/views.cljs
+++ src/cljs/cljs_browser_repl/views.cljs
@@ -317,7 +317,6 @@
               [h-box
                :size "0 1 auto"
                :gap "10px"
-               ;; :height "40px"
                :children [[v-box
                            :size "1 0 auto"
                            :children (for [topic (:topics section)]
@@ -331,6 +330,7 @@
                                         [h-box
                                          :size "none"
                                          :gap "2px"
+                                         :style {:flex-flow "wrap"}
                                          :class "wrap"
                                          :children (for [symbol (:symbols topic)]
                                                      [build-symbol-ui symbol popover-position])])]]]]]])


fix search field

fix search field

--- src/cljs/iwaswhere_web/ui/search.cljs
+++ src/cljs/iwaswhere_web/ui/search.cljs
@@ -51,7 +51,8 @@
             hashtags-list (map (fn [h] {:name h}) hashtags)

             search-send (fn [text editor-state]
-                          (let [s (merge query
+                          (let [query (query-id (:queries @query-cfg))
+                                s (merge query
                                          (p/parse-search text)
                                          {:editor-state editor-state})]
                             (put-fn [:search/update s])))


CMR-546: Fixed issue with multiple expired concept cleanup jobs running at the same time. Switched to stateful jobs and that prevented quartz from executing it concurrently on each host.

--- src/cmr/metadata_db/services/jobs.clj
+++ src/cmr/metadata_db/services/jobs.clj
@@ -2,7 +2,7 @@
   (:require [clojurewerkz.quartzite.scheduler :as qs]
             [clojurewerkz.quartzite.triggers :as t]
             [clojurewerkz.quartzite.jobs :as jobs]
-            [clojurewerkz.quartzite.jobs :refer [defjob]]
+            [clojurewerkz.quartzite.stateful :refer [def-stateful-job]]
             [clojurewerkz.quartzite.schedule.calendar-interval :refer [schedule with-interval-in-seconds]]
             [clojurewerkz.quartzite.conversion :as c]
             [cmr.metadata-db.db-holder :as db-holder]
@@ -27,7 +27,7 @@
     (System/setProperty "org.quartz.dataSource.myDS.password" password)))

-(defjob ExpiredConceptCleanupJob
+(def-stateful-job ExpiredConceptCleanupJob
   [ctx]
   (info "Executing expired concepts cleanup.")
   (try
@@ -46,7 +46,7 @@
   (qs/initialize)
   (qs/start)
   ;; We delete exiting job and recreate it
-  (if (qs/get-job job-key)
+  (when (qs/get-job job-key)
     (qs/delete-job (jobs/key job-key)))
   (let [job (jobs/build
               (jobs/of-type ExpiredConceptCleanupJob)


Clear lower button label before drawing another.

The code assumes overlays can, well, overlay each other! :)

--- src/afterglow/controllers/ableton_push_2.clj
+++ src/afterglow/controllers/ableton_push_2.clj
@@ -627,6 +627,9 @@
         context (.getFontRenderContext graphics)
         label (fit-string text font context (- button-cell-width button-cell-margin))
         width (string-width label font context)]
+    (set-graphics-color graphics off-color)
+    (.fillRect graphics (* index button-cell-width) (- Wayang/DISPLAY_HEIGHT 15)
+               button-cell-width 15)
     (set-graphics-color graphics color)
     (.setFont graphics font)
     (.drawString graphics label (int (math/round (- (* (+ index 0.5) button-cell-width) (/ width 2))))


Don't throw. The user isn't guaranteed to be using the gem.

--- src/circle/backend/build/inference/rails.clj
+++ src/circle/backend/build/inference/rails.clj
@@ -106,7 +106,6 @@
                   (.setPrettyFlow true))
         yaml (org.yaml.snakeyaml.Yaml. options)
         adapter (db-yml-adapter repo)]
-    (throw-if-not adapter "Error generating database.yml. Could not find appropriate Gem")
     (->> {:test
           {:adapter adapter
            :database "circle_test"


Fix issue with blocks having too many layers

--- src/clj/jest/compiler/NativeJestCompiler.clj
+++ src/clj/jest/compiler/NativeJestCompiler.clj
@@ -23,6 +23,9 @@
     :prefix "-"
     :main false))

+(defn- make-seqable
+  [x]
+  `(seq ~x))

 (defn upper-first
   [string]
@@ -64,6 +67,17 @@
     :else [obj]))

+
+
+(defn- wrap-in-do
+  [expressions]
+  (cond
+    (not (instance? List expressions)) expressions
+    (= 0 (count expressions)) (throw (new NotImplementedException))
+    (= 1 (count expressions)) (first expressions)
+    :else `(do ~@expressions)))
+
+
 ;; HELPER
 (defn merge-items
   "Takes two items and joins them as a single sequence."
@@ -365,9 +379,6 @@
     :else '()))

-(defn- make-seqable
-  [x]
-  `(seq ~x))

 (defn -visitForLoop
   [this ^JestParser$ForLoopContext ctx]
@@ -385,14 +396,17 @@
 (defn -visitBlock
   [this ^JestParser$BlockContext ctx]

-  (cond
-    (. ctx expression) (self-visit this ctx expression)
-
-    (. ctx term) (into [] (map #(.. this (visitStatementTerm %)) (. ctx term)))
-
-    (. ctx scope)  (map #(.. this (visitVarScope %)) (. ctx scope))
-
-    :else (throw (new ClojureSourceGenerator$BadSource ctx))))
+  (wrap-in-do
+    (cond
+      (. ctx expression) (self-visit this ctx expression)
+
+      ;;(. ctx term) (into [] (map #(.. this (visitStatementTerm %)) (. ctx term)))
+
+      (. ctx term) (map #(.. this (visitStatementTerm %)) (. ctx term))
+
+      (. ctx scope) (map #(.. this (visitVarScope %)) (. ctx scope))
+
+      :else (throw (new ClojureSourceGenerator$BadSource ctx)))))

 (defn -visitVarScope
@@ -400,25 +414,17 @@
   (let [names (into [] (map #(symbol (. % getText)) (. ctx name)))
         vals (into [] (map #(.. this (visitExpression %)) (. ctx exp)))
         bindings (apply concat (zip names vals))
-        expressions (into [] (map #(. this (visitStatementTerm %)) (. ctx terms)))]
+        expressions (map #(. this (visitStatementTerm %)) (. ctx terms))]
     `(let [~@bindings] ~@expressions)))

-
-(defn- wrap-in-do
-  [expressions]
-  (cond
-    (not (instance? List expressions)) expressions
-    (= 0 (count expressions)) (throw (new NotImplementedException))
-    (= 1 (count expressions)) (first expressions)
-    :else `(do ~@expressions)))

 (defn -visitConditional
   [this ^JestParser$ConditionalContext ctx]

   (let [conditions (map #( .. this (visitExpression %)) (merge-items (. ctx ifCondition) (. ctx elifExpression)))
-        results (map #(wrap-in-do (.. this (visitBlock %))) (merge-items (. ctx iftrue) (. ctx elifBlock)))
-        else (if (. ctx elseBlock) (wrap-in-do (.. this (visitBlock (. ctx elseBlock)))) nil)
+        results (map #(.. this (visitBlock %)) (merge-items (. ctx iftrue) (. ctx elifBlock)))
+        else (if (. ctx elseBlock) (.. this (visitBlock (. ctx elseBlock))) nil)
         single-if (= (. conditions size) 1)]

     (cond


Add update-server URL to check-for-updates error message

I was running into an issue where, when my server was starting up,
it was failing to connect to the server on `check-for-updates`.
The error message that showed up in the logs wasn't entirely
intuitive; adding the URL to it makes it at least a bit more clear.

--- src/com/puppetlabs/puppetdb/cli/services.clj
+++ src/com/puppetlabs/puppetdb/cli/services.clj
@@ -125,7 +125,7 @@
   (let [{:keys [version newer link]} (try
                                        (update-info update-server)
                                        (catch Throwable e
-                                         (log/debug e "Could not retrieve update information")))
+                                         (log/debug e (format "Could not retrieve update information (%s)" update-server))))
         link-str                     (if link
                                        (format "Visit %s for details." link)
                                        "")


anly apply git, if it's selected

anly apply git, if it's selected

--- src/dda/pallet/dda_managed_vm/app.clj
+++ src/dda/pallet/dda_managed_vm/app.clj
@@ -64,11 +64,13 @@
  [domain-config :- domain/DdaVmDomainConfig
   & options]
  (let [{:keys [group-key] :or {group-key infra/facility}} options
-       resolved-domain-config (resolve-secrets domain-config)]
+       resolved-domain-config (resolve-secrets domain-config)
+       {:keys [type]} resolved-domain-config]
    (mu/deep-merge
      (user/app-configuration (domain/user-config resolved-domain-config) :group-key group-key)
-     ; TODO - only if install-git is selected
-     (git/app-configuration (domain/vm-git-config resolved-domain-config) :group-key group-key)
+     (if (= type :desktop-minimal)
+       {}
+       (git/app-configuration (domain/vm-git-config resolved-domain-config) :group-key group-key))
      (serverspec/app-configuration (domain/vm-serverspec-config resolved-domain-config) :group-key group-key)
      {:group-specific-config
         {group-key (domain/infra-configuration resolved-domain-config)}})))


CMR-3210 Cleans up permission check test

--- access-control-app/int_test/cmr/access_control/int_test/permission_check_test.clj
+++ access-control-app/int_test/cmr/access_control/int_test/permission_check_test.clj
@@ -8,7 +8,6 @@
            [cmr.common.util :refer [are2]]
            [cmr.access-control.int-test.fixtures :as fixtures]
            [cmr.access-control.test.util :as u]
-           [cmr.umm-spec.core :as umm-spec]
            [cmr.umm-spec.test.expected-conversion :refer [example-collection-record]]
            [clj-time.core :as t]))

@@ -74,6 +73,33 @@
 				    <Orderable>true</Orderable>
 				</Granule>")

+(def granule-num
+  "An atom storing the next number used to generate unique granules."
+  (atom 0))
+
+(defn save-granule
+  "Saves a granule with given property map to metadata db and returns concept id."
+  [parent-collection-id]
+  (let [short-name (str "gran" (swap! granule-num inc))
+        version-id "v1"
+        native-id short-name
+        parent-collection (mdb/get-latest-concept (u/conn-context) parent-collection-id)]
+    (:concept-id
+      (mdb/save-concept (u/conn-context)
+                        {:format "application/echo10+xml"
+                         :metadata granule-metadata
+                         :concept-type :granule
+                         :provider-id "PROV1"
+                         :native-id native-id
+                         :revision-id 1
+                         :extra-fields {:short-name short-name
+                                        :entry-title short-name
+                                        :entry-id (str short-name "_" version-id)
+                                        :granule-ur (str short-name "ur")
+                                        :version-id version-id
+                                        :parent-collection-id parent-collection-id
+                                        :parent-entry-title (:entry-title (:extra-fields parent-collection))}}))))
+
 (deftest collection-simple-catalog-item-identity-permission-check-test
   ;; tests ACLs which grant access to collections based on provider id and/or entry title
   (let [token (e/login (u/conn-context) "user1" ["group-create-group"])
@@ -82,28 +108,14 @@
         ;; then create a group that contains our user, so we can find collections that grant access to this user
         user1-group (create-group {:name "groupwithuser1" :members ["user1"]})
         ;; create some collections
-        ingest-prov1-collection #(u/save-collection {:provider-id "PROV1"
+        save-prov1-collection #(u/save-collection {:provider-id "PROV1"
                                                      :entry-title (str % " entry title")
                                                      :native-id %
                                                      :short-name %})
-        coll1 (ingest-prov1-collection "coll1")
-        coll2 (ingest-prov1-collection "coll2")
-        coll3 (ingest-prov1-collection "coll3")
-        gran1 (:concept-id
-                (mdb/save-concept (u/conn-context)
-                                  {:format "application/echo10+xml"
-                                   :metadata granule-metadata
-                                   :concept-type :granule
-                                   :provider-id "PROV1"
-                                   :native-id "gran1"
-                                   :revision-id 1
-                                   :extra-fields {:short-name "gran1"
-                                                  :entry-title "gran1"
-                                                  :entry-id "gran1"
-                                                  :granule-ur "gran1ur"
-                                                  :version-id "v1"
-                                                  :parent-collection-id coll1
-                                                  :parent-entry-title "coll1"}}))
+        coll1 (save-prov1-collection "coll1")
+        coll2 (save-prov1-collection "coll2")
+        coll3 (save-prov1-collection "coll3")
+        gran1 (save-granule coll1)
         ;; local helpers to make the body of the test cleaner
         create-acl #(:concept_id (ac/create-acl (u/conn-context) % {:token token}))
         update-acl #(ac/update-acl (u/conn-context) %1 %2 {:token token})
@@ -213,20 +225,20 @@
 (deftest collection-catalog-item-identifier-access-value-test
   ;; tests ACLs which grant access to collections based on their access value
   (let [token (e/login (u/conn-context) "user1" [])
-        ingest-access-value-collection (fn [short-name access-value]
+        save-access-value-collection (fn [short-name access-value]
                                          (u/save-collection {:entry-title (str short-name " entry title")
                                                              :short-name short-name
                                                              :native-id short-name
                                                              :provider-id "PROV1"
                                                              :access-value access-value}))
         ;; one collection with a low access value
-        coll1 (ingest-access-value-collection "coll1" 1)
+        coll1 (save-access-value-collection "coll1" 1)
         ;; one with an intermediate access value
-        coll2 (ingest-access-value-collection "coll2" 4)
+        coll2 (save-access-value-collection "coll2" 4)
         ;; one with a higher access value
-        coll3 (ingest-access-value-collection "coll3" 9)
+        coll3 (save-access-value-collection "coll3" 9)
         ;; and one with no access value
-        coll4 (ingest-access-value-collection "coll4" nil)
+        coll4 (save-access-value-collection "coll4" nil)
         create-acl #(:concept_id (ac/create-acl (u/conn-context) % {:token token}))
         update-acl #(ac/update-acl (u/conn-context) %1 %2 {:token token})
         get-coll-permissions #(get-permissions :guest coll1 coll2 coll3 coll4)]
@@ -299,16 +311,16 @@
 (deftest collection-catalog-item-identifier-temporal-test
   ;; tests ACLs that grant access based on a collection's temporal range
   (let [token (e/login (u/conn-context) "user1" [])
-        ingest-temporal-collection (fn [short-name start-year end-year]
+        save-temporal-collection (fn [short-name start-year end-year]
                                      (u/save-collection {:entry-title (str short-name " entry title")
                                                          :short-name short-name
                                                          :native-id short-name
                                                          :provider-id "PROV1"
                                                          :temporal-range {:BeginningDateTime (t/date-time start-year)
                                                                           :EndingDateTime (t/date-time end-year)}}))
-        coll1 (ingest-temporal-collection "coll1" 2001 2002)
-        coll2 (ingest-temporal-collection "coll2" 2004 2005)
-        coll3 (ingest-temporal-collection "coll3" 2007 2009)
+        coll1 (save-temporal-collection "coll1" 2001 2002)
+        coll2 (save-temporal-collection "coll2" 2004 2005)
+        coll3 (save-temporal-collection "coll3" 2007 2009)
         ;; coll4 will have no temporal extent, and should not be granted any permissions by our ACLs in this test
         coll4 (u/save-collection {:entry-id "coll4"
                                   :native-id "coll4"
@@ -381,26 +393,12 @@
         created-group-concept-id (:concept_id (u/create-group token group))
         ;; required for ACLs that will reference this group
         _ (u/wait-until-indexed)
-        ingest-prov1-collection #(u/save-collection {:provider-id "PROV1"
+        save-prov1-collection #(u/save-collection {:provider-id "PROV1"
                                                       :entry-title (str % " entry title")
                                                       :native-id %
                                                       :short-name %})
-        coll1 (ingest-prov1-collection "coll1")
-        gran1 (:concept-id
-                (mdb/save-concept (u/conn-context)
-                                  {:format "application/echo10+xml"
-                                   :metadata granule-metadata
-                                   :concept-type :granule
-                                   :provider-id "PROV1"
-                                   :native-id "gran1"
-                                   :revision-id 1
-                                   :extra-fields {:short-name "gran1"
-                                                  :entry-title "gran1"
-                                                  :entry-id "gran1"
-                                                  :granule-ur "gran1ur"
-                                                  :version-id "v1"
-                                                  :parent-collection-id coll1
-                                                  :parent-entry-title "coll1 entry title"}}))
+        coll1 (save-prov1-collection "coll1")
+        gran1 (save-granule coll1)
         create-acl #(:concept_id (ac/create-acl (u/conn-context) % {:token token}))
         update-acl #(ac/update-acl (u/conn-context) %1 %2 {:token token})]

@@ -460,42 +458,14 @@
         created-group-concept-id (:concept_id (u/create-group token group))
         ;; required for ACLs that will reference this group
         _ (u/wait-until-indexed)
-        ingest-prov1-collection #(u/save-collection {:provider-id "PROV1"
+        save-prov1-collection #(u/save-collection {:provider-id "PROV1"
                                                      :entry-title (str % " entry title")
                                                      :native-id %
                                                      :short-name %})
-        coll1 (ingest-prov1-collection "coll1")
-        coll2 (ingest-prov1-collection "coll2")
-        gran1 (:concept-id
-                (mdb/save-concept (u/conn-context)
-                                  {:format "application/echo10+xml"
-                                   :metadata granule-metadata
-                                   :concept-type :granule
-                                   :provider-id "PROV1"
-                                   :native-id "gran1"
-                                   :revision-id 1
-                                   :extra-fields {:short-name "gran1"
-                                                  :entry-title "gran1"
-                                                  :entry-id "gran1"
-                                                  :granule-ur "gran1ur"
-                                                  :version-id "v1"
-                                                  :parent-collection-id coll1
-                                                  :parent-entry-title "coll1 entry title"}}))
-        gran2 (:concept-id
-                (mdb/save-concept (u/conn-context)
-                                  {:format "application/echo10+xml"
-                                   :metadata granule-metadata
-                                   :concept-type :granule
-                                   :provider-id "PROV1"
-                                   :native-id "gran2"
-                                   :revision-id 1
-                                   :extra-fields {:short-name "gran2"
-                                                  :entry-title "gran2"
-                                                  :entry-id "gran2"
-                                                  :granule-ur "gran2ur"
-                                                  :version-id "v1"
-                                                  :parent-collection-id coll2
-                                                  :parent-entry-title "coll2 entry title"}}))
+        coll1 (save-prov1-collection "coll1")
+        coll2 (save-prov1-collection "coll2")
+        gran1 (save-granule coll1)
+        gran2 (save-granule coll2)
         create-acl #(:concept_id (ac/create-acl (u/conn-context) % {:token token}))
         update-acl #(ac/update-acl (u/conn-context) %1 %2 {:token token})]

@@ -588,8 +558,6 @@
         group (u/make-group {:name "groupwithuser1" :members ["user1"]})
         created-group-concept-id (:concept_id (u/create-group token group))
         ;; create some collections
-        coll1-umm (assoc example-collection-record :EntryTitle "coll1 entry title")
-        coll1-metadata (umm-spec/generate-metadata (u/conn-context) coll1-umm :echo10)
         coll1 (u/save-collection {:provider-id "PROV1"
                                   :entry-title "coll1"
                                   :native-id "coll1"


[clojure] clean up lein profile

[clojure] clean up lein profile

--- etc/lein/profiles.clj
+++ etc/lein/profiles.clj
@@ -1,10 +1,7 @@
 {:repl {:dependencies [^:displace [org.clojure/clojure "1.10.1"]
-                       [com.cemerick/pomegranate "1.1.0"]
                        [lambdaisland/kaocha "0.0-554"]
                        [nrepl "0.6.0"]
-                       [hashp "0.1.0"]
                        [org.clojure/tools.namespace "0.3.1"]]
-        :injections [(require 'hashp.core)]
         :repl-options {:color false}}
  :user {:dependencies [^:displace [org.clojure/clojure "1.10.1"]
                        [cljfmt "0.6.6"]]


Fix repl namespace checking

Fix repl namespace checking

--- src/main/clojure/vimclojure/nails.clj
+++ src/main/clojure/vimclojure/nails.clj
@@ -225,7 +225,7 @@
   "Usage: ng vimclojure.nails.Repl [options]"
   [[id i "The id of the repl to act on."]]
   (let [id (Integer/parseInt id)]
-    (get (get @repl/*repls* :id {:ns "user"}) :ns)))
+    (get (get @repl/*repls* id {:ns "user"}) :ns)))

 (defnail CheckSyntax
   "Usage: ng vimclojure.nails.CheckSyntax"


CMR-4508 - Added route intercept for /search/concepts.

--- search-app/src/cmr/search/api/routes.clj
+++ search-app/src/cmr/search/api/routes.clj
@@ -393,7 +393,12 @@
           (OPTIONS "/" req common-routes/options-response)
           (GET "/"
               {params :params headers :headers ctx :request-context}
-              (find-concept-by-cmr-concept-id ctx path-w-extension params headers)))
+              ;; XXX REMOVE this check and the stubs once the service and
+               ;;     the associations work is complete
+               (if (headers "cmr-prototype-umm")
+                 (stubs/handle-prototype-request
+                  path-w-extension params headers)
+                 (find-concept-by-cmr-concept-id ctx path-w-extension params headers))))

         ;; Find concepts
         (context ["/:path-w-extension" :path-w-extension #"(?:(?:granules)|(?:collections)|(?:variables)|(?:services))(?:\..+)?"] [path-w-extension]


Add better logging for when a file is unavailable

--- src/kixi/datastore/structural_validation.clj
+++ src/kixi/datastore/structural_validation.clj
@@ -21,11 +21,13 @@
 (defn metadata->file
   [filestore metadata]
   (let [id (::ms/id metadata)
-        f (temp-file id)]
-    (bs/transfer
-     (retrieve filestore id)
-     f)
-    f))
+        ^File f (temp-file id)]
+    (if (.exists f)
+      (do (bs/transfer
+           (retrieve filestore id)
+           f)
+          f)
+      (error "File does exist: " id))))

 (defn csv-schema-test
   [schemastore schema-id file]
@@ -49,7 +51,7 @@
 (defn structural-validator
   [filestore schemastore]
   (fn [metadata]
-    (let [^File file (metadata->file filestore metadata)]
+    (when-let [^File file (metadata->file filestore metadata)]
       (try
         {:kixi.comms.event/key :kixi.datastore/file-metadata-updated
          :kixi.comms.event/version "1.0.0"


Add dom/prepend! function.

Add dom/prepend! function.

--- src/cljs/c2/dom.cljs
+++ src/cljs/c2/dom.cljs
@@ -57,6 +57,13 @@
              el
              (build-dom-elem el))]
     (gdom/appendChild (select container) el)
+    el))
+
+(defn prepend! [container el]
+  (let [el (if (dom-element? el)
+             el
+             (build-dom-elem el))]
+    (gdom/insertChildAt (select container) el 0)
     el))

 (defn remove! [el]


fix find-doc-keyword

fix find-doc-keyword

--- src/strictly_specking/core.clj
+++ src/strictly_specking/core.clj
@@ -134,7 +134,7 @@
          (some #(search-for-key-in-via via %)))))

 (defn find-doc-keyword [e]
-  (->> e :in-path reverse (filter keyword?) first))
+  (->> e ::error-path :in-path reverse (filter keyword?) first))

 (defn look-up-ns-keywords-in-spec
   "Fetches the child ns-keys of a spec given the un-namespaced keys."


Code cleanup for creating a new book

Code cleanup for creating a new book


Allow annotation when can read any of entity


Fixed broken test

Fixed broken test

--- test/fogus/me/invariant_tests.clj
+++ test/fogus/me/invariant_tests.clj
@@ -39,7 +39,7 @@

 (deftest test-constrained-type-with-vector-spec
   (is (= (.a (->Bar 1 2)) 1))
-  (is (= (:b (->Bar 1 2)) 2))
+  (is (= (.b (->Bar 1 2)) 2))
   (is (thrown? Error (->Bar :a :b))))

 ;; testing default clojure pre/post maps


Starting to cleanup the async tests

Starting to cleanup the async tests

--- test/momentum/test/core/async.clj
+++ test/momentum/test/core/async.clj
@@ -5,10 +5,11 @@
   (:import
    [momentum.async
     AsyncTransferQueue
-    TimeoutException]))
-
-;; TODO:
-;; * async-seq fn throws, what happens?
+    TimeoutException]
+   [java.io
+    IOException]))
+
+;; ==== Helpers

 (defn- async-inc
   [i]
@@ -25,156 +26,183 @@
      (when (> i 0)
        (cons i (async-dec-seq (dec i)))))))

-(defn- defer
-  [v]
-  (future*
-   (Thread/sleep 10)
-   v))
+(defmacro defer
+  [& body]
+  `(future*
+    (Thread/sleep 10)
+    ~@body))
+
+(def BOOM (RuntimeException. "BOOM"))
+
+(defn- boom
+  [& args]
+  (throw BOOM))
+
+(defn- defer-boom
+  [& args]
+  (defer (boom)))
+
+(defn- compare-and-inc
+  [expected]
+  (fn [v]
+    (if (= expected v)
+      (inc v)
+      v)))
+
+;; ==== doasync
+
+(defn- async-compare-and-inc
+  [expected]
+  (fn [v]
+    (if (= expected v)
+      (defer (inc v))
+      v)))

 (deftest doasync-with-no-stages
-  (are [x y] (= x y)
-       1   @(doasync 1)
-       [1] @(doasync [1])
-       nil @(doasync nil)
-       1   @(doasync (future* (Thread/sleep 10) 1))
-       [1] @(doasync (future* (Thread/sleep 10) [1]))
-       nil @(doasync (future* (Thread/sleep 10) nil))))
-
-(deftest simple-do-async
-  (let [res (atom nil)]
-    (receive
-     (doasync 1
-       inc inc)
-     #(reset! res %)
-     identity)
-    (is (= 3 @res))))
-
-(deftest successful-pipeline-seeded-with-async-value
-  (let [res (atom nil)
-        val (async-val)]
-    (receive
-     (doasync val
-       inc inc)
-     #(compare-and-set! res nil %)
-     #(reset! res %))
-    (put val 1)
-    (is (= 3 @res))))
-
-(deftest successful-pipeline-with-async-values-at-each-stage
-  (is (= 3 @(doasync 1 async-inc async-inc))))
-
-(deftest aborting-seed-async-value-aborts-pipeline
-  (let [res (atom nil)
-        err (Exception.)
-        val (async-val)]
-    (receive
-     (doasync val inc inc)
-     #(reset! res %)
-     #(compare-and-set! res nil %))
-    (abort val err)
-    (is (= err @res))))
-
-(deftest thrown-exception-in-stage-aborts-pipeline
-  (let [res (atom nil)
-        err (Exception.)]
-    (receive
-     (doasync 1 (fn [_] (throw err)) inc)
-     #(reset! res %)
-     #(compare-and-set! res nil %))
-    (is (= err @res))
-
-    (reset! res nil)
-
-    (receive
-     (doasync 1 inc (fn [_] (throw err)))
-     #(reset! res %)
-     #(compare-and-set! res nil %))
-    (is (= err @res))))
+  (are [x y] (= x @y)
+       1   (doasync 1)
+       [1] (doasync [1])
+       nil (doasync nil)
+       1   (doasync (defer 1))
+       [1] (doasync (defer [1]))
+       nil (doasync (defer nil))))
+
+(deftest doasync-succeeding
+  (let [q    (atom [])
+        fail (fn [] (swap! q #(conj % :fail)))]
+
+    (are [x] (= 3 @x)
+
+         (doasync 1
+           (compare-and-inc 1)
+           (compare-and-inc 2))
+
+         (doasync (defer 1)
+           (compare-and-inc 1)
+           (compare-and-inc 2))
+
+         (doasync 1
+           (async-compare-and-inc 1)
+           (compare-and-inc 2))
+
+         (doasync 1
+           (async-compare-and-inc 1)
+           (async-compare-and-inc 2))
+
+         (doasync (defer 1)
+           (async-compare-and-inc 1)
+           (async-compare-and-inc 2))
+
+         (doasync 3
+           (catch Exception e (fail)))
+
+         (doasync 3
+           (catch RuntimeException e (fail))
+           (catch Exception e (fail)))
+
+         (doasync 3
+           (finally (swap! q #(conj % :1))))
+
+         (doasync 3
+           (catch Exception e (fail))
+           (finally (swap! q #(conj % :2))))
+
+         (doasync 3
+           (catch Exception e (fail))
+           (catch RuntimeException e (fail))
+           (finally (swap! q #(conj % :3))))
+
+         (doasync 2 inc
+           (catch Exception e (fail))))
+
+    (is (= [:1 :2 :3] @q))))
+
+(deftest doasync-aborting
+  (let [q    (atom [])
+        push (fn [v] (swap! q #(conj % v)))
+        fail #(push :fail)]
+
+    (are [x] (thrown-with-msg? Exception #"BOOM" @x)
+
+         (doasync (defer-boom))
+         (doasync (defer-boom) fail)
+         (doasync 1 boom)
+         (doasync 1 boom fail)
+         (doasync (defer 1) boom)
+         (doasync (defer 1) boom fail)
+         (doasync 1 defer-boom)
+         (doasync 1 defer-boom fail)
+         (doasync (defer 1) defer-boom)
+         (doasync (defer 1) defer-boom fail)
+
+         (doasync (defer-boom)
+           (finally (push :1)))
+
+         (doasync (defer-boom)
+           (catch IOException e))
+
+         (doasync (defer-boom)
+           (catch IOException e)
+           (finally (push :2)))
+
+         (doasync 1
+           (finally (boom)))
+
+         (doasync (defer (throw (Exception. "BLURP")))
+           (catch Exception e (boom)))
+
+         (doasync (defer (throw (Exception. "BLURP")))
+           (finally (boom))))
+
+    (is (= [:1 :2] @q))))
+
+(deftest doasync-catching-exceptions
+  (let [q    (atom [])
+        fail (fn [] (swap! q #(conj % :fail)))]
+
+    (are [x] (= 3 @x)
+
+         (doasync (defer-boom)
+           (catch Exception e 3))
+
+         (doasync (defer-boom)
+           (catch IOException e (fail))
+           (catch Exception e 3))
+
+         (doasync (defer-boom)
+           (catch Exception e
+             (when (= BOOM e)
+               3))
+           (finally (swap! q #(conj % :1))))
+
+         (doasync 1 boom
+           (catch Exception e 3))
+
+         (doasync 1 boom
+           (catch Exception e 3)
+           (finally (swap! q #(conj % :2))))
+
+         (doasync 1 defer-boom
+           (catch Exception e 3))
+
+         (doasync 1 defer-boom
+           (catch Exception e 3)
+           (finally (swap! q #(conj % :3)))))
+
+    (is (= [:1 :2 :3] @q))))
+
+(deftest nesting-pipelines
+  (are [x] (= 3 @x)
+       (doasync (doasync 3))
+
+       (doasync (doasync 2 inc))
+
+       (doasync 1
+         #(doasync %
+            (compare-and-inc 1)
+            (compare-and-inc 2)))))

 ;; ==== Catching exceptions
-
-(deftest successful-pipeline-with-catch-statement
-  (let [res (atom nil)]
-    (receive
-     (doasync 1 inc
-       (catch Exception e
-         (reset! res e)))
-     #(compare-and-set! res nil %)
-     #(reset! res %))
-
-    (is (= 2 @res))))
-
-(deftest successful-blocking-pipeline-with-catch
-  (let [val (async-val)]
-    (future
-      (Thread/sleep 10)
-      (put val 1))
-    (is (= 2
-           @(doasync val inc
-              (catch Exception e :fail))))))
-
-(deftest catching-aborted-pipeline-succeeds-with-value
-  (let [res (atom nil)
-        val (async-val)]
-    (receive
-     (doasync val
-       identity
-       (catch Exception _ :hello))
-     #(compare-and-set! res nil %)
-     #(reset! val %))
-
-    (abort val (Exception.))
-    (is (= :hello @res))))
-
-(deftest catching-exception-thrown-during-stage-succeeds-with-value
-  (let [res (atom nil)]
-    (receive
-     (doasync 1
-       (fn [_] (throw (Exception.)))
-       (catch Exception e :hello))
-     #(reset! res %)
-     #(reset! res %))
-    (is (= :hello @res))))
-
-;; === Finally statements
-
-(deftest finally-statement-called-after-value-realized
-  (let [res (atom nil)]
-    (doasync 1
-      #(reset! res %)
-      (finally
-       (compare-and-set! res 1 :win)))
-    (is (= :win @res))))
-
-(deftest finally-statement-called-after-aborted
-  (let [res (atom nil)]
-    (doasync 1
-      (fn [_] (throw (Exception.)))
-      (finally
-       (compare-and-set! res nil :win)))
-    (is (= :win @res))))
-
-(deftest finally-statement-called-after-caught-exception
-  (let [res (atom nil)]
-    (doasync 1
-      (fn [_] (throw (Exception.)))
-      (catch Exception _)
-      (finally
-       (compare-and-set! res nil :win)))
-    (is (= :win @res))))
-
-(deftest throwing-in-finally
-  (is (thrown-with-msg?
-        Exception #"BOOM"
-        @(doasync 1 inc
-           (finally (throw (Exception. "BOOM")))))))
-
-(deftest throwing-in-finally-overrides-aborted-exception
-  (is (thrown-with-msg?
-        Exception #"BOOM"
-        @(doasync 1
-           (fn [_] (throw (Exception. "BAM")))
-           (finally (throw (Exception. "BOOM")))))))

 (deftest aborting-in-progress
   (is (thrown-with-msg?


Code tweaks

Code tweaks

--- taxi-rides-clj/src/taxi_rides_clj/core.clj
+++ taxi-rides-clj/src/taxi_rides_clj/core.clj
@@ -81,10 +81,10 @@
    "Lpep_dropoff_datetime"   [:basic-datetime  :dropoff-dt]
    "Store_and_fwd_flag"      [:keyword         :store-flag]
    "RateCodeID"              [:int             :rate-code-id]
-   "Pickup_longitude"        [:latlon          :pickup-lon      :skip-in-es]
-   "Pickup_latitude"         [:latlon          :pickup-lat      :skip-in-es]
-   "Dropoff_longitude"       [:latlon          :dropoff-lon     :skip-in-es]
-   "Dropoff_latitude"        [:latlon          :dropoff-lat     :skip-in-es]
+   "Pickup_longitude"        [:latlon          :pickup-lon]
+   "Pickup_latitude"         [:latlon          :pickup-lat]
+   "Dropoff_longitude"       [:latlon          :dropoff-lon]
+   "Dropoff_latitude"        [:latlon          :dropoff-lat]
    "Passenger_count"         [:int             :n-passengers]
    "Trip_distance"           [:float           :travel-km]
    "Fare_amount"             [:float           :paid-fare]
@@ -97,7 +97,8 @@
    "Trip_type"               [:keyword         :trip-type]
    "Extra"                   nil

-   ; These are formed by mergin latitude an longitude columns, not part of CSV
+   ; These are generated, not part of CSV
+   :company      [:keyword  :company]
    :pickup-pos   [:geopoint :pickup-pos]
    :dropoff-pos  [:geopoint :dropoff-pos]
    :dlat-km      [:float    :dlat-km]
@@ -132,7 +133,7 @@
           dist     (fn [a b] (if (and a b) (Math/sqrt (+ (* a a) (* b b))) 0.0))
           to-time  (fn [datetime]
                      (let [time (apply + (map / (map #(->> % (apply str) ((:int parsers))) (->> datetime (drop 9) (partition 2))) [1.0 60.0 3600.0]))]
-                       (if (not= time 0.0) (round time))))
+                       (if (not= time 0.0) (min (round time) 23.999))))
           docs     (for [row rows :when (>= (count row) n-cols)]
                      (let [doc (into (sorted-map) (map (fn [h v] (if h [(second h) ((-> h first parsers) v)])) header row))]
                        (-> doc
@@ -141,13 +142,15 @@
                          (into           (weather (-> doc :pickup-dt (subs 0 8)))))))]
         (for [doc docs :when (pos? (:travel-km doc))]
           (-> doc
-              (update :travel-km   mile2km)
-              (assoc :pickup-pos   (if (:pickup-lon  doc) (mapv doc [:pickup-lon  :pickup-lat])))
-              (assoc :dropoff-pos  (if (:dropoff-lon doc) (mapv doc [:dropoff-lon :dropoff-lat])))
-              (assoc :dlat-km      (delta-km (:pickup-lat doc) (:dropoff-lat doc)))
-              (assoc :dlon-km      (delta-km (:pickup-lon doc) (:dropoff-lon doc)))
-              (assoc :pickup-time  (to-time (:pickup-dt  doc)))
-              (assoc :dropoff-time (to-time (:dropoff-dt doc)))
+              (assoc  :company       "Green")
+              (update :travel-km     mile2km)
+              (assoc  :pickup-pos    (if (:pickup-lon  doc) (mapv doc [:pickup-lon  :pickup-lat])))
+              (assoc  :dropoff-pos   (if (:dropoff-lon doc) (mapv doc [:dropoff-lon :dropoff-lat])))
+              (assoc  :dlat-km       (delta-km (:pickup-lat doc) (:dropoff-lat doc)))
+              (assoc  :dlon-km       (delta-km (:pickup-lon doc) (:dropoff-lon doc)))
+              (assoc  :pickup-time   (to-time (:pickup-dt  doc)))
+              (assoc  :dropoff-time  (to-time (:dropoff-dt doc)))
+              (update :paid-ehail   #(or % 0.0))
               (#(assoc % :travel-h   (let [pickup-time  (:pickup-time  %)
                                            dropoff-time (:dropoff-time %)]
                                        (if (and dropoff-time pickup-time (not= dropoff-time pickup-time))
@@ -155,7 +158,7 @@
                                                   (if (pos? delta) delta (+ delta 24))))))))
              ;(update :pickup-time  to-int-str)
              ;(update :dropoff-time to-int-str)
-              (#(assoc % :speed-kmph (if-let [travel-h (:travel-h %)] (round (/ (:travel-km %) travel-h)))))
+              (#(assoc % :speed-kmph (if-let [travel-h (:travel-h %)] (if (> travel-h 0.17) (round (/ (:travel-km %) travel-h))))))
               (#(if (< (dist (:dlat-km %) (:dlon-km %)) 0.2) (reduce dissoc % [:dlat-km :dlon-km]) %))
               drop-fields)))))
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Pick ackers.

Pick ackers.

--- src/onyx/scheduling/common_job_scheduler.clj
+++ src/onyx/scheduling/common_job_scheduler.clj
@@ -73,6 +73,32 @@
           (cts/drop-peers replica job overflow))))
     (:jobs replica))))

+(defn exempt-from-acker? [replica job task]
+  (or (some #{task} (get-in replica [:exempt-tasks job]))
+      (and (get-in replica [:acker-exclude-inputs job])
+           (some #{task} (get-in replica [:input-tasks job])))
+      (and (get-in replica [:acker-exclude-outputs job])
+           (some #{task} (get-in replica [:output-tasks job])))))
+
+(defn choose-acker-candidates [replica peers]
+  (remove
+   (fn [p]
+     (let [{:keys [job task]} (common/peer->allocated-job replica p)]
+       (exempt-from-acker? replica job task)))
+   peers))
+
+(defn choose-ackers [replica]
+  ;; TODO: ensure this behaves consistently with respect to ordering
+  (reduce
+   (fn [result job]
+     (let [peers (apply concat (vals (get-in result [:allocations job])))
+           pct (get-in result [:acker-percentage job])
+           n (int (Math/ceil (* (* 0.01 pct) peers)))
+           candidates (choose-acker-candidates result peers)]
+       (assoc-in result [:ackers job] (take n candidates))))
+   replica
+   (:jobs replica)))
+
 (defn reconfigure-cluster-workload [replica]
   (let [job-offers (job-offer-n-peers replica)
         job-claims (job->task-claims replica job-offers)
@@ -80,22 +106,4 @@
         max-utilization (claim-spare-peers replica job-claims spare-peers)
         current-allocations (current-job-allocations replica)
         peers-to-displace (find-displaced-peers replica current-allocations max-utilization)]
-    (reallocate-peers replica peers-to-displace max-utilization)))
-
-(defn exempt-from-acker? [replica job task args]
-  (or (some #{task} (get-in replica [:exempt-tasks job]))
-      (and (get-in replica [:acker-exclude-inputs job])
-           (some #{task} (get-in replica [:input-tasks job])))
-      (and (get-in replica [:acker-exclude-outputs job])
-           (some #{task} (get-in replica [:output-tasks job])))))
-
-(defn offer-acker [replica job task args]
-  (let [peers (count (apply concat (vals (get-in replica [:allocations job]))))
-        ackers (count (get-in replica [:ackers job]))
-        pct (get-in replica [:acker-percentage job])
-        current-pct (int (Math/ceil (* 10 (double (/ ackers peers)))))]
-    (if (and (< current-pct pct) (not (exempt-from-acker? replica job task args)))
-      (-> replica
-          (update-in [:ackers job] conj (:id args))
-          (update-in [:ackers job] vec))
-      replica)))
+    (choose-ackers (reallocate-peers replica peers-to-displace max-utilization))))


solved problem 8

solved problem 8

--- euler-clj/src/euler_clj/core.clj
+++ euler-clj/src/euler_clj/core.clj
@@ -133,12 +133,12 @@
   "Return the greatest product of m consecutive digits in a number n."
   [m n]
   (apply max
-    (loop [p      (pmap #(bigint (java.lang.Integer/parseInt %)) (rest (string/split (str n) #"")))
-           result []]
-      (let [result (conj result (apply * (take m p)))]
+    (loop [p       (pmap #(bigint (java.lang.Integer/parseInt %)) (rest (string/split (str n) #"")))
+           results []]
+      (let [results (conj results (apply * (take m p)))]
         (if (<= (count p) m)
-          result
-          (recur (rest p) result))))))
+          results
+          (recur (rest p) results))))))

 (defn -main
   [& args]


.positions has been removed from SequenceSettings: use the passed PositionList instead

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@11612 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -35,6 +35,7 @@
                                          ProcessorStack SequenceSettings
                                          MMAcquisition
                                          TaggedImageStorageRam]
+           [org.micromanager.navigation PositionList]
            [org.micromanager.utils ReportingUtils]
            [mmcorej TaggedImage Configuration Metadata]
            (java.util.concurrent Executors TimeUnit)
@@ -757,7 +758,7 @@

 ;; generic metadata

-(defn convert-settings [^SequenceSettings settings]
+(defn convert-settings [^SequenceSettings settings ^PositionList position-list]
   (def seqSettings settings)
   (into (sorted-map)
         (-> settings
@@ -776,7 +777,7 @@
             (assoc :frames (range (.numFrames settings))
                    :channels (vec (filter :use-channel
                                           (map ChannelSpec-to-map (.channels settings))))
-                   :positions (vec (range (.. settings positions size)))
+                   :positions (vec (range (.getNumberOfPositions position-list)))
                    :slices (vec (.slices settings))
                    :default-exposure (core getExposure)
                    :custom-intervals-ms (vec (.customIntervalsMs settings)))
@@ -895,11 +896,12 @@

 (defn -run
   ([this acq-settings cleanup? position-list autofocus-device]
-    (let [settings (convert-settings acq-settings)]
+    (let [settings (convert-settings acq-settings position-list)]
       (run this settings cleanup? position-list autofocus-device)))
   ([this acq-settings cleanup?]
-    (let [settings (convert-settings acq-settings)]
-      (run this settings cleanup? (.getPositionList gui) (.. gui getAutofocusManager getDevice))))
+    (let [position-list (.getPositionList gui)
+          settings (convert-settings acq-settings position-list)]
+      (run this settings cleanup? position-list (.. gui getAutofocusManager getDevice))))
   ([this acq-settings]
     (-run this acq-settings true)))


Hoist the client child processing up a level (WIP)

In my handshake "unit" test.

i.e. Stuff the bytes it receives into a stream. Have the "real"
processing consume that stream asynchronously.

This isn't working. It gets the initial challenge back from the server,
acts like it's ready to forward the response, and then everything stops
until the test times out.

--- test/frereth_cp/message/handshake_test.clj
+++ test/frereth_cp/message/handshake_test.clj
@@ -192,92 +192,89 @@
                  "Partial message in"
                  bs))))

-(defn mock-client-child
-  [client-atom client-state decode-src decode-sink succeeded? chzbrgr-length bs]
+(defn client-child-processor
+  "Process the messages queued by mock-client-child"
+  [client-atom client-state-atom succeeded? chzbrgr-length incoming]
+  (is incoming)
+  (is (or (keyword? incoming)
+          (< 0 (count incoming))))
   (let [prelog (utils/pre-log "Handshake Client: child callback")
-        _ (log/debug prelog "Message arrived at client's child")
-        ;; It looks as though buffering is to blame for this.
-        ;; The server is sending back the ::kk and the chzbrgr.
-        ;; In a message packet that looks bigger than I expect
-        ;; (even accounting for the fact that it's EDN rather than
-        ;; a "real" byte-array).
-        ;; I'm getting that big message here in state 2, extracting
-        ;; ::kk, and then doing nothing.
-        ;; I think I need another layer of indirection.
-        ;; This should stuff the incoming message frames into
-        ;; decode-src.
-        ;; And then I need the actual handler to either s/consume
-        ;; or s/map from decode-sink.
-        ;; TODO: Start back with this.
-        incoming (decode-bytes->child decode-src decode-sink bs)]
-    (is bs)
-    (is (< 0 (count bs)))
+        client-state @client-state-atom]
     (log/info prelog
               (str "Client State: "
-                   @client-state
+                   client-state
                    "\nreceived: "
                    incoming ", a " (class incoming)))
     (if incoming
-      (let [{n ::count} @client-state
-            next-message
-            (condp = n
-              0 (do
-                  (is (= incoming ::orly?))
-                  ::yarly)
-              1 (do
-                  (is (= incoming ::kk))
-                  ::icanhazchzbrgr?)
-              2 (do
-                  (is (= incoming ::kk))
-                  ;; This is the protocol-level ACK
-                  ;; (which is different than the CurveCP
-                  ;; ACK message) associated
-                  ;; with the chzbrgr request
-                  ;; No response to send for this
-                  nil)
-              3 (do
-                  ;; This is based around an implementation
-                  ;; detail that the message stream really consists
-                  ;; of either
-                  ;; a) the same byte array sent by the other side
-                  ;; b) several of those byte arrays, if the block
-                  ;; is too big to send all at once.
-                  ;; TODO: don't rely on that.
-                  ;; It really would be more efficient for the other
-                  ;; side to batch up the ACK and this response
-                  (is (b-t/bytes= incoming (vec (range chzbrgr-length))))
-                  ::kthxbai)
-              4 (do
-                  (is (= incoming ::kk))
-                  (log/info "Client child callback is done")
-                  (dfrd/success! succeeded? ::kthxbai)
-                  (try
-                    (message/child-close! @client-atom)
-                    (catch RuntimeException ex
-                      ;; CIDER doesn't realize that this is a failure.
-                      ;; I blame something screwy in the testing
-                      ;; harness. I *do* see this error message
-                      ;; and the stack trace.
-                      (log/error ex "This really shouldn't pass")
-                      (is (not ex))))
-                  nil))]
-        (log/info prelog
-                  incoming
-                  "triggered a response:"
-                  next-message)
-        ;; Hmm...I've wound up with a circular dependency
-        ;; on the io-handle again.
-        ;; Q: Is this a problem with my architecture, or just
-        ;; a testing artifact?
-        (when next-message
-          (swap! client-state update ::count inc)
-          (buffer-response! @client-atom
-                            prelog
-                            next-message
-                            "Buffered bytes from child"
-                            "Giving up on sending message from child"
-                            {})))
-      (log/debug prelog "No bytes decoded"))))
+      (let [result (dfrd/future
+                     (let [{n ::count} client-state
+                           next-message
+                           (condp = n
+                             0 (do
+                                 (is (= incoming ::orly?))
+                                 ::yarly)
+                             1 (do
+                                 (is (= incoming ::kk))
+                                 ::icanhazchzbrgr?)
+                             2 (do
+                                 (is (= incoming ::kk))
+                                 ;; This is the protocol-level ACK
+                                 ;; (which is different than the CurveCP
+                                 ;; ACK message) associated
+                                 ;; with the chzbrgr request
+                                 ;; No response to send for this
+                                 nil)
+                             3 (do
+                                 ;; This is based around an implementation
+                                 ;; detail that the message stream really consists
+                                 ;; of either
+                                 ;; a) the same byte array sent by the other side
+                                 ;; b) several of those byte arrays, if the block
+                                 ;; is too big to send all at once.
+                                 ;; TODO: don't rely on that.
+                                 ;; It really would be more efficient for the other
+                                 ;; side to batch up the ACK and this response
+                                 (is (b-t/bytes= incoming (vec (range chzbrgr-length))))
+                                 ::kthxbai)
+                             4 (do
+                                 (is (= incoming ::kk))
+                                 (log/info "Client child callback is done")
+                                 (dfrd/success! succeeded? ::kthxbai)
+                                 (try
+                                   (message/child-close! @client-atom)
+                                   (catch RuntimeException ex
+                                     ;; CIDER doesn't realize that this is a failure.
+                                     ;; I blame something screwy in the testing
+                                     ;; harness. I *do* see this error message
+                                     ;; and the stack trace.
+                                     (log/error ex "This really shouldn't pass")
+                                     (is (not ex))))
+                                 nil))]
+                       (log/info prelog
+                                 incoming
+                                 "triggered a response:"
+                                 next-message)
+                       (swap! client-state update ::count inc)
+                       ;; Hmm...I've wound up with a circular dependency
+                       ;; on the io-handle again.
+                       ;; Q: Is this a problem with my architecture, or just
+                       ;; a testing artifact?
+                       (when next-message
+                         (buffer-response! @client-atom
+                                           prelog
+                                           next-message
+                                           "Buffered bytes from child"
+                                           "Giving up on sending message from child"
+                                           {}))
+                       (<= 5 n)))])
+      (log/error prelog "No bytes decoded. Shouldn't have gotten here"))))
+
+(defn mock-client-child
+  "This is the callback for messages arriving from server"
+  [decode-src bs]
+  (let [prelog (utils/pre-log "Handshake Client: child callback")]
+    (log/debug prelog "Message arrived at client's child")
+    (strm/put! decode-src bs)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Tests
@@ -364,16 +361,22 @@
           ;; since sending a raw byte-buffer really isn't an option.
           ;; And it's silly to pretend that this is a unit test.
           chzbrgr-length 182
+          ;; For this implementation, it would make more sense to use
+          ;; strm/onto to put this onto an executor. I'm not doing so
+          ;; because tracking all the different threads that are involved
+          ;; is already annoying, and this test isn't about trying to
+          ;; maximize throughput/bandwidth/responsiveness.
+          ;; (My first run after switching to this approach stretches
+          ;; the callback out to around 23 ms, which is completely unacceptable)
           clnt-decode-src (strm/stream)
           clnt-decode-sink (decoder clnt-decode-src)
-          client-child-cb (partial mock-client-child
-                                   client-atom
-                                   client-state
-                                   clnt-decode-src
-                                   clnt-decode-sink
-                                   succeeded?
-                                   chzbrgr-length)
-
+          client-child-cb (partial mock-client-child clnt-decode-src)
+          client-child-processing (strm/consume-async (partial client-child-processor
+                                                               client-atom
+                                                               client-state
+                                                               succeeded?
+                                                               chzbrgr-length)
+                                                      clnt-decode-sink)
           server-atom (atom nil)
           server-state-atom (atom {::prefix nil
                                    ::count 0})
@@ -429,8 +432,11 @@
                               "Handshake initiation failed"
                               {})
             ;; TODO: Find a reasonable value for this timeout
-            (let [really-succeeded? (deref succeeded? 10000 ::timed-out)]
+            (let [really-succeeded? (deref succeeded? 10000 ::timed-out)
+                  child-finished? (deref client-child-processing 500 ::timed-out)]
               (log/info prelog "handshake-test run through. Need to see what happened")
+              (is (and child-finished?
+                       (not= ::timed-out child-finished?)))
               (let [client-message-state (message/get-state client-io time-out ::timed-out)]
                 (when (or (= client-message-state ::timed-out)
                           (instance? Throwable client-state)


Test wip

Test wip

--- test/onyx/coordinator/single_peer_test.clj
+++ test/onyx/coordinator/single_peer_test.clj
@@ -177,14 +177,14 @@

   (<!! status-spy)

-  #_(facts "Touching the exhaustion node triggers the callback"
+  (facts "Touching the exhaustion node triggers the callback"
          (let [nodes (:nodes (extensions/read-place sync payload-node))]
-           (extensions/touch-place sync (:exhaust nodes))
+           (extensions/touch-place sync (:node/exhaust nodes))
            (let [event (<!! seal-ch-spy)]
              (fact (:seal? event) => true)
-             (fact (:seal-node event) => (:seal nodes)))))
-
-  #_(<!! seal-node-spy)
+             (fact (:seal-node event) => (:node/seal nodes)))))
+
+  (<!! seal-node-spy)

   #_(facts "The resource should be sealed"
          (let [nodes (:nodes (extensions/read-place sync payload-node))]


Update PDFA

Update PDFA


adapting figwheel dev settings

adapting figwheel dev settings

--- resources/leiningen/new/closp/project.clj
+++ resources/leiningen/new/closp/project.clj
@@ -86,16 +86,11 @@
   :cljsbuild
   {:builds {:dev {:source-paths ["src/cljs" "src/cljc" "env/dev/cljs"]
                   :figwheel {:css-dirs ["resources/public/css"]             ;; watch and update CSS
-                             :on-jsload "{{name}}.dev/main  "}
+                             :on-jsload "{{name}}.dev/main"}
                   :compiler     {:main           "{{name}}.dev"
                                  :asset-path     "/js/compiled/out"
                                  :output-to      "resources/public/js/compiled/app.js"
-                                 :output-dir     "resources/public/js/compiled/out"
-                                 :source-map     "resources/public/js/compiled/out.js.map"
-                                 :optimizations  :none
-                                 :cache-analysis true
-                                 :pretty-print   true
-                                 :source-map-timestamp true}}
+                                 :output-dir     "resources/public/js/compiled/out"}}
             :adv {:source-paths ["src/cljs" "src/cljc"]
                   :compiler     {:output-to     "resources/public/js/compiled/app.js"
                                  ; leaving this commented because of: https://github.com/cursiveclojure/cursive/issues/369


Fix docs link in header nav on 404 page.

--- src-cljs/frontend/components/header.cljs
+++ src-cljs/frontend/components/header.cljs
@@ -174,7 +174,7 @@
                    [:li (maybe-active nav-point :pricing)
                     [:a.menu-item (open-ext {:href "/pricing/"}) "Pricing"]]))
                [:li (maybe-active nav-point :documentation)
-                [:a.menu-item {:href "https://circleci.com/docs"}
+                [:a.menu-item {:href "https://circleci.com/docs/"}
                  (if (config/enterprise?)
                   "CircleCI Documentation"
                   "Documentation")]]


Track running/crashed/ready

Track running/crashed/ready

--- src-frontend/cljs/cljs_webrepl/core.cljs
+++ src-frontend/cljs/cljs_webrepl/core.cljs
@@ -91,9 +91,9 @@
 (defn on-repl-result [state num [ns result]]
   (if num
     (swap! state #(-> %
-                      (assoc :ns ns)
+                      (assoc :ns ns :ready? true)
                       (update-in [:history num] assoc :result result)))
-    (swap! state assoc :ns ns)))
+    (swap! state assoc :ns ns :ready? true)))

 (defn on-repl-print [state num [s]]
   (when num
@@ -123,11 +123,13 @@
       (put! from-repl [:repl/eval num (:ns @state) expression])
       (put! to-repl [:repl/eval num expression])
       (recur (inc num)))
+    (swap! state assoc :running? false :ready? false :crashed? false)
     (close! to-eval)
     (close! to-repl)))

 (defn reset-repl! [state]
   (when-let [{:keys [from-repl to-repl]} (:repl @state)]
+    (swap! state assoc :running? false :ready? false :crashed? false)
     (close! from-repl)
     (close! to-repl))

@@ -180,6 +182,7 @@
       ;; Enter
       13 (do (eval-input state)
              (. event preventDefault))
+      (swap! state assoc :ready? false :input "" :cursor 0))))

       ;; Escape
       27 (do (swap! state clear-input)
@@ -350,10 +353,14 @@

 (defn about-dialog [props]
   [:dialog.mdl-dialog.mdl-dialog__wide {:id "about-dialog"}
-   [:h4.mdl-dialog__title "CLJS-WebREPL"]
+   [:h4.mdl-dialog__title (str "CLJS-WebREPL")]
    [:div.mdl-dialog__content
     [:p "A ClojureScript browser based REPL"]
     [:p (str "Using ClojureScript version " *clojurescript-version*)]
+    [:p
+     "Running: " (if (:running? @state) "Yes" "No") [:br]
+     "Ready: " (if (:ready? @state) "Yes" "No") [:br]
+     "Crashed: " (if (:crashed? @state) "Yes" "No")]
     [:h5 "License"]
     [:p
      "Copyright © 2016 Andrew Phillips, Dan Holmsand, Mike Fikes, David Nolen, Rich Hickey, Joel Martin & Contributors"]


Add test that prints example.com site to PDF

--- test/clj_chrome_devtools/automation_test.clj
+++ test/clj_chrome_devtools/automation_test.clj
@@ -2,7 +2,8 @@
   (:require [clj-chrome-devtools.automation :as a]
             [clj-chrome-devtools.automation.fixture :refer [create-chrome-fixture]]
             [clojure.spec.test.alpha :as stest]
-            [clojure.test :as t :refer [deftest is testing]]))
+            [clojure.test :as t :refer [deftest is testing]]
+            [clojure.string :as str]))

 (stest/instrument)

@@ -24,3 +25,11 @@
          (a/evaluate @a/current-automation
                     "Array(1024 ** 3).fill().map(Math.random).length"
                     100)))))
+
+
+(deftest pdf-print-test
+  (a/to "http://example.com")
+  (a/print-pdf @a/current-automation "example.pdf")
+  (let [pdf (slurp "example.pdf")]
+    (is (str/starts-with? pdf "%PDF-1.4")) ; file exists and starts with proper PDF header
+    (is (> (count pdf) 50000)))) ; file should be little over 50k


Fixed namespace refactoring regression

Fixed namespace refactoring regression

--- test/clj/gorilla_repl/handle_test.clj
+++ test/clj/gorilla_repl/handle_test.clj
@@ -1,8 +1,8 @@
 (ns gorilla-repl.handle-test
   (:require [ring.mock.request :as mock]
             [clojure.java.io :as io]
-            [gorilla-repl.handle :as handle]
-            [gorilla-repl.route :refer :all])
+            [pinkgorilla.handle :as handle]
+            [pinkgorilla.route :refer :all])
   (:use clojure.test))

 ;; TODO: How about the repl websocket handler?
@@ -20,16 +20,16 @@
 ;; (use-fixtures :once my-test-fixture)

 (deftest not-found-test
-  (is (= (#'gorilla-repl.route/default-handler (mock/request :get "/404"))
+  (is (= (#'pinkgorilla.route/default-handler (mock/request :get "/404"))
          {:status  404
           :headers {"Content-Type" "text/html; charset=utf-8"}
           :body    "Bummer, not found"}))
-  (let [resp (#'gorilla-repl.route/default-handler (mock/request :get "/gorilla-files"))
+  (let [resp (#'pinkgorilla.route/default-handler (mock/request :get "/gorilla-files"))
         status (:status resp)]
     (is (= 200 status))))

 (deftest files-test
-  (let [resp (#'gorilla-repl.route/default-handler
+  (let [resp (#'pinkgorilla.route/default-handler
                (mock/request :get "/gorilla-files"))
         status (:status resp)
         headers (:headers resp)
@@ -38,7 +38,7 @@
     (is (= "application/json; charset=utf-8" content-type))))

 (deftest config-test
-  (let [resp (#'gorilla-repl.route/default-handler (mock/request :get "/config"))
+  (let [resp (#'pinkgorilla.route/default-handler (mock/request :get "/config"))
         status (:status resp)
         headers (:headers resp)
         content-type (get headers "Content-Type")]
@@ -46,7 +46,7 @@
     (is (= "application/json; charset=utf-8" content-type))))

 (deftest document-test
-  (let [resp (#'gorilla-repl.route/default-handler (mock/request :get "/worksheet.html"))
+  (let [resp (#'pinkgorilla.route/default-handler (mock/request :get "/worksheet.html"))
         status (:status resp)
         headers (:headers resp)
         cookie (get headers "Set-Cookie")
@@ -56,7 +56,7 @@
     (is (= "text/html; charset=utf-8" content-type))))

 (deftest resource-test
-  (let [resp (#'gorilla-repl.route/default-handler
+  (let [resp (#'pinkgorilla.route/default-handler
                (mock/request :get "/favicon.ico"))
         status (:status resp)
         headers (:headers resp)
@@ -66,7 +66,7 @@

 (deftest default-handler-save-test
   (with-redefs [handle/persist mock-persist]
-    (let [resp (#'gorilla-repl.route/default-handler
+    (let [resp (#'pinkgorilla.route/default-handler
                  (mock/request :post "/save" {:worksheet-data     "dummy"
                                               :worksheet-filename "foobar.clj"}))
           status (:status resp)
@@ -77,7 +77,7 @@

 (deftest default-handler-load-test
   (with-redefs [handle/read-sheet-locally mock-read-sheet-locally]
-    (let [resp (#'gorilla-repl.route/default-handler
+    (let [resp (#'pinkgorilla.route/default-handler
                  (mock/request :get "/load?worksheet-filename=gorilla_repl%2Fhandle_test.clj"))
           status (:status resp)
           headers (:headers resp)


Finish unit tests for search_result.

Finish unit tests for search_result.

--- project/scrape-summitpost-data/test/scrape_summitpost_data/search_result_test.clj
+++ project/scrape-summitpost-data/test/scrape_summitpost_data/search_result_test.clj
@@ -1,6 +1,45 @@
 (ns scrape-summitpost-data.search-result-test
   (require [clojure.test :refer [deftest is]]
            [scrape-summitpost-data.search-result :as test-ns]))
+
+(deftest ensure-sequence-test
+  (is (= [1 2 3] (#'test-ns/ensure-sequence [1 2 3]))
+      "returns sequence when given a sequence")
+  (is (= [1] (#'test-ns/ensure-sequence 1))
+      "returns sequence when given an int"))
+
+(deftest extract-result-links-test
+  (let [jsoup-snippet (reaver/parse
+                        "

+

+

+
+
+
+
+

+

+
")]
+    (is (= "/test-item-name/12345"
+           (#'test-ns/extract-result-links jsoup-snippet))
+        "extracts link to item from search results table")))
+
+(deftest extract-pager-links-test
+  (let [jsoup-snippet (reaver/parse
+                        "
+
+                         	")]
+    (is (= ["/test?foo=bar&page=1"]
+           (#'test-ns/extract-pager-links jsoup-snippet))
+        "extracts pager link"))
+  (let [jsoup-snippet (reaver/parse
+                        "
+
+
+                         	")]
+    (is (= ["/test?foo=bar&page=1"]
+           (#'test-ns/extract-pager-links jsoup-snippet))
+        "ignores links without page param")))

 (deftest extract-last-page-test
   (is (= 1
@@ -14,3 +53,20 @@
   (is (thrown? java.lang.NumberFormatException
          (#'test-ns/extract-last-page ["http://example.org?page=f"]))
       "fails on a non-integer value of page param"))
+
+(deftest extract-all-pager-links-test
+  (let [jsoup-snippet (reaver/parse
+                        "
+
+
+
+                         	")]
+    (is (= ["/test?page=1", "/test?page=2", "/test?page=3"
+            "/test?page=4", "/test?page=5", "/test?page=6"]
+           (#'test-ns/extract-all-pager-links jsoup-snippet))
+        "extracts entire range of links")))
+
+(deftest extract-item-name-test
+  (is (= "test-item-name"
+         (#'test-ns/extract-item-name "http://www.summitpost.org/test-item-name/12345"))
+      "extracts item name from page"))


Add REPL specials to completions. Fixes #33.

Former-commit-id: d5468ab2f16989d94ba17bed384a7c7d3fd1ea6c

--- planck-cljs/src/planck/core.cljs
+++ planck-cljs/src/planck/core.cljs
@@ -88,9 +88,11 @@
                                (keys (:cljs.analyzer/namespaces @planck.core/st)))
         all-candidates (into
                          (into
-                           (into #{} namespace-candidates)
-                           (completion-candidates-for-ns 'cljs.core false))
-                         (completion-candidates-for-ns @current-ns true))]
+                           (into
+                             (into #{} namespace-candidates)
+                             (completion-candidates-for-ns 'cljs.core false))
+                           (completion-candidates-for-ns @current-ns true))
+                         (map str repl-specials))]
     (let [buffer-match-suffix (re-find #"[a-zA-Z]*$" buffer)
           buffer-prefix (subs buffer 0 (- (count buffer) (count buffer-match-suffix)))]
       (clj->js (if (= "" buffer-match-suffix)


Convey filename to JSC when executing a path

--- planck-cljs/src/planck/repl.cljs
+++ planck-cljs/src/planck/repl.cljs
@@ -472,7 +472,7 @@
       (cljs->transit-json (get-in @planck.repl/st [:source-maps name]))))
   (if (and (not (empty? path))
            (not= "Expression" path))
-    (let [exception (js/PLANCK_EVAL source (get @name-path name path))]
+    (let [exception (js/PLANCK_EVAL source (get @name-path name name))]
       (when exception
         (throw exception)))
     (js/eval source)))
@@ -531,7 +531,8 @@
                                        [raw-load [source modified]]
                                        [js/PLANCK_READ_FILE (js/PLANCK_READ_FILE path)])]
     (when source
-      (swap! name-path assoc name path)
+      (when name
+        (swap! name-path assoc name path))
       (cb (merge
             {:lang   lang
              :source source}
@@ -901,7 +902,7 @@
     (cb {:value nil})))

 (defn- process-execute-source
-  [source-text expression-form {:keys [expression? print-nil-expression? in-exit-context? include-stacktrace?] :as opts}]
+  [source-text expression-form {:keys [expression? print-nil-expression? in-exit-context? include-stacktrace? source-path] :as opts}]
   (try
     (let [initial-ns @current-ns]
       ;; For expressions, do an extra no-op eval-str for :verbose printing side effects w/o :def-emits-var
@@ -924,7 +925,7 @@
       (cljs/eval-str
         st
         source-text
-        (if expression? "Expression" "File")
+        (if expression? "Expression" (or source-path "File"))
         (merge
           {:ns         initial-ns
            :verbose    (and (not expression?)
@@ -957,7 +958,7 @@
             cljs/*eval-fn* caching-js-eval
             r/*data-readers* tags/*cljs-data-readers*]
     (if-not (= "text" source-type)
-      (process-execute-path source-value opts)
+      (process-execute-path source-value (assoc opts :source-path source-value))
       (let [source-text     source-value
             expression-form (and expression? (first (repl-read-string source-text)))]
         (if (repl-special? expression-form)


pass the env to the underlying script call

--- plugins/matross/tasks/script.clj
+++ plugins/matross/tasks/script.clj
@@ -32,4 +32,4 @@
           src (get-script conf)
           final (run-task conn (template-conf conf src script))]
       (run-task conn {:type :command :command (str "chmod +x " script)})
-      (run-task conn {:type :command :command script}))))
+      (run-task conn {:type :command :command script :env (get conf :env {})}))))


CMR-1980: Change type hint to Java type

CMR-1980: Change type hint to Java type

--- search-app/src/cmr/search/api/keyword.clj
+++ search-app/src/cmr/search/api/keyword.clj
@@ -104,7 +104,7 @@
 (defn- get-hierarchy-from-field
   "Returns all of the fields in the hierarchy starting from the provided field and including all
   fields after."
-  [^clojure.lang.ISeq keyword-hierarchy field]
+  [^java.util.List keyword-hierarchy field]
   (let [field-index (.indexOf keyword-hierarchy field)]
     (filter #(<= field-index (.indexOf keyword-hierarchy %)) keyword-hierarchy)))


CMR-2583 Remove a rookie mistake.

CMR-2583 Remove a rookie mistake.

--- search-app/src/cmr/search/api/keyword.clj
+++ search-app/src/cmr/search/api/keyword.clj
@@ -145,8 +145,6 @@
 (defn- flat-keywords->hierarchical-keywords
   "Converts flat keywords into hierarchical keywords."
   [flat-keywords keyword-hierarchy]
-  (proto/save 1)
-  (proto/saved-values)
   (->> flat-keywords
        (map #(keyword->hierarchy % keyword-hierarchy))
        (reduce merge-hierarchical-maps sorted-hierarchical-map)


icon explaining where each thing is

icon explaining where each thing is

--- src/cljs/just_married/home/timeline.cljs
+++ src/cljs/just_married/home/timeline.cljs
@@ -1,25 +1,29 @@
 (ns just-married.home.timeline
   (:require [just-married.home.language :refer [translate]]))

+(def ^:private icons
+  {:lepri "images/rings_small.png"
+   :parco "images/party_small.png"})
+
 (def ^:private timeline-def
-  [["11:00" :waiting]
-   ["11:15" :civil-start]
-   ["12:15" :civil-end]
-   ["12:15 - 13:00" :cheers]
-   ["13:00" :grand-buffet]
-   ["14:00" :lunch-reception]
-   ["16:00" :cake-champagne]
-   ["16:30" :games-kick-off]
-   ["19:00" :evening-reception]
-   ["21:00" :music-party]
-   ["23:00" :final-cake]])
+  [["11:00" :lepri :waiting]
+   ["11:15" :lepri :civil-start]
+   ["12:15" :lepri :civil-end]
+   ["12:15" :lepri :cheers]
+   ["13:00" :parco :grand-buffet]
+   ["14:00" :parco :lunch-reception]
+   ["16:00" :parco :cake-champagne]
+   ["16:30" :parco :games-kick-off]
+   ["19:00" :parco :evening-reception]
+   ["21:00" :parco :music-party]
+   ["23:00" :parco :final-cake]])

 (def ^:private timeline-dict
   {:en {:waiting "Waiting for the bride aperitif"
         :timeline "Timeline"
         :civil-start "Civil cerimony starts"
         :civil-end "Civil cerimony ends"
-        :cheers "Cheers and Greetings to Mr and Mrs Andrea Crotti - Moving to Parco dei Principi"
+        :cheers "Cheers and Greetings to Mr and Mrs Andrea Crotti"
         :grand-buffet "Grand Buffet"
         :lunch-reception "Lunch Reception"
         :games-kick-off "Games kick-off"
@@ -48,7 +52,8 @@
   [:div.timeline {:id "timeline"}
    [:h3 (tr :timeline)]
    (into [:ul]
-         (for [[time key] timeline-def]
-           [:li
+         (for [[time place key] timeline-def]
+           [:li {:class (place icons)}
+            [:img.timeline__icon {:src (place icons)}]
             [:span.timeline__time time]
             [:span.timeline__msg (tr key)]]))])


be consistent

be consistent

--- sidecar/src/figwheel_sidecar/repl_api.clj
+++ sidecar/src/figwheel_sidecar/repl_api.clj
@@ -7,7 +7,7 @@
   [& ids]
   (fr/build-once ids))

-(defn clean-builds
+(defn clean-build
   "Deletes the compiled artifacts for the builds with the provided build ids (or the current default ids)."
   [& ids]
   (fr/clean-build ids))