Use full-name alias

Use full-name alias

--- src/cljs/cglossa/core.cljs
+++ src/cljs/cglossa/core.cljs
@@ -1,5 +1,5 @@
 (ns cglossa.core
-  (:require [reagent.core :as r]
+  (:require [reagent.core :as reagent]
             [ajax.core :as ajax]
             [cglossa.start :as start]
             [cglossa.results :as results]))
@@ -16,8 +16,8 @@
 (def data {:corpus nil
            :metadata-categories nil})

-(defonce app-state (into {} (map (fn [[k v]] [k (r/atom v)]) state)))
-(defonce app-data (into {} (map (fn [[k v]] [k (r/atom v)]) data)))
+(defonce app-state (into {} (map (fn [[k v]] [k (reagent/atom v)]) state)))
+(defonce app-data (into {} (map (fn [[k v]] [k (reagent/atom v)]) data)))

 (defn response-handler [models response]
   (doseq [model (flatten [models])]
@@ -48,7 +48,7 @@
       [:img.textlab-logo {:src "img/tekstlab.gif"}]]]))

 (defn ^:export main []
-  (r/render-component
+  (reagent/render-component
     (fn []
       [app app-state app-data])
     (. js/document (getElementById "app"))))


Little restructurings

Little restructurings

--- src/clojure/flambo/sql.clj
+++ src/clojure/flambo/sql.clj
@@ -287,11 +287,11 @@

 (defn query
   "Query a parquet file at **url** with **sql** statement creating temporary
-  table key **table** (default to `schema-tmp`).
+  table key **table** (default to `tmp`).

   See [[setup-temporary-view]] for `:type` key."
   [url sql & {:keys [table partitions] :as m
-              :or {table "schema-tmp"}}]
+              :or {table "tmp"}}]
   (apply setup-temporary-view url table (apply concat m))
   (cond-> (.getOrCreate (SparkSession/builder))
     true (.sql sql)
@@ -302,8 +302,7 @@

   See [[setup-temporary-view]] for `:type` key."
   [url & {:keys [type]}]
-  (-> (query url "select * from schema-tmp" :type type)
-      (schema)))
+  (schema (query url "select * from schema-tmp" :type type :table "schema-tmp")))

 (defn struct-type
   "Create a `org.apache.spark.sql.types.StructType` from an array of maps, each
@@ -417,9 +416,8 @@
           :integer (Encoders/INT)
           :long (Encoders/LONG)
           :string-tuple (Encoders/tuple (Encoders/STRING) (Encoders/STRING)))
-        :else (-> (format "Invalid encoder option: %s" type-)
-                  (ex-info {:type type-})
-                  throw)))
+        :else (throw (ex-info (format "Invalid encoder option: %s" type-)
+                              {:type type-}))))

 (defn ^Dataset map
   "Returns a new dataframe formed by passing each element of the source through


Overhauled the evolution functions, this makes a friendlier REPL API.

--- src/clojure_robby/core.clj
+++ src/clojure_robby/core.clj
@@ -129,11 +129,20 @@
                     (mapv breed-one individuals))]
     (mapv mutate (concat (breed-all) (breed-all)))))

-(defn nth-best [n]
-  "Returns the best individual after n generations."
-  (let [population (repeatedly individual-count rand-dna)
-        iteration (iterate #(breed (select %)) population)]
-    (last (nth iteration n))))
+(defn evolve-from [population n]
+  "Returns the population after n generations, starting with a given population."
+  (let [iteration (iterate #(breed (select %)) population)]
+    (nth iteration n)))
+
+(defn evolve [n]
+  "Returns the population after n generations, starting with a random population."
+  (evolve-from n (repeatedly individual-count rand-dna)))
+
+(defn best [population]
+  "Returns the best individual in a generation."
+  (if (> (count population) 1)
+    (best (select population))
+    (first population)))

 ; Entry point, starts a REPL
@@ -151,9 +160,11 @@
 (defn help []
   (doall (map println ["Clojure-robby, a genetic algorithm that evolves a simple robot.",
                        "Main funcions:",
-                       "   help          - Prints this help.",
-                       "   config        - Prints current configuration."
-                       "   nth-best n    - Returns the best individual after evolving n generations.",
+                       "   help           - Prints this help.",
+                       "   config         - Prints current configuration."
+                       "   evolve n       - Returns a random population, after evolving for n generations.",
+                       "   evolve-from p n- Returns population p, after evolving it for n generations.",
+                       "   best p         - Returns the DNA of the best individual in a population.",
                        "",
                        "Example usage:",
                        "(def champ (nth-best 50))"]))


Fixed the -main.

Fixed the -main.

--- src/clojure_robby/core.clj
+++ src/clojure_robby/core.clj
@@ -133,5 +133,6 @@

 ; Entry point
 (defn -main [num & args]
-  (nth-best num))
+  (println (nth-best (Integer. num)))
+  (shutdown-agents))


Workers should bind, master should connect

--- src/lazubot/worker.clj
+++ src/lazubot/worker.clj
@@ -9,7 +9,7 @@
   (let [addr "tcp://127.0.0.1:8080"
         [reply-in reply-out] (repeatedly 2 #(chan (sliding-buffer 64)))]
     (register-socket! {:in reply-in :out reply-out :socket-type :rep
-                       :configurator (fn [socket] (.connect socket addr))})
+                       :configurator (fn [socket] (.bind socket addr))})
     (go-loop []
              (when-let [message (<! reply-out)]
                (>! reply-in message)


Schema guard on get-access-token

Schema guard on get-access-token

--- src/cylon/oauth/client.clj
+++ src/cylon/oauth/client.clj
@@ -1,6 +1,7 @@
 (ns cylon.oauth.client
   (:require
-   [clojure.tools.logging :refer :all]))
+   [clojure.tools.logging :refer :all]
+   [schema.core :as s]))

 ;; I don't think this is a wonderful name but until we can think of
 ;; something better :)
@@ -22,6 +23,14 @@
     in a new request being made with an access token, if possible."
     ))

+(s/defn get-access-token+ :- (s/maybe {:access-token s/Str
+                                       :scope #{s/Keyword}
+                                       (s/optional-key :original-uri) s/Str
+                                       s/Keyword s/Any})
+  [p :- (s/protocol AccessTokenGrantee)
+   req :- s/Any]
+  (get-access-token p req))
+
 (defprotocol UserIdentity
   (get-claims [_ req]
     "Get the claims contained in the id-token returned as part of an
@@ -38,19 +47,19 @@
   identity and access-token are still retrieved."
   [h client & [role]]
   (fn [req]
-    (let [{:keys [access-token scope]} (get-access-token client req)
+    (let [{:keys [access-token scope] :as at} (s/with-fn-validation (get-access-token+ client req))
           identity (-> (get-claims client req) :sub)]
       (cond
        (nil? access-token)
        (do
          (debugf "No access token, so soliciting one from client %s" client)
          (solicit-access-token client req))
-       ;; The thinking here is that any refresh token that was returned
-       ;; to the client will still be held by the client and can be
-       ;; used to refresh the access-token
        (expired? client req access-token)
        (do
          (debugf "access token has expired, seeking to refresh it")
+         ;; The thinking here is that any refresh token that was returned
+         ;; to the client will still be held by the client and can be
+         ;; used to refresh the access-token
          (refresh-access-token client req))

        (and role (not (contains? scope role)))


Refactored out vis-run-controls.

Refactored out vis-run-controls.

--- src/cbfg/core.cljs
+++ src/cbfg/core.cljs
@@ -252,6 +252,20 @@

 ;; ------------------------------------------------

+(defn vis-run-controls [event-delay step-ch]
+  (let [run-controls {"run"      #(do (when (< @event-delay 0) (put! step-ch true))
+                                      (reset! event-delay 0))
+                      "run-slow" #(do (when (< @event-delay 0) (put! step-ch true))
+                                      (reset! event-delay
+                                              (js/parseInt (get-el-value "run-slowness"))))
+                      "pause"    #(reset! event-delay -1)
+                      "step"     #(do (reset! event-delay -1)
+                                      (put! step-ch true))}]
+    (go-loop [run-control-ch (merge (map #(listen (gdom/getElement %) "click")
+                                         (keys run-controls)))]
+      ((get run-controls (.-id (.-target (<! run-control-ch)))))
+      (recur run-control-ch))))
+
 (defn vis-init [cmds cmd-handlers]
   (let [max-inflight (atom 10)
         event-delay (atom 0)
@@ -269,19 +283,7 @@
                              ;         :msgs {msg -> true}
                              ;         :first-taker-actx actx-or-nil}}.
                    :gen-id gen-id
-                   :last-id (fn [] @last-id)})
-        run-controls {"run"      #(do (when (< @event-delay 0) (put! step-ch true))
-                                      (reset! event-delay 0))
-                      "run-slow" #(do (when (< @event-delay 0) (put! step-ch true))
-                                      (reset! event-delay
-                                              (js/parseInt (get-el-value "run-slowness"))))
-                      "pause"    #(reset! event-delay -1)
-                      "step"     #(do (reset! event-delay -1)
-                                      (put! step-ch true))}]
-    (go-loop [run-control-ch (merge (map #(listen (gdom/getElement %) "click")
-                                         (keys run-controls)))]
-      ((get run-controls (.-id (.-target (<! run-control-ch)))))
-      (recur run-control-ch))
+                   :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))
@@ -319,7 +321,8 @@
                      (let [result (atake user-out out)]
                        (set-el-innerHTML "output" result)
                        (recur (inc num-outs))))
-           (make-fenced-pump world in out @max-inflight)))))
+           (make-fenced-pump world in out @max-inflight)))
+    (vis-run-controls event-delay step-ch)))

 ;; ------------------------------------------------


CleanUp demo.cljs

CleanUp demo.cljs

--- src/cljs/demo.cljs
+++ src/cljs/demo.cljs
@@ -3,23 +3,6 @@
             [om.dom :as dom :include-macros true]))

 (enable-console-print!)
-
-(.log js/console "hi cljs")
-
-(defn stripe [text bgc]
-  (let [st #js {:backgroundColor bgc}]
-    (dom/li #js {:style st} text)))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; (om/root                                                      ;;
-;;  (fn [app owner]                                               ;;
-;;    (om/component                                              ;;
-;;     (apply dom/ul #js {:className "animals"}                  ;;
-;;            (map stripe (:list app) (cycle ["#ff0" "fff"]))))) ;;
-;;  app-state                                                    ;;
-;;  {:target (. js/document (getElementById "demo"))})           ;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 (def app-data
   (atom
    {:users


bug fix

bug fix

--- src/glasses/traversals.clj
+++ src/glasses/traversals.clj
@@ -15,7 +15,7 @@
     (lens/traversal
      (fn [item]
        [[item] (fn [f] (lens/update item lens f))])
-     (fn [] "traversal[" (str lens) "]"))))
+     (fn [] (str "traversal[" (str lens) "]")))))

 (def mapped
   "a traversal over a seq of items


Fix bug/typo in previous commit.

Fix bug/typo in previous commit.

--- src/grafter/rdf/sesame.clj
+++ src/grafter/rdf/sesame.clj
@@ -273,7 +273,7 @@
            (.add (IStatement->sesame-statement statement)
                  (into-array Resource [(URIImpl. graph)])))
          (doto this
-           (.add stmt
+           (.add statement
                  (into-array Resource [])))))

     ([this graph statement]


support getting statements from rdf4j Models

--- src/grafter_2/rdf4j/io.clj
+++ src/grafter_2/rdf4j/io.clj
@@ -13,7 +13,7 @@
            [java.net MalformedURLException URL]
            java.time.temporal.ChronoField
            [javax.xml.datatype DatatypeConstants DatatypeFactory XMLGregorianCalendar]
-           [org.eclipse.rdf4j.model BNode Literal Statement URI]
+           [org.eclipse.rdf4j.model BNode Literal Statement URI Model]
            [org.eclipse.rdf4j.model.impl BNodeImpl ContextStatementImpl LiteralImpl SimpleValueFactory StatementImpl URIImpl]
            [org.eclipse.rdf4j.rio RDFFormat RDFHandler Rio]))

@@ -663,7 +663,12 @@

   java.io.Reader
   (pr/to-statements [this opts]
-    (to-statements* this opts)))
+    (to-statements* this opts))
+
+  Model
+  (to-statements [this _opts]
+    ;; Works because a Model is a java.util.Set
+    (map backend-quad->grafter-quad this)))

 (extend-protocol IURIable
   org.eclipse.rdf4j.model.URI


Add pipeline length option.

Add pipeline length option.

--- src/dsbdp/main.clj
+++ src/dsbdp/main.clj
@@ -53,6 +53,9 @@

 (def cli-options
   [["-h" "--help"]
+   ["-l" "--pipeline-length"
+    :default 2
+    :parse-fn #(Integer/parseInt %)]
    ["-S" "--scenario"
     "The scenario that is to be used."
     :default "no-op"]])
@@ -84,11 +87,12 @@
                     "factorial" 24N
                     "nil" nil
                     )
+          pipeline-length (:pipeline-length options)
           pipeline (if (not (nil? in-data))
                      (create-local-processing-pipeline
                        (condp = scenario
-                         "no-op" (create-no-op-proc-fns 2)
-                         "factorial" (create-factorial-proc-fns 2))
+                         "no-op" (create-no-op-proc-fns pipeline-length)
+                         "factorial" (create-factorial-proc-fns pipeline-length))
                        out-fn))
           in-fn (if (not (nil? in-data))
                   (get-in-fn pipeline))
@@ -106,7 +110,7 @@
       (.start in-loop)
       (run-repeat (executor) (fn []
                                (stats-fn)
-                               (thread-info-fn) (println)
+                               ;(thread-info-fn) (println)
                                )
                   1000)
       (run-once (executor) (fn [] (System/exit 0)) 120000))))


Defensively prevent chances of deadlock via retry-ch

--- src/onyx/plugin/datomic.clj
+++ src/onyx/plugin/datomic.clj
@@ -59,9 +59,11 @@
       (d/index-range db attribute range-start range-end))))

 (defn close-read-datoms-resources
-  [{:keys [datomic/producer-ch datomic/commit-ch datomic/read-ch] :as event} lifecycle]
+  [{:keys [datomic/producer-ch datomic/commit-ch datomic/read-ch datomic/retry-ch] :as event} lifecycle]
   (close! read-ch)
+  (close! retry-ch)
   (while (poll! read-ch))
+  (while (poll! retry-ch))
   (close! commit-ch)
   (close! producer-ch)
   {})
@@ -77,6 +79,7 @@
     (if (= :complete (:status content))
       (throw (Exception. "Restarted task and it was already complete. This is currently unhandled."))
       (let [ch (:read-ch pipeline)
+            retry-ch (:retry-ch pipeline)
             start-index (:chunk-index content)
             conn (safe-connect task-map)
             db (safe-as-of task-map conn)
@@ -103,6 +106,7 @@
                               (>!! ch e))))]

         {:datomic/read-ch ch
+         :datomic/retry-ch retry-ch
          :datomic/commit-ch (:commit-ch pipeline)
          :datomic/producer-ch producer-ch
          :datomic/drained? (:drained pipeline)
@@ -122,10 +126,11 @@
   (empty? (remove #(= :done (:message %))
                   messages)))

-(defn completed? [batch pending-messages read-ch]
+(defn completed? [batch pending-messages read-ch retry-ch]
   (and (all-done? (vals @pending-messages))
        (all-done? batch)
        (zero? (count (.buf read-ch)))
+       (zero? (count (.buf retry-ch)))
        (or (not (empty? @pending-messages))
            (not (empty? batch)))))

@@ -141,7 +146,7 @@
 (defrecord DatomicInput [log task-id max-pending batch-size batch-timeout
                          pending-messages drained?
                          top-chunk-index top-acked-chunk-index pending-chunk-indices
-                         read-ch commit-ch]
+                         read-ch retry-ch commit-ch]
   p-ext/Pipeline
   (write-batch
       [this event]
@@ -153,12 +158,12 @@
           max-segments (min (- max-pending pending) batch-size)
           timeout-ch (timeout batch-timeout)
           batch (->> (range max-segments)
-                     (keep (fn [_] (first (alts!! [read-ch timeout-ch] :priority true)))))]
+                     (keep (fn [_] (first (alts!! [retry-ch read-ch timeout-ch] :priority true)))))]
       (doseq [m batch]
         (feedback-producer-exception! m)
         (update-chunk-indices! m top-chunk-index pending-chunk-indices)
         (swap! pending-messages assoc (:id m) m))
-      (when (completed? batch pending-messages read-ch)
+      (when (completed? batch pending-messages read-ch retry-ch)
         (>!! commit-ch {:status :complete})
         (reset! drained? true))
       {:onyx.core/batch batch}))
@@ -176,7 +181,7 @@
   (retry-segment
       [_ event segment-id]
     (when-let [msg (get @pending-messages segment-id)]
-      (>!! read-ch (assoc msg :id (random-uuid))))
+      (>!! retry-ch (assoc msg :id (random-uuid))))
     (swap! pending-messages dissoc segment-id))

   (pending?
@@ -193,6 +198,7 @@
         batch-size (:onyx/batch-size catalog-entry)
         batch-timeout (or (:onyx/batch-timeout catalog-entry) (:onyx/batch-timeout defaults))
         read-ch (chan (or (:datomic/read-buffer catalog-entry) 1000))
+        retry-ch (chan (* 2 max-pending))
         commit-ch (chan (sliding-buffer 1))]
     (->DatomicInput (:onyx.core/log pipeline-data)
                     (:onyx.core/task-id pipeline-data)
@@ -203,6 +209,7 @@
                     (atom -1)
                     (atom #{})
                     read-ch
+                    retry-ch
                     commit-ch)))

 (defn read-datoms [pipeline-data]
@@ -225,9 +232,11 @@
    (:added datom)])

 (defn close-read-log-resources
-  [{:keys [datomic/producer-ch datomic/commit-ch datomic/read-ch datomic/shutdown-ch] :as event} lifecycle]
+  [{:keys [datomic/producer-ch datomic/commit-ch datomic/read-ch datomic/retry-ch datomic/shutdown-ch] :as event} lifecycle]
   (close! read-ch)
+  (close! retry-ch)
   (while (poll! read-ch))
+  (while (poll! retry-ch))
   (close! commit-ch)
   (close! shutdown-ch)
   (<!! producer-ch)
@@ -277,7 +286,7 @@

   (let [start-tx (:datomic/log-start-tx task-map)
         max-tx (:datomic/log-end-tx task-map)
-        {:keys [read-ch shutdown-ch commit-ch]} pipeline
+        {:keys [read-ch retry-ch shutdown-ch commit-ch]} pipeline
         checkpoint-key (or (:checkpoint/key task-map) task-id)
         _ (set-starting-offset! log task-map checkpoint-key start-tx)
         checkpointed (extensions/read-chunk log :chunk checkpoint-key)
@@ -320,6 +329,7 @@
                           (>!! read-ch e))))]

     {:datomic/read-ch read-ch
+     :datomic/retry-ch retry-ch
      :datomic/shutdown-ch shutdown-ch
      :datomic/commit-ch commit-ch
      :datomic/producer-ch producer-ch
@@ -343,7 +353,7 @@
 (defrecord DatomicLogInput
     [log task-id max-pending batch-size batch-timeout pending-messages drained?
      top-tx top-acked-tx pending-txes
-     read-ch commit-ch shutdown-ch]
+     read-ch retry-ch commit-ch shutdown-ch]
   p-ext/Pipeline
   (write-batch
       [this event]
@@ -357,12 +367,12 @@
           batch (if (zero? max-segments)
                   (<!! timeout-ch)
                   (->> (range max-segments)
-                       (keep (fn [_] (first (alts!! [read-ch timeout-ch] :priority true))))))]
+                       (keep (fn [_] (first (alts!! [retry-ch read-ch timeout-ch] :priority true))))))]
       (doseq [m batch]
         (feedback-producer-exception! m)
         (update-top-txes! m top-tx pending-txes)
         (swap! pending-messages assoc (:id m) m))
-      (when (completed? batch pending-messages read-ch)
+      (when (completed? batch pending-messages read-ch retry-ch)
         (when-not (:checkpoint/key (:onyx.core/task-map event))
           (>!! commit-ch {:status :complete}))
         (reset! drained? true))
@@ -382,7 +392,7 @@
   (retry-segment
       [_ event segment-id]
     (when-let [msg (get @pending-messages segment-id)]
-      (>!! read-ch (assoc msg :id (random-uuid))))
+      (>!! retry-ch (assoc msg :id (random-uuid))))
     (swap! pending-messages dissoc segment-id))

   (pending?
@@ -399,6 +409,7 @@
         batch-size (:onyx/batch-size catalog-entry)
         batch-timeout (or (:onyx/batch-timeout catalog-entry) (:onyx/batch-timeout defaults))
         read-ch (chan (or (:datomic/read-buffer catalog-entry) 1000))
+        retry-ch (chan (* 2 max-pending))
         commit-ch (chan (sliding-buffer 1))
         shutdown-ch (chan 1)
         top-tx (atom -1)
@@ -413,6 +424,7 @@
                        top-acked-tx
                        pending-txes
                        read-ch
+                       retry-ch
                        commit-ch
                        shutdown-ch)))


Fix arity.

Fix arity.

--- src/onyx/plugin/hornetq.clj
+++ src/onyx/plugin/hornetq.clj
@@ -91,8 +91,8 @@
   (swap! pending-messages dissoc message-id))

 (defmethod p-ext/apply-fn [:output :hornetq]
-  [event]
-  {:onyx.core/results (:onyx.core/decompressed event)})
+  [event segment]
+  segment)

 (defmethod p-ext/compress-batch [:output :hornetq]
   [{:keys [onyx.core/results]}]


bytes

bytes

--- src/hack_the_drive/web.clj
+++ src/hack_the_drive/web.clj
@@ -54,14 +54,15 @@
                        (car/all-vehicles))))
   (mp/wrap-multipart-params
      (POST "/capture" {params :params}
-        (let [content (get params "image")
+        (let [content (get params :image)
               bytes (or (:bytes content)
-                        (if (get content "tempfile")
-                          (IOUtils/toByteArray (io/input-stream (get content "tempfile")))))
+                        (if (get content :tempfile)
+                          (IOUtils/toByteArray (io/input-stream (get content :tempfile)))))
               id (store-media
-                  (merge
+                  (merge
+                   {:bytes bytes}
                    (vehicle-details (get params "vehicle"))
-       ;           ; (if bytes {:intensity (thermal-intensity (image-from-bytes bytes) 20)})
+                   (if bytes {:intensity (thermal-intensity (image-from-bytes bytes) 20)})
                    (assoc content
                           :vehicle (get params "vehicle"))))]
           ; (render (success))


Fix formatting

Fix formatting

Signed-off-by: ivermac <cd640042a8f3b0ff08bacdf4feae34fdd495051d@gmail.com>

--- src/hatti/views/table.cljs
+++ src/hatti/views/table.cljs
@@ -394,7 +394,8 @@
     (.setItems dataview
                (clj->js
                 (cond-> data
-                  submission-review? replace-review-num-status-with-text-status))
+                  submission-review?
+                  replace-review-num-status-with-text-status))
                _id)
     (resizeColumns grid)
     [grid dataview]))


Story ID: RPC-236 Summary: Renamed impl.terminal :as ... from report to impl

--- src/untangled_spec/reporters/terminal.clj
+++ src/untangled_spec/reporters/terminal.clj
@@ -1,7 +1,7 @@
 (ns untangled-spec.reporters.terminal
   (:require [clojure.test :as t :refer (are is deftest with-test run-tests testing testing-vars-str)]
             [clojure.stacktrace :as stack]
-            [untangled-spec.reporters.impl.terminal :as report]
+            [untangled-spec.reporters.impl.terminal :as impl]
             [colorize.core :as c]
             [clojure.data :refer [diff]]
             [io.aviso.exception :refer [format-exception *traditional*]])
@@ -97,7 +97,7 @@
   "Prints the current report data from the report data state and applies colors based on test results"
   []
   (t/with-test-out
-    (let [report-data @report/*test-state*
+    (let [report-data @impl/*test-state*
           namespaces (get report-data :namespaces)]
       (try (->> namespaces
                 (mapv #(print-namespace %)))
@@ -117,7 +117,7 @@

 (defmethod untangled-report :pass [m]
   (t/inc-report-counter :pass)
-  (report/pass))
+  (impl/pass))

 (defmethod untangled-report :error [m]
   (t/inc-report-counter :error)
@@ -127,7 +127,7 @@
                 :actual     (str (:actual m))
                 :raw-actual (:actual m)
                 :extra      (:extra m)}]
-    (report/error detail)))
+    (impl/error detail)))

 (defmethod untangled-report :fail [m]
   (t/inc-report-counter :fail)
@@ -137,42 +137,42 @@
                 :actual     (str (:actual m))
                 :raw-actual (:actual m)
                 :extra      (:extra m)}]
-    (report/fail detail)))
+    (impl/fail detail)))

 (defmethod untangled-report :begin-test-ns [m]
-  (report/begin-namespace (ns-name (:ns m))))
+  (impl/begin-namespace (ns-name (:ns m))))

 (defmethod untangled-report :end-test-ns [m]
-  (report/end-namespace))
+  (impl/end-namespace))

 (defmethod untangled-report :begin-specification [m]
-  (report/begin-specification (:string m)))
+  (impl/begin-specification (:string m)))

 (defmethod untangled-report :end-specification [m]
-  (report/end-specification))
+  (impl/end-specification))

 (defmethod untangled-report :begin-behavior [m]
-  (report/begin-behavior (:string m)))
+  (impl/begin-behavior (:string m)))

 (defmethod untangled-report :end-behavior [m]
-  (report/end-behavior))
+  (impl/end-behavior))

 (defmethod untangled-report :begin-manual [m]
-  (report/begin-behavior (str (:string m) "(MANUAL)")))
+  (impl/begin-behavior (str (:string m) "(MANUAL)")))

 (defmethod untangled-report :end-manual [m]
-  (report/end-behavior))
+  (impl/end-behavior))

 (defmethod untangled-report :begin-provided [m]
-  (report/begin-provided (:string m)))
+  (impl/begin-provided (:string m)))

 (defmethod untangled-report :end-provided [m]
-  (report/end-provided))
+  (impl/end-provided))

 (defmethod untangled-report :summary [m]
   (let [stats {:tested (:test m) :passed (:pass m)
                :failed (:fail m) :error (:error m)}]
-    (report/summary stats)
+    (impl/summary stats)
     (print-report-data)))

 (defmacro with-untangled-output


optimize 106

optimize 106

--- stuf/src/sandbox/4clojure.clj
+++ stuf/src/sandbox/4clojure.clj
@@ -702,15 +702,15 @@
 ;;    (merge {(first s) (take-while (complement keyword?) (rest s))}
 ;;           (mf (drop-while (complement keyword?) (rest s)))) {} ))

-;;106 Number Maze
-(letfn [(aux [x y n]
+;;106 Number Maze (optimized)
+(letfn [(aux [mem x y n]
           (cond
             (= n 0) nil
             (= x y) (list x)
-            (aux (* x 2) y (dec n)) (cons x (aux (* x 2) y (dec n)))
-            (aux (+ x 2) y (dec n)) (cons x (aux (+ x 2) y (dec n)))
-            (and (even? x) (aux (/ x 2) y (dec n))) (cons x (aux (/ x 2) y (dec n)))))]
-  (fn f [x y] (count (some #(aux x y %) (range)))))
+            (mem mem (* x 2) y (dec n)) (cons x (mem mem (* x 2) y (dec n)))
+            (mem mem (+ x 2) y (dec n)) (cons x (mem mem (+ x 2) y (dec n)))
+            (and (even? x) (mem mem (/ x 2) y (dec n))) (cons x (mem mem (/ x 2) y (dec n)))))]
+  (defn ff [x y] (count (some #(aux (memoize aux) x y %) (range)))))

 ;;107 Simple closures
 (fn [n] #(reduce * (repeat n %)))


This should have never been checked in.

This should have never been checked in.

--- modules/core/src/main/clojure/immutant/logger.clj
+++ modules/core/src/main/clojure/immutant/logger.clj
@@ -1,5 +0,0 @@
-(ns immutant.logger
-  (:import (org.jboss.logging Logger)))
-
-(defn log [message]
-  )


Adds preliminary deep=, cleans, and reorganizes

--- src/overcode/introvert.cljs
+++ src/overcode/introvert.cljs
@@ -1,6 +1,18 @@
 (ns overcode.introvert)

-(def ->js)
+;;***************************************************************************
+;; Utilities
+;;***************************************************************************
+(defn arr? [v]
+  "Returns if an object is a JS Array."
+  (= (type v) js/Array))
+
+(defn obj? [v]
+  "Returns if an object is a JS Object."
+  (= (type v) js/Object))
+
+(defn obj-size [obj]
+  (count (filter #(.hasOwnProperty obj %) (.keys js/Object obj))))

 (defn array-append [arr seq]
   "Inserts all elements from a Seq into an existing JS array."
@@ -19,8 +31,13 @@
    (swap! visited assoc obj out)
    out)

-  ([visited obj] (visit! visited obj true)))
+  ([visited obj] (visit! visited obj "Circular Ref")))

+
+;;***************************************************************************
+;; ->js
+;;***************************************************************************
+(def ->js)
 (defn seq->js
   "Converts a seq-like value into a JS Array."
   ([obj flat visited]
@@ -46,7 +63,7 @@
          was-visited)
        (let [out (js-obj)]
          (visit! visited obj out)
-         (doall
+         (dorun
           (map
            #(let [key (->js (first %)  flat visited)
                   val (->js (second %) flat visited)]
@@ -61,24 +78,47 @@
   "Converts a cljs data structure into a close JS approximation."
   ([obj flat visited]
    (cond
+     (= (type obj) Atom) (->js @obj flat visited)
      (keyword? obj)      (name obj)
      (symbol? obj)       (name obj)
-     (= (type obj) Atom) (->js @obj flat visited)
+     (map? obj)          (map->js obj flat visited)
      (seq? obj)          (seq->js obj flat visited)
      (set? obj)          (seq->js obj flat visited)
-     (map? obj)          (map->js obj flat visited)
+     (vector? obj)       (seq->js obj flat visited)
      :else               obj))

   ([obj flat] (->js obj flat (atom {})))
   ([obj] (->js obj false (atom {}))))

-(.log js/console (let [a (atom [1])
-      b [9 a]
-      a-js (array 1)
-      b-js (array 9 a-js)]
+;;***************************************************************************
+;; deep=
+;;***************************************************************************
+(def deep=)

-  (swap! a conj b)
-  (.push a-js b)
+(defn deep-arr=
+  ([val1 val2 visited]
+   (if (= (count val1) (count val2))
+     (every? identity (map #(deep= % %2 visited) val1 val2))
+     false)))

-  (seq->js b true)))
+(defn deep-obj=
+  ([val1 val2 visited]
+  (if (and (= (obj-size val1) (obj-size val2))
+           (deep-arr= (.keys js/Object val1)
+                      (.keys js/Object val2)
+                      visited))
+    (every? identity
+            (map #(deep= (aget val1 %) (aget val2 %) visited)
+                 (.keys js/Object val1)))
+    false)))
+
+(defn deep=
+  "Compares JS values for equality by value instead of by reference."
+  ([val1 val2 visited]
+   (cond
+    (and (arr? val1) (arr? val2)) (deep-arr= val1 val2 visited)
+    (and (obj? val1) (obj? val2)) (deep-obj= val1 val2 visited)
+    :else (= val1 val2)))
+
+  ([val1 val2] (deep= val1 val2 (atom {}))))


Use set-state! instead of updating the db directly

--- src/mdr2/production.clj
+++ src/mdr2/production.clj
@@ -193,4 +193,4 @@
   ;; create a config file for obi
   (obi/config-file production)
   ;; update the status
-  (update! (assoc production :state "structured")))
+  (set-state! production "structured"))


Fix load-changes logic in table.

Fix load-changes logic in table.

--- src/merkle_db/table.clj
+++ src/merkle_db/table.clj
@@ -415,12 +415,13 @@
   tombstones. This will load the table's patch tablet if present and merge in
   any locally pending changes."
   [^Table table]
-  (->>
-    (when-let [patch (some->> (::patch table)
-                              (mdag/get-data (.store table)))]
-      (::patch/changes patch))
-    (into (or (.pending table) (sorted-map)))
-    (not-empty)))
+  (into
+    (sorted-map)
+    (concat
+      (when-let [patch (some->> (::patch table)
+                                (mdag/get-data (.store table)))]
+        (::patch/changes patch))
+      (.pending table))))

 (defn- -scan


working with no x axis labels

working with no x axis labels

--- statspop/src/statspop/charts/scatter.cljs
+++ statspop/src/statspop/charts/scatter.cljs
@@ -11,11 +11,20 @@
          (mapv #(identity {:x (first %) :y (second %)})))))

 (defn make-scatterplot [variables]
-  (let [data [(reformat-data variables)]]
+  (let [data {:series [(reformat-data variables)]}]
     (.log js/console (clj->js data))
     {:chart-type js/Chartist.Line
      :data data
      :options {:showLine false
-               :axisX {:type js/Chartist.AutoScaleAxis
-                       :onlyInteger true}}
+               :axisX {:high 5
+                       :low 0
+                       :scaleMinSpace 20
+                       :referenceValue 3
+                       :onlyInteger true}
+               :axisY {:high 200
+                       :low 0
+                       :scaleMinSpace 20
+                       :referenceValue 100
+                       :onlyInteger true}
+               }
      :class "ct-chart"}))


Add debug logging just before invoking handler function

--- src/io/aviso/rook/core.clj
+++ src/io/aviso/rook/core.clj
@@ -196,6 +196,7 @@
         args (-> rook-data :metadata :arglists first)
         argument-values (map #(extract-argument-value % request arg-resolvers) args)]
     (when fun
+      (l/debug "Invoking handler function" fun)
       (apply fun argument-values))))

 (defn namespace-handler


Еще переработал обработку ошибок в транзите

--- radiolamp-6P3S/src/ixinfestor/net.cljs
+++ radiolamp-6P3S/src/ixinfestor/net.cljs
@@ -37,7 +37,7 @@
               (catch js/Error e
                 (.getResponseText ee))))

-          (print-error [s ee show-alert]
+          (print-error [s ee show-alert]
             (println "ERROR IN " s "\n"
                      "LastErrorCode: " (.getLastErrorCode ee) "\n"
                      "Status: " (.getStatus ee) " - " (.getStatusText ee) "\n"
@@ -60,8 +60,8 @@
           (make-reload-if-reload-client [r]
             (when (get r :reload-client)
               (do (js/alert "СЕРВЕР ПРИСЛАЛ СИГНАЛ НА ОБНОВЛЕНИЕ")
-                (set! (.-location js/window) "/"))))]
-
+                  (set! (.-location js/window) "/"))))]
+
     (let [req (goog.net.XhrIo.)
           progress-element (if disable-progress-element?
                              false
@@ -71,21 +71,30 @@
       (when progress-element
         (set! (-> progress-element .-style .-display) ""))

+
       (events/listen req goog.net.EventType.ERROR
                      (fn [e]
-                       (print "REQUEST ERROR: ")
-                       (let [ee (.-target e)
-                             rt (.getResponseText ee)]
+                       (print "REQUEST ERROR")
+                       (let [ee (.-target e)]
                          (try
-                           (let [response (t/read r rt)]
+                           (make-reload-if-reload-client (t/read r (.getResponseText ee)))
+                           (catch js/Error e
+                             (println "ERR -1 " e)))
+                         (print-error "ERROR" ee false)
+                         (if error-fn (error-fn e)))))
+
+      (events/listen req goog.net.EventType.SUCCESS
+                     (fn [e]
+                       (println "REQUEST SUCCESS")
+                       (let [ee (.-target e)]
+                         ;;(redirect-to-root-when-not-transit ee)
+                         (try
+                           (let [r (t/read r (.getResponseText ee))]
                              (make-reload-if-reload-client r)
-                             (print-error "ERROR: " ee false)
-                             ;;(js/alert (str "ОШИБКА ОБРАЩЕНИЯ К СЕРВЕРУ:\n" response))
-                             (if error-fn (error-fn response)))
-                           (catch js/Error e
-                             (let [m (str "ERROR: " e)]
-                               (print-error "ERRON IN ERROR:" ee true)
-                               (js/alert (str  "ERRON IN ERROR: " rt))))))))
+                             (success-fn r))
+                           (catch js/Error e
+                             (println (str "ERR 1 " e))
+                             (print-error "ERRON IN REQUEST SUCCESS" ee false))))))

       (events/listen req goog.net.EventType.COMPLETE
                      (fn [e]
@@ -99,25 +108,11 @@
                            (set! (-> progress-element .-style .-display) "none"))

                          (println "REQUEST COMPLETE")
-
-                         (let [])
-
                          (if complete-fn (complete-fn e)))))

-      (events/listen req goog.net.EventType.SUCCESS
-                     (fn [e]
-                       (println "REQUEST SUCCESS")
-                       (let [ee (.-target e)]
-                         ;;(redirect-to-root-when-not-transit ee)
-                         (try
-                           (let [r (t/read r (.getResponseText ee))]
-                             (make-reload-if-reload-client r)
-                             (success-fn r))
-                           (catch js/Error e
-                             (let [m (str "Ошибка сохранения: " e)]
-                               (println m)
-                               (print-error "ERRON IN REQUEST SUCCESS" ee false)))))))
+
+
       (.send req
              uri
              "POST"


Updated test module jenkins_api_test according to changes made in sources

--- test/emender_jenkins/jenkins_api_test.clj
+++ test/emender_jenkins/jenkins_api_test.clj
@@ -84,40 +84,10 @@
         (is (callable? 'emender-jenkins.jenkins-api/error-response-structure))))

-(deftest test-job-related-command-existence
-    "Check that the emender-jenkins.jenkins-api/job-related-command definition exists."
-    (testing "if the emender-jenkins.jenkins-api/job-related-command definition exists."
-        (is (callable? 'emender-jenkins.jenkins-api/job-related-command))))
-
-
 (deftest test-update-template-existence
     "Check that the emender-jenkins.jenkins-api/update-template definition exists."
     (testing "if the emender-jenkins.jenkins-api/update-template definition exists."
         (is (callable? 'emender-jenkins.jenkins-api/update-template))))
-
-
-(deftest test-start-job-existence
-    "Check that the emender-jenkins.jenkins-api/start-job definition exists."
-    (testing "if the emender-jenkins.jenkins-api/start-job definition exists."
-        (is (callable? 'emender-jenkins.jenkins-api/start-job))))
-
-
-(deftest test-enable-job-existence
-    "Check that the emender-jenkins.jenkins-api/enable-job definition exists."
-    (testing "if the emender-jenkins.jenkins-api/enable-job definition exists."
-        (is (callable? 'emender-jenkins.jenkins-api/enable-job))))
-
-
-(deftest test-disable-job-existence
-    "Check that the emender-jenkins.jenkins-api/disable-job definition exists."
-    (testing "if the emender-jenkins.jenkins-api/disable-job definition exists."
-        (is (callable? 'emender-jenkins.jenkins-api/disable-job))))
-
-
-(deftest test-delete-job-existence
-    "Check that the emender-jenkins.jenkins-api/delete-job definition exists."
-    (testing "if the emender-jenkins.jenkins-api/delete-job definition exists."
-        (is (callable? 'emender-jenkins.jenkins-api/delete-job))))

 (deftest test-log-operation-existence


Generalize synchronous wrappers for async functions

--- src/snergly/algorithms.cljc
+++ src/snergly/algorithms.cljc
@@ -45,17 +45,19 @@
       grid
       (g/link-cells grid cell (rand-nth neighbors)))))

-(s/defn maze-binary-tree [grid :- g/Grid result-chan]
-  (go-loop [grid (assoc grid :algorithm-name "binary-tree")
-            [coord & coords] (g/grid-coords grid)]
-    (if-not coord
-      (do
-        (when result-chan (async/close! result-chan))
-        grid)
-      (do
-        (when (and result-chan (g/changed? grid))
-          (async/>! result-chan grid))
-        (recur (binary-tree-step (g/begin-step grid) coord) coords)))))
+(s/defn maze-binary-tree
+  ([grid :- g/Grid] (maze-binary-tree grid nil))
+  ([grid :- g/Grid result-chan]
+    (go-loop [grid (assoc grid :algorithm-name "binary-tree")
+              [coord & coords] (g/grid-coords grid)]
+             (if-not coord
+               (do
+                 (when result-chan (async/close! result-chan))
+                 grid)
+               (do
+                 (when (and result-chan (g/changed? grid))
+                   (async/>! result-chan grid))
+                 (recur (binary-tree-step (g/begin-step grid) coord) coords))))))

 (defn sidewinder-end-run? [cell]
   (let [on-east-side? (not (:east cell))
@@ -79,39 +81,43 @@
                    (g/link-cells grid cell (:east cell)))]
     [new-grid (if end-run? [] run)]))

-(s/defn maze-sidewinder [grid :- g/Grid result-chan]
-  (go-loop [grid (assoc grid :algorithm-name "sidewinder")
-            [coord & coords] (g/grid-coords grid)
-            current-run [coord]]
-           (when (and result-chan (g/changed? grid))
-             (async/>! result-chan grid))
-    (let [[new-grid processed-run] (sidewinder-step (g/begin-step grid) coord current-run)]
-      (if (empty? coords)
-        (do
-          (when result-chan (async/close! result-chan))
-          new-grid)
-        (recur new-grid
-               coords
-               (conj processed-run (first coords)))))))
-
-(s/defn maze-aldous-broder [grid :- g/Grid result-chan]
-  (go-loop [grid (assoc grid :algorithm-name "aldous-broder")
-            current (g/random-coord grid)
-            unvisited (dec (g/grid-size grid))]
-           (when (and result-chan (g/changed? grid))
-             (async/>! result-chan grid))
-    (let [cell (g/grid-cell grid current)
-          neighbor (rand-nth (g/cell-neighbors cell))
-          neighbor-new? (empty? (:links (g/grid-cell grid neighbor)))]
-      (if (= unvisited 0)
-        (do
-          (when result-chan (async/close! result-chan))
-          grid)
-        (recur (if neighbor-new?
-                 (g/link-cells (g/begin-step grid) cell neighbor)
-                 (g/begin-step grid))
-               neighbor
-               (if neighbor-new? (dec unvisited) unvisited))))))
+(s/defn maze-sidewinder
+  ([grid :- g/Grid] (maze-sidewinder grid nil))
+  ([grid :- g/Grid result-chan]
+    (go-loop [grid (assoc grid :algorithm-name "sidewinder")
+              [coord & coords] (g/grid-coords grid)
+              current-run [coord]]
+             (when (and result-chan (g/changed? grid))
+               (async/>! result-chan grid))
+      (let [[new-grid processed-run] (sidewinder-step (g/begin-step grid) coord current-run)]
+        (if (empty? coords)
+          (do
+            (when result-chan (async/close! result-chan))
+            new-grid)
+          (recur new-grid
+                 coords
+                 (conj processed-run (first coords))))))))
+
+(s/defn maze-aldous-broder
+  ([grid :- g/Grid] (maze-aldous-broder grid nil))
+  ([grid :- g/Grid result-chan]
+    (go-loop [grid (assoc grid :algorithm-name "aldous-broder")
+              current (g/random-coord grid)
+              unvisited (dec (g/grid-size grid))]
+             (when (and result-chan (g/changed? grid))
+               (async/>! result-chan grid))
+      (let [cell (g/grid-cell grid current)
+            neighbor (rand-nth (g/cell-neighbors cell))
+            neighbor-new? (empty? (:links (g/grid-cell grid neighbor)))]
+        (if (= unvisited 0)
+          (do
+            (when result-chan (async/close! result-chan))
+            grid)
+          (recur (if neighbor-new?
+                   (g/link-cells (g/begin-step grid) cell neighbor)
+                   (g/begin-step grid))
+                 neighbor
+                 (if neighbor-new? (dec unvisited) unvisited)))))))

 (defn wilsons-loop-erased-walk [grid start-coord unvisited]
   (let [unvisited-set (into #{} unvisited)]
@@ -148,24 +154,26 @@
                new-unvisited
                pairs)))))

-(s/defn maze-wilsons [grid :- g/Grid result-chan]
-  (go-loop [grid (assoc grid :algorithm-name "wilsons")
-            unvisited (rest (shuffle (g/grid-coords grid)))
-            coord (rand-nth unvisited)]
-           (let [path (wilsons-loop-erased-walk grid coord unvisited)
-                 ;; because this algorithm first finds a path and then carves
-                 ;; it out as separate steps, it would be good to have
-                 ;; wilsons-loop-erased-walk also animate the path-finding,
-                 ;; perhaps by annotating the path cells with a color.
-                 path-chan (wilsons-carve-passage grid path unvisited result-chan)
-                 [new-grid new-unvisited] (async/<! path-chan)]
-             (if (empty? new-unvisited)
-               (do
-                 (when result-chan (async/close! result-chan))
-                 new-grid)
-               (recur new-grid
-                      new-unvisited
-                      (rand-nth new-unvisited))))))
+(s/defn maze-wilsons
+  ([grid :- g/Grid] (maze-wilsons grid nil))
+  ([grid :- g/Grid result-chan]
+    (go-loop [grid (assoc grid :algorithm-name "wilsons")
+              unvisited (rest (shuffle (g/grid-coords grid)))
+              coord (rand-nth unvisited)]
+             (let [path (wilsons-loop-erased-walk grid coord unvisited)
+                   ;; because this algorithm first finds a path and then carves
+                   ;; it out as separate steps, it would be good to have
+                   ;; wilsons-loop-erased-walk also animate the path-finding,
+                   ;; perhaps by annotating the path cells with a color.
+                   path-chan (wilsons-carve-passage grid path unvisited result-chan)
+                   [new-grid new-unvisited] (async/<! path-chan)]
+               (if (empty? new-unvisited)
+                 (do
+                   (when result-chan (async/close! result-chan))
+                   new-grid)
+                 (recur new-grid
+                        new-unvisited
+                        (rand-nth new-unvisited)))))))

 (defn hunt-and-kill-start-new-walk [grid]
   (loop [[current-coord & other-coords] (g/grid-coords grid)]
@@ -187,42 +195,56 @@
         [(g/link-cells grid current-cell neighbor)
          neighbor]))))

-(s/defn maze-hunt-and-kill [grid :- g/Grid result-chan]
-  (go-loop [grid (assoc grid :algorithm-name "hunt-and-kill")
-            current-coord (g/random-coord grid)]
-      (when (and result-chan (g/changed? grid))
-        (async/>! result-chan grid))
-    (let [[new-grid next-coord] (hunt-and-kill-step (g/begin-step grid) current-coord)]
-      (if-not next-coord
-        (do
-          (when result-chan (async/close! result-chan))
-          new-grid)
-        (recur new-grid next-coord)))))
+(s/defn maze-hunt-and-kill
+  ([grid :- g/Grid] (maze-hunt-and-kill grid nil))
+  ([grid :- g/Grid result-chan]
+    (go-loop [grid (assoc grid :algorithm-name "hunt-and-kill")
+              current-coord (g/random-coord grid)]
+             (when (and result-chan (g/changed? grid))
+               (async/>! result-chan grid))
+      (let [[new-grid next-coord] (hunt-and-kill-step (g/begin-step grid) current-coord)]
+        (if-not next-coord
+          (do
+            (when result-chan (async/close! result-chan))
+            new-grid)
+          (recur new-grid next-coord))))))

 (s/defn find-distances :- g/Distances
-  [grid :- g/Grid
-   start :- g/CellPosition
-   result-chan]
-  (go-loop [distances {start 0 :origin start}
-            current start
-            frontier #?(:clj PersistentQueue/EMPTY
-                        :cljs #queue [])]
-    (when result-chan
-      (async/>! result-chan distances))
-    (let [cell (g/grid-cell grid current)
-          current-distance (distances current)
-          links (remove #(contains? distances %) (:links cell))
-          next-frontier (apply conj frontier links)]
-      (if (empty? next-frontier)
-        (do
-          (when result-chan (async/close! result-chan))
-          (assoc distances :max current-distance :max-coord current))
-        (recur (if (empty? links)
-                 distances
-                 (apply assoc distances
-                        (mapcat #(vector % (inc current-distance)) links)))
-               (peek next-frontier)
-               (pop next-frontier))))))
+  ([grid :- g/Grid start :- g/CellPosition] (find-distances grid start nil))
+  ([grid :- g/Grid
+    start :- g/CellPosition
+    result-chan]
+    (go-loop [distances {start 0 :origin start :max 0}
+              current start
+              frontier #?(:clj PersistentQueue/EMPTY
+                          :cljs #queue [])]
+      ;(when result-chan
+      ;  (async/>! result-chan distances))
+      (let [cell (g/grid-cell grid current)
+            current-distance (distances current)
+            links (remove #(contains? distances %) (:links cell))
+            next-frontier (apply conj frontier links)]
+        (if (empty? next-frontier)
+          (do
+            (when result-chan (async/close! result-chan))
+            (assoc distances :max current-distance :max-coord current))
+          (recur (if (empty? links)
+                   distances
+                   ;; This is *super* clumsy, but has the desirable effect that
+                   ;; we only animate when the max distance actually increases.
+                   ;; That seems right to me, and makes for a very pleasing
+                   ;; animation (not too slow, but you can still see what's
+                   ;; going on, and it really gives the impression of a flood).
+                   ;; I just need to figure out a better way of triggering that
+                   ;; condition.
+                   (let [new-distances (apply assoc distances :max (inc current-distance)
+                                              (mapcat #(vector % (inc current-distance)) links))]
+                     (when (and result-chan
+                                (> (new-distances (peek next-frontier)) current-distance))
+                       (async/>! result-chan new-distances))
+                     new-distances))
+                 (peek next-frontier)
+                 (pop next-frontier)))))))

 (s/defn find-path :- g/Distances
   [grid :- g/Grid
@@ -251,30 +273,32 @@
    "hunt-and-kill" maze-hunt-and-kill})

 #?(:clj
-   (defn synchronous-algorithm [alg-name]
-     (fn [grid]
-       (async/<!! ((algorithm-functions alg-name) grid nil))))
+   (defn synchronous-fn [func]
+     (fn [& opts]
+       (async/<!! (apply func opts))))
    )

-(defn algorithm-fn [name options]
-  ;; Commenting this out for now while restructuring the cljs version
-  ;(let [algorithm (synchronous-algorithm name)
-  ;      analyze-distances (fn [maze] (find-distances maze (:distances options)))
-  ;      analyze-path (fn [maze] (find-path maze (:path-to options)
-  ;                                         (analyze-distances maze)))
-  ;      analyze-longest-path (fn [maze]
-  ;                             (let [distances (find-distances maze [0 0])
-  ;                                   distances-from-farthest (find-distances maze (:max-coord distances))]
-  ;                               (find-path maze (:max-coord distances-from-farthest) distances-from-farthest)))
-  ;      analyze (cond
-  ;                (:longest options) analyze-longest-path
-  ;                (:path-to options) analyze-path
-  ;                (:distances options) analyze-distances
-  ;                :else (fn [_] {}))]
-  ;  (fn [grid]
-  ;    (let [maze (algorithm grid)
-  ;          analysis (analyze maze)]
-  ;      (g/grid-annotate-cells maze
-  ;                                {:label (g/xform-values util/base36 analysis)
-  ;                                 :color (g/xform-values #(util/color-cell (:max analysis) %) analysis)}))))
-)
+#?(:clj
+   (defn algorithm-fn [name options]
+     ;; Commenting this out for now while restructuring the cljs version
+     (let [algorithm (synchronous-fn (algorithm-functions name))
+           analyze-distances (fn [maze] ((synchronous-fn find-distances) maze (:distances options)))
+           analyze-path (fn [maze] (find-path maze (:path-to options)
+                                              (analyze-distances maze)))
+           analyze-longest-path (fn [maze]
+                                  (let [distances (find-distances maze [0 0])
+                                        distances-from-farthest (find-distances maze (:max-coord distances))]
+                                    (find-path maze (:max-coord distances-from-farthest) distances-from-farthest)))
+           analyze (cond
+                     (:longest options) analyze-longest-path
+                     (:path-to options) analyze-path
+                     (:distances options) analyze-distances
+                     :else (fn [_] {}))]
+       (fn [grid]
+         (let [maze (algorithm grid)
+               analysis (analyze maze)]
+           (g/grid-annotate-cells maze
+                                  {:label (g/xform-values util/base36 analysis)
+                                   :color (g/xform-values #(util/color-cell (:max analysis) %) analysis)}))))
+     )
+   )


Cosmetic

Cosmetic

--- test/onyx/coordinator/simulation_test.clj
+++ test/onyx/coordinator/simulation_test.clj
@@ -147,7 +147,9 @@
                       :hornetq/queue-name "out-queue"}]
             workflow {:in {:inc :out}}
             offer-ch-spy (chan 1)]
-        (tap (:offer-mult coordinator) offer-ch-spy)
+
+        (tap (:offer-mult coordinator) offer-ch-spy)
+
         (>!! (:planning-ch-head coordinator)
              {:catalog catalog :workflow workflow})

@@ -155,14 +157,14 @@
               db (d/db (:conn log))]

           (testing "There is one job"
-              (let [query '[:find ?j :in $ ?id :where [?j :job/id ?id]]
-                    result (d/q query db job-id)]
-                (is (= (count result) 1))))
-
-          (testing "There are three tasks")
-          (let [query '[:find ?n :where [?t :task/name ?n]]
-                result (d/q query db)]
-            (is (= result #{[:in] [:inc] [:out]})))
+            (let [query '[:find ?j :in $ ?id :where [?j :job/id ?id]]
+                  result (d/q query db job-id)]
+              (is (= (count result) 1))))
+
+          (testing "There are three tasks"
+            (let [query '[:find ?n :where [?t :task/name ?n]]
+                  result (d/q query db)]
+              (is (= result #{[:in] [:inc] [:out]}))))

           (testing ":in's ingress queue is preset"
             (let [query '[:find ?qs :where
@@ -185,14 +187,14 @@
                   result (d/q query db)]
               (is (empty? result))))

-          (testing ":inc's ingress queue is :in's egress queue")
-          (let [in-query '[:find ?qs :where
-                           [?t :task/name :in]
-                           [?t :task/egress-queues ?qs]]
-                inc-query '[:find ?qs :where
-                            [?t :task/name :inc]
-                            [?t :task/ingress-queues ?qs]]]
-            (is (= (d/q in-query db) (d/q inc-query db))))
+          (testing ":inc's ingress queue is :in's egress queue"
+            (let [in-query '[:find ?qs :where
+                             [?t :task/name :in]
+                             [?t :task/egress-queues ?qs]]
+                  inc-query '[:find ?qs :where
+                              [?t :task/name :inc]
+                              [?t :task/ingress-queues ?qs]]]
+              (is (= (d/q in-query db) (d/q inc-query db)))))

           (testing ":out's ingess queue is :inc's egress queue"
             (let [inc-query '[:find ?qs :where


update example

update example

--- example/counter/core.cljs
+++ example/counter/core.cljs
@@ -1,7 +1,6 @@
 (ns counter.core
   (:require [rum.core :as rum]
-            [scrum.dispatcher :as d]
-            [scrum.core :refer [subscription]]))
+            [scrum.core :as scrum]))

 ;;
 ;; define controller & event handlers
@@ -11,47 +10,38 @@

 (defmulti control (fn [action] action))

-(defmethod control :init [_ _ db]
-  (assoc db :counter initial-state))
+(defmethod control :init []
+  initial-state)

-(defmethod control :inc [_ _ db]
-  (update db :counter inc))
+(defmethod control :inc [_ _ counter]
+  (inc counter))

-(defmethod control :dec [_ _ db]
-  (update db :counter dec))
-
-
-;;
-;; define subscription
-;;
-
-(def counter (subscription [:counter]))
+(defmethod control :dec [_ _ counter]
+  (dec counter))

 ;;
 ;; define UI component
 ;;

-;; create dispatcher for particular controller
-(def dispatch-counter! (partial d/dispatch! :counter))
-
-(rum/defc Counter < rum/reactive []
+(rum/defc Counter < rum/reactive [r]
   [:div
-   [:button {:on-click #(dispatch-counter! :dec)} "-"]
-   [:span (rum/react counter)]
-   [:button {:on-click #(dispatch-counter! :inc)} "+"]])
+   [:button {:on-click #(scrum/dispatch! r :counter :dec)} "-"]
+   [:span (rum/react (scrum/subscription r [:counter]))]
+   [:button {:on-click #(scrum/dispatch! r :counter :inc)} "+"]])

 ;;
 ;; start up
 ;;

-;; register controller
-(d/register! :counter control)
+;; create Reconciler instance
+(defonce reconciler
+  (scrum/reconciler (atom {}) {:counter control}))

-;; initialize registered controllers
-(defonce dispatched-init (d/broadcast! :init))
+;; initialize controllers
+(defonce init-ctrl (scrum/broadcast! reconciler :init))

 ;; render
-(rum/mount (Counter)
+(rum/mount (Counter reconciler)
            (. js/document (getElementById "app")))


Delete old foo.clj

Delete old foo.clj

--- resources/leiningen/new/chestnut/foo.clj
+++ resources/leiningen/new/chestnut/foo.clj
@@ -1 +0,0 @@
-(def {{name}} :foo)


whitespace

whitespace

--- test/babel/test/fr.cljc
+++ test/babel/test/fr.cljc
@@ -295,21 +295,18 @@
                                   {:synsem {:infl :present
                                             :subcat {:1 {:agr {:number :plur
                                                                :person :1st}}}}}))))
-
 (deftest conjugate-conditional
   (is (= "parlerions"
          (conjugate "parler"
                     {:synsem {:infl :conditional
                               :subcat {:1 {:agr {:number :plur
                                                  :person :1st}}}}}))))
-
 (deftest conjugate-future
   (is (= "parleront"
          (conjugate "parler"
                     {:synsem {:infl :future
                               :subcat {:1 {:agr {:number :plur
                                                  :person :3rd}}}}}))))
-
 (deftest conjugate1
   (let [from #"s'([aeéiou].*)er$"
         infinitive "s'amuser"


speedup tests by creating language-models outside of tests

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -3,7 +3,7 @@
   (:require
    [babel.directory :refer [models]]
    [babel.generate :as generate]
-   [babel.italiano :refer [analyze fo-ps generate lightning-bolts medium morph np-grammar parse preprocess small]]
+   [babel.italiano :as italiano :refer [analyze fo-ps generate lightning-bolts morph parse preprocess]]
    [babel.italiano.grammar :as grammar :refer [model]]
    [babel.italiano.morphology :as morph :refer [analyze-regular replace-patterns]]
    [babel.italiano.morphology.nouns :as nouns]
@@ -18,6 +18,10 @@
    [clojure.set :as set]
    [dag_unify.core :refer [copy fail? get-in strip-refs unifyc]]))

+(def medium (italiano/medium))
+(def np-grammar (italiano/np-grammar))
+(def small (italiano/small))
+
 (deftest analyze-1
   (let [singular (analyze "compito")
         plural  (analyze "compiti")]
@@ -38,7 +42,7 @@
                                    :sem {:pred :be
                                          :subj {:pred :I}
                                          :tense :present}}}
-                         :model (small)
+                         :model small
                          :do-enrich false)]
     (is (= "io sono" (morph result)))))

@@ -49,7 +53,7 @@
                                    :sem {:subj {:pred :I}
                                          :tense :past
                                          :aspect :perfect}}}
-                         :model (small))]
+                         :model small)]
     (is (not (nil? result)))
     (is (= "io ho bevuto" (morph result)))))

@@ -89,7 +93,7 @@
                                          :subj {:pred :I}
                                          :tense :past
                                          :aspect :perfect}}}
-                         :model (small))]
+                         :model small)]
     (is (not (nil? result)))
     (is (= "io mi sono alzata" (morph result)))))

@@ -99,7 +103,7 @@
                                    :sem {:pred :be-called
                                          :subj {:pred :I}
                                          :iobj {:pred :luisa}}}}
-                         :model (small))]
+                         :model small)]
     (is (not (nil? result)))
     (is (= "io mi chiamo Luisa" (morph result)))))

@@ -114,20 +118,20 @@
                                        :mod {:pred :difficile}
                                        :number :sing
                                        :pred :donna}}}
-                       :model (np-grammar))]
+                       :model np-grammar)]
     (is (or (= (morph expr) "la donna difficile")
             (= (morph expr) "la difficile donna")))
     (is (not (empty? (reduce concat (map
-                                     :parses (parse (morph expr) (np-grammar)))))))))
+                                     :parses (parse (morph expr) np-grammar))))))))

 (deftest forbid-mispelling
- (is (empty? (:parses (parse (morph "la donna difficila") (np-grammar))))))
+ (is (empty? (:parses (parse (morph "la donna difficila") np-grammar)))))

 (deftest generate-and-parse-noun-phrase-with-specifier
   ;; create a noun phrase where the determiner is "ventotto", but the head of the noun phrase
   ;; might be anything.
   (let [result (generate {:synsem {:sem {:spec {:def :twentyeight}}}}
-                         :model (np-grammar))]
+                         :model np-grammar)]
     (is (not (= "" (morph result))))
     (is (= :twentyeight (get-in result [:synsem :sem :spec :def])))
     (is (not (empty? (parse (morph result)))))))
@@ -153,12 +157,12 @@
                                         ;; generic spec to something more specific
                                         ;; if this test fails and you want to investigate
                                         ;; why.
-                                        :model (np-grammar))))]
+                                        :model np-grammar)))]
     (is (= do-this-many
            (count (map-fn (fn [expr]
                             (let [surface (morph expr)
                                   parsed (reduce concat (map :parses
-                                                             (parse surface (np-grammar))))]
+                                                             (parse surface np-grammar)))]
                               (if (not (empty? parsed))
                                 (log/info (str "parse OK:" surface))
                                 (log/error (str "parse failed: " surface)))
@@ -172,7 +176,7 @@
                            #(generate {:synsem {:cat :verb
                                                 :sem {:tense :present}
                                                 :subcat '()}}
-                                      :model (small))))]
+                                      :model small)))]
     (is (= do-this-many
            (count (map-fn (fn [expr]
                             (let [surface (morph expr)
@@ -192,7 +196,7 @@
                                                 :sem {:tense :past
                                                       :aspect :progressive}
                                                 :subcat '()}}
-                                      :model (small))))]
+                                      :model small)))]
     (is (= do-this-many
            (count (map-fn (fn [expr]
                             (let [surface (morph expr)
@@ -212,7 +216,7 @@
                                                 :sem {:tense :past
                                                       :aspect :perfect}
                                                 :subcat '()}}
-                                      :model (small))))]
+                                      :model small)))]
     (is (= do-this-many
            (count (map-fn (fn [expr]
                           (let [surface (morph expr)
@@ -230,7 +234,7 @@
                            #(generate {:synsem {:cat :verb
                                                 :sem {:tense :future}
                                                 :subcat '()}}
-                                      :model (small))))]
+                                      :model small)))]
     (is (= do-this-many
            (count (map-fn (fn [expr]
                           (let [surface (morph expr)
@@ -248,7 +252,7 @@
                            #(generate {:synsem {:cat :verb
                                                 :sem {:tense :conditional}
                                                 :subcat '()}}
-                                      :model (small))))]
+                                      :model small)))]
     (is (= do-this-many
            (count (map-fn (fn [expr]
                           (let [surface (morph expr)
@@ -277,7 +281,7 @@
           (let [semantics (strip-refs
                            (get-in
                             (first
-                             (reduce concat (map :parses (parse surface (medium)))))
+                             (reduce concat (map :parses (parse surface medium))))
                             [:synsem :sem]))]
             (is (map? semantics))))
         ["la sua ragazza"
@@ -337,7 +341,7 @@
         (generate {:synsem {:sem {:subj {:pred :loro}
                                   :pred :manage
                                   :tense :present}}}
-                  :model (small))]
+                  :model small)]
     (is (= "loro gestiscono" (morph result)))))

 (deftest casa-generate
@@ -522,7 +526,7 @@
                                        :tense :past
                                        :subj {:gender :fem
                                               :pred :loro}}}}
-                       :model (small)))
+                       :model small))
      "loro sono andate")))

 (deftest exists1
@@ -533,7 +537,7 @@
                                        :tense :conditional}}
                         :root {:italiano {:italiano "essere"}}
                         :comp {:synsem {:agr {:number :sing}}}}
-                       :model (small)))
+                       :model small))
          "ci sarebbe")))

 (deftest exists2
@@ -545,7 +549,7 @@
                                        :tense :past}}
                         :root {:italiano {:italiano "essere"}}
                         :comp {:synsem {:agr {:number :sing}}}}
-                       :model (small)))
+                       :model small))
          "c'era")))

 (deftest exists3
@@ -556,7 +560,7 @@
                                        :tense :present}}
                         :root {:italiano {:italiano "essere"}}
                         :comp {:synsem {:agr {:number :sing}}}}
-                       :model (small)))
+                       :model small))
          "c'è")))

 (deftest bisogno


CLJS-1375: cljs.js/require does not conj to *loaded*

Use Mike Fikes changes which highlighted some broken thigns.

require did not invoke the callback if library was already loaded. Macro namespaces
need to be renamed, otherwise unintuitively prevents loads.

--- src/main/cljs/cljs/js.cljs
+++ src/main/cljs/cljs/js.cljs
@@ -171,56 +171,62 @@
   ([bound-vars name opts cb]
    (require bound-vars name nil opts cb))
   ([bound-vars name reload opts cb]
-   (when (= :reload reload)
-     (swap! *loaded* disj name))
-   (when (= :reload-all reload)
-     (reset! *loaded* #{}))
-   (when (:verbose opts)
-     (debug-prn (str "Loading " name (when (:macros-ns opts) " macros") " namespace")))
-   (when-not (contains? @*loaded* name)
-     (let [env (:*env* bound-vars)]
-       (try
-         ((:*load-fn* bound-vars)
-           {:name   name
-            :macros (:macros-ns opts)
-            :path   (ns->relpath name)}
-          (fn [resource]
-            (assert (or (map? resource) (nil? resource))
-              "*load-fn* may only return a map or nil")
-            (if resource
-              (let [{:keys [lang source cache source-map]} resource]
-                (condp = lang
-                  :clj (eval-str* bound-vars source name opts
-                         (fn [res]
-                           (if (:error res)
-                             (cb res)
-                             (cb {:value true}))))
-                  :js  (let [res (try
-                                   ((:*eval-fn* bound-vars) resource)
-                                   (when cache
-                                     (load-analysis-cache!
-                                       (:*compiler* bound-vars) name cache))
-                                   (when source-map
-                                     (load-source-map!
-                                       (:*compiler* bound-vars) name source-map))
-                                   (catch :default cause
-                                     (wrap-error
-                                       (ana/error env
-                                         (str "Could not require " name) cause))))]
-                         (if (:error res)
-                           (cb res)
-                           (cb {:value true})))
-                  (cb (wrap-error
-                        (ana/error env
-                          (str "Invalid :lang specified " lang ", only :clj or :js allowed"))))))
-              (cb (wrap-error
-                    (ana/error env
-                      (ana/error-message :undeclared-ns
-                        {:ns-sym name :js-provide (cljs.core/name name)})))))))
-         (catch :default cause
-           (cb (wrap-error
-                 (ana/error env
-                   (str "Could not require " name) cause)))))))))
+   (let [name (cond-> name (:macro-ns opts) ana/macro-ns-name)]
+     (when (= :reload reload)
+       (swap! *loaded* disj name))
+     (when (= :reload-all reload)
+       (reset! *loaded* #{}))
+     (when (:verbose opts)
+       (debug-prn (str "Loading " name (when (:macros-ns opts) " macros") " namespace")))
+     (if-not (contains? @*loaded* name)
+       (let [env (:*env* bound-vars)]
+         (try
+           ((:*load-fn* bound-vars)
+             {:name name
+              :macros (:macros-ns opts)
+              :path (ns->relpath name)}
+             (fn [resource]
+               (assert (or (map? resource) (nil? resource))
+                 "*load-fn* may only return a map or nil")
+               (if resource
+                 (let [{:keys [lang source cache source-map]} resource]
+                   (condp = lang
+                     :clj (eval-str* bound-vars source name opts
+                            (fn [res]
+                              (if (:error res)
+                                (cb res)
+                                (do
+                                  (swap! *loaded* conj name)
+                                  (cb {:value true})))))
+                     :js  (let [res (try
+                                      ((:*eval-fn* bound-vars) resource)
+                                      (when cache
+                                        (load-analysis-cache!
+                                          (:*compiler* bound-vars) name cache))
+                                      (when source-map
+                                        (load-source-map!
+                                          (:*compiler* bound-vars) name source-map))
+                                      (catch :default cause
+                                        (wrap-error
+                                          (ana/error env
+                                            (str "Could not require " name) cause))))]
+                            (if (:error res)
+                              (cb res)
+                              (do
+                                (swap! *loaded* conj name)
+                                (cb {:value true}))))
+                     (cb (wrap-error
+                           (ana/error env
+                             (str "Invalid :lang specified " lang ", only :clj or :js allowed"))))))
+                 (cb (wrap-error
+                       (ana/error env
+                         (ana/error-message :undeclared-ns
+                           {:ns-sym name :js-provide (cljs.core/name name)})))))))
+           (catch :default cause
+             (cb (wrap-error
+                   (ana/error env
+                     (str "Could not require " name) cause))))))
+       (cb {:value true})))))

 (declare ns-side-effects analyze-deps)

@@ -822,9 +828,9 @@
     (fn [{:keys [error] :as res}]
       (if error
         (do
-          (println error)
+          (println "Error:" error)
           (println (.. error -cause -stack)))
-        (println res))))
+        (println "Result:" res))))

   (cljs/eval-str st
     "(ns foo.bar)\n(first [1 2 3])"
@@ -854,12 +860,11 @@
           (println (.. error -cause -stack)))
         (println res))))

-  ;; inline source maps work under Node.js
   (cljs/eval-str st
     "(ns foo.bar)\n(ffirst [1 2 3])"
     'foo.bar
     {:verbose true
-     :source-map false
+     :source-map true
      :eval node-eval
      :load node-load}
     (fn [{:keys [error] :as res}]


comment typos

comment typos

--- src/re_frame/core.cljs
+++ src/re_frame/core.cljs
@@ -40,7 +40,7 @@
 (def clear-all-events!   events/clear-all-handlers!)
 (def clear-event!        events/clear-handler!)

-;; Registers a pure event handler. Places pure middleare in the correct, LHS position.
+;; Registers a pure event handler. Places pure middleware in the correct, LHS position.
 (defn def-event
   ([id handler]
     (events/register-base id pure handler))
@@ -48,7 +48,7 @@
     (events/register-base id [pure middleware] handler)))

-;; Registers an effectful event handler. Places fx middleare in the correct, LHS position.
+;; Registers an effectful event handler. Places fx middleware in the correct, LHS position.
 (defn def-event-fx
   ([id handler]
    (events/register-base id fx handler))


search_table is no longer an expected id on the home page

--- pedestal-app/test/semtag_web/integration_test.clj
+++ pedestal-app/test/semtag_web/integration_test.clj
@@ -118,11 +118,11 @@
   (Thread/sleep 1000)
   (url-ends-with "#/search?query=maxwell&search-type=tagged-with-type"))

-(def expected-tables
+(def expected-ids
   {"#/types" "#type_stats_table"
    "#/tag-stats" "#tag_stats_table"
    "#/all" "#all_table"
-   "#/" "#search_table"})
+   "#/" "#search_box"})

 (deftest direct-urls-work
   (doseq [rel-url (vals route/routes)]
@@ -130,7 +130,7 @@
     ;; necessary for a hash url to be recognized
     (taxi/refresh)
     (Thread/sleep 500)
-    (is (taxi/element (get expected-tables rel-url)) "renders correct table")
+    (is (taxi/element (get expected-ids rel-url)) "renders correct table")
     (url-ends-with rel-url)))

 (deftest direct-search-url-works


Explain the monkey-patch to print-sequential

--- src/reply/printing.clj
+++ src/reply/printing.clj
@@ -1,7 +1,12 @@
 (ns reply.printing)

 (in-ns 'clojure.core)
-(defn- print-sequential [^String begin, print-one, ^String sep, ^String end, sequence, ^Writer w]
+
+(defn- print-sequential
+  "The monkey-patch here is to be a good citizen in the face of thread
+  interruption. Only the (when (Thread/interrupted) ...) forms are
+  different from the clojure.core implementation."
+  [^String begin, print-one, ^String sep, ^String end, sequence, ^Writer w]
   (binding [*print-level* (and (not *print-dup*) *print-level* (dec *print-level*))]
     (if (and *print-level* (neg? *print-level*))
       (.write w "#")


More var names.

More var names.

--- src/rewindable/ago.clj
+++ src/rewindable/ago.clj
@@ -6,6 +6,14 @@
   (:require [cljs.core.async.impl.ioc-macros :as ioc]))

 ; From https://github.com/clojure/core.async/blob/master/src/main/clojure/cljs/core/async/impl/ioc_macros.clj
+(def ^:const FN-IDX 0)
+(def ^:const STATE-IDX 1)
+(def ^:const VALUE-IDX 2)
+(def ^:const BINDINGS-IDX 3)
+(def ^:const EXCEPTION-FRAMES 4)
+(def ^:const CURRENT-EXCEPTION 5)
+(def ^:const USER-START-IDX 6)
+
 (def my-async-terminators
   {'<!                    'rewindable.agos/agos-take
    'cljs.core.async/<!    'rewindable.agos/agos-take
@@ -21,8 +29,10 @@
     `(let [c# (cljs.core.async/chan 1)]
        (cljs.core.async.impl.dispatch/run
         (fn []
-          (let [f# ~sm
-                state# (-> (f#)
-                           (ioc/aset-all! cljs.core.async.impl.ioc-helpers/USER-START-IDX c#))]
+          (let [sm# ~sm
+                sm-instance# (sm#)
+                state# (ioc/aset-all! sm-instance#
+                                      cljs.core.async.impl.ioc-helpers/USER-START-IDX
+                                      c#)]
             (cljs.core.async.impl.ioc-helpers/run-state-machine-wrapped state#))))
        c#)))


What a bad idea!

What a bad idea!

--- test/parmenides/core_test.clj
+++ test/parmenides/core_test.clj
@@ -100,7 +100,6 @@
                            :test/id-1 a
                            :test/id-2 b})
                         ids))
-     (/ 1 0)
      (unleash-the-cupids! conn)
      (= outcome
         (characteristics (d/db conn))))))


Tweak setup

Tweak setup

--- demo/sitetools.cljs
+++ demo/sitetools.cljs
@@ -99,12 +99,14 @@
            (.isSupported Html5History)
            (#{"http:" "https:"} proto)))))

-(defn create-history []
+(defn create-history [p]
   (if (use-html5-history)
     (doto (Html5History.)
       (.setUseFragment false))
-    (doto (History.)
-      (.setToken @page))))
+    (let [h (History.)]
+      (when p
+        (.setToken h p))
+      h)))

 (def history nil)

@@ -112,9 +114,9 @@
   (if (use-html5-history)
     (:base-path @config)))

-(defn setup-history []
+(defn setup-history [p]
   (when (nil? history)
-    (set! history (create-history))
+    (set! history (create-history p))
     (swap! page-state assoc :has-history (some? history))
     (when-let [h history]
       (evt/listen h hevt/NAVIGATE
@@ -259,7 +261,7 @@
       (swap! config merge conf)
       (when page-name
         (set-start-page page-name))
-      (setup-history)
+      (setup-history page-name)
       (set! (.-title js/document) (get-title))
       (reagent/render-component (body)
                                 (.' js/document :body)))))


Desctructure routes arguments

Desctructure routes arguments

--- server/src/spira/rest_adapter/routes.clj
+++ server/src/spira/rest_adapter/routes.clj
@@ -34,42 +34,42 @@
 ;; PUT       /api/foo/<id>    -> update record
 ;; DELETE    /api/foo/<id>    -> delete record

-(defn app-routes [state]
+(defn app-routes [{garden-repo :garden-repo plant-desc-repo :plant-desc-repo}]
   (compojure.core/routes

    ;; /api/garden
    (GET "/api/garden/:id" [id]
         (json-response
-         (gs/req-garden (:garden-repo state) (util/parse-uint id))))
+         (gs/req-garden garden-repo (util/parse-uint id))))
    (GET "/api/garden" []
         (json-response
-         (gs/req-garden-list (:garden-repo state))))
+         (gs/req-garden-list garden-repo)))
    (POST "/api/garden" [& params]
          (json-response
-          (gs/create-garden (:garden-repo state) params)))
+          (gs/create-garden garden-repo params)))
    (PUT "/api/garden/:id" [id & params]
         (json-response
-         (gs/update-garden (:garden-repo state) (util/parse-uint id) params)))
+         (gs/update-garden garden-repo (util/parse-uint id) params)))
    (DELETE "/api/garden/:id" [id]
            (json-response
-            (gs/delete-garden (:garden-repo state) (util/parse-uint id))))
+            (gs/delete-garden garden-repo (util/parse-uint id))))

    ;; /api/plantdesc
    (GET "/api/plantdesc/:id" [id]
          (json-response
-          (pds/req-plant-desc (:plant-desc-repo state) (util/parse-uint id))))
+          (pds/req-plant-desc plant-desc-repo (util/parse-uint id))))
    (GET "/api/plantdesc" []
         (json-response
-         (pds/req-plant-desc-list (:plant-desc-repo state))))
+         (pds/req-plant-desc-list plant-desc-repo)))
    (POST "/api/plantdesc" [& params]
          (json-response
-          (pds/create-plant-desc (:plant-desc-repo state) params)))
+          (pds/create-plant-desc plant-desc-repo params)))
    (PUT "/api/plantdesc/:id" [id & params]
         (json-response
-         (pds/update-plant-desc (:plant-desc-repo state) (util/parse-uint id) params)))
+         (pds/update-plant-desc plant-desc-repo (util/parse-uint id) params)))
    (DELETE "/api/plantdesc/:id" [id]
            (json-response
-            (pds/delete-plant-desc (:plant-desc-repo state) (util/parse-uint id))))
+            (pds/delete-plant-desc plant-desc-repo (util/parse-uint id))))

    ;; fallback
    (route/not-found "Not Found")


Fix the logging from previous PR

Fix the logging from previous PR

I determined it was hitting the error state, so add more in depth
logging there, and return the state unchanged so we don't wipe it out
by setting it to nil.

--- src-cljs/frontend/controllers/api.cljs
+++ src-cljs/frontend/controllers/api.cljs
@@ -124,15 +124,25 @@
                                          {})]]
           (merge new-project
                  (select-keys matching-project [:recent-builds :build-timing])))]
-    (js/console.log (str "PROJECT API RESP: " resp))
-    (js/console.log (str "PROJECT API NEW PROJECTS: " new-projects))
-    (js/console.log (str "PROJECT API LOOKUP: " (str old-projects-lookup)))
-    (js/console.log (str "PROJECT API PROCESSED PROJECTS: " processed-new-projects))
     (assoc-in current-state state/projects-path processed-new-projects)))

 (defmethod api-event [:projects :failed]
   [target message status args state]
-  (js/console.log "PROJECT API FAILED"))
+  (js/console.log (str "PROJECT API FAILED: \n"
+                       "target: " target "\n"
+                       "message: " message "\n"
+                       "status: " status "\n"
+                       "args: " args "\n"))
+  state)
+
+
+(defmethod post-api-event! [:projects :failed]
+  [target message status args previous-state current-state comms]
+  (js/console.log (str "PROJECT API FAILED: \n"
+                       "target: " target "\n"
+                       "message: " message "\n"
+                       "status: " status "\n"
+                       "args: " args "\n")))

 (defmethod post-api-event! [:projects :success]
   [target message status args previous-state {:keys [navigation-point] :as current-state} comms]


Minor formatting.

Minor formatting.

--- src-cljs/main/githubcomments/core.cljs
+++ src-cljs/main/githubcomments/core.cljs
@@ -19,8 +19,8 @@
          [:div.github-comment-content (:body_html comment)]]))

 (defn comments-to-ul [comments]
-  (html [:ul
-         (for [comment (take 10 comments)] (comment-to-li-tag comment))]))
+  (html [:ul (for [comment (take 10 comments)]
+               (comment-to-li-tag comment))]))

 (defn error-msg [response] (html [:p "Cannot display comments."]))


Make `unsatisfy-all-dependencies` idempotent...

This is used in `shutdown-server` and was causing boot to fail if
shutdown-server (and `unsatisfy-all-dependencies`) had been called more
than once because the second call wiped out all of the todo's.

--- src/overtone/libs/deps.clj
+++ src/overtone/libs/deps.clj
@@ -120,7 +120,7 @@
   []
   (send dep-state* (fn [deps]
                      {:satisfied #{}
-                      :todo (deps :done)
+                      :todo (concat (deps :todo) (deps :done))
                       :done []})))

 (defn satisfied-deps


Improve buffer recording fns - fix up #'buffer-save - choose defaults that actually work and improve docstring. Also remove streaming capability. This is now achieved using #'buffer-stream which may be used with the disk-out ugen to record buffer updates. Also add #'buffer-stream-close for closing buffer streams and #'buffer-stream?

--- src/overtone/sc/buffer.clj
+++ src/overtone/sc/buffer.clj
@@ -1,5 +1,6 @@
 (ns overtone.sc.buffer
-  (:use [overtone.util lib]
+  (:use [overtone.helpers file]
+        [overtone.util lib]
         [overtone.libs event]
         [overtone.sc server]
         [overtone.sc.machinery defaults allocator]
@@ -142,22 +143,94 @@
        (last (:args (deref! prom))))))

 (defn buffer-save
-  "Save the float audio data in an audio buffer to a wav file."
+  "Save the float audio data in buf to a file in the specified path on the
+  filesystem. The following options are also available (note: not all header
+  and sample combinations work - incorrect combinations will fail silently):
+
+   :header      - Header format: \"aiff\", \"next\", \"wav\", \"ircam\", \"raw\"
+                  Default \"wav\"
+   :samples     - Sample format: \"int8\", \"int16\", \"int24\", \"int32\",
+                                 \"float\", \"double\", \"mulaw\", \"alaw\"
+                  Default \"int16\"
+   :n-frames    - Number of frames to write. If < 0 then all frames from
+                  start-frame to the end of the buffer are written
+                  Default -1
+   :start-frame - starting frame in buffer (0 is the start of the buffer)
+                  Default 0
+
+   Example usage:
+   (buffer-save buf \"~/Desktop/foo.wav\" :header \"aiff\" :samples \"int32\"
+                                          :start-frame 100)"
   [buf path & args]
   (assert (buffer? buf))

-  (let [arg-map (merge (apply hash-map args)
+  (let [path (resolve-tilde-path path)
+        arg-map (merge (apply hash-map args)
                        {:header "wav"
-                        :samples "float"
-                        :size -1
-                        :start-frame 0
-                        :leave-open 0})
-        {:keys [header samples n-frames start-frame leave-open]} arg-map]
+                        :samples "int16"
+                        :n-frames -1
+                        :start-frame 0})
+        {:keys [header samples n-frames start-frame]} arg-map]

     (snd "/b_write" (:id buf) path header samples
-         n-frames start-frame
-         (floatify-truth leave-open))
+                    n-frames start-frame 0)
     :done))
+
+(defn buffer-stream
+  "Returns a buffer-stream which is similar to a regular buffer but may be used
+  with the disk-out ugen to stream to a specific file on disk.
+  Use #'buffer-stream-close to close the stream to finish recording to disk.
+
+  Options:
+
+  :n-chans     - Number of channels for the buffer
+                 Default 2
+  :size        - Buffer size
+                 Default 65536
+  :header      - Header format: \"aiff\", \"next\", \"wav\", \"ircam\", \"raw\"
+                 Default \"wav\"
+  :samples     - Sample format: \"int8\", \"int16\", \"int24\", \"int32\",
+                                \"float\", \"double\", \"mulaw\", \"alaw\"
+                 Default \"int16\"
+
+  Example usage:
+  (buffer-stream \"~/Desktop/foo.wav\" :n-chans 1 :header \"aiff\"
+                                       :samples \"int32\")"
+
+  [path & args]
+  (let [path (resolve-tilde-path path)
+        arg-map (merge (apply hash-map args)
+                       {:n-chans 2
+                        :size 65536
+                        :header "wav"
+                        :samples "int16"})
+        {:keys [n-chans size header samples]} arg-map
+        buf (buffer size n-chans)]
+    (snd "/b_write" (:id buf) path header samples -1 0 1)
+    (with-meta
+      (assoc buf
+        :path path
+        :open? (atom true))
+      {:type ::buffer-stream})))
+
+(derive ::buffer-stream ::buffer)
+
+(defn buffer-stream?
+  [bs]
+  (isa? (type bs) ::buffer-stream))
+
+(defn buffer-stream-close
+  "Close a buffer stream created with #'buffer-stream. Also frees the internal
+  buffer. Returns the path of the newly created file."
+  [buf-stream]
+  (assert (buffer-stream? buf-stream))
+  (when-not @(:open? buf-stream)
+    (throw (Exception. "buffer-stream already closed.")))
+
+  (snd "/b_close" (:id buf-stream))
+  (buffer-free buf-stream)
+  (reset! (:open? buf-stream) false)
+  (:path buf-stream))

 (defmulti buffer-id type)
 (defmethod buffer-id java.lang.Integer [id] id)


Fixed the doc of defaults in threadpool-service

--- src/riemann/service.clj
+++ src/riemann/service.clj
@@ -281,10 +281,10 @@
   "An ExecutorServiceService based on a ThreadPoolExecutor with core and
   maximum threadpool sizes, and a LinkedBlockingQueue of a given size. Options:

-  :core-pool-size             Default 0
-  :max-pool-size              Default 4
-  :keep-alive-time            Default 5
-  :keep-alive-unit            Default SECONDS
+  :core-pool-size             Default 1
+  :max-pool-size              Default 128
+  :keep-alive-time            Default 10
+  :keep-alive-unit            Default MILLISECONDS
   :queue-size                 Default 1000"
   ([name] (threadpool-service name {}))
   ([name {:keys [core-pool-size


Fix docstring convention issue

Fix docstring convention issue

--- src/riemann/streams.clj
+++ src/riemann/streams.clj
@@ -1467,7 +1467,6 @@
            ~@condp-clauses)))))

 (defn runs
-  [len-run field & children]
   "Usable to perform flap detection, runs examines a moving-event-window of
   n events and determines if :field is the same across all them. If it is,
   runs passes on the *first* event of the window. In practice, this can be
@@ -1475,6 +1474,7 @@
   state changes.

   (runs 3 :state prn) ; Print events where there are 3-in-a-row of a state."
+  [len-run field & children]
   (moving-event-window
     len-run
     (smap


scale wraps a common smap idiom

scale wraps a common smap idiom

--- src/riemann/streams.clj
+++ src/riemann/streams.clj
@@ -1199,6 +1199,15 @@
               event (assoc event field value)]
           (call-rescue event children))))
     (apply smap (first args) (rest args))))
+
+(defn scale
+  "Passes on a changed version of each event by multiplying each
+   metric with the input scale factor"
+  [factor & children]
+  (let [scale-event (fn [{:keys [metric] :as event}]
+                      (assoc event :metric
+                             (if metric (* metric factor))))]
+    (apply smap scale-event children)))

 (defn tag
   "Adds a new tag, or set of tags, to events which flow through.


use correct form

use correct form

--- src/riemann/streams.clj
+++ src/riemann/streams.clj
@@ -146,9 +146,9 @@
   "Returns a function which takes a seq of events.
   Combines events with f, then forwards the result to children."
   [f & children]
-  (deprecate "Combine is deprecated in favor of smap/smap*"
-             (fn stream [events]
-               (call-rescue (f events) children))))
+  (deprecated "Combine is deprecated in favor of smap/smap*"
+              (fn stream [events]
+                (call-rescue (f events) children))))

 (defn smap*
   "Streaming map: less magic. Calls children with (f event).


draw refacto

draw refacto

--- src/sandbox/fractal.clj
+++ src/sandbox/fractal.clj
@@ -8,43 +8,25 @@
   (vec (map #(apply yield %) (partition 2 1 (concat [0] pascal-row [0])))))

 (defn pascal-rows [yield row-number]
-  (take row-number (iterate (partial pascal-row-step yield) [1])))
+  (vec (take row-number (iterate (partial pascal-row-step yield) [1]))))

 (defn even-odd-yield
   [n1 n2]
-  (+ n1 n2))
+  (mod (+ n1 n2) 2))

 (def gr-triangles (partial pascal-rows even-odd-yield))

 (defn draw [size]
   (let [img (BufferedImage. size size BufferedImage/TYPE_INT_ARGB)
-;;=> Creating img as a Buffered Image
         plot-rows (gr-triangles size)
-;;=> computing the triangle of 0 and 1
         plots (for [x (range 0 size) y (range 0 x)]
                 (if (= 1 (get (get plot-rows x) y))
                   [x y]))
-;;=> we save the positions holding 1 in vectors. As the structure
-;; is triangular;
-;; the first counter, "x" goes up to "size", and the second one,
-;; "y",
-;;    goes up to "x"
         gfx (.getGraphics img)]
-;;=> we get the graphics component, where to draw from the Java
-;; Object.
     (.setColor gfx Color/WHITE)
     (.fillRect gfx 0 0 size size )
-;;=> we set a white background for the image.
     (.setColor gfx Color/BLACK)
-;;=> We set the pen color to black again
-    (doseq [p (filter (comp not nil?)  plots)]
-      (.drawLine gfx
-                 (get p 0)
-                 (get p 1)
-                 (get p 0)
-                 (get p 1)))
-;;=> We plot, by drawing a line from and to the same point.
-    (ImageIO/write img "png"
-                   (File. "result.png"))))
-;;=> and we save the image as a png in this location.
-;; Be sure to set a correct one when running on your machine !
+    (doseq [[x y] (filter (comp not nil?)  plots)]
+      (.drawLine gfx x y x y))
+    (ImageIO/write img "png" (File. "result.png"))))
+


Apply compatibility updates for latest ClojureScript

--- src/app/cljs/one/repmax/datastore_configuration/view.cljs
+++ src/app/cljs/one/repmax/datastore_configuration/view.cljs
@@ -1,5 +1,5 @@
 (ns one.repmax.datastore-configuration.view
-  (:use [domina.xpath :only (xpath)])
+  (:use [domina.xpath :only [xpath]])
   (:require-macros [one.repmax.snippets :as snippets])
   (:require [clojure.browser.event :as event]
             [domina :as d]


Removed :resource-paths from project.clj. Resources are now in the default location.

--- reports/project.clj
+++ reports/project.clj
@@ -19,6 +19,5 @@
                  [org.slf4j/slf4j-api "1.7.3"]
                  [org.slf4j/slf4j-simple "1.7.3"]]
   :plugins [[lein-ring "0.8.3"]]
-  :resource-paths ["src/resource"]
   :ring {:handler reports.core/app
          :init reports.core/init})