Fire trigger multimethod.

Fire trigger multimethod.

[ci skip]

--- src/onyx/windowing/triggers.clj
+++ src/onyx/windowing/triggers.clj
@@ -1,5 +1,5 @@
 (ns onyx.windowing.triggers
-  (:require [onyx.windowing.coerce :refer [to-standard-units]]
+  (:require [onyx.windowing.coerce :refer [to-standard-units standard-units-for]]
             [onyx.windowing.window-id :as wid]
             [onyx.peer.operation :refer [kw->fn]]
             [onyx.static.planning :refer [find-window]]
@@ -8,6 +8,10 @@
 (defmulti trigger-setup
   (fn [event trigger id]
     (:trigger/type trigger)))
+
+(defmulti trigger-fire
+  (fn [event trigger id invoker & args]
+    [(:trigger/type trigger) invoker]))

 (defmulti trigger-teardown
   (fn [event trigger id]
@@ -20,29 +24,35 @@
 (defmethod trigger-setup :periodically
   [event trigger id]
   ;; TODO: validate that :trigger/period is a time-based value.
+  (if (= (standard-units-for (second (:trigger/period trigger))) :milliseconds)
+    (let [ms (apply to-standard-units (:trigger/period trigger))
+          fut
+          (future
+            (loop []
+              (try
+                (Thread/sleep ms)
+                (trigger-fire event trigger id :timer)
+                (catch InterruptedException e
+                  (throw e))
+                (catch Throwable e
+                  (fatal e)))
+              (recur)))]
+      (assoc-in event [:onyx.triggers/period-threads id] fut))
+    event))
+
+(defmethod trigger-fire [:periodically :timer]
+  [event trigger id invoker]
   (let [f (kw->fn (:trigger/sync trigger))
-        fut
-        (future
-          (loop []
-            (try
-              (let [ms (apply to-standard-units (:trigger/period trigger))]
-                (Thread/sleep ms)
-                (let [state (refine-state event trigger)
-                      window-ids (get state (:trigger/window-id trigger))]
-                  (doseq [[window-id state] window-ids]
-                    (let [window (find-window (:onyx.core/windows event) (:trigger/window-id trigger))
-                          win-min (or (:window/min-value window) 0)
-                          w-range (apply to-standard-units (:window/range window))
-                          w-slide (apply to-standard-units (or (:window/slide window) (:window/range window)))
-                          lower (wid/extent-lower win-min w-range w-slide window-id)
-                          upper (wid/extent-upper win-min w-slide window-id)]
-                      (f event window-id lower upper state)))))
-              (catch InterruptedException e
-                (throw e))
-              (catch Throwable e
-                (fatal e)))
-            (recur)))]
-    (assoc-in event [:onyx.triggers/period-threads id] fut)))
+        state (refine-state event trigger)
+        window-ids (get state (:trigger/window-id trigger))]
+    (doseq [[window-id state] window-ids]
+      (let [window (find-window (:onyx.core/windows event) (:trigger/window-id trigger))
+            win-min (or (:window/min-value window) 0)
+            w-range (apply to-standard-units (:window/range window))
+            w-slide (apply to-standard-units (or (:window/slide window) (:window/range window)))
+            lower (wid/extent-lower win-min w-range w-slide window-id)
+            upper (wid/extent-upper win-min w-slide window-id)]
+        (f event window-id lower upper state)))))

 (defmethod trigger-teardown :periodically
   [event trigger id]
@@ -76,9 +86,12 @@
                      #(dissoc % (:trigger/window-id trigger)))))

 (defmethod trigger-setup :default
-  [event _ _]
+  [event trigger id]
   event)

+(defmethod trigger-fire :default
+  [event trigger id invoker])
+
 (defmethod trigger-teardown :default
-  [event _ _]
+  [event trigger id]
   event)


add buf-io metadata. Still missing some buffer stuff  such as scope-buf.

--- src/overtone/sc/ugen/buf_io.clj
+++ src/overtone/sc/ugen/buf_io.clj
@@ -31,18 +31,18 @@
       ;; }

       {:name "TGrains",
-       :args [{:name "numChannels" :mode :num-outs :default 2}
-              {:name "trigger", :default 0}
-              {:name "bufnum", :default 0}
-              {:name "rate", :default 1}
-              {:name "centerPos", :default 0}
-              {:name "dur", :default 0.1}
-              {:name "pan", :default 0.0}
-              {:name "amp", :default 0.1}
-              {:name "interp", :default 4}],
+       :args [{:name "numChannels" :mode :num-outs :default 2 :doc "number of output channels"}
+              {:name "trigger", :default 0 :doc "at each trigger, the following arguments are sampled and used as the arguments of a new grain. A trigger occurs when a signal changes from <= 0 to > 0. If the trigger is audio rate then the grains will start with sample accuracy."}
+              {:name "bufnum", :default 0 :doc "the index of the buffer to use. It must be a one channel (mono) buffer."}
+              {:name "rate", :default 1 :doc "1.0 is normal, 2.0 is one octave up, 0.5 is one octave down -1.0 is backwards normal rate. Unlike PlayBuf, the rate is multiplied by BufRate, so you needn't do that yourself."}
+              {:name "centerPos", :default 0 :doc "the position in the buffer in seconds at which the grain envelope will reach maximum amplitude."}
+              {:name "dur", :default 0.1 :doc "duration of the grain in seconds"}
+              {:name "pan", :default 0.0 :doc "a value from -1 to 1. Determines where to pan the output in the same manner as PanAz."}
+              {:name "amp", :default 0.1 :doc "amplitude of the grain."}
+              {:name "interp", :default 4 :doc "1,2,or 4. Determines whether the grain uses (1) no interpolation, (2) linear interpolation, or (4) cubic interpolation."}],
        :rates #{:ar}
        :check (num-outs-greater-than 1)
-       :doc "sample playback from a buffer with fine control for doing granular synthesis"}
+       :doc "sample playback from a buffer with fine control for doing granular synthesis. Triggers generate grains from a single channel (mono) buffer. Each grain has a Hann envelope (sin^2(x) for x from 0 to pi) and is panned between two channels of multiple outputs."}

       {:name "BufRd",
        :args [{:name "numChannels"    :default 1, :mode :num-outs,
@@ -60,12 +60,12 @@
        :doc "reads the contents of a buffer at a given index."}

       {:name "BufWr",
-       :args [{:name "inputArray", :mode :append-sequence}
-              {:name "bufnum", :default 0}
-              {:name "phase", :default 0.0}
-              {:name "loop", :default 1.0}]
+       :args [{:name "inputArray", :mode :append-sequence :doc "input ugens (channelArray)"}
+              {:name "bufnum", :default 0 :doc "the index of the buffer to use"}
+              {:name "phase", :default 0.0 :doc "modulatable index into the buffer (has to be audio rate)."}
+              {:name "loop", :default 1.0 :doc "1 means true, 0 means false.  This is modulatable"}]
        :check (when-ar (nth-input-ar 1))
-       :doc "writes to a buffer at a given index"}
+       :doc "writes to a buffer at a given index. Note, buf-wr (in difference to buf-rd) does not do multichannel expansion, because input is an array."}

       {:name "RecordBuf",
        :args [{:name "inputArray", :mode :append-sequence}
@@ -77,11 +77,12 @@
               {:name "loop", :default 1.0}
               {:name "trigger", :default 1.0}
               {:name "action", :default 0 :map DONE-ACTIONS}]
-       :doc "record a stream of values into a buffer"}
+       :doc "record a stream of values into a buffer. If recLevel is 1.0 and preLevel is 0.0 then the new input overwrites the old data. If they are both 1.0 then the new data is added to the existing data. (Any other settings are also valid.) Note that the number of channels must be fixed for the SynthDef, it cannot vary depending on which buffer you use."}

       {:name "ScopeOut",
        :args [{:name "inputArray", :mode :append-sequence}
               {:name "bufnum", :default 0.0}],
+       :rates #{:ar}
        :num-outs 0}

       ;; TODO investigate local bufs system, flesh out LocalBuf


defgraft macro to declare a graph transforming pipeline and expose it to plugin.

--- src/tabular/grafter/tabular.clj
+++ src/tabular/grafter/tabular.clj
@@ -601,6 +601,35 @@
         (alter-meta! var# (fn [_#] (merge vmeta# {:pipeline true})))
         var#))))

+(defmacro defgraft
+  "Declares an entry point to a grafter pipeline allowing it to be
+  exposed to the Grafter import service and executed via the leiningen
+  plugin.
+
+  It is effectively equivalent to the following call with additional
+  metadata benefits:
+
+  (def my-graft (comp make-graph my-pipeline))
+
+  It is used with defpipeline to indicate that a transformation also
+  supports conversion into graph data.
+
+  It takes an optional docstring, if no docstring is specified then a
+  default docstring will be generated."
+
+  ([name pipeline graphfn]
+   (let [default-docstring (str "Calls " pipeline " and transforms data into graph data by calling " graphfn)
+         docstring (or (:doc (meta name)) default-docstring)]
+
+     `(defgraft ~name ~docstring ~pipeline ~graphfn)))
+
+  ([name docstring pipeline graphfn]
+   (let [name-with-meta (vary-meta name assoc
+                                   :doc docstring
+                                   :arglists (:arglists (meta pipeline)))]
+
+     `(def ~name-with-meta (comp ~graphfn ~pipeline)))))
+
 (comment
   ;; TODO implement inner join, maybe l/r outer joins too
   (defn join [csv f & others]


re-adding deletion logic. oops.

re-adding deletion logic. oops.

--- src/vignette/util/thumbnail.clj
+++ src/vignette/util/thumbnail.clj
@@ -77,7 +77,10 @@
     (when-let [local-original (original->local original thumb-map)]
       (try+
         (when-let [thumb (original->thumbnail local-original thumb-map)]
-          (ls/create-stored-object thumb))
+          (ls/create-stored-object thumb (fn [stored-object]
+                                           (background-save-thumbnail (store system)
+                                                                      stored-object
+                                                                      thumb-map))))
         (catch Object _ (throw+))
         (finally
           (background-delete-file local-original))))


temp solution for bug in ws259

temp solution for bug in ws259

--- src/wb_es/datomic/data/util.clj
+++ src/wb_es/datomic/data/util.clj
@@ -62,8 +62,9 @@
   ([species-entity bioproject-id]
    (if species-entity
      (if bioproject-id
-         (format "%s (%s)" (:species/id species-entity) (bioprojec-to-strain (d/entity-db species-entity) bioproject-id))
-         (:species/id species-entity)))))
+       ;; (format "%s (%s)" (:species/id species-entity) (bioprojec-to-strain (d/entity-db species-entity) bioproject-id)) ;; broken in ws259
+       (format "%s (%s)" (:species/id species-entity) bioproject-id) ;; temp fix for ws259
+       (:species/id species-entity)))))

 (def format-species-text-memoized (memoize format-species-text))


Improve locking code.

Improve locking code.

--- src/wonko/export/prometheus.clj
+++ src/wonko/export/prometheus.clj
@@ -12,12 +12,18 @@
            java.util.concurrent.locks.ReentrantLock
            java.io.StringWriter))

-;; This contains prometheus created metrics in a map of the form:
-;; {:service {:metric-type {metric-name metric} :registry registry}}
-(defonce created-metrics
+
+(defonce
+  ^{:doc "This contains prometheus created metrics in a map of the form:
+          {:service {:metric-type {metric-name metric} :registry registry}}"}
+  created-metrics
   (atom {}))

-(defonce lock (ReentrantLock.))
+(defonce
+  ^{:doc "Used to regulate access to registry creation.
+          TODO: At some point we might need finer-grained locking,
+                but this seems adequate for now."}
+  lock (Object.))

 (defn get-label-names [properties]
   (sort (keys properties)))
@@ -26,27 +32,21 @@
   (map properties (get-label-names properties)))

 (defn get-or-create-metric [registry {:keys [service metric-name metric-type properties] :as event}]
-  (try
-    (.lock lock)
+  (locking registry
     (let [metric-path [service (keyword metric-type) metric-name]
           label-names (get-label-names properties)]
       (or (get-in @created-metrics metric-path)
           (let [created-metric (create/metric registry (assoc event :label-names label-names))]
             (swap! created-metrics assoc-in metric-path created-metric)
-            created-metric)))
-    (finally
-      (.unlock lock))))
+            created-metric)))))

 (defn get-or-create-registry [service]
-  (try
-    (.lock lock)
+  (locking lock
     (let [registry-path [service :registry]]
       (or (get-in @created-metrics registry-path)
           (let [created-registry (create/registry)]
             (swap! created-metrics assoc-in registry-path created-registry)
-            created-registry)))
-    (finally
-      (.unlock lock))))
+            created-registry)))))

 (defn register-event [{:keys [service metric-value properties] :as event}]
   ;; FIXME: This is a broad fix to make this function thread-safe. We should


try to make code more readable

try to make code more readable

--- frontend/components/forms.cljs
+++ frontend/components/forms.cljs
@@ -61,7 +61,23 @@
   (close! (om/get-state owner [:api-tap]))
   (js/clearTimeout (om/get-state owner [:idle-timer])))

-(defn stateful-button
+(defn wrap-handler
+  "Wraps the on-click handler with a uuid binding to trace the channel passing, and taps
+  the api channel so that we can wait for the api call to finish successfully."
+  [handler owner]
+  (let [api-tap (om/get-state owner [:api-tap])
+        api-mult (om/get-shared owner [:comms :api-mult])]
+    (fn [& args]
+      (append-cycle owner :loading)
+      (let [uuid (utils/uuid)]
+        (binding [frontend.async/*uuid* uuid]
+          (tap-api api-mult api-tap uuid
+                   {:success-fn
+                    #(append-cycle owner :success)
+                    :error-fn
+                    #(append-cycle owner :failed)})
+          (apply handler args))))))
+
 (defn stateful-button*
   "Takes an ordinary input or button hiccup form.
   Disables the button while it waits for the API response to come back.
@@ -85,33 +101,29 @@
         (schedule-idle owner lifecycle)))

     om/IRenderState
-    (render-state [_ {:keys [lifecycle api-tap]}]
-      (let [api-mult (om/get-shared owner [:comms :api-mult])
-            button-state (last lifecycle)
+    (render-state [_ {:keys [lifecycle]}]
+      (let [button-state (last lifecycle)
             [tag attrs & rest] hiccup-form
-            new-value (get attrs (keyword (str "data-" (name button-state) "-text")) (:value attrs))
+            data-field (keyword (str "data-" (name button-state) "-text"))
+            new-value (-> (merge {:data-loading-text "..."
+                                  :data-success-text "Saved"
+                                  :data-failed-text "Failed"}
+                                 attrs)
+                          (get data-field (:value attrs)))
             new-body (cond (= :idle button-state) rest
                            (:data-spinner attrs) common/spinner
                            :else new-value)
             new-attrs (-> attrs
-                          ;; disable the button when it's not idl
+                          ;; Disable the button when it's not idle
+                          ;; We're changing the value of the button, so its safer not to let
+                          ;; people click on it.
                           (assoc :disabled (not= :idle button-state))
                           (update-in [:class] (fn [c] (cond (= :idle button-state) c
                                                             (string? c) (str c  " disabled")
                                                             (coll? c) (conj c "disabled")
                                                             :else "disabled")))
                           ;; Update the on-click handler to watch the api channel for success
-                          (update-in [:on-click] (fn [f]
-                                                   (fn [& args]
-                                                     (append-cycle owner :loading)
-                                                     (let [uuid (utils/uuid)]
-                                                       (binding [frontend.async/*uuid* uuid]
-                                                         (tap-api api-mult api-tap uuid
-                                                                  {:success-fn
-                                                                   #(append-cycle owner :success)
-                                                                   :error-fn
-                                                                   #(append-cycle owner :failed)})
-                                                         (apply f args))))))
+                          (update-in [:on-click] wrap-handler owner)
                           (update-in [:value] (fn [v]
                                                 (or new-value v))))]
         (html


Sketch the notes. There's an issue with redrawing.

--- src/leipzig_live/views.cljs
+++ src/leipzig_live/views.cljs
@@ -5,29 +5,25 @@
     [quil.middleware :as middleware]
     [reagent.core :as reagent]))

-(quil/defsketch sketch
-  :setup (constantly [{:time 0 :pitch 440}
-                      {:time 1 :pitch 660}
-                      {:time 2 :pitch 880}
-                      {:time 3 :pitch 660}
-                      {:time 4 :pitch 440}])
-  :draw (fn [state]
-          (quil/background 255)
-          (doseq [{:keys [time pitch]} state]
-            (quil/ellipse
-              (-> time (* 100) (+ 17))
-              (-> pitch - (* 0.25) (+ 300))
-              30
-              30)))
-  :host "graph"
-  :no-start true
-  :middleware [middleware/fun-mode]
-  :size [600 300])
+(defn draw-graph [{:keys [music]}]
+  (quil/sketch :setup (constantly music)
+               :draw (fn [state]
+                       (quil/background 255)
+                       (doseq [{:keys [time pitch]} state]
+                         (quil/ellipse
+                           (-> time (* 100) (+ 17))
+                           (-> pitch - (* 0.25) (+ 300))
+                           30
+                           30)))
+               :host "graph"
+               :no-start true
+               :middleware [middleware/fun-mode]
+               :size [600 300]))

 (defn graph [handle! state]
   (reagent/create-class
     {:render (fn [] [:canvas#graph {:width 300 :height 300}])
-     :component-did-mount sketch}))
+     :component-did-update #(draw-graph state)}))

 (defn editor-did-mount [handle! _]
   (fn [this]


Use an atom to keep the graph up-to-date. Might be nice if there's another way to propagate state.

--- src/leipzig_live/views.cljs
+++ src/leipzig_live/views.cljs
@@ -5,11 +5,11 @@
     [quil.middleware :as middleware]
     [reagent.core :as reagent]))

-(defn draw-graph [{:keys [music]}]
-  (quil/sketch :setup (constantly music)
-               :draw (fn [state]
+(defn draw-graph [state-atom]
+  (quil/sketch :setup (constantly nil)
+               :draw (fn [_]
                        (quil/background 255)
-                       (doseq [{:keys [time pitch]} state]
+                       (doseq [{:keys [time pitch]} (:music @state-atom)]
                          (quil/ellipse
                            (-> time (* 100) (+ 17))
                            (-> pitch - (* 0.25) (+ 300))
@@ -20,10 +20,10 @@
                :middleware [middleware/fun-mode]
                :size [600 300]))

-(defn graph [handle! state]
+(defn graph [handle! state-atom]
   (reagent/create-class
     {:render (fn [] [:canvas#graph {:width 300 :height 300}])
-     :component-did-update #(draw-graph state)}))
+     :component-did-mount #(draw-graph state-atom)}))

 (defn editor-did-mount [handle! _]
   (fn [this]
@@ -46,6 +46,6 @@
                  [:button {:on-click #(handle! (action/->Stop))} "Stop"])
         error (:error state)]
     [:div
-     [:div {:class "graph"} [graph handle! state]]
+     [:div {:class "graph"} [graph handle! state-atom]]
      [:div {:class "controls"} button]
      [:div {:class (if error "error" "")} [editor handle! state]]]))


nil punning

nil punning

--- s3/src/s3/blog.clj
+++ s3/src/s3/blog.clj
@@ -2,7 +2,7 @@
   (:use
         [s3 log mongodb parser formats utils])
   (:require [monger.collection :as mc]
-            [s3.mongoquery :as filter]
+            [s3.mongoquery :as querystr]
             [monger.result :as mr]
             [monger.query :as mq]
             [monger.conversion]
@@ -16,14 +16,12 @@
 (use-logging)

 (defn _id-to-id [mongo-object]
-  (if (nil? mongo-object)
-    nil
+  (when mongo-object
     (let [id (str (:_id mongo-object))]
       (-> mongo-object (dissoc :_id) (assoc :id id)))))

 (defn id-to-sid [mongo-object]
-  (if (nil? mongo-object)
-    nil
+  (when mongo-object
     (-> mongo-object (assoc :sid (:id mongo-object)))))

 (defn own? [user dbo]
@@ -128,7 +126,8 @@
       (error "Db object deleted or not own. Refusing to update: " user params id))))

 (defn generate-publication-date [blog]
-  (assoc blog :published (local/local-now)))
+  (when blog
+    (assoc blog :published (local/local-now))))

 (defn publish [user params]
   (let [id (:id params)
@@ -164,12 +163,12 @@

 (defn list-by [user params]
   (let [page (parse-int (params :page "1"))
-        rules (merge (filter/make-query-from params) {:draft false})
-        sort-order (filter/sort-results-by params)]
+        rules (merge (querystr/make-query-from params) {:draft false})
+        sort-order (querystr/sort-results-by params)]
     (list-result user page rules sort-order)))

 (defn list-drafts [user params]
   (let [page (parse-int (params :page "1"))
         rules {:user user :draft true}
-        sort-order (filter/sort-results-by params)]
+        sort-order (querystr/sort-results-by params)]
     (list-result user page rules sort-order)))


added series label in add conference form

--- src/cljs/conference_rating/add_conference_page/add_conference_page.cljs
+++ src/cljs/conference_rating/add_conference_page/add_conference_page.cljs
@@ -42,7 +42,7 @@

 (defn conference-form-template [data-atom]
   [:div
-   [(conference-series-component data-atom)]
+   (form-input "Series" [(conference-series-component data-atom)])
    (form-input "Name" [:input {:field :text :id :name :class "form-control" :placeholder "Name of the conference"}])
    [:div {:class "row"}
     [:div {:class "col-md-6"} (form-input "From" [:div {:field :datepicker :id :from-date :date-format "yyyy/mm/dd" :inline false :auto-close? true}])]


CMR-4336 (#221)

CMR-4336 (#221)

* CMR-4336 fixes tests not running correctly, recomments out tests that shouldn't have been uncommented

* CMR-4336 addresses pr comments

--- system-int-test/test/cmr/system_int_test/bootstrap/bulk_index_test.clj
+++ system-int-test/test/cmr/system_int_test/bootstrap/bulk_index_test.clj
@@ -25,8 +25,10 @@
     [cmr.transmit.config :as tc]
     [cmr.umm.echo10.echo10-core :as echo10]))

-(use-fixtures :each (join-fixtures
-                      [(ingest/reset-fixture {"provguid1" "PROV1"}) {:grant-all-access-control? false}]))
+(use-fixtures :each (join-fixtures [(ingest/reset-fixture {"provguid1" "PROV1"} {:grant-all-ingest? true
+                                                                                :grant-all-search? true
+                                                                                :grant-all-access-control? false})
+                                    tags/grant-all-tag-fixture]))

 (defn- save-collection
   "Saves a collection concept"
@@ -156,8 +158,14 @@
   (s/only-with-real-database
    ;; Disable message publishing so items are not indexed as part of the initial save.
    (dev-sys-util/eval-in-dev-sys `(cmr.metadata-db.config/set-publish-messages! false))
-   (let [
-         acl1 (save-acl 1
+
+   ;; Remove fixture ACLs
+   (let [response (ac/search-for-acls (u/conn-context) {} {:token (tc/echo-system-token)})
+         items (:items response)]
+     (doseq [acl items]
+       (e/ungrant (s/context) (:concept_id acl))))
+
+   (let [acl1 (save-acl 1
                         {:extra-fields {:acl-identity "system:token"
                                         :target-provider-id "PROV1"}}
                         "TOKEN")
@@ -189,7 +197,7 @@
        (search-results-match? items [acl1 acl2]))

      ;; Groups
-     (let [response (ac/search-for-groups (u/conn-context) {})
+     (let [response (ac/search-for-groups (u/conn-context) {:token (tc/echo-system-token)})
            ;; Need to filter out admin group created by fixture
            items (filter #(not (= "mock-admin-group-guid" (:legacy_guid %))) (:items response))]
        (search-results-match? items [group1 group3]))
@@ -233,8 +241,9 @@
       (bootstrap/bulk-index-concepts "PROV1" :collection colls)
       (bootstrap/bulk-index-concepts "PROV1" :granule [(:concept-id gran2)])
       (bootstrap/bulk-index-concepts "PROV1" :tag [(:concept-id tag1)])
-      (bootstrap/bulk-index-concepts "CMR" :access-group [(:concept-id group2)])
-      (bootstrap/bulk-index-concepts "CMR" :acl [(:concept-id acl2)])
+      ;; Commented out until ACLs and groups are supported in the index by concept-id API
+      ; (bootstrap/bulk-index-concepts "CMR" :access-group [(:concept-id group2)])
+      ; (bootstrap/bulk-index-concepts "CMR" :acl [(:concept-id acl2)])

       (index/wait-until-indexed)

@@ -250,15 +259,15 @@
           :granule [gran2])

         ; ;; ACLs
-        (let [response (ac/search-for-acls (u/conn-context) {} {:token (tc/echo-system-token)})
-              items (:items response)]
-          (search-results-match? items [acl2]))
+        ; (let [response (ac/search-for-acls (u/conn-context) {} {:token (tc/echo-system-token)})
+        ;       items (:items response)]
+        ;   (search-results-match? items [acl2]))

         ;; Groups
-        (let [response (ac/search-for-groups (u/conn-context) {})
-              ;; Need to filter out admin group created by fixture
-              items (filter #(not (= "mock-admin-group-guid" (:legacy_guid %))) (:items response))]
-          (search-results-match? items [group2]))
+        ; (let [response (ac/search-for-groups (u/conn-context) {})
+        ;       ;; Need to filter out admin group created by fixture
+        ;       items (filter #(not (= "mock-admin-group-guid" (:legacy_guid %))) (:items response))]
+        ;   (search-results-match? items [group2]))

         (are3 [expected-tags]
           (let [result-tags (update
@@ -306,15 +315,16 @@
       (bootstrap/bulk-delete-concepts "PROV1" :collection (map :concept-id [coll1]))
       (bootstrap/bulk-delete-concepts "PROV1" :granule (map :concept-id [gran1 gran3 gran4]))
       (bootstrap/bulk-delete-concepts "PROV1" :tag [(:concept-id tag1)])
-      (bootstrap/bulk-index-concepts "CMR" :access-group [(:concept-id group2)])
-      (bootstrap/bulk-index-concepts "CMR" :acl [(:concept-id acl2)])
+      ;; Commented out until ACLs and groups are supported in the index by concept-id API
+      ; (bootstrap/bulk-index-concepts "CMR" :access-group [(:concept-id group2)])
+      ; (bootstrap/bulk-index-concepts "CMR" :acl [(:concept-id acl2)])

       (index/wait-until-indexed)

       (testing "Concepts are deleted"
         ;; Collections and granules
         (are3 [concept-type expected]
-          (d/refs-match? expected (search/find-refs concept-type {}))
+          (d/refs-match? expected (search/find-refs concept-type {:token (tc/echo-system-token)}))

           "Collections"
           :collection [coll2 coll3]
@@ -337,6 +347,13 @@
   (s/only-with-real-database
     ;; Disable message publishing so items are not indexed.
     (dev-sys-util/eval-in-dev-sys `(cmr.metadata-db.config/set-publish-messages! false))
+
+    ;; Remove fixture ACLs
+    (let [response (ac/search-for-acls (u/conn-context) {} {:token (tc/echo-system-token)})
+          items (:items response)]
+      (doseq [acl items]
+        (e/ungrant (s/context) (:concept_id acl))))
+
     (let [;; saved but not indexed
           coll1 (save-collection 1)
           coll2 (save-collection 2 {:revision-date "3016-01-01T10:00:00Z"})
@@ -362,7 +379,7 @@

       (testing "Only concepts after date are indexed."
         (are3 [concept-type expected]
-          (d/refs-match? expected (search/find-refs concept-type {}))
+          (d/refs-match? expected (search/find-refs concept-type {:token (tc/echo-system-token)}))

           "Collections"
           :collection [coll2]
@@ -376,7 +393,7 @@
           (search-results-match? items [acl2]))

         ;; Groups
-        (let [response (ac/search-for-groups (u/conn-context) {})
+        (let [response (ac/search-for-groups (u/conn-context) {:token (tc/echo-system-token)})
               ;; Need to filter out admin group created by fixture
               items (filter #(not (= "mock-admin-group-guid" (:legacy_guid %))) (:items response))]
           (search-results-match? items [group2]))


Assume assetDirectory and outputDirectory are passed in as File

--- src/main/resources/com/semperos/screwdriver/clojure/screwdriver_api.clj
+++ src/main/resources/com/semperos/screwdriver/clojure/screwdriver_api.clj
@@ -48,9 +48,9 @@
     (nn debug-mode
         (.setDebugMode c __))
     (nn asset-directory
-        (.setAssetDirectory c (File. __)))
+        (.setAssetDirectory c __))
     (nn output-directory
-        (.setOutputDirectory c (File. __)))
+        (.setOutputDirectory c __))
     (nn js-sub-directory-name
         (.setJsSubDirectoryName c __))
     (nn css-sub-directory-name


some cleanup

some cleanup

--- test/acceptance/push_prison.clj
+++ test/acceptance/push_prison.clj
@@ -23,7 +23,7 @@
   (-> (make-everything-interpreter
         :config {:step-limit 20000
                  :lenient true
-                 :max-collection-size 32768}
+                 :max-collection-size 131072}
         :bindings (:bindings prisoner)
         :program (:program prisoner))
       reset-interpreter))
@@ -52,15 +52,15 @@
           (if (is-done? s)
             (println "DONE")
             (recur (do
-              (println (str "\n>>> " (:counter s)
-                            "\nstacks (pts): " (fix/count-collection-points (:stacks s))
-                            "\nbindings (pts): " (fix/count-collection-points (:bindings s))
-                            "\nall items in :log (sum of chars): "
-                            (apply (juxt max +')
-                              (into '(0)
-                                (map
-                                  #(count (str (:item %)))
-                                  (u/get-stack s :log))))
+              (println (str ">>> " (:counter s)
+                            ; "\nstacks (pts): " (fix/count-collection-points (:stacks s))
+                            ; "\nbindings (pts): " (fix/count-collection-points (:bindings s))
+                            ; "\nall items in :log (sum of chars): "
+                            ; (apply (juxt max +')
+                            ;   (into '(0)
+                            ;     (map
+                            ;       #(count (str (:item %)))
+                            ;       (u/get-stack s :log))))
                             ; "\n items on :exec " (u/get-stack s :exec)
                             ; "\n>>> ATTEMPTING " (pr-str (first (u/get-stack s :exec)))
                             ; "\n items on :OUTPUT " (get-in s [:bindings :OUTPUT] '())
@@ -86,12 +86,17 @@
    'push.type.definitions.quoted.QuotedCode map->QuotedCode
     })

+(def prisoner-names
+  (file-seq (clojure.java.io/file "test/acceptance/prisoners")))
+
+
 (def prisoners
   [
-    (edn/read-string {:readers edn-readers}
-                     (slurp "test/acceptance/prisoners/e445321c-22bf-45b2-acce-3aac6acffe61.txt"))
+    ; (edn/read-string {:readers edn-readers}
+    ;                  (slurp "test/acceptance/prisoners/0d18a279-1a6b-4585-b239-3c9c927d2023.txt"))
+    ; (edn/read-string {:readers edn-readers}
+    ;                  (slurp  "test/acceptance/prisoners/e445321c-22bf-45b2-acce-3aac6acffe61.txt"))
   ])
-

 (fact "no exceptions are raised when I step through any of these problematic programs"
   :debug :acceptance


Prototype of stream lazy seq by ams-clj.

--- test/async/http/client/test.clj
+++ test/async/http/client/test.clj
@@ -242,7 +242,7 @@

 (deftest test-stream
   (let [stream (ref #{})
-        consume-stream (fn [state bytes]
+        consume-stream (fn [_ bytes]
                          (if (not (empty? bytes))
                            (let [s (apply str (map char bytes))]
                              (dosync (alter stream conj s)))
@@ -256,3 +256,35 @@
     (doseq [s @stream]
       (let [part s]
         (is (contains? #{"part1" "part2"} part))))))
+
+(require 'clojure.contrib.json)
+(deftest test-stream-proto
+  (let [stream-queue (java.util.concurrent.LinkedBlockingQueue. 10)
+        stream-seq ((fn thisfn []
+                      (lazy-seq
+                       (let [v (.take stream-queue)]
+                         ;(println "took: " v)
+                         (when-not (= ::done v)
+                           (cons
+                            v
+                            (thisfn)))))))
+        create-lazy-seq (fn [state bytes]
+                          (if (not (empty? bytes))
+                           (let [v (apply str (map char bytes))]
+                             ;(println "putting: " v)
+                             (.put stream-queue v))))
+        lazy-seq-completed (fn [state]
+                             (println "putting: nil")
+                             (.put stream-queue ::done))
+        resp (execute-request
+              (prepare-request :get "http://stream.twitter.com/1/statuses/sample.json"
+                               {:headers {:authorization "Basic YWhjY2xqOmFoY2NsajEx"}})
+              {:status status-collect
+               :headers headers-collect
+               :part create-lazy-seq
+               :completed lazy-seq-completed
+               :error error-collect})]
+    (doseq [s (take 2 stream-seq)] (println (select-keys (clojure.contrib.json/read-json s) [:text :screen_name])))
+    (is (= "part1" (first stream-seq)))
+    (is (= "part2" (nth stream-seq 1)))
+    (is (= nil (nnext stream-seq)))))


[cleanup]

[cleanup]

--- src/og/clj_dstream/core.clj
+++ src/og/clj_dstream/core.clj
@@ -8,7 +8,6 @@
              :refer [log trace debug info warn error fatal]]
             [taoensso.tufte :as tufte :refer (defnp p profiled profile)]))

-;;TODO remove as sporadic needs to compute if char vec is sporadic, nothing does that ATM
 ;;TODO remove log-it and use real logging with contexts
 ;;TODO initial clustering never goes more than 2 iterations, could there be a bug in state exchanges?
 ;;TODO remove concept of 'NO_CLASS', as that is an impl detail from ref paper
@@ -95,17 +94,9 @@
   (->>
     pos-idx
     (map-indexed (fn [idx pos-idx]
-
-                   (let [{:keys [::domain-start ::domain-end ::domain-interval]} (get phase-space idx)
-                         ]
-
-                     (+ domain-start (* pos-idx domain-interval))
-
-                     )
-
-                   )))
-
-  )
+                   (let [{:keys [::domain-start ::domain-end ::domain-interval]} (get phase-space idx)]
+                     (+ domain-start (* pos-idx domain-interval)))))
+    vec))

 (defn position-value->position-index [{:keys [::position-value ::phase-space]}]
   (when-not (= (count position-value) (count phase-space))


Test all working paths with static-handlers

--- test/cljc/reitit/ring_test.cljc
+++ test/cljc/reitit/ring_test.cljc
@@ -284,7 +284,7 @@
                               (ring/create-resource-handler {:path "/files"})
                               (ring/create-resource-handler {:path "/"})
                               (ring/create-default-handler)))]]
-             prefix ["/" "/files"]
+             prefix ["" "/" "/files" "/files/"]
              :let [request (fn [uri] {:uri (str prefix uri), :request-method :get})]]

        (testing test
@@ -302,6 +302,10 @@
            (let [response (app (request "/docs"))]
              (is (= "text/html" (get-in response [:headers "Content-Type"])))
              (is (get-in response [:headers "Last-Modified"]))
+             (is (= "
hello
\n" (slurp (:body response)))))
+           (let [response (app (request "/docs/"))]
+             (is (= "text/html" (get-in response [:headers "Content-Type"])))
+             (is (get-in response [:headers "Last-Modified"]))
              (is (= "
hello
\n" (slurp (:body response))))))

          (testing "not found"


slight adjustment to docs in test/walk.clj

--- test/forma/matrix/test/walk.clj
+++ test/forma/matrix/test/walk.clj
@@ -6,7 +6,7 @@
                 (range j (+ j 5))))

 (fact
- "the `windowed-function` retains the number of elements of the original matrix"
+ "`windowed-function` retains the number of elements of the original matrix"
  (count (windowed-function + 1 test-mat)) => (count (flatten test-mat)))


make sure we really started waiting in test to avoid race conditions

--- test/lambdacd_git/core_test.clj
+++ test/lambdacd_git/core_test.clj
@@ -144,6 +144,7 @@
                     (git-commit "initial commit")
                     (git-checkout-b "some-branch")
                     (start-wait-for-git-step-with-ref (fn [ref] (.endsWith ref "some-branch")))
+                    (wait-a-bit)
                     (git-commit "other commit")
                     (get-step-result))]
       (is (= :success (:status (step-result state))))


test for get shelf books

test for get shelf books

--- test/shelver/goodreads_test.clj
+++ test/shelver/goodreads_test.clj
@@ -133,8 +133,81 @@
             (is (= expected-id (-> shelf zip/xml-zip zip/down zip/node :content first)))))))))

 (deftest test-get-shelf-books
+  ;<?xml version="1.0" encoding="UTF-8"?>
+  ;<GoodreadsResponse>
+  ;   <Request>
+  ;      <authentication>true</authentication>
+  ;      <key><![CDATA[EV7wnkrFg211dYRJNf8bg]]></key>
+  ;      <method><![CDATA[review_list]]></method>
+  ;   </Request>
+  ;   <reviews start="1" end="1" total="1">
+  ;      <review>
+  ;         <id>1263549541</id>
+  ;         <book>
+  ;            <id type="integer">10281630</id>
+  ;            <isbn nil="true" />
+  ;            <isbn13 nil="true" />
+  ;            <text_reviews_count type="integer">0</text_reviews_count>
+  ;            <title>Clojure in Small Pieces</title>
+  ;            <image_url>https://s.gr-assets.com/assets/nophoto/book/111x148-bcc042a9c91a29c1d680899eff700a03.png</image_url>
+  ;            <small_image_url>https://s.gr-assets.com/assets/nophoto/book/50x75-a91bf249278a81aabab721ef782c4a74.png</small_image_url>
+  ;            <large_image_url />
+  ;            <link>https://www.goodreads.com/book/show/10281630-clojure-in-small-pieces</link>
+  ;            <num_pages />
+  ;            <format />
+  ;            <edition_information />
+  ;            <publisher />
+  ;            <publication_day />
+  ;            <publication_year />
+  ;            <publication_month />
+  ;            <average_rating>5.00</average_rating>
+  ;            <ratings_count>1</ratings_count>
+  ;            <description>A literate programming port of the source for Clojure.</description>
+  ;            <authors>
+  ;               <author>
+  ;                  <id>7145075</id>
+  ;                  <name>Rich Hickey</name>
+  ;                  <role />
+  ;                  <image_url><![CDATA[https://s.gr-assets.com/assets/nophoto/user/u_200x266-e183445fd1a1b5cc7075bb1cf7043306.png]]></image_url>
+  ;                  <small_image_url><![CDATA[https://s.gr-assets.com/assets/nophoto/user/u_50x66-632230dc9882b4352d753eedf9396530.png]]></small_image_url>
+  ;                  <link><![CDATA[https://www.goodreads.com/author/show/7145075.Rich_Hickey]]></link>
+  ;                  <average_rating>5.00</average_rating>
+  ;                  <ratings_count>1</ratings_count>
+  ;                  <text_reviews_count>0</text_reviews_count>
+  ;               </author>
+  ;            </authors>
+  ;            <published />
+  ;         </book>
+  ;         <rating>0</rating>
+  ;         <votes>0</votes>
+  ;         <spoiler_flag>false</spoiler_flag>
+  ;         <spoilers_state>none</spoilers_state>
+  ;         <shelves>
+  ;            <shelf name="to-read" exclusive="true" review_shelf_id="969361495" sortable="true" />
+  ;         </shelves>
+  ;         <recommended_for />
+  ;         <recommended_by />
+  ;         <started_at />
+  ;         <read_at />
+  ;         <date_added>Fri Apr 24 19:24:43 -0700 2015</date_added>
+  ;         <date_updated>Fri Apr 24 19:24:44 -0700 2015</date_updated>
+  ;         <read_count />
+  ;         <body />
+  ;         <comments_count>0</comments_count>
+  ;         <url><![CDATA[https://www.goodreads.com/review/show/1263549541]]></url>
+  ;         <link><![CDATA[https://www.goodreads.com/review/show/1263549541]]></link>
+  ;         <owned>0</owned>
+  ;      </review>
+  ;   </reviews>
+  ;</GoodreadsResponse>
   (testing "testing get shelf books"
     (let [goodreads-client (gr/new-goodreads-client (default-oauth-client) (env :goodreads-access-token) nil)]
       (testing "simple request"
-        (let [resp (gr/get-shelf-books goodreads-client "to-read")]
-          (println resp))))))
+        (let [resp (gr/get-shelf-books goodreads-client "to-read")
+              expected "Clojure in Small Pieces"
+              expected-id "10281630"
+              book (-> resp
+                       :parsed
+                       zip/xml-zip
+                       (zx/xml1-> :reviews :review :book [:title expected]))]
+          (is (= expected-id (-> book zip/down zip/node :content first))))))))


adding integration facts

adding integration facts

--- test/celestial/features/kvm.clj
+++ test/celestial/features/kvm.clj
@@ -22,17 +22,15 @@
           (just {
             :user "celestial" :name "red1.local"
             :image {:flavor :debian :template "/home/ronen/images/ubuntu-1504-server.img"}
-           })))
+            :cpu 2 :ram 1024
+           })))))

-    #_(fact "legal instance gce" :kvm
-      (:gce (vconstruct redis-gce)) =>
-         (contains {
-           :name "red1"
-           :machineType machine-type
-           :disks [{
-              :initializeParams {:sourceImage source-image} :autoDelete true
-              :type "PERSISTENT" :boot true
-            }]
-          })
-
-         )))
+(with-admin
+  (with-conf local-conf
+    (with-state-changes [(before :facts (populate-system redis-type redis-kvm))]
+      (fact "kvm creation workflows" :integration :kvm :workflow
+           (wf/create (spec)) => nil
+          ;; (wf/stop (spec)) => nil
+          ;; (wf/start (spec)) => nil
+          ;; (wf/destroy (spec)) => nil
+          ))))


reify is cleaner than proxy

reify is cleaner than proxy

--- modules/messaging/src/main/clojure/immutant/messaging.clj
+++ modules/messaging/src/main/clojure/immutant/messaging.clj
@@ -84,8 +84,8 @@
               destination (destination session dest-name)
               consumer (.createConsumer session destination selector)]
           (.setMessageListener consumer
-                               (proxy [javax.jms.MessageListener] []
-                                 (onMessage [message]
+                               (reify javax.jms.MessageListener
+                                 (onMessage [_ message]
                                    (binding [*connection* connection
                                              *sessions* {}]
                                      (tx/requires-new


Add string-latch test for repl no-prompt scenario.

--- test/cli4clj/test/cli_tests.clj
+++ test/cli4clj/test/cli_tests.clj
@@ -211,3 +211,18 @@
         out (cli-tests/test-cli-stdout #(clojure.main/repl :prompt str) in-cmds)]
     (test/is (= (cli-tests/expected-string ["#'user/x" "22" "21" "nil"]) out))))

+(test/deftest clojure-repl-stdout-let-inc-println-no-prompt-string-latch-test
+  (let [in-cmds ["(def x 21)" "(inc x)" "(println x)"]
+        val-0 (atom nil)
+        val-1 (atom nil)
+        val-2 (atom nil)
+        sl (cli-tests/string-latch [["#'user/x" #(reset! val-0 %)]
+                                    ["22" #(reset! val-1 %)]
+                                    ["21" #(reset! val-2 %)]
+                                    "nil"])
+        out (cli-tests/test-cli-stdout #(clojure.main/repl :prompt str) in-cmds sl)]
+    (test/is (= ["#'user/x"] @val-0))
+    (test/is (= ["#'user/x" "\n" "22"] @val-1))
+    (test/is (= ["#'user/x" "\n" "22" "\n" "21"] @val-2))
+    (test/is (= (cli-tests/expected-string ["#'user/x" "22" "21" "nil"]) out))))
+


Refactor powertree_tests for inserts

Refactor powertree_tests for inserts

--- test/gigrig/powertree_test.cljs
+++ test/gigrig/powertree_test.cljs
@@ -32,6 +32,9 @@
   ([from to] (for [i (range from (inc to))]
                (isolator-pedal i))))

+(defn insert-times [base x]
+  (reduce #(ptree/insert %1 [:pedal (str "pedal" %2)]) base (range 1 (inc x))))
+
 (defn timelord-pedal [n]
   {:brand "X"
    :model (str "pedal" n)
@@ -56,36 +59,23 @@
     (is (eql-zip [:distributor [[:pedal "pedal1"]] nil]
                  (ptree/insert root [:pedal "pedal1"])))
     (is (eql-zip [:distributor [[:pedal "pedal1"] [:pedal "pedal2"] [:pedal "pedal3"] [:pedal "pedal4"] [:pedal "pedal5"] [:pedal "pedal6"]] nil]
-                 (-> root
-                     (ptree/insert [:pedal "pedal1"])
-                     (ptree/insert [:pedal "pedal2"])
-                     (ptree/insert [:pedal "pedal3"])
-                     (ptree/insert [:pedal "pedal4"])
-                     (ptree/insert [:pedal "pedal5"])
-                     (ptree/insert [:pedal "pedal6"]))))
+                 (insert-times root 6)))
     (is (eql-zip [:distributor [[:pedal "pedal1"] [:pedal "pedal2"] [:pedal "pedal3"] [:pedal "pedal4"] [:pedal "pedal5"] [:distributor [[:pedal "pedal6"] [:pedal "pedal7"]] nil]] nil]
-                 (-> root
-                     (ptree/insert [:pedal "pedal1"])
-                     (ptree/insert [:pedal "pedal2"])
-                     (ptree/insert [:pedal "pedal3"])
-                     (ptree/insert [:pedal "pedal4"])
-                     (ptree/insert [:pedal "pedal5"])
-                     (ptree/insert [:pedal "pedal6"])
-                     (ptree/insert [:pedal "pedal7"]))))
-    (is (= [:distributor [[:pedal "pedal1"]
-                          [:pedal "pedal2"]
-                          [:pedal "pedal3"]
-                          [:pedal "pedal4"]
-                          [:pedal "pedal5"]
-                          [:distributor [[:pedal "pedal6"]
-                                         [:pedal "pedal7"]
-                                         [:pedal "pedal8"]
-                                         [:pedal "pedal9"]
-                                         [:pedal "pedal10"]
-                                         [:distributor [[:pedal "pedal11"] [:pedal "pedal12"]] nil]]
-                           nil]]
-            nil]
-           (zip/root (ptree/insert (ptree/build (distributor-pedals 11)) [:pedal "pedal12"]))))
+                 (insert-times root 7)))
+    (is (eql-zip [:distributor [[:pedal "pedal1"]
+                                [:pedal "pedal2"]
+                                [:pedal "pedal3"]
+                                [:pedal "pedal4"]
+                                [:pedal "pedal5"]
+                                [:distributor [[:pedal "pedal6"]
+                                               [:pedal "pedal7"]
+                                               [:pedal "pedal8"]
+                                               [:pedal "pedal9"]
+                                               [:pedal "pedal10"]
+                                               [:distributor [[:pedal "pedal11"] [:pedal "pedal12"]] nil]]
+                                 nil]]
+                  nil]
+                 (insert-times root 12)))
     (is (eql-zip [:distributor [[:pedal "pedal1"] [:isolator [:pedal "pedal2"]]] nil]
                  (-> root
                      (ptree/insert [:pedal "pedal1"])


Fix broken test

Fix broken test

--- test/integration/test/cache.clj
+++ test/integration/test/cache.clj
@@ -76,7 +76,7 @@

   (testing "it runs cleaning operations as part of the worker cycle"
     (let [cleanups (atom 0)
-          cache (c/create-query-cache "query_cache" (fn [_] (swap! cleanups inc)))
+          cache (c/create-query-cache "query_cache" (fn [_] (swap! cleanups inc) []))
           worker (c/create-worker cache)]
       (run-all-jobs worker)
       (does= @cleanups 1))))


Minor stylistic changes

Minor stylistic changes

--- test/atomix_jepsen/testing.clj
+++ test/atomix_jepsen/testing.clj
@@ -4,11 +4,13 @@
             [atomix-jepsen.core :as core]
             [jepsen.core :as jepsen]
             [clojure.set :as set])
-  (:import (java.util.concurrent TimeUnit Executors)))
+  (:import (java.util.concurrent TimeUnit Executors)
+           (java.util Arrays)
+           (java.lang.management ManagementFactory)))

 (defn dump-threads []
-  (println (java.util.Arrays/toString (.dumpAllThreads
-                                        (java.lang.management.ManagementFactory/getThreadMXBean) false false))))
+  (println (Arrays/toString (.dumpAllThreads
+                              (ManagementFactory/getThreadMXBean) false false))))

 ;(.scheduleAtFixedRate (Executors/newSingleThreadScheduledExecutor) dump-threads 0 5 TimeUnit/SECONDS)


Clean up unnecessary tests

Clean up unnecessary tests

--- test/beehive/patterns_test.clj
+++ test/beehive/patterns_test.clj
@@ -17,7 +17,8 @@
   (:require [beehive.core :as beehive]
             [beehive.service :as service]
             [beehive.patterns :as patterns])
-  (:import (java.util.concurrent CountDownLatch)))
+  (:import (java.util.concurrent CountDownLatch)
+           (java.util.concurrent.atomic AtomicInteger)))

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

@@ -26,9 +27,9 @@
 (def service3 nil)

 (defn- start-and-stop [f]
-  (alter-var-root #'service1 (fn [_] (beehive/service "1" 1 1)))
-  (alter-var-root #'service2 (fn [_] (beehive/service "2" 1 1)))
-  (alter-var-root #'service3 (fn [_] (beehive/service "3" 1 1)))
+  (alter-var-root #'service1 (fn [_] (beehive/service "1" 2 1)))
+  (alter-var-root #'service2 (fn [_] (beehive/service "2" 2 1)))
+  (alter-var-root #'service3 (fn [_] (beehive/service "3" 2 1)))
   (f)
   (service/shutdown service1)
   (service/shutdown service2)
@@ -87,38 +88,28 @@

 (deftest shotgun
   (let [shotgun (patterns/shotgun {service1 {} service2 {} service3 {}} 2)
+        all-done (atom (CountDownLatch. 2))
         action-blocking-latch (atom (CountDownLatch. 1))
         test-blocking-latch (atom (CountDownLatch. 1))
-        counter (atom 0)
-        inc-fn (fn [current]
-                 (if (= 1 current)
-                   (do (.await ^CountDownLatch @action-blocking-latch)
-                       (inc current))
-                   (inc current)))
-        action-fn (fn [_] (let [result (swap! counter inc-fn)]
-                            (when (= result 2)
+        counter (AtomicInteger. 0)
+        action-fn (fn [_] (let [result (.incrementAndGet counter)]
+                            (if (= 1 result)
+                              (.await ^CountDownLatch @action-blocking-latch)
                               (.countDown ^CountDownLatch @test-blocking-latch))
+                            (.countDown ^CountDownLatch @all-done)
                             result))]
     (testing "Actions submitted to multiple services"
-      (reset! counter 0)
+      (.set counter 0)
+      (reset! all-done (CountDownLatch. 2))
       (reset! action-blocking-latch (CountDownLatch. 1))
       (reset! test-blocking-latch (CountDownLatch. 1))
-      (is (= 1 @(patterns/submit-action shotgun action-fn Long/MAX_VALUE)))
+      (is (= 2 @(patterns/submit-action shotgun action-fn Long/MAX_VALUE)))
       (.countDown ^CountDownLatch @action-blocking-latch)
       (.await ^CountDownLatch @test-blocking-latch)
-      (is (= 2 @counter)))
-    (testing "Result is from the the first services to response"
-      (reset! counter 0)
-      (reset! action-blocking-latch (CountDownLatch. 1))
-      (reset! test-blocking-latch (CountDownLatch. 1))
-      (let [f (patterns/submit-action shotgun action-fn Long/MAX_VALUE)]
-        @f
-        (.countDown ^CountDownLatch @action-blocking-latch)
-        ;; TODO: Need to rework to avoid occasional race condition
-        (.await ^CountDownLatch @test-blocking-latch)
-        (is (= 1 @f))))
+      (is (= 2 (.get counter)))
+      (.await ^CountDownLatch @all-done))
     (testing "Nil returned if all services reject action"
-      (reset! counter 0)
+      (.set counter 0)
       (reset! action-blocking-latch (CountDownLatch. 1))
       (reset! test-blocking-latch (CountDownLatch. 1))
       (let [shotgun (patterns/shotgun {service1 {}


Comment out debug code

Comment out debug code

--- src/rpi_challenger/core.clj
+++ src/rpi_challenger/core.clj
@@ -46,7 +46,7 @@

 (defn record-reponse
   [participant response challenge]
-  (println "Record strike:" participant response challenge)
+  ;(println "Record strike:" participant response challenge)
   (dosync
     (alter tournament t/record-strike participant (s/make-strike response challenge)))
   ; TODO: load state on restart


Document an approach to deferring connection opening my middleware until actual use.

--- src/sql_file/middleware.clj
+++ src/sql_file/middleware.clj
@@ -27,6 +27,12 @@

 (def ^:dynamic *db* nil)

+;;; TODO: Current logic opens a database connection on every request,
+;;; regardless of whether or not it's used within the middleware wrapped
+;;; function. This should be changed to defer opening of the connection
+;;; until use via that { :factory .... } connection form. (Which will also
+;;; make it easier to integrate sql-file with yesql, given that yesql
+;;; only accepts a static connection map passed into defqueries.)
 (defn call-with-db-connection [ fn db-connection ]
   (jdbc/with-db-connection [ conn db-connection ]
     (binding [ *db* conn ]


Fixes status-im#13263

Fixes status-im#13263

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


added link to self in json format

added link to self in json format

--- src/statuses/views/json.clj
+++ src/statuses/views/json.clj
@@ -1,5 +1,5 @@
 (ns statuses.views.json
-  (:require [statuses.routes :refer [avatar-path profile-path]]))
+  (:require [statuses.routes :refer [avatar-path profile-path update-path]]))

 (defn add-avatar [items]
   (map #(assoc % :avatar (avatar-path (:author %))) items))
@@ -7,7 +7,11 @@
 (defn add-profile [items]
   (map #(assoc % :profile (profile-path (:author %))) items))

+(defn add-self [items]
+  (map #(assoc % :self (update-path (:id %))) items))
+
 (defn decorate [items]
   (->> items
     (add-avatar)
-    (add-profile)))
+    (add-profile)
+    (add-self)))


Added ns-browser and commands-math-3

Added ns-browser and commands-math-3

--- lein/profiles.clj
+++ lein/profiles.clj
@@ -1,5 +1,7 @@
 {:user {:plugins [
     [lein-marginalia "0.7.1"]
     [lein-swank "1.4.4"]
+    [clj-ns-browser "1.3.0"]
+    [marmaduke/commons-math-3 "3"]
 ]}}


Added comments to data collector.

Added comments to data collector.

--- data_collection/profanity-power-index/src/profanity_power_index/core.clj
+++ data_collection/profanity-power-index/src/profanity_power_index/core.clj
@@ -36,8 +36,8 @@
   (AsyncStreamingCallback.
     ;; resp is the HTTP response, baos is the stream itself.
     ;; This is the 'on-body' function for the callback.
-    ;; Note that tweets can be chunked. This is a problem ... for turbine.
-    ;; A partition-by transducer with (= % "\n") might do the trick.
+    ;; It does no processing - turbine will combine the tweets with a transducer
+    ;; on the input channel.
     (fn [response baos] (>!! transfer-chan (.toString baos)))
     ;; This is the 'failure' function for the callback.
     (fn [resp] (binding [*out* *err*] (println "failed")))


Update core.clj

Update core.clj

--- src/hello_world/core.clj
+++ src/hello_world/core.clj
@@ -31,7 +31,7 @@
 (defn page [name]
   (str ""
        (if name
-  (str "Nice to meet you, " name "! \n" "

")
+  (str "Nice to meet you, " name "! \n" "

")
         (str "<form>"
               "Name: <input name='name' type='text'>"
               "<input type='submit'>"
@@ -41,7 +41,7 @@

 (defn handler [{{name "name"} :params}]
-  (-> (r/response (page [name]))
+  (-> (r/response (page name))
       (r/content-type "text/html")))

 (def app


Nimbus-HAL: Bug fix, install watch on code-distrbutor everytime sync-code is called.

--- storm-core/src/clj/backtype/storm/daemon/nimbus.clj
+++ storm-core/src/clj/backtype/storm/daemon/nimbus.clj
@@ -367,8 +367,8 @@
   (if (< min-replication-count @current-replication-count)
     (log-message "desired replication count "  min-replication-count " achieved,
       current-replication-count" @current-replication-count)
-    (log-message "desired replication count of "  min-replication-count " not achieved but we have hit the max wait time
-      so moving on with replication count = " @current-replication-count)
+    (log-message "desired replication count of "  min-replication-count " not achieved but we have hit the max wait time "
+      max-replication-wait-time " so moving on with replication count = " @current-replication-count)
     )))

 (defn- read-storm-topology [conf storm-id]
@@ -1485,7 +1485,7 @@
 (defmethod sync-code :distributed [conf nimbus]
   (let [storm-cluster-state (:storm-cluster-state nimbus)
         code-ids (set (code-ids (:conf nimbus)))
-        active-topologies (set (.code-distributor storm-cluster-state nil))
+        active-topologies (set (.code-distributor storm-cluster-state (fn [] (sync-code conf nimbus))))
         missing-topologies (set/difference active-topologies code-ids)]
     (if (not (empty? missing-topologies))
       (do
@@ -1499,8 +1499,8 @@
                 (try
                   (download-code conf nimbus missing (.getHost nimbus-host-port) (.getPort nimbus-host-port))
                   (catch Exception e (log-error e "Exception while trying to syn-code for missing topology" missing)))))))))
-    (.addToLeaderLockQueue (:leader-elector nimbus))
-    (log-message "local disk is completely in sync with zk code-distributor.")))
+    ;;TODO Ideally This should only be called if all missing topology code was successfully downloaded.
+    (.addToLeaderLockQueue (:leader-elector nimbus))))

 (defmethod sync-code :local [conf nimbus]
   nil)


Tidying.

Tidying.

--- test/clojure_the_language/clojure_numerics_test.clj
+++ test/clojure_the_language/clojure_numerics_test.clj
@@ -21,36 +21,35 @@
 ;;;; Tests whether two arguments are the same object.

 ;;; /Clojure Programming/ p433 says:
-;;;     In general, numbers will never be identical?, even if provided as
-;;;     literals.
+;;;   In general, numbers will never be identical?, even if provided as
+;;;   literals.

-;;; Here are my first thoughts (partly inspired by my understanding of Common
-;;; Lisp):
-
-(fact (identical? 2 2)       => true)  ; Of course
-(fact (identical? 2N 2N)     => false) ; Possibly surprising
-(fact (identical? 2/3 2/3)   => false) ; Possibly surprising
-(fact (identical? 2M 2M)     => false) ; Possibly surprising
-(fact (identical? 2.0M 2.0M) => false) ; Possibly surprising
-(fact (identical? 2.0 2.0)   => false) ; Possibly surprising
+(fact (identical? 2 2)       => true)  ; Identical! But remember the "in general"
+(fact (identical? 2000 2000) => false) ; That's more like it
+(fact (identical? 2N 2N)     => false)
+(fact (identical? 2/3 2/3)   => false)
+(fact (identical? 2M 2M)     => false)
+(fact (identical? 2.0M 2.0M) => false)
+(fact (identical? 2.0 2.0)   => false)

 (fact (let [x 2N] (identical? x x)) => true) ; Of course

-(fact (identical? 2 2N)      => false) ; Not surprising
-(fact (identical? 2 2M)      => false) ; Not surprising
-(fact (identical? 2 2.0M)    => false) ; Not surprising
-(fact (identical? 2.0 2.0)   => false) ; Not surprising
+(fact (identical? 2 2N)      => false)
+(fact (identical? 2 2M)      => false)
+(fact (identical? 2 2.0M)    => false)
+(fact (identical? 2.0 2.0)   => false)

 ;;; But then I found this:
+(fact (identical? -129 -129) => false)
+(fact (identical? -128 -128) => true)
 (fact (identical?  127  127) => true)
 (fact (identical?  128  128) => false)
-(fact (identical? -128 -128) => true)
-(fact (identical? -129 -129) => false)
-;;; /Clojure Programming/ p433 says:
-;;;     The exception is that the JVM (and therefore Clojure) provides for a
-;;;     limited range of fixnums. Fixnums are a pool of boxed integer values
-;;;     that are always used in preference to allocating a new integer. [...]
-;;;     The Oracle JVM’s fixnum range is ±127.
+;;; Explained by /Clojure Programming/ p433 which says:
+;;;   The exception is that the JVM (and therefore Clojure) provides for a
+;;;   limited range of fixnums. Fixnums are a pool of boxed integer values
+;;;   that are always used in preference to allocating a new integer. [...]
+;;;   The Oracle JVM’s fixnum range is ±127.
+;;;     jsk: Actually -128 to +127

 ;;;; ---------------------------------------------------------------------------
 ;;;; ---- `=` ----


Fixing test failure in CI

Fixing test failure in CI

--- test/cmr/spatial/test/arc_segment_intersections.clj
+++ test/cmr/spatial/test/arc_segment_intersections.clj
@@ -36,7 +36,11 @@
         ;; They do intersect
         (and (every? (fn [point]
                        (let [lon (:lon point)
-                             line-point (p/point lon (s/segment+lon->lat ls lon))
+                             line-point (if (s/vertical? ls)
+                                          (if (s/point-on-segment? ls point)
+                                            point
+                                            :point-not-on-vertical-segment)
+                                          (p/point lon (s/segment+lon->lat ls lon)))
                              arc-point (if (a/vertical? arc)
                                          (first (a/points-at-lat arc (:lat point)))
                                          (a/point-at-lon arc lon))]


fixing more tests

fixing more tests

--- test/celestial/test/api.clj
+++ test/celestial/test/api.clj
@@ -29,39 +29,40 @@

 (fact "getting host type"
       (non-sec-app
-         (header
+        (header
           (request :get (<< "/host/type/1")) "accept" "application/json")) => (contains {:status 200})
-       (provided
-         (p/get-system "1") => {:type "redis"}
-         (p/type-of "redis") => {:classes {:redis {:append true}}}))
-
- #_(def type-req
-     (merge {:params (slurp-edn "fixtures/redis-type.edn")}
-            (header (request :post "/type") "Content-type" "application/edn")))
-
- ; TODO is seems that ring-mock isn't working correctly with '&' distructuing
- #_(fact "type requests"
-         (non-sec-app type-req) => {:status 200}
-         (provided
-           (p/new-type "redis" (dissoc (slurp-edn "fixtures/redis-type.edn") :type)) => nil
-           ))
+      (provided
+        (p/get-system "1") => {:type "redis"}
+        (p/type-of "redis") => {:classes {:redis {:append true}}}))
+
+#_(def type-req
+    (merge {:params (slurp-edn "fixtures/redis-type.edn")}
+           (header (request :post "/type") "Content-type" "application/edn")))
+
+; TODO is seems that ring-mock isn't working correctly with '&' distructuing
+#_(fact "type requests"
+        (non-sec-app type-req) => {:status 200}
+        (provided
+          (p/new-type "redis" (dissoc (slurp-edn "fixtures/redis-type.edn") :type)) => nil
+          ))

 #_(let [machine {:type "redis" :machine {:host "foo"}} type {:classes {:redis {}}}]
-  (fact "provisioning job"
-        (non-sec-app (request :post "/job/provision/1")) => (contains {:status 200})
-        (provided
-          (p/get-system "1")  => machine
-          (p/type-of "redis") => type
-          (jobs/enqueue "provision" {:identity "1" :args [type machine]}) => nil)))
+    (fact "provisioning job"
+          (non-sec-app (request :post "/job/provision/1")) => (contains {:status 200})
+          (provided
+            (p/get-system "1")  => machine
+            (p/type-of "redis") => type
+            (jobs/enqueue "provision" {:identity "1" :args [type machine]}) => nil)))

-;; (fact "staging job"
-;;       (non-sec-app (request :post "/job/stage/redis-local")) => (contains {:status 200})
-;;       (provided
-;;         (p/host "redis-local") => "p/host result"
-;;         (jobs/enqueue "stage" {:identity "redis-local" :args ["p/host result"]}) => nil))
-;;
-;; (fact "creation job"
-;;       (non-sec-app (request :post "/job/create/redis-local"))  => (contains {:status 200})
-;;       (provided
-;;         (p/host "redis-local")  => "p/host result"
-;;         (jobs/enqueue "machine" {:identity "redis-local" :args ["p/host result"]}) => nil))
+(fact "staging job"
+      (non-sec-app (request :post "/job/stage/1")) => (contains {:status 200})
+      (provided
+        (p/get-system "1") => "p/host result"
+        (jobs/enqueue "stage" {:identity "1" :args ["p/host result"]}) => nil))
+
+(fact "creation job"
+      (non-sec-app (request :post "/job/create/1"))  => (contains {:status 200})
+      (provided
+        (p/system-exists? "1") => true
+        (p/get-system "1")  => {}
+        (jobs/enqueue "reload" {:identity "1" :args [{:system-id 1}]}) => nil))


Fix typo

Fix typo

--- src-cljs/kixi/hecuba/model.cljs
+++ src-cljs/kixi/hecuba/model.cljs
@@ -8,7 +8,7 @@
                  :data     []
                  :selected nil
                  :editing false
-                 :eidted-row nil}
+                 :edited-row nil}
     :projects {:name     "Projects"
                :data     []
                :selected nil}


msg chg

msg chg

--- gae/src/gae/user_impl.clj
+++ gae/src/gae/user_impl.clj
@@ -5,7 +5,7 @@
 ;; CAUTION: these routes must match up with the URL pattern specified in
 ;; web.xml for this servlet.
 (defroutes theRouter
-  (GET "/user/hello" [] "
Hi there User from gae.user GAE servlet!
")
+  (GET "/user/hello" [] "
Hi there User from gae.user servlet!
")
   (GET "/user/goodbye" [] "
Goodbye User from gae.user servlet!
")
   (route/not-found "
User page not found
"))


custom field query test

custom field query test

--- test/riemann/query_test.clj
+++ test/riemann/query_test.clj
@@ -249,6 +249,19 @@
             [{:host 1} {:service 3} {}]
             [{:host 2 :service 3}]))

+(deftest custom-fields
+  (f "paws = 4 and tagged \"catz\""
+     [{:paws 4, :time 2, :tags ["fuzzy" "catz"]}]
+     [; Bad tags
+      {:paws 4, :time 2, :tags ["fuzzy"]}
+      {:paws 4, :time 2, :tags []}
+      {:paws 4, :time 2}
+
+      ; Bad paws
+      {:paws 3,   :time 2, :tags ["fuzzy" "catz"]}
+      {:paws nil, :time 2, :tags ["fuzzy" "catz"]}
+      {           :time 2, :tags ["fuzzy" "catz"]}]))
+
 (deftest fast
          (let [fun (fun (ast
                       "host =~ \"api %\" and state = \"ok\" and metric > 0"))


Add returning test for insert statement.

--- test/suricatta/dsl_test.clj
+++ test/suricatta/dsl_test.clj
@@ -241,12 +241,19 @@
 )

 (deftest dsl-insert
-  (testing "Insert statement from values"
+  (testing "Insert statement from values as maps"
     (let [q (-> (dsl/insert-into :t1)
                 (dsl/insert-values {:f1 1 :f2 3})
                 (dsl/insert-values {:f1 2 :f2 4}))]
       (is (= (fmt/get-sql q {:dialect :pgsql})
-             "insert into t1 (f1, f2) values (?, ?), (?, ?)")))))
+             "insert into t1 (f1, f2) values (?, ?), (?, ?)"))))
+  (testing "Insert statement from values as maps with returning"
+    (let [q (-> (dsl/insert-into :t1)
+                (dsl/insert-values {:f1 1 :f2 3})
+                (dsl/insert-values {:f1 2 :f2 4})
+                (dsl/returning :f1))]
+      (is (= (fmt/get-sql q {:dialect :pgsql})
+             "insert into t1 (f1, f2) values (?, ?), (?, ?) returning f1")))))

 (deftest dsl-update
   (testing "Update statement without condition using map"


shorter timeout

shorter timeout

--- src/babel/italiano/workbook.clj
+++ src/babel/italiano/workbook.clj
@@ -115,8 +115,7 @@
                         ]))
    :refer-clojure false
    ;; using 60000 for development: for production, use much smaller value.
-   :timeout 60000
-;   :timeout 15000
+   :timeout 5000
    :namespace 'babel.italiano.workbook))


Updated make-clean docs

Updated make-clean docs

--- src/clj/forma/trends/filter.clj
+++ src/clj/forma/trends/filter.clj
@@ -240,7 +240,8 @@
 (defn make-clean
   "Wrapper for `make-reliable`, `deseasonalize` and any future data cleaning
    functions we decide to include. See `make-reliable` and `deseasonalize` for
-   further documentation"
+   further documentation. We use round to remove unwarranted numerical precision
+   from cleaned timeseries values."
   [freq good-set bad-set spectral-ts reli-ts]
   (->> (make-reliable good-set bad-set spectral-ts reli-ts)
        (deseasonalize freq)


use helper fns for create/update price

use helper fns for create/update price

--- src/clj_money/models/prices.clj
+++ src/clj_money/models/prices.clj
@@ -9,7 +9,9 @@
             [clj-money.validation :as validation]
             [clj-money.coercion :as coercion]
             [clj-money.authorization :as authorization]
-            [clj-money.models.helpers :refer [with-storage]]
+            [clj-money.models.helpers :refer [with-storage
+                                              create-fn
+                                              update-fn]]
             [clj-money.models.entities :as entities]
             [clj-money.models.commodities :as commodities]
             [clj-money.models.storage :refer [create-price
@@ -26,7 +28,7 @@
 (s/def ::existing-price (s/keys :req-un [::id ::trade-date ::price] :opt-un [::commodity-id]))

 (defn- before-save
-  [price]
+  [_ price]
   (update-in price [:trade-date] to-sql-date))

 (defn- after-read
@@ -65,16 +67,12 @@
        before-validation
        (validation/validate spec (validation-rules storage))))

-(defn create
-  [storage-spec price]
-  (with-storage [s storage-spec]
-    (let [validated (validate s ::new-price price)]
-      (if (validation/has-error? validated)
-        validated
-        (->> validated
-             before-save
-             (create-price s)
-             after-read)))))
+(def create
+  (create-fn {:create create-price
+              :before-save before-save
+              :spec ::new-price
+              :rules-fn validation-rules
+              :coercion-rules coercion-rules}))

 (defn find-by-id
   [storage-spec id]
@@ -89,17 +87,14 @@
     (->> (select-prices s criteria)
          (map after-read))))

-(defn update
-  [storage-spec price]
-  (with-storage [s storage-spec]
-    (let [validated (validate s ::existing-price price)]
-      (if (validation/has-error? validated)
-        validated
-        (do
-          (->> validated
-               before-save
-               (update-price s))
-          (find-by-id s (:id price)))))))
+(def update
+  (update-fn {:update update-price
+              :before-save before-save
+              :rules-fn validation-rules
+              :find find-by-id
+              :spec ::existing-price
+              :after-read after-read
+              :coercion-rules coercion-rules}))

 (defn delete
   [storage-spec id]


Add a fake method to fetch the data on the server

--- src/cljs/clojure_rest/core.cljs
+++ src/cljs/clojure_rest/core.cljs
@@ -54,31 +54,42 @@

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(def card-list
-  (r/atom
-    [(create-card
-       1 "1st card"
-       "This is my first description"
-       :bug-fix
-       :backlog
-       (create-task 1 "Done some stuff" true))
-     (create-card
-       2 "2nd card"
-       "This is my second description"
-       :enhancement
-       :under-dev
-       (create-task 2 "Done some stuff" true)
-       (create-task 3 "Done some more stuff" false))
-     (create-card
-       3 "3rd card"
-       "This is my third description"
-       :bug-fix
-       :under-dev)
-     (create-card
-       4 "4th card"
-       "This is my fourth description"
-       :enhancement
-       :done)]))
+(def card-list (r/atom []))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(def init-card-list
+  "Fake card list returned by the server"
+  [(create-card
+     1 "1st card"
+     "This is my first description"
+     :bug-fix
+     :backlog
+     (create-task 1 "Done some stuff" true))
+   (create-card
+     2 "2nd card"
+     "This is my second description"
+     :enhancement
+     :under-dev
+     (create-task 2 "Done some stuff" true)
+     (create-task 3 "Done some more stuff" false))
+   (create-card
+     3 "3rd card"
+     "This is my third description"
+     :bug-fix
+     :under-dev)
+   (create-card
+     4 "4th card"
+     "This is my fourth description"
+     :enhancement
+     :done)])
+
+(defn fake-fetch
+  []
+  (js/setTimeout
+    #(reset! card-list init-card-list)
+    1000))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

@@ -153,6 +164,12 @@
       ])
     ))

+(def fetch-and-render-app
+  "Render the app - adding a fetching of data when the DOM is mounted"
+  (with-meta render-app
+    {:component-did-mount fake-fetch}))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(r/render [render-app] (js/document.getElementById "app"))
+(r/render [fetch-and-render-app]
+  (js/document.getElementById "app"))


Renamings

Renamings

--- src/cljs/clojure_rest/core.cljs
+++ src/cljs/clojure_rest/core.cljs
@@ -73,13 +73,13 @@

 (defn render-card
   []
-  (let [is-show-details (r/atom false)
-        show-details #(swap! is-show-details not)
+  (let [show-details (r/atom false)
+        toggle-details #(swap! show-details not)
         title-style #(if % :div.card__title--is-open :div.card__title)]
     (fn [card]
       [:div.card
-       [(title-style @is-show-details) {:on-click show-details} (:title card)]
-       (when @is-show-details
+       [(title-style @show-details) {:on-click toggle-details} (:title card)]
+       (when @show-details
          [:div.card__details
           (:description card)
           [render-tasks (:tasks card)]


Make filters case-insensitive and anchored at front

--- src/cljs/comic_reader/main.cljs
+++ src/cljs/comic_reader/main.cljs
@@ -101,9 +101,15 @@
                         :page 1})))
        comic-list))

+(defn re-string [letter]
+  (if (= letter "#")
+    "^[^a-z]"
+    (str "^" letter)))
+
 (defn filter-comics [cl-filter comic-list]
   (if cl-filter
-    (let [filter-re (re-pattern (str "(?i)" cl-filter))]
+    (let [filter-re (re-pattern (str "(?i)"
+                                     (re-string cl-filter)))]
       (filter (fn [{:keys [name]}]
                 (re-find filter-re name))
               comic-list))


correct yelp url

correct yelp url

--- src/cljs/montheway/mmodern.cljs
+++ src/cljs/montheway/mmodern.cljs
@@ -225,8 +225,8 @@
      (let [yelp-url (str "http://localhost:3000/yelp-bounds?bounds="
                                    (:sw-lat map-bounds) "," (:sw-lng map-bounds) "|"
                                    (:ne-lat map-bounds) "," (:ne-lng map-bounds))
-           yelp-url-2 "/yelp-bounds?bounds=45.5179568%2C-122.6886258%7C45.5357952%2C-122.6762918"
-           yelp-response (<! (http/get yelp-url))
+           yelp-url-2 "http://dipity.bennetthiles.com/yelp-bounds?bounds=45.5179568%2C-122.6886258%7C45.5357952%2C-122.6762918"
+           yelp-response (<! (http/get yelp-url-2))
            businesses (-> yelp-response :body)
            relevant-biz (->> businesses
                              (find-businesses-on-the-way lat-lngs)
@@ -235,7 +235,7 @@
                              relevant-biz
                              (iterate inc 1))]
        (dommy/append! (sel1 :body)
-                      [:p (str "Fetched yelp url: " yelp-url)])
+                      [:p (str "Fetched yelp url: " yelp-url-2)])
        (dommy/append! (sel1 :body)
                       [:p (str "Fetched yelp data: " (count numbered-biz))])
        (dommy/append! (sel1 :#biz-container)


Rename DigestType protocol and its method to more consistent names.

--- src/clojure/buddy/core/hash.clj
+++ src/clojure/buddy/core/hash.clj
@@ -52,14 +52,12 @@
    (instance? IFn alg) (alg)
    (instance? Digest alg) alg))

-(defprotocol DigestType
-  (make-digest [input algorithm] "Low level interface, always returns bytes"))
+(defprotocol IDigest
+  (^:private digest* [input algorithm] "Low level interface, always returns bytes"))

-(alter-meta! #'make-digest assoc :no-doc true :private true)
-
-(extend-protocol DigestType
+(extend-protocol IDigest
   (Class/forName "[B")
-  (make-digest [^bytes input ^Keyword alg]
+  (digest* [^bytes input ^Keyword alg]
     (let [digest (resolve-digest alg)
           buffer (byte-array (.getDigestSize digest))]
       (.update digest input 0 (count input))
@@ -67,11 +65,11 @@
       buffer))

   String
-  (make-digest [^String input ^Keyword alg]
-    (make-digest (->byte-array input) alg))
+  (digest* [^String input ^Keyword alg]
+    (digest* (->byte-array input) alg))

   java.io.InputStream
-  (make-digest [^java.io.InputStream input ^Keyword alg]
+  (digest* [^java.io.InputStream input ^Keyword alg]
     (let [digest  (resolve-digest alg)
           buffer1 (byte-array 5120)
           buffer2 (byte-array (.getDigestSize digest))]
@@ -84,21 +82,21 @@
       buffer2))

   java.io.File
-  (make-digest [^java.io.File input ^Keyword alg]
-    (make-digest (io/input-stream input) alg))
+  (digest* [^java.io.File input ^Keyword alg]
+    (digest* (io/input-stream input) alg))

   java.net.URL
-  (make-digest [^java.net.URL input ^Keyword alg]
-    (make-digest (io/input-stream input) alg))
+  (digest* [^java.net.URL input ^Keyword alg]
+    (digest* (io/input-stream input) alg))

   java.net.URI
-  (make-digest [^java.net.URI input ^Keyword alg]
-    (make-digest (io/input-stream input) alg)))
+  (digest* [^java.net.URI input ^Keyword alg]
+    (digest* (io/input-stream input) alg)))

 (defn digest
   "Generic function for create cryptographic hash."
   [input ^Keyword alg]
-  (make-digest input alg))
+  (digest* input alg))

 (def sha256 #(digest % :sha256))
 (def sha384 #(digest % :sha384))


Support PGNs with non-standard initial positions.

--- src/clojure/clj_chess/game.cljc
+++ src/clojure/clj_chess/game.cljc
@@ -806,26 +806,32 @@
   "Creates a game from ECN data, or from parsed PGN."
   [ecn & {:keys [include-annotations? san]
           :or {include-annotations? true san false}}]
-  (try
-    (let [game (reduce #(apply set-tag %1 %2)
-                       (new-game)
-                       (rest (second ecn)))]
-      (case (first (nth ecn 2))
-        :byte-moves (add-byte-move-sequence game (vec (second (nth ecn 2))))
-        :moves (if-not include-annotations?
-                 (-> game ((if san
-                             add-san-move-sequence
-                             add-uci-move-sequence)
-                            (filter string? (-> ecn (nth 2) rest))))
-                 (let [z (zip-add-ecn-data (if san
-                                             board/move-from-san
-                                             board/move-from-uci)
-                                           (game-zip game) (nth ecn 2))]
-                   (to-beginning
-                     (assoc game :root-node (zip/root z)))))))
-    (catch #?(:clj Exception :cljs js/Error) _
-      (println "Illegal or ambiguous move in game:")
-      (prn ecn))))
+  (let [fen (reduce (fn [fen tag-value-pair]
+                      (if-not (= (first tag-value-pair) "FEN")
+                        fen
+                        (second tag-value-pair)))
+                    board/start-fen
+                    (rest (second ecn)))]
+    (try
+      (let [game (reduce #(apply set-tag %1 %2)
+                         (new-game :start-fen fen)
+                         (rest (second ecn)))]
+        (case (first (nth ecn 2))
+          :byte-moves (add-byte-move-sequence game (vec (second (nth ecn 2))))
+          :moves (if-not include-annotations?
+                   (-> game ((if san
+                               add-san-move-sequence
+                               add-uci-move-sequence)
+                              (filter string? (-> ecn (nth 2) rest))))
+                   (let [z (zip-add-ecn-data (if san
+                                               board/move-from-san
+                                               board/move-from-uci)
+                                             (game-zip game) (nth ecn 2))]
+                     (to-beginning
+                       (assoc game :root-node (zip/root z)))))))
+      (catch #?(:clj Exception :cljs js/Error) _
+        (println "Illegal or ambiguous move in game:")
+        (prn ecn)))))

 (defn from-pgn
   "Creates a game from a PGN string."


CMR-149: Updated to use persistent http connections.

--- src/cmr/ingest/data/indexer.clj
+++ src/cmr/ingest/data/indexer.clj
@@ -6,23 +6,21 @@
             [cmr.common.services.errors :as errors]
             [cmr.system-trace.core :refer [deftracefn]]
             [cmr.system-trace.http :as ch]
-            [cmr.transmit.config :as transmit-config]))
-
-(defn- context->indexer-url
-  [context]
-  (let [{:keys [host port]} (transmit-config/context->app-connection context :indexer)]
-    (format "http://%s:%s" host port)))
+            [cmr.transmit.config :as transmit-config]
+            [cmr.transmit.connection :as transmit-conn]))

 (deftracefn index-concept
   "Forward newly created concept for indexer app consumption."
   [context concept-id revision-id]
-  (let [indexer-url (context->indexer-url context)
+  (let [conn (transmit-config/context->app-connection context :indexer)
+        indexer-url (transmit-conn/root-url conn)
         concept-attribs {:concept-id concept-id, :revision-id revision-id}
         response (client/post indexer-url {:body (cheshire/generate-string concept-attribs)
                                            :content-type :json
                                            :throw-exceptions false
                                            :accept :json
-                                           :headers (ch/context->http-headers context)})
+                                           :headers (ch/context->http-headers context)
+                                           :connection-manager (transmit-conn/conn-mgr conn)})
         status (:status response)]
     (when-not (= 201 status)
       (errors/internal-error! (str "Operation to index a concept failed. Indexer app response status code: "  status  " " response)))))
@@ -30,11 +28,13 @@
 (deftracefn delete-concept-from-index
   "Delete a concept with given revision-id from index."
   [context concept-id revision-id]
-  (let [indexer-url (context->indexer-url context)
+  (let [conn (transmit-config/context->app-connection context :indexer)
+        indexer-url (transmit-conn/root-url conn)
         response (client/delete (format "%s/%s/%s" indexer-url concept-id revision-id)
                                 {:accept :json
                                  :throw-exceptions false
-                                 :headers (ch/context->http-headers context)})
+                                 :headers (ch/context->http-headers context)
+                                 :connection-manager (transmit-conn/conn-mgr conn)})
         status (:status response)]
     (when-not (some #{200, 201} [status])
       (errors/internal-error! (str "Delete concept operation failed. Indexer app response status code: "  status " " response)))))


Removing log line.

Removing log line.

--- src/com/okl/tokenmgr/tokens.clj
+++ src/com/okl/tokenmgr/tokens.clj
@@ -180,7 +180,6 @@
   (let [name (:name token)
         description (:description token)]
     (map (fn [x]
-           (log/info (str "EEE token has value "  (get (:values token) x)))
            {:name name
             :description description
             :environment x


Add dependency on data.csv

Add dependency on data.csv

--- project/scrape-summitpost-data/build.boot
+++ project/scrape-summitpost-data/build.boot
@@ -3,6 +3,7 @@
 (set-env!
   :source-paths #{"src", "test"}
   :dependencies '[[org.clojure/clojure "1.8.0"]
+                  [org.clojure/data.csv "0.1.3"]
                   [org.clojure/tools.cli "0.3.5"]
                   [reaver "0.1.2"]
                   [adzerk/boot-test "1.2.0" :scope "test"]])


Moved when event-delay checks to loop end.

--- src/cbfg/core.cljs
+++ src/cbfg/core.cljs
@@ -295,9 +295,9 @@
                    :last-id (fn [] @last-id)})]
     (go-loop [num-events 0
               vis-last nil
-              vis-last-positions nil]
-      (when (> @event-delay 0) (<! (timeout @event-delay)))
-      (when (< @event-delay 0) (<! step-ch))
+              vis-last-positions nil
+              vis-last-html nil
+              vis-last-svg nil]
       (let [[actx event] (<! event-ch)
             [verb step & args] event
             vis-positions (atom {})
@@ -317,7 +317,9 @@
                           (apply str (flatten (vis-html-actx @vis @root-actx actx-ch-ch-infos))))
         (set-el-innerHTML (str el-prefix "-svg")
                           (apply str (flatten (vis-svg-actxs @vis @vis-positions deltas :curr))))
-        (recur (inc num-events) @vis @vis-positions)))
+        (when (> @event-delay 0) (<! (timeout @event-delay)))
+        (when (< @event-delay 0) (<! step-ch))
+        (recur (inc num-events) @vis @vis-positions nil nil)))
     (ago world w
          (reset! root-actx world)
          (let [in-ch (achan-buf world 100)


Whitespace.

Whitespace.

--- src/cbfg/core.cljs
+++ src/cbfg/core.cljs
@@ -147,10 +147,8 @@

 (defn vis-html-loop-state
   ([vis loop-state]
-     (interpose ", "
-                (mapv (fn [nv] [(vis-html-loop-state vis
-                                                     (first nv) (second nv))])
-                      loop-state)))
+     (interpose ", " (mapv (fn [x] [(vis-html-loop-state vis (first x) (second x))])
+                           loop-state)))
   ([vis name val]
      (let [name-parts (string/split (str name) #"-")]
        (cond (= "ch" (last name-parts)) [name " " (vis-html-ch vis val)]


Do rounding in better place.

Do rounding in better place.

Since doubles have limited precision, convert back to long before
trying to do math with numbers as large as the current epoch
timestamp.

--- src/afterglow/rhythm.clj
+++ src/afterglow/rhythm.clj
@@ -257,7 +257,7 @@
   (metro-start [metro start-beat]
     (dosync
      (ensure bpm)
-     (let [new-start (round (- (now) (* (dec start-beat) (metro-tick metro))))]
+     (let [new-start (- (now) (round (* (dec start-beat) (metro-tick metro))))]
        (ref-set start new-start))))

   (metro-bar-start [metro start-bar]