pprint in use

pprint in use

--- src/json_to_edn/core.cljs
+++ src/json_to_edn/core.cljs
@@ -5,7 +5,9 @@
             [om.dom :as dom]
             [cljs.core.async :refer [put! chan <!]]
             [clojure.string]
-            [cljs.reader]))
+            [cljs.reader]
+            [cljs.pprint :refer [write]])
+  (:import  [goog.string StringBuffer]))

 (enable-console-print!)

@@ -58,7 +60,11 @@

 (defn edn-str [edn]
   (if edn
-    (str edn)))
+    (let [sb (StringBuffer.)
+          writer (StringBufferWriter. sb)]
+      (write edn :pretty true :readably true :right-margin 48 :stream writer)
+      (println (.toString sb))
+      (.toString sb))))

 (def edn->json-str (comp json-str edn->json))
 (def json->edn-str (comp edn-str json->edn))
@@ -90,14 +96,13 @@
     (let [source-code (first (:code source))
           syntax-checker (source-key syntax-checkers)
           syntax-error (syntax-checker source-code)]
-      (println syntax-error)
       (dom/div #js {:className "source-header"}
         (dom/span #js {:className (css-classes "source-title" (if syntax-error "text-danger"))}
           (to-title source-key))
           (if syntax-error (dom/span #js {:className "badge"} "!"))))))

 (defn source-code
-  [{:keys [source is-editor?]} owner {:keys [source-key translation-fn translation-source translation-target]:as opts}]
+  [{:keys [source is-editor?]} owner {:keys [source-key translation-fn translation-source translation-target] :as opts}]
   (reify
     om/IWillMount
     (will-mount [_]
@@ -144,8 +149,9 @@
       (let [{:keys [json-chan edn-chan]} state
             editor (first (:editor app))]
         (dom/div #js {:className "container"}
-          (dom/h2 nil "JSON <-> EDN")
-          (markdown->om "resources/public/md/description.md" :container-opts #js {:className "row"})
+          (dom/h1 nil "JSON <-> EDN")
+          (markdown->om "resources/public/md/description.md"
+                        :container-opts #js {:className "row"})
           (dom/div #js {:className "row"}

             (om/build source-code {:is-editor? (= editor :json)
@@ -165,7 +171,8 @@
                   :translation-target edn-chan }}))
           (dom/div  (clj->js {:className "row"})
             (om/build controls app))
-          (markdown->om "resources/public/md/footer.md" :container-opts #js {:className "row footer"}))))))
+          (markdown->om "resources/public/md/footer.md"
+                        :container-opts #js {:className "row footer"}))))))

 (when-let [target (element-by-id "app")]
   (om/root main app-state {:target target}))


Remove unused imports.

Remove unused imports.

--- src/onyx/peer/task_lifecycle.clj
+++ src/onyx/peer/task_lifecycle.clj
@@ -1,5 +1,5 @@
 (ns ^:no-doc onyx.peer.task-lifecycle
-    (:require [clojure.core.async :refer [alts!! alt!! <!! >!! <! >! timeout chan close! thread go]]
+    (:require [clojure.core.async :refer [alts!! <!! >!! <! >! timeout chan close! thread go]]
               [com.stuartsierra.component :as component]
               [taoensso.timbre :refer [info error warn trace fatal] :as timbre]
               [onyx.static.rotating-seq :as rsc]
@@ -7,7 +7,6 @@
               [onyx.log.entry :as entry]
               [onyx.monitoring.measurements :refer [emit-latency emit-latency-value]]
               [onyx.static.planning :refer [find-task]]
-              [onyx.static.validation :as validation]
               [onyx.static.uuid :as uuid]
               [onyx.messaging.acking-daemon :as acker]
               [onyx.peer.task-compile :as c]
@@ -16,23 +15,14 @@
               [onyx.peer.function :as function]
               [onyx.peer.operation :as operation]
               [onyx.windowing.window-extensions :as we]
-              [onyx.windowing.window-id :as wid]
-              [onyx.windowing.units :as units]
               [onyx.windowing.aggregation :as agg]
               [onyx.triggers.triggers-api :as triggers]
               [onyx.extensions :as extensions]
-              [onyx.compression.nippy]
               [onyx.types :refer [->Ack ->Results ->MonitorEvent dec-count! inc-count! map->Event]]
               [onyx.peer.transform :refer [apply-fn]]
               [onyx.peer.grouping :as g]
               [onyx.flow-conditions.fc-routing :as r]
               [onyx.log.commands.peer-replica-view :refer [peer-site]]
-              [clj-tuple :as t]
-              [onyx.interop]
-              [onyx.state.log.bookkeeper]
-              [onyx.state.log.none]
-              [onyx.state.filter.set]
-              [onyx.state.filter.rocksdb]
               [onyx.state.state-extensions :as state-extensions]
               [onyx.static.default-vals :refer [defaults arg-or-default]]))


Fix issue where :checkpointed window state event would initialize tracking state with old replica-version, not new one.

--- src/onyx/peer/task_lifecycle.clj
+++ src/onyx/peer/task_lifecycle.clj
@@ -786,9 +786,13 @@
                                    (fn [v]
                                      (when (= :NodeDataChanged (:event-type v))
                                        (swap! track-checkpointed
-                                              merge
-                                              (select-keys (cp/read-checkpoint-coordinate log tenancy-id job-id)
-                                                           [:epoch :replica-version])))
+                                              (fn [tc]
+                                                (if-let [coord (cp/read-checkpoint-coordinate log tenancy-id job-id)]
+                                                  (if (= (:replica-version tc)
+                                                         (:replica-version coord))
+                                                    (merge tc (select-keys coord [:epoch :replica-version]))
+                                                    tc)
+                                                  tc))))
                                      (when (and (not @task-kill-flag)
                                                 (not @kill-flag))
                                        (setup-checkpoint-watch! event track-checkpointed))))
@@ -976,8 +980,9 @@
   (set-replica! [this new-replica]
     (set! replica new-replica)
     (let [new-version (get-in new-replica [:allocation-version (:onyx.core/job-id event)])]
+      (assert new-version)
       (when-not (= new-version replica-version)
-        (reset! track-checkpointed {:replica-version replica-version :epoch 0 :sealed-epoch 0})
+        (reset! track-checkpointed {:replica-version new-version :epoch 0 :sealed-epoch 0})
         (set-epoch! this initialize-epoch)
         (set! replica-version new-version)))
     this)


util/simpledb.clj: make get-simpledb a per-thread singleton

--- src/org/altlaw/util/simpledb.clj
+++ src/org/altlaw/util/simpledb.clj
@@ -1,4 +1,6 @@
 (ns org.altlaw.util.simpledb
+  (:require [org.altlaw.util.context :as context]
+            [clojure.contrib.singleton :as sing])
   (:import (com.xerox.amazonws.sdb SimpleDB ItemAttribute)
            (java.util ArrayList)))

@@ -35,13 +37,15 @@

 (def #^{:doc "Returns the (cached) SimpleDB object."}
      get-simpledb
-     (memoize (fn []
-                (SimpleDB. (System/getenv "AWS_ACCESS_KEY_ID")
-                           (System/getenv "AWS_SECRET_ACCESS_KEY")))))
+     (sing/per-thread-singleton
+      (fn []
+        (SimpleDB. (context/aws-access-key-id)
+                   (context/aws-secret-access-key)))))

 (def #^{:doc "Returns the (cached) SimpleDB Domain object for name."}
      get-domain
-     (memoize (fn [name] (.getDomain (get-simpledb) (keystr name)))))
+     (memoize
+      (fn [name] (.getDomain (get-simpledb) (keystr name)))))

 (defn- get-item
   "Returns the SimpleDB item object with the given name in the


small compatibility check for plugins

small compatibility check for plugins

--- src/lt/objs/platform.cljs
+++ src/lt/objs/platform.cljs
@@ -3,6 +3,8 @@
             [lt.objs.app :as app]
             [lt.util.dom :as dom])
   (:require-macros [lt.macros :refer [behavior]]))
+
+(def atom-shell true)

 (def clipboard (js/require "clipboard"))
 (def shell (js/require "shell"))


class ui improvments

class ui improvments

--- src/tango/cljs/runtime/core.cljs
+++ src/tango/cljs/runtime/core.cljs
@@ -199,8 +199,10 @@
       ;; - Startlist (participants)
       (log "Selected class")
       (log selected-class)
-      (dom/div nil
-        (dom/h2 {:className "sub-header"} "Create new class")
+      (dom/div #js {:className "col-sm-12"}
+        (dom/div #js {:className "col-sm-offset-3"}
+          (dom/h3 {:className " sub-header"} "Create new class"))
+
         (dom/div #js {:className "container"}
           (dom/div #js {:className "form-horizontal"}

@@ -258,7 +260,7 @@
                                                   reconciler
                                                   `[(app/select-page {:selected-page :dances})
                                                     :app/selected-page]))}
-                              (dom/span #js {:className "glyphicon glyphicon-plus"}))
+                              (dom/span #js {:className "glyphicon glyphicon-edit"}))
                   (dom/p nil (str "Dances : " (count (:class/dances selected-class)))))

                 (map #(dom/button #js {:className "col-sm-6 btn btn-default"}
@@ -277,7 +279,7 @@
                                                   `[(app/select-page {:selected-page :edit-class-participants})

                                                     :app/selected-page]))}
-                              (dom/span #js {:className "glyphicon glyphicon-plus"}))
+                              (dom/span #js {:className "glyphicon glyphicon-edit"}))
                   (dom/p nil (str "Starting : " (count (:class/starting selected-class)))))
                 ;(dom/ul nil)
                 (map #(dom/button #js {:className "col-sm-6 btn btn-default"}
@@ -286,9 +288,15 @@

             ;; Create
             (dom/div #js {:className "form-group"}
-              (dom/div #js {:className "col-sm-offset-2 col-sm-10"}
+              (dom/div #js {:className "col-sm-offset-2 col-sm-8"}
+                (dom/button #js {:className "btn btn-default"
+                                 :onClick   #(om/transact! this `[(app/select-page
+                                                                    {:selected-page :classes})
+                                                                  :app/selected-page])}
+                            (dom/span #js {:className "glyphicon glyphicon-arrow-left"})
+                            " Undo")
                 (dom/button
-                  #js {:className "btn btn-default"
+                  #js {:className "btn btn-primary col-sm-offset-8"
                        :type      "submit"
                        :onClick   (fn [e]
                                     (om/transact!
@@ -296,7 +304,8 @@
                                       `[(class/save {:class ~selected-class})
                                         (app/select-page {:selected-page :classes})
                                         :app/selected-page]))}
-                  "Save")))))
+                  (dom/span #js {:className "glyphicon glyphicon-ok"})
+                  " Save")))))
         ))))

 ;(dom/div #js {:className "container"}
@@ -454,35 +463,39 @@
       (log "SelectedClassParticipantsView")
       (log selected-class)
       (dom/div #js {:className "col-sm-12"}
-        (dom/h2 {:className "sub-header"} (str "Select Participants for Class "
-                                               (:class/name selected-class)))
-        (dom/div nil
-          (dom/button #js {:className (str "btn btn-default")
-                           :onClick   #()}
-                      (dom/span #js {:className "glyphicon glyphicon-arrow-left"}))
-
-          (dom/button #js {:className (str "btn btn-default")
-                           :onClick   #(om/transact! this `[(app/select-page {:selected-page :create-class})
-                                                            :app/selected-page])}
-                      (dom/span #js {:className "glyphicon glyphicon-ok"})))
-
-        (map #(dom/button #js {:className (str "col-sm-3 btn" (if (selected? %)
-                                                                " btn-primary"
-                                                                " btn-default"))
-                               :onClick   (fn [e]
-                                            (let [updated-starting
-                                                  (if (selected? %)
-                                                    (filter (fn [p]
-                                                              (not= (:participant/id p) (:participant/id %)))
-                                                            starting)
-                                                    (conj starting %))]
-                                              (om/transact!
-                                                reconciler
-                                                `[(class/update
-                                                    {:class/starting ~updated-starting})
-                                                  :app/selected-class])))}
-                          (str (:participant/number %) " - " (:participant/name %)))
-             participants)))))
+
+        (dom/div #js {:className "col-sm-12"}
+          (dom/div #js {:className "page-header"}
+            (dom/div #js {:className "btn-toolbar pull-right"}
+              (dom/div #js {:className "btn-group"}
+                (dom/button #js {:type      "button"
+                                 :className "btn btn-primary"
+                                 :onClick   #(om/transact!
+                                              this `[(app/select-page {:selected-page :create-class})
+                                                     :app/selected-page])}
+                            (dom/span #js {:className "glyphicon glyphicon-ok"})
+                            " Done")))
+            (dom/h2 nil (str "Select Participants for Class " (:class/name selected-class)))))
+
+        (dom/div #js {:className "col-sm-12"}
+
+          (map #(dom/button #js {:className (str "col-sm-3 btn" (if (selected? %)
+                                                                  " btn-primary"
+                                                                  " btn-default"))
+                                 :onClick   (fn [e]
+                                              (let [updated-starting
+                                                    (if (selected? %)
+                                                      (filter (fn [p]
+                                                                (not= (:participant/id p) (:participant/id %)))
+                                                              starting)
+                                                      (conj starting %))]
+                                                (om/transact!
+                                                  reconciler
+                                                  `[(class/update
+                                                      {:class/starting ~updated-starting})
+                                                    :app/selected-class])))}
+                            (str (:participant/number %) " - " (:participant/name %)))
+               participants))))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Import/Export Component
@@ -637,6 +650,15 @@

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; DancesView
+;

+;

+;

+;<button type='button' class='btn btn-primary'>Button Text</button>
+;

+;

+;
Header Text

+;

+
 (defui DancesView
   static om/IQuery
   (query [_]
@@ -647,24 +669,24 @@
     (let [dances (:dances (om/props this))
           ;{:keys [selected-class]} (om/get-computed this)
           selected-class (:selected-class (om/props this))
-          selected-dance (:selected-dance (om/props this))
-
-          ]
+          selected-dance (:selected-dance (om/props this))]
       (log "DancesView")
       (log dances)
       (log selected-dance)
       (dom/div #js {:className "col-sm-12"}
-        (dom/h2 {:className "sub-header"} "Dances")
-
-        (dom/div nil
-          (dom/button #js {:className (str "btn btn-default")
-                           :onClick   #()}
-                      (dom/span #js {:className "glyphicon glyphicon-arrow-left"}))
-
-          (dom/button #js {:className (str "btn btn-default")
-                           :onClick   #(om/transact! this `[(app/select-page {:selected-page :create-class})
-                                                            :app/selected-page])}
-                      (dom/span #js {:className "glyphicon glyphicon-ok"})))
+
+        (dom/div #js {:className "col-sm-12"}
+          (dom/div #js {:className "page-header"}
+            (dom/div #js {:className "btn-toolbar pull-right"}
+              (dom/div #js {:className "btn-group"}
+                (dom/button #js {:type      "button"
+                                 :className "btn btn-primary"
+                                 :onClick   #(om/transact!
+                                              this `[(app/select-page {:selected-page :create-class})
+                                                     :app/selected-page])}
+                            (dom/span #js {:className "glyphicon glyphicon-ok"})
+                            " Done")))
+            (dom/h1 nil "Dances")))

         (dom/div #js {:className "col-sm-6"}
           (dom/div #js {:className "col-sm-12"}


Unmemoize etiquette.

Unmemoize etiquette.

Create memoized-etiquette and use it in bad-manners.

--- src/manners/victorian.clj
+++ src/manners/victorian.clj
@@ -66,9 +66,9 @@
            (first)
            (sequence)))))

-(defn- unmemoized-etiquette
-  "Return a memoized function which takes a value to run the given etiquette
-  on."
+(defn etiquette
+  "Create a function from a an etiquette which returns a lazy sequence of bad
+  manners."
   [etq]
   {:pre [((some-fn sequential? coach?) etq)]}
   (if (coach? etq)
@@ -83,22 +83,20 @@
                      (keep identity)
                      (distinct))))))

-;; The actual definition of coach is memoized so that when the same etiquette is
-;; passed in we do not generate a new memoized function.
-(def etiquette
-  "Create a function from a an etiquette which returns a lazy sequence of bad
-  manners."
-  (memoize unmemoized-etiquette))
-
 (defn manners
   "Creates a coach from one or more manners or coaches."
   [& manners-and-coaches]
   (etiquette manners-and-coaches))

+(def memoized-etiquette
+  "A memoized version of etiquette. Note that the coach etiquette returns will
+  be memoized without using memoized-etiquette."
+  (memoize etiquette))
+
 (defn bad-manners
   "Return all bad manners found with the given etiquette on the given value."
   [etq value]
-  ((etiquette etq) value))
+  ((memoized-etiquette etq) value))

 (defn proper?
   "A predicate to determine if the given value has any bad manners according to the


don't walk the state to replate tempids if there are no tempids to replace

--- src/tudu/ui.cljs
+++ src/tudu/ui.cljs
@@ -169,7 +169,9 @@
   (clojure.walk/prewalk #(if (om.tempid/tempid? %) (get tid->rid %) %) state))

 (defn tempid-migrate [pure query tempids id-key]
-  (resolve-tempids pure tempids))
+  (if (empty? tempids)
+    pure
+    (resolve-tempids pure tempids)))

 (defonce reconciler (om/reconciler
                       {:state initial-state


Change Route Back to a PUT

Change Route Back to a PUT

Reflects the change of the front end from
a form submission to an ajax request. Issue #3

--- src/movie_app/handler.clj
+++ src/movie_app/handler.clj
@@ -22,7 +22,7 @@
              (cc/GET "/movie/:id" [id] (response/get-movie-entry id))
              (cc/GET "/review" [] (response/get-review-list))
              (cc/GET "/review/:id" [id] (response/get-review-entry id))
-             (cc/POST "/review/:id" {params :params} (response/update-review params))
+             (cc/PUT "/review/:id" {params :params} (response/update-review params))
              (route/resources "/")
              (route/not-found "Not Found")))


emiting errors to stderr fixing vim buffer support and adding context to errors

--- src/node_cljfmt/main.cljs
+++ src/node_cljfmt/main.cljs
@@ -37,8 +37,12 @@
     (.call (aget stdin "setEncoding") stdin "utf8")
     (.call (aget stdin "on") stdin "readable" (fn [] (if-let [s (.call (aget stdin "read") stdin)] (swap! content str s))))
     (.call (aget stdin "on") stdin "end" (fn []
-                                           (let [formatted (cljfmt/reformat-string @content opts)]
-                                             (.log js/console formatted))))))
+                                           (try
+                                             (let [formatted (cljfmt/reformat-string @content opts)]
+                                               (.log js/console formatted)) s
+                                             (catch :default e
+                                               (.log js/console @content)
+                                               (.error js/console e)))))))

 (defn -main []
   (let [parsed (parse-args (aget js/process "argv"))


Update checkpoint to include partition.

Update checkpoint to include partition.

--- src/onyx/plugin/kafka.clj
+++ src/onyx/plugin/kafka.clj
@@ -38,10 +38,10 @@
   (let [policy (:kafka/offset-reset task-map)
         start-offsets (:kafka/start-offsets task-map)]
     (doseq [kpartition kpartitions]
-      (cond checkpoint
-            (do
-              (info log-prefix "Seeking to checkpointed offset at:" (inc checkpoint))
-              (seek-to-offset! consumer {:topic topic :partition kpartition} (inc checkpoint)))
+      (cond (get checkpoint kpartition)
+            (let [offset (get checkpoint kpartition)]
+              (info log-prefix "Seeking to checkpointed offset at:" (inc offset))
+              (seek-to-offset! consumer {:topic topic :partition kpartition} (inc offset)))

             start-offsets
             (let [offset (get start-offsets kpartition)]
@@ -129,7 +129,7 @@
 (deftype KafkaReadMessages
   [log-prefix task-map topic ^:unsynchronized-mutable kpartitions batch-timeout
    deserializer-fn segment-fn read-offset ^:unsynchronized-mutable consumer
-   ^:unsynchronized-mutable iter ^:unsynchronized-mutable offset ^:unsynchronized-mutable drained]
+   ^:unsynchronized-mutable iter ^:unsynchronized-mutable partition->offset ^:unsynchronized-mutable drained]
   p/Plugin
   (start [this event]
     (let [{:keys [kafka/group-id kafka/consumer-opts]} task-map
@@ -161,12 +161,12 @@

   p/Checkpointed
   (checkpoint [this]
-    offset)
+    partition->offset)

   (recover! [this replica-version checkpoint]
     (set! drained false)
     (set! iter nil)
-    (set! offset checkpoint)
+    (set! partition->offset checkpoint)
     (seek-offset! log-prefix consumer kpartitions task-map topic checkpoint)
     this)

@@ -183,15 +183,16 @@
   (poll! [this _]
     (if (and iter (.hasNext ^java.util.Iterator iter))
       (let [rec ^ConsumerRecord (.next ^java.util.Iterator iter)
-            new-offset (if rec (.offset rec) offset)
             deserialized (some-> rec segment-fn)]
-        (if (= :done deserialized)
-          (do (set! drained true)
-              nil)
-          (do
-           (.set ^AtomicLong read-offset new-offset)
-           (set! offset new-offset)
-           deserialized)))
+        (cond (= :done deserialized)
+              (do (set! drained true)
+                  nil)
+              deserialized
+              (let [new-offset (.offset rec)
+                    part (.partition rec)]
+                (.set ^AtomicLong read-offset new-offset)
+                (set! partition->offset (assoc partition->offset part new-offset))
+                deserialized)))
       (do (set! iter
                 (.iterator ^ConsumerRecords
                            (.poll ^Consumer (.consumer ^FranzConsumer consumer)


minor styling

minor styling

--- src/quick_chess/core.cljs
+++ src/quick_chess/core.cljs
@@ -164,7 +164,10 @@
                default-keybindings)]
       (reduce
        (fn [hmap [[row col] char]]
-         (update-in hmap [:board row col] assoc :color color :text char))
+         (update-in hmap [:board row col]
+                    assoc
+                    :color color
+                    :text char))
        state
        pos->str))))


reversing expiry and timeout order

reversing expiry and timeout order

--- src/celestial/jobs.clj
+++ src/celestial/jobs.clj
@@ -38,7 +38,7 @@
     (let [{:keys [wait-time expiry]} (map-vals (or (get* :celestial :job) defaults) #(* minute %) )]
       (try
        (if identity
-         (do (with-lock (server-conn) identity wait-time expiry (apply f args)) {:status :success})
+         (do (with-lock (server-conn) identity expiry wait-time (apply f args)) {:status :success})
          (do (apply f args) {:status :success}))
        (catch Throwable e (error e) {:status  :error}))))))


try to get a new file on upload completion

--- src/frontend/core.cljs
+++ src/frontend/core.cljs
@@ -80,15 +80,20 @@
              i 0]
         (if (>= i (count (:music-info @app-state)))
           nil
-          (let [music-info (nth (:music-info @app-state) track-num)
-                track-id (.-id music-info)]
-            (if-not (is-track-downloaded? track-id)
-              track-id
-              (if (< track-num (count (:music-info @app-state)))
-                (recur (+ 1 track-num)
-                       (+ 1 i))
-                (recur 0
-                       (+ 1 i))))))))))
+          (if (< track-num (count (:music-info @app-state)))
+            (let [music-info (nth (:music-info @app-state) track-num)
+                  track-id (.-id music-info)]
+              (if-not (is-track-downloaded? track-id)
+                track-id
+                  (recur (+ 1 track-num)
+                         (+ 1 i))))
+              (recur 0
+                     (+ 1 i))))))))
+
+(defn request-new-track []
+  (let [id (get-next-track-to-download)]
+    (if-not (nil? id)
+      (.emit socket "file-download-request" id))))

 (defn pause []
   (.pause js/soundManager current-sound-id)
@@ -174,10 +179,9 @@
   (fn [music-info]
     (swap! app-state assoc :music-info
       (merge (:music-info @app-state) music-info))
+
     (if-not (:is-file-downloading? @app-state)
-      (let [id (get-next-track-to-download)]
-        (if-not (nil? id)
-          (.emit socket "file-download-request" id))))))
+      (request-new-track))))

 (.on (new js/ss socket) "file-download"
   (fn [stream track-id file-size]
@@ -204,7 +208,7 @@
         (swap! app-state assoc :is-file-downloading? false)
         (swap! app-state assoc :download-progress nil)
         (swap! app-state assoc :data-downloaded 0)
-
+        (request-new-track)
         (if (= (:current-track-id @app-state) track-id)
           (.emit socket "ready-to-start"))))))


heads pointing down

heads pointing down

--- src/lights/my_show.clj
+++ src/lights/my_show.clj
@@ -391,16 +391,6 @@
         (show/fixtures-named "head") #(= (:type %) :shutter))))
 )

-(defn london-init
-  "Init of London show"
-  []
-  (midi-help "automap")
-  (midi-help "audio6")
-  (shutter-open)
-  )
-
-(london-init)
-
 (defn calibrate-heads
   "Helper functions to calibrate heads"
   []
@@ -414,8 +404,8 @@
       "Tilt" (params/build-variable-param :tilt)
       (afterglow.channels/extract-channels
         (show/fixtures-named "head") #(= (:type %) :tilt))))
-  (afterglow.show/set-variable! :pan 0)
-  (afterglow.show/set-variable! :tilt 0)
+  (afterglow.show/set-variable! :pan 130)
+  (afterglow.show/set-variable! :tilt 120)
   )

 (defn head-direction-z
@@ -425,8 +415,19 @@

   (show/add-effect! :position
     (move/direction-effect
-     "Towards z" (params/build-direction-param :x 0 :y 0 :z 1) (show/fixtures-named "head")))
-  )
+     "Towards z" (params/build-direction-param :x 0 :y -1 :z 0) (show/fixtures-named "head")))
+  )
+
+(defn london-init
+  "Init of London show"
+  []
+  (midi-help "automap")
+  (midi-help "audio6")
+  (shutter-open)
+  (calibrate-heads)
+  )
+
+(london-init)

 (defn head-aim-center
   "Direct head to the center of dancefloor"


(SERVER-391) Return 503 on borrow error

(SERVER-391) Return 503 on borrow error

--- src/clj/puppetlabs/services/request_handler/request_handler_service.clj
+++ src/clj/puppetlabs/services/request_handler/request_handler_service.clj
@@ -3,18 +3,28 @@
             [puppetlabs.services.protocols.request-handler :as handler]
             [puppetlabs.services.request-handler.request-handler-core :as core]
             [puppetlabs.services.jruby.jruby-puppet-service :as jruby]
-            [puppetlabs.trapperkeeper.services :as tk-services]))
+            [puppetlabs.trapperkeeper.services :as tk-services]
+            [clojure.tools.logging :as log]))

 (defn- handle-request
-  [request jruby-service config]
-  (jruby/with-jruby-puppet jruby-puppet jruby-service
-    (core/handle-request request jruby-puppet config)))
+  [request jruby-service config puppet-version]
+  (try
+    (jruby/with-jruby-puppet jruby-puppet jruby-service
+                             (core/handle-request request jruby-puppet config))
+    (catch IllegalStateException e
+      (let [message (.getMessage e)]
+        (log/error message)
+        {:status  503
+         :body    message
+         :headers {"Content-Type"     "text/plain"
+                   "X-Puppet-version" puppet-version}}))))

 (tk/defservice request-handler-service
                handler/RequestHandlerService
-               [[:PuppetServerConfigService get-config]]
+               [[:PuppetServerConfigService get-config get-in-config]]
                (handle-request
                  [this request]
                  (let [jruby-service (tk-services/get-service this :JRubyPuppetService)
-                       config (core/config->request-handler-settings (get-config))]
-                   (handle-request request jruby-service config))))
+                       config (core/config->request-handler-settings (get-config))
+                       puppet-version (get-in-config [:puppet-server :puppet-version])]
+                   (handle-request request jruby-service config puppet-version))))


Wrap long line

Wrap long line

--- src/tabular/grafter/tabular/melt.clj
+++ src/tabular/grafter/tabular/melt.clj
@@ -120,7 +120,9 @@
                     col-count (count cols)]
                 (if (= 0 (mod col-count group-size))
                   (partition group-size cols)
-                  (throw (IllegalArgumentException. (str "Column group size should be a multiple of the number of non-fixed columns (" col-count ").")))))
+                  (throw (IllegalArgumentException.
+                          (str "Column group size should be a multiple of the "
+                               "number of non-fixed columns (" col-count ").")))))
               (partition (count output-column-names) cols))
             (build-row [cols row]
               (let [col-map (zipmap cols output-column-names)]


Improved dir list

Improved dir list

--- src/yada/resources/file_resource.clj
+++ src/yada/resources/file_resource.clj
@@ -17,6 +17,8 @@
    [yada.protocols :as p]
    [yada.media-type :as mt])
   (:import [java.io File]
+           [java.nio.file Files]
+           [java.nio.file.attribute PosixFileAttributeView PosixFilePermissions]
            [java.util Date TimeZone]
            [java.text SimpleDateFormat]
            [java.nio.charset Charset]))
@@ -94,30 +96,40 @@
              (str (.getName child) \newline)))

     "text/html"
-    (with-newline
-      (html
-       [:html
-        [:head
-         [:title (.getName dir)]]
-        [:body
-         [:table {:style "font-family: monospace"}
-          [:thead
-           [:tr
-            [:th "Name"]
-            [:th "Size"]
-            [:th "Last modified"]]]
-          [:tbody
-           (for [child (sort (.listFiles dir))]
+    (let [path (.toPath dir)]
+      (with-newline
+        (html
+         [:html
+          [:head
+           [:title (.getName dir)]
+           [:style "th {font-family: sans-serif} td {font-family: monospace} td, th {border-bottom: 1px solid #aaa; padding: 4px} a {text-decoration: none} td.monospace {font-family: monospace; }"]]
+
+          [:body
+           [:table {:style "border-spacing: 14px; border: 1px solid black; border-collapse: collapse"}
+            #_[:thead
              [:tr
-              [:td [:a {:href (if (.isDirectory child) (str (.getName child) "/") (.getName child))} (.getName child)]]
-              [:td {:style "align: right"}
-               (if (.isDirectory child) "" (.length child))]
-              [:td (.format
-                    (doto (SimpleDateFormat. "yyyy-MM-dd HH:mm:ss zzz")
-                      (.setTimeZone (TimeZone/getTimeZone "UTC")))
-                    (java.util.Date. (.lastModified child)))]])]]]]))))
-
-
+              [:th "Permissions"]
+              [:th "Owner"]
+              [:th "Size"]
+              [:th "Last modified"]
+              [:th "Name"]]]
+            [:tbody
+             (for [child (sort (.listFiles dir))
+                   :let [path (.toPath child)
+                         attrs (.readAttributes (Files/getFileAttributeView path PosixFileAttributeView (into-array java.nio.file.LinkOption [])))]]
+               [:tr
+                [:td.monospace (str (if (Files/isDirectory path (into-array java.nio.file.LinkOption [])) "d" "-") (PosixFilePermissions/toString (.permissions attrs)))]
+                [:td
+                 (.getName (.owner attrs))
+                 ]
+                [:td.monospace {:style "text-align: right"}
+                 (if (.isDirectory child) "" (.length child))]
+                [:td.monospace [:small (.format
+                                        (doto (SimpleDateFormat. "yyyy-MM-dd HH:mm:ss zzz")
+                                          (.setTimeZone (TimeZone/getTimeZone "UTC")))
+                                        (java.util.Date. (.lastModified child)))]]
+                [:td (let [href (if (.isDirectory child) (str (.getName child) "/") (.getName child))]
+                       [:a {:href href} (.getName child)])]])]]]])))))

 (defn dir-properties
   "Return properties of directory"
@@ -195,3 +207,5 @@
       (new-directory-resource f {})
       (new-file-resource f {})
       )))
+
+


Clean up tests substantially

Clean up tests substantially

--- test/comic_reader/sites_test.clj
+++ test/comic_reader/sites_test.clj
@@ -4,59 +4,66 @@
             [comic-reader.scrape :as scrape]
             [net.cgrand.enlive-html :as html]))

-(defn extract-comics-list-test []
+(deftest extract-comics-list-test
   (binding [options (read-site-options "manga-fox")]
-    (is (not= (comic-list-selector)
-              nil))
+    (are [selector] (is (not= (selector)
+                              nil))
+      chapter-number-match-pattern
+      page-list-selector
+      link-url-normalize
+      manga-pattern-match-portion
+      page-normalize-format
+      manga-list-format
+      page-normalize-pattern
+      chapter-number-pattern
+      comic->url-format
+      link-name-normalize
+      chapter-list-selector
+      manga-url-format
+      root-url
+      comic-list-selector
+      image-selector)

     (let [html (html/html [:div {}])
           comics (extract-comics-list html)]
       (is (= (seq comics)
              nil)))

-    (let [html (html/html-resource "test/manga_fox/comic_list.html")
-          url-list (scrape/extract-list html
-                                        (comic-list-selector)
-                                        identity)
-          comics (extract-comics-list html)]
-      (is (= (count url-list)
-             15))
+    (let [html (html/html-resource "test/manga_fox/comic_list.html")]
+      (let [url-list (scrape/extract-list html
+                                          (comic-list-selector)
+                                          identity)]
+        (is (= (count url-list)
+               15))

-      (is (= (first url-list)
-             '{:tag :a,
-               :attrs
-               {:href "http://mangafox.me/manga/6mm_no_taboo/",
-                :rel "4558",
-                :class "series_preview manga_open"},
-               :content ("-6mm no Taboo")}))
+        (is (= (first url-list)
+               '{:tag :a,
+                 :attrs
+                 {:href "http://mangafox.me/manga/6mm_no_taboo/",
+                  :rel "4558",
+                  :class "series_preview manga_open"},
+                 :content ("-6mm no Taboo")})))

-      (is (= clojure.core/first (link-name-normalize)))
+      (let [link-6mm '{:tag :a,
+                       :attrs
+                       {:href "http://mangafox.me/manga/6mm_no_taboo/",
+                        :rel "4558",
+                        :class "series_preview manga_open"},
+                       :content ("-6mm no Taboo")}]

-      (is (= (link->map '{:tag :a,
-                          :attrs
-                          {:href "http://mangafox.me/manga/6mm_no_taboo/",
-                           :rel "4558",
-                           :class "series_preview manga_open"},
-                          :content ("-6mm no Taboo")})
-             '{:name "-6mm no Taboo"
-               :url  "http://mangafox.me/manga/6mm_no_taboo/"}))
+        (is (= (link->map link-6mm)
+               '{:name "-6mm no Taboo"
+                 :url  "http://mangafox.me/manga/6mm_no_taboo/"}))

-      (is (= (comic-link-normalize '{:tag :a,
-                                     :attrs
-                                     {:href "http://mangafox.me/manga/6mm_no_taboo/",
-                                      :rel "4558",
-                                      :class "series_preview manga_open"},
-                                     :content ("-6mm no Taboo")})
-             '{:name "-6mm no Taboo",
-               :url "http://mangafox.me/manga/6mm_no_taboo/",
-               :id "6mm_no_taboo"}))
+        (is (= (comic-link-normalize link-6mm)
+               '{:name "-6mm no Taboo",
+                 :url "http://mangafox.me/manga/6mm_no_taboo/",
+                 :id "6mm_no_taboo"})))

-      (is (= (count comics)
-             15))
-      (is (= (first comics)
-             {:name "-6mm no Taboo",
-              :url "http://mangafox.me/manga/6mm_no_taboo/",
-              :id "6mm_no_taboo"})))))
-
-(deftest unit-tests
-  (extract-comics-list-test))
+      (let [comics (extract-comics-list html)]
+        (is (= (count comics)
+               15))
+        (is (= (first comics)
+               {:name "-6mm no Taboo",
+                :url "http://mangafox.me/manga/6mm_no_taboo/",
+                :id "6mm_no_taboo"}))))))


namespace removed

namespace removed

--- Clojure-Websockets/MainApp/src/clj/birdwatch/persistence/elastic.clj
+++ Clojure-Websockets/MainApp/src/clj/birdwatch/persistence/elastic.clj
@@ -1,7 +1,6 @@
 (ns birdwatch.persistence.elastic
   (:gen-class)
   (:require
-   [birdwatch.data :as d]
    [birdwatch.persistence.tools :as pt]
    [clojure.tools.logging :as log]
    [clojure.pprint :as pp]


time-format/parse barfs on nil; protect frontend against nil :trial-end in plans.

--- src-cljs/frontend/models/plan.cljs
+++ src-cljs/frontend/models/plan.cljs
@@ -27,7 +27,8 @@
   (boolean (:trial plan)))

 (defn trial-over? [plan]
-  (time/after? (time/now) (time-format/parse (:trial_end plan))))
+  (or (nil? (:trial_end plan))
+      (time/after? (time/now) (time-format/parse (:trial_end plan)))))

 (defn in-trial? [plan]
   (and (trial? plan) (not (trial-over? plan))))
@@ -76,7 +77,8 @@
 (defn days-left-in-trial
   "Returns number of days left in trial, can be negative."
   [plan]
-  (let [trial-end (time-format/parse (:trial_end plan))
+  (let [trial-end (when (:trial_end plan)
+                    (time-format/parse (:trial_end plan)))
         now (time/now)]
     (when (not (nil? trial-end))
       (if (time/after? trial-end now)
@@ -85,16 +87,17 @@
         (- (time/in-days (time/interval trial-end now)))))))

 (defn pretty-trial-time [plan]
-  (let [trial-interval (time/interval (time/now) (time-format/parse (:trial_end plan)))
-        hours-left (time/in-hours trial-interval)]
-    (cond (< 24 hours-left)
-          (str (days-left-in-trial plan) " days")
+  (when-not (nil? (:trial_end plan))
+    (let [trial-interval (time/interval (time/now) (time-format/parse (:trial_end plan)))
+          hours-left (time/in-hours trial-interval)]
+      (cond (< 24 hours-left)
+            (str (days-left-in-trial plan) " days")

-          (< 1 hours-left)
-          (str hours-left " hours")
+            (< 1 hours-left)
+            (str hours-left " hours")

-          :else
-          (str (time/in-minutes trial-interval) " minutes"))))
+            :else
+            (str (time/in-minutes trial-interval) " minutes")))))

 (defn per-container-cost [plan]
   (let [template-properties (or (-> plan :paid :template)


CMR-5444 Typo fix.

CMR-5444 Typo fix.

--- indexer-app/src/cmr/indexer/data/concepts/collection/collection_util.clj
+++ indexer-app/src/cmr/indexer/data/concepts/collection/collection_util.clj
@@ -12,7 +12,7 @@
     (catch Exception _ version-id)))

 (defn opendap-url?
-  "Determins if the related-url is a OPeNDAP service url."
+  "Determines if the related-url is a OPeNDAP service url."
   [related-url]
   (if (and (= (:URLContentType related-url)  "DistributionURL")
            (= (:Type related-url) "USE SERVICE API")


Add org name to the front of the NUX Bootstrap experience

before the reponame was just "circle", now it is "circleci / circle".
This should help mitigate confusion between forks.

--- src-cljs/frontend/components/dashboard.cljs
+++ src-cljs/frontend/components/dashboard.cljs
@@ -56,7 +56,7 @@
                                                                                index
                                                                                :checked)
                                                                                %)}]
-                                                   (:reponame project)]]))))
+                                                   (str (:username project)" / "(:reponame project))]]))))
                    deselect-activity-repos (fn [path]
                                              ((om/get-shared owner :track-event) {:event-type :deselect-all-projects-clicked
                                                                                :properties event-properties})


Remove newly-defunct test.

Remove newly-defunct test.

--- test/active/clojure/config_test.cljc
+++ test/active/clojure/config_test.cljc
@@ -239,15 +239,6 @@
            []
            {})))))

-(deftest reduce-scalar-config-settings-test
-  ;; basic
-  (is (= [[[:outer :inherits :foo] 5] [[:inherits :foo] 0]]
-         (c/reduce-scalar-config-settings schema3 (fn [range k res st]
-                                                    (conj res [k st]))
-                                          []
-                                          {:outer {:inherits {:foo 5}}}))))
-
-
 (deftest subconfig-test
   (let [config
         (c/make-configuration


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

--- test/emender_jenkins/config_test.clj
+++ test/emender_jenkins/config_test.clj
@@ -147,6 +147,15 @@
             (assoc-in-if-not-nil {:first {:left "L" :right "R"} :second {:left "L" :right "R"}} [:second :left] "***")  {:first {:left "L",   :right "R"},   :second {:left "***", :right "R"}}
             (assoc-in-if-not-nil {:first {:left "L" :right "R"} :second {:left "L" :right "R"}} [:second :right] "***") {:first {:left "L",   :right "R"},   :second {:left "L",   :right "***"}})))

+(deftest test-assoc-in-if-not-nil-6
+    "Check the behaviour of function emender-jenkins.config/assoc-in-if-not-nil."
+    (testing "the behaviour of function emender-jenkins.config/assoc-in-if-not-nil."
+        (are [x y] (= x y)
+            (assoc-in-if-not-nil {:first {:left "L" :right "R"} :second {:left "L" :right "R"}} [:first :left] nil)   {:first {:left "L", :right "R"}, :second {:left "L", :right "R"}}
+            (assoc-in-if-not-nil {:first {:left "L" :right "R"} :second {:left "L" :right "R"}} [:first :right] nil)  {:first {:left "L", :right "R"}, :second {:left "L", :right "R"}}
+            (assoc-in-if-not-nil {:first {:left "L" :right "R"} :second {:left "L" :right "R"}} [:second :left] nil)  {:first {:left "L", :right "R"}, :second {:left "L", :right "R"}}
+            (assoc-in-if-not-nil {:first {:left "L" :right "R"} :second {:left "L" :right "R"}} [:second :right] nil) {:first {:left "L", :right "R"}, :second {:left "L", :right "R"}})))
+
 (deftest test-print-configuration
     "Check the behaviour of function emender-jenkins.config/print-configuration."
         ; use mock instead of clojure.pprint/pprint


core.async: Fix `the-sentynil-value`.

core.async: Fix `the-sentynil-value`.

--- test/com/nomistech/clojure_the_language/core_async_mapping_etc_test.clj
+++ test/com/nomistech/clojure_the_language/core_async_mapping_etc_test.clj
@@ -132,7 +132,7 @@

 (def the-sentynil-value
   "A sentinel value that is put on channels instead of nil."
-  (cons nil nil))
+  ::sentynil)

 (defn nil->sentynil [x] (if (nil? x) the-sentynil-value x))


Lint/test fixes

Lint/test fixes

--- test/toucan/test_models/category.clj
+++ test/toucan/test_models/category.clj
@@ -20,7 +20,25 @@
   :in  maybe-lowercase-string
   :out maybe-lowercase-string)

-(models/defmodel Category :categories)
+(declare assert-parent-category-exists
+         delete-child-categories
+         add-category-to-moderation-queue!
+         add-category-to-updated-queue!)
+
+(models/defmodel Category :categories
+  models/IModel
+  (types [_]
+    {:name :lowercase-string})
+  (pre-insert [this]
+    (assert-parent-category-exists this))
+  (post-insert [this]
+    (add-category-to-moderation-queue! this))
+  (pre-update [this]
+    (assert-parent-category-exists this))
+  (post-update [this]
+    (add-category-to-updated-queue! this))
+  (pre-delete [this]
+    (delete-child-categories this)))

 (defn- assert-parent-category-exists [{:keys [parent-category-id], :as category}]
   (when parent-category-id
@@ -45,18 +63,3 @@

 (defn add-category-to-updated-queue! [{:keys [id]}]
   (swap! categories-recently-updated conj id))
-
-(extend-protocol models/IModel
-  CategoryInstance
-  (types [_]
-    {:name :lowercase-string})
-  (pre-insert [this]
-    (assert-parent-category-exists this))
-  (post-insert [this]
-    (add-category-to-moderation-queue! this))
-  (pre-update [this]
-    (assert-parent-category-exists this))
-  (post-update [this]
-    (add-category-to-updated-queue! this))
-  (pre-delete [this]
-    (delete-child-categories this)))


Clarify phases of UI updates.

Clarify phases of UI updates.

Be consistent in naming the rendering and update phases; the former
determines what should be shown, the latter sends it to the Push.

--- src/afterglow/controllers/ableton_push_2.clj
+++ src/afterglow/controllers/ableton_push_2.clj
@@ -1173,9 +1173,8 @@
     (.setPaint graphics color)
     (.fill graphics path)))

-(defn- update-metronome-section
-  "Updates the sections of the interface related to metronome
-  control."
+(defn- render-metronome-section
+  "Draws the sections of the interface related to metronome control."
   [controller snapshot]
   (let [marker (rhythm/snapshot-marker snapshot)
         metronome-button (:metronome control-buttons)
@@ -1516,7 +1515,7 @@
   (let [color (colors/desaturate (colors/create-color :blue) 70)]
     (java.awt.Color. (colors/red color) (colors/green color) (colors/blue color))))

-(defn- update-effect-list
+(defn- render-effect-list
   "Display information about the four most recently activated
   effects (or three, if the metronome is taking up a slot)."
   [controller snapshot]
@@ -1621,7 +1620,7 @@

 (declare enter-stop-mode)

-(defn- update-scroll-arrows
+(defn- render-scroll-arrows
   "Activate the arrow buttons for directions in which scrolling is
   possible."
   [controller]
@@ -1647,7 +1646,7 @@
       (swap! (:next-text-buttons controller)
              assoc (:up-arrow control-buttons) dim-white-color))))

-(defn- update-mode-buttons
+(defn- render-mode-buttons
   "Illuminate the buttons which activate modes while they are held
   down. Make them dim when not held, and bright when held."
   [controller mode-buttons]
@@ -1680,17 +1679,17 @@
     (reset! (:next-touch-strip controller) [0 touch-strip-mode-sysex])

     (let [snapshot (rhythm/metro-snapshot (get-in controller [:show :metronome]))]
-      (update-effect-list controller snapshot)
-      (update-metronome-section controller snapshot)
+      (render-effect-list controller snapshot)
+      (render-metronome-section controller snapshot)

       ;; If the show has stopped without us noticing, enter stop mode
       (with-show (:show controller)
         (when-not (or (show/running?) (in-mode? controller :stop))
           (enter-stop-mode controller :already-stopped true)))

-      (update-mode-buttons controller [:shift :record])
+      (render-mode-buttons controller [:shift :record])
       (render-cue-grid controller snapshot)
-      (update-scroll-arrows controller)
+      (render-scroll-arrows controller)

       ;; Make the User button bright, since we live in User mode
       (swap! (:next-text-buttons controller) assoc (:user-mode control-buttons) white-color)


Removed bitrate

Removed bitrate

--- src/video_server/html.clj
+++ src/video_server/html.clj
@@ -40,7 +40,6 @@
                      (:video container)
                      (:audio container)
                      (format-size (:size container))
-                     (format-bitrate (:bitrate container))
                      (format-filetype (:filetype container))]
                     (remove str/blank?)
                     (map #(vector :td %)))])))


Bump Elastisch to 2.1.0-beta7

Bump Elastisch to 2.1.0-beta7

--- joplin.elasticsearch/project.clj
+++ joplin.elasticsearch/project.clj
@@ -6,6 +6,6 @@
   :license {:name "Eclipse Public License"
             :url "http://www.eclipse.org/legal/epl-v10.html"}
   :dependencies [[org.clojure/clojure "1.6.0"]
-                 [clojurewerkz/elastisch "2.1.0-beta6"]
+                 [clojurewerkz/elastisch "2.1.0-beta7"]
                  [joplin.core "0.1.12-SNAPSHOT"]
                  [clj-time "0.7.0"]])


Review changes PT2

Review changes PT2

--- src/clj/collect_earth_online/db/projects.clj
+++ src/clj/collect_earth_online/db/projects.clj
@@ -21,6 +21,15 @@

 (def tmp-dir  (System/getProperty "java.io.tmpdir"))
 (def path-env (System/getenv "PATH"))
+
+;;;
+;;; Helper function
+;;;
+
+(defn- remove-vector-items [coll & items]
+  (->> coll
+       (remove (set items))
+       (vec)))

 ;;;
 ;;; Auth functions
@@ -457,15 +466,15 @@
                                (update r :visible_id tc/val->int)
                                (dissoc r :lon :lat)))
                            (rest rows))]
-      (if (and (contains? header-keys :lon)
-               (contains? header-keys :lon))
-        [(dissoc header-keys :lon :lat) body]
+      (if (and (some #(= % :lon) header-keys)
+               (some #(= % :lat) header-keys))
+        [(remove-vector-items header-keys [:lon :lat]) body]
         (init-throw (str "The provided "
                          design-type
                          " CSV file must contain a LAT and LON column."))))))

 (defmethod get-file-data :default [distribution _ _ _]
-  (throw (str "No such distribution (" distribution ") defined for ollect-earth-online.db.projects/get-file-data")))
+  (throw (str "No such distribution (" distribution ") defined for collect-earth-online.db.projects/get-file-data")))

 (defn- check-headers [headers primary-key design-type]
   (let [header-diff     (set/difference (set primary-key) (set headers))
@@ -1009,11 +1018,6 @@
     (.format (SimpleDateFormat. "YYYY-MM-dd HH:mm")
              pg-time)))

-(defn- remove-vector-items [coll & items]
-  (->> coll
-       (remove (set items))
-       (vec)))
-
 ;;;
 ;;; Dump aggregate
 ;;;


Fix string escaping

Fix string escaping

--- src/clj/jest/compiler/NativeJestCompiler.clj
+++ src/clj/jest/compiler/NativeJestCompiler.clj
@@ -259,7 +259,7 @@

     (. ctx ID) (symbol (.. ctx ID getText))

-    (. ctx STRING) (.. ctx STRING getText)
+    (. ctx STRING) (read-string (.. ctx STRING getText))

     ;; TODO: Rename 'symbol' to 'keyword'
     (. ctx SYMBOL) (keyword (subs (.. ctx SYMBOL getText) 1)) ;;(keyword (.. ctx SYMBOL getText))


lookup earliest partition date on price select query

--- src/clj_money/models/storage/sql_storage.clj
+++ src/clj_money/models/storage/sql_storage.clj
@@ -283,10 +283,10 @@
     {:trade-date (t/local-date 2017 3 2)} - searches for the specified date
     {:trade-date [:between (t/local-date 2017 1 1) (t/local-date 2017 131)]} - searches the specified range, inclusively
     {:trade-date [:between nil (t/local-date 2017 3 2)]} - searches from the first available date to the specified date"
-  [{trade-date :trade-date}]
+  [{trade-date :trade-date} earliest-fn]
   (if (sequential? trade-date)
     (-> trade-date
-        (update-in [1] #(or % (to-sql-date (t/local-date 2015 1 1))))
+        (update-in [1] #(or % (to-sql-date (earliest-fn))))
         rest)
     [trade-date trade-date]))

@@ -520,9 +520,12 @@
     (.select-prices this criteria {}))

   (select-prices
-    [_ {trade-date :trade-date :as criteria} options]
+    [this {trade-date :trade-date :as criteria} options]
     (validate-criteria criteria ::price-criteria)
-    (let [[start end] (extract-trade-dates criteria)
+    (let [[start end] (extract-trade-dates criteria (fn []
+                                                      (or (when-let [v (.get-setting this "earliest-partition-date")]
+                                                            (read-string v))
+                                                          (t/local-date 2000 1 1))))
           tables (tables-for-range start
                                    end
                                    :prices


Improve naming.

Improve naming.

--- src/dsbdp/local_data_processing_pipeline.clj
+++ src/dsbdp/local_data_processing_pipeline.clj
@@ -74,9 +74,9 @@
     obj))

 (defmacro enqueue
-  [obj data enqueued-counter dropped-counter]
+  [q data enqueued-counter dropped-counter]
   (println "Enqueueing data via:")
-  (let [queue (add-type-hint obj)
+  (let [queue (add-type-hint q)
         expr (condp (fn [^String v ^String s] (.contains s v)) queue-setup
                "add-counted-yield" `(if (< (.size ~queue) queue-size)
                                       (do
@@ -155,9 +155,9 @@
       expr))

 (defmacro take-from-queue
-  [obj]
+  [q]
   (println "Retrieving data via:")
-  (let [queue (add-type-hint obj)
+  (let [queue (add-type-hint q)
         expr (condp (fn [^String v ^String s] (.endsWith s v)) queue-setup
                "remove-yield" `(if (not (.isEmpty ~queue))
                                  (.remove ~queue)


GAWB-1397: oops

GAWB-1397: oops

--- src/cljs/main/broadfcui/page/workspace/monitor/workflow_details.cljs
+++ src/cljs/main/broadfcui/page/workspace/monitor/workflow_details.cljs
@@ -68,7 +68,6 @@
         (if (:expanded @state)
           (.timingDiagram js/window (:data props) (:workflow-name props) nil)
           (when (.getElementById js/document "chart_div") (gdom/remove-children "chart_div")))])
-   :component-will-receive-props (fn [m] (swap! (:state m) identity))
    :component-did-update
    (fn [{:keys [props state]}]
      (if (:expanded @state)
@@ -80,13 +79,7 @@
              (gdom/remove-children "chart_div")
              (.timingDiagram js/window (:data props) (:workflow-name props) (+ 50 height))))
          0)
-       (when (.getElementById js/document "chart_div") (gdom/remove-children "chart_div"))))
-   :component-did-mount
-   (fn [state]
-     #_(js/setTimeout (fn [] (utils/log (.-childNodes (.getElementById js/document "chart_div")))) 2000)
-     ;;    (.querySelector {:aria-label "A chart."})
-     ;;(gdom/set-properties (.getElementsById js/document "chart_div") {:height (.get(.getElementsById js/document "chart_div"))} ))
-     )})
+       (when (.getElementById js/document "chart_div") (gdom/remove-children "chart_div"))))})

 (defn- backend-logs [data]
   (when-let [log-map (data "backendLogs")]


Fix bug in `wait-for-condition`...

Fix bug in `wait-for-condition`...

- Check for timeout before calling `test-fun`.

--- test/com/nomistech/clojure_the_language/c_850_utils/s_200_test_utils.clj
+++ test/com/nomistech/clojure_the_language/c_850_utils/s_200_test_utils.clj
@@ -73,12 +73,12 @@
                                            :priority true)]
                        (= c timeout)))]
     (loop [cnt 1]
-      (let [finished? (test-fun)]
-        (when debug? (println "cnt =" cnt "time =" (System/currentTimeMillis)))
-        (if finished?
-          finished?
-          (if (timed-out?)
-            false
+      (if (timed-out?)
+        false
+        (let [finished? (test-fun)]
+          (when debug? (println "cnt =" cnt "time =" (System/currentTimeMillis)))
+          (if finished?
+            finished?
             (do
               (a/<!! (a/timeout delay-ms))
               (recur (inc cnt)))))))))
@@ -107,7 +107,8 @@

   (fact "timeout when `test-fun` always returns logical false"
     (wait-for-condition (fn [] (rand-nth [nil false]))
-                        :timeout-ms 70)
+                        :timeout-ms 70 ; make this test run fast
+                        )
     => false)

   (fact "correct call count when `test-fun` always returns logical false"
@@ -115,7 +116,18 @@
           res (wait-for-condition (fn []
                                     (swap! cnt-atom inc)
                                     nil)
-                                  :timeout-ms 70)]
+                                  :timeout-ms 70 ; make this test run fast
+                                  )]
       [res @cnt-atom])
     => (just [false
-              #(<= % 3)])))
+              #(<= % 3)]))
+
+  (fact "`:delay-ms` works"
+    (let [cnt-atom (atom 0)
+          res (wait-for-condition (fn []
+                                    (swap! cnt-atom inc)
+                                    nil)
+                                  :timeout-ms 70 ; make this test run fast
+                                  :delay-ms  100)]
+      [res @cnt-atom])
+    => [false 1]))


check for (get-string) returning nil

check for (get-string) returning nil

--- src/babel/francais/morphology.cljc
+++ src/babel/francais/morphology.cljc
@@ -34,6 +34,7 @@

         ;; je + aime = j'aime
         (and (not (nil? b))
+             (not (nil? (get-string b)))
              (let [a (get-string word)
                    b (get-string b)]
                (and (re-find #"^(je)$" a)


comment out non-existant style from mobile style

--- src/braid/client/mobile/style.cljs
+++ src/braid/client/mobile/style.cljs
@@ -135,7 +135,7 @@
               [:.badge
                {:font-size "0.8rem"}]])]]

-         braid.client.ui.styles.misc/tag
+         ;braid.client.ui.styles.misc/tag

          [:.page
           {:position "absolute"


Use dangerouslySetINnerHTML for component-css rendering

--- src/cljs/comic_reader/ui/component_css.cljs
+++ src/cljs/comic_reader/ui/component_css.cljs
@@ -28,4 +28,6 @@
     (vals css)))

 (defn component-css []
-  [:style (g/css (component-garden-css))])
+  [:style {:dangerouslySetInnerHTML
+           {:__html
+            (g/css (component-garden-css))}}])


Use the correct operator for tag array comparison

This was previously using an incorrect operator. Using the correct
operator seems better.

--- src/com/puppetlabs/puppetdb/scf/storage.clj
+++ src/com/puppetlabs/puppetdb/scf/storage.clj
@@ -78,7 +78,7 @@

 (defmethod sql-array-query-string "PostgreSQL"
   [column]
-  (format "ARRAY[?::text] = %s" column))
+  (format "ARRAY[?::text] <@ %s" column))

 (defmethod sql-array-type-string "HSQL Database Engine"
   [basetype]


Cmr-3376: Added another test for completeness.

--- system-int-test/test/cmr/system_int_test/ingest/translation_test.clj
+++ system-int-test/test/cmr/system_int_test/ingest/translation_test.clj
@@ -85,8 +85,10 @@
             output-format :umm-json
             options {:skip-sanitize-umm-c true :query-params {:skip_umm_validation true}}
             input-xml (umm-spec/generate-metadata test-context expected-conversion/example-collection-record input-format)
-            {:keys [status]} (ingest/translate-metadata :collection input-format input-xml
-                                                                    output-format options)]
+            {:keys [status body]} (ingest/translate-metadata :collection input-format input-xml
+                                                                         output-format options)
+            parsed-umm-json (umm-spec/parse-metadata test-context :collection output-format body)]
+        (is (= nil (:DataCenters parsed-umm-json)))
         (is (= 200 status))))

     (testing (format "Translating iso19115 to dif10 with skipping sanitizing")


add some todo comments

add some todo comments

--- src/chat/client/views/message.cljs
+++ src/chat/client/views/message.cljs
@@ -161,6 +161,9 @@
   (reify
     om/IDidMount
     (did-mount [_]
+      ; TODO: use prettyPrintOne to only do the content of this node
+      ; TODO: also call on IDidUpdate?
+      ; TODO: don't call if don't have code?
       (when-let [PR (aget js/window "PR")]
         ((aget PR "prettyPrint"))))
     om/IRender


Ignore interruptions when reading *in*

Ignore interruptions when reading *in*

Previously this would blow up the whole repl

--- src/clj/reply/eval_modes/nrepl.clj
+++ src/clj/reply/eval_modes/nrepl.clj
@@ -64,14 +64,17 @@
     (doseq [{:keys [ns value out err] :as res}
             (take-while
               #(not (and (= command-id (:id %))
-                         (some #{"done" "interrupted" "error"} (:status %))))
+                         (some #{"done" "interrupted" "error" "eval-error"} (:status %))))
               (filter identity (session-responses session)))]
       (when (some #{"need-input"} (:status res))
+        (reset! current-command-id nil)
         (let [input-result (safe-read-line {:no-jline true
-                                            :prompt-string ""})]
-          (session-sender
-            {:op "stdin" :stdin (str input-result "\n")
-             :id (nrepl.misc/uuid)})))
+                                            :prompt-string ""})
+              in-message-id (nrepl.misc/uuid)
+              message {:op "stdin" :stdin (str input-result "\n")
+                       :id in-message-id}]
+          (session-sender message)
+          (reset! current-command-id command-id)))
       (when value ((:value options print) value))
       (flush)
       (when (and ns (not (:session options)))
@@ -198,8 +201,9 @@
         session            (nrepl/new-session client)
         completion-session (nrepl/new-session client)]
     (reset! current-session session)
-    (swap! response-queues assoc session (LinkedBlockingQueue.))
-    (swap! response-queues assoc completion-session (LinkedBlockingQueue.))
+    (swap! response-queues assoc
+           session (LinkedBlockingQueue.)
+           completion-session (LinkedBlockingQueue.))
     (let [options (assoc options :prompt
                     (fn [ns] (str ns "=> ")))
           options (if (:color options)


RR: indentation

RR: indentation

--- src/cljs/hatti/views/dataview.cljs
+++ src/cljs/hatti/views/dataview.cljs
@@ -72,7 +72,7 @@
     (when (contains? (set views) view)
       (shared/transact-app-state! shared/app-state
                                   [:views :selected]
-                                    (fn [_] view))
+                                  (fn [_] view))
       (put! shared/event-chan {:re-render view}))))

 (defmethod tabbed-dataview :default


Rearrange code in message namespace (WIP)

I've eliminated the circular dependencies between the scheduling
function and the trigger functions that it calls. Moved them above it so
I don't have declare them.

--- src/clojure/frereth_cp/message.clj
+++ src/clojure/frereth_cp/message.clj
@@ -79,6 +79,21 @@
       deref
       ::specs/message-loop-name
       utils/pre-log))
+
+(defn build-un-ackd-blocks
+  []
+  (sorted-set-by (fn [x y]
+                   (let [x-time (::specs/time x)
+                         y-time (::specs/time y)]
+                     (if (= x-time y-time)
+                       ;; Assume that we never have multiple messages with the
+                       ;; same timestamp.
+                       ;; We do hit this case when disj is trying to
+                       ;; remove an existing block.
+                       0
+                       (if (< x-time y-time)
+                         -1
+                         1))))))

 ;;;; Q: what else is in the reference implementation?
 ;;;; A: Lots. Scattered around quite a bit now
@@ -133,6 +148,180 @@

 ;;;     634-643: try closing pipe to child: (DJB)
 ;;;         Well, maybe. If we're done with it
+
+(s/fdef trigger-output
+        :args (s/cat :state ::specs/state)
+        :ret ::specs/state)
+(defn trigger-output
+  [{{:keys [::specs/->child]} ::specs/incoming
+    {:keys [::specs/next-action]} ::specs/flow-control
+    :keys [::specs/message-loop-name]
+    :as state}]
+  (let [prelog (utils/pre-log message-loop-name)]
+    (log/debug prelog "Triggering Output")
+    ;; Originally, it seemed like it would make sense to cancel
+    ;; the timer here, to avoid duplicating the call when I
+    ;; get input from either the parent or the child.
+    ;; Doing it that way entails too much delay. If the
+    ;; timer is running in a tight loop, it might trigger
+    ;; several more times before they get around to
+    ;; actually calling this.
+    (let [state
+          (as-> state state
+            (assoc state ::specs/recent (System/nanoTime))
+            ;; It doesn't make any sense to call this if
+            ;; we were triggered by a message coming in from
+            ;; the parent.
+            ;; Even if there pending blocks are ready to
+            ;; send, outgoing messages are throttled by
+            ;; the flow-control logic.
+            ;; Likewise, there isn't a lot of sense in
+            ;; calling it from the child, due to the same
+            ;; throttling issues.
+            ;; This really only makes sense when the
+            ;; timer triggers to let us know that it's
+            ;; OK to send a new message.
+            ;; The timeout on that may completely change
+            ;; when the child schedules another send,
+            ;; or a message arrives from parent to
+            ;; update the RTT.
+            (to-parent/maybe-send-block! state))]
+      ;; At the end of the main ioloop in the refernce
+      ;; implementation, there's a block that closes the pipe
+      ;; to the child if we're done.
+      ;; I think the point is that we'll quit polling on
+      ;; that and start short-circuiting out of the blocks
+      ;; that might do the send, once we've hit EOF
+      ;; Q: What can I do here to
+      ;; produce the same effect?
+      ;; TODO: Worry about that once the basic idea works.
+
+      ;; If the child sent a big batch of data to go out
+      ;; all at once, don't waste time setting up a timeout
+      ;; scheduler. The poll in the original would have
+      ;; returned immediately anyway.
+      ;; Except that n-sec-per-block puts a hard limit on how
+      ;; fast we can send.
+      (comment
+        (let [unsent-blocks-from-child? (from-child/blocks-not-sent? state)]
+          (if unsent-blocks-from-child?
+            (recur state)
+            (schedule-next-timeout! state))))
+      state)))
+
+(s/fdef trigger-from-child
+        :args (s/cat :array-o-bytes bytes?
+                     :state ::specs/state)
+        :ret ::specs/state)
+(defn trigger-from-child
+  [^bytes array-o-bytes
+   {{:keys [::specs/strm-hwm]
+     :as outgoing} ::specs/outgoing
+    :keys [::specs/message-loop-name]
+    :as state}]
+  {:pre [array-o-bytes]}
+  (let [prelog (utils/pre-log message-loop-name)]
+    (log/info prelog
+              "trigger-from-child\nSent stream address: "
+              strm-hwm)
+    (let [state' (if (from-child/room-for-child-bytes? state)
+                   (do
+                     (log/debug prelog
+                                "There is room for another message")
+                     (let [result (from-child/consume-from-child state array-o-bytes)]
+                       result))
+                   ;; trigger-output does some state management, even
+                   ;; if we discard the incoming bytes because our
+                   ;; buffer is full.
+                   ;; TODO: Need a way to signal the child to
+                   ;; try again shortly
+                   (do
+                     (log/error prelog
+                                "Discarding incoming bytes, silently")
+                     state))]
+      ;; TODO: check whether we can do output now.
+      ;; It's pointless to call this if we just have
+      ;; to wait for the timer to expire.
+      (let [state'' (trigger-output
+                     state')]
+        (log/debug prelog
+                   "Truly updating agent state due to input from child")
+        state''))))
+
+(s/fdef trigger-from-parent
+        :args (s/cat :array-o-bytes bytes?
+                     :specs/state ::specs/state)
+        :ret ::specs/state)
+(defn trigger-from-parent
+  "Message block arrived from parent. Agent has been handed work"
+  ;; TODO: Move as much of this as possible into from-parent
+  ;; The only reason I haven't already moved the whole thing
+  ;; is that we need to use to-parent to send the ACK, and I'd
+  ;; really rather not introduce dependencies between those namespaces
+  [^bytes message
+   {{:keys [::specs/->child]
+     :as incoming} ::specs/incoming
+    :keys [::specs/message-loop-name]
+    :as state}
+   ]
+  (let [prelog (utils/pre-log message-loop-name)]
+    (when-not ->child
+      (throw (ex-info (str prelog
+                           "Missing ->child")
+                      {::detail-keys (keys incoming)
+                       ::top-level-keys (keys state)
+                       ::details state})))
+
+    (log/debug prelog "Incoming from parent")
+
+    ;; This is basically an iteration of the top-level
+    ;; event-loop handler from main().
+    ;; I can skip the pieces that only relate to reading
+    ;; from the child, because I'm using an active callback
+    ;; approach, and this was triggered by a block of
+    ;; data coming from the parent.
+
+    ;; However, there *is* the need to handle packets that the
+    ;; child has buffered up to send to the parent.
+
+    ;; Except that we can't do this here/now. That part's
+    ;; limited by the flow-control logic (handled by the
+    ;; timer) and the callbacks arriving from the child.
+    ;; It seems like we probably should cancel/reschedule,
+    ;; since whatever ACK just arrived might adjust the RTT
+    ;; logic.
+    (try
+      (let [pre-processed (from-parent/try-processing-message!
+                           (assoc-in state
+                                     [::specs/incoming ::specs/parent->buffer]
+                                     message))
+            state' (to-child/forward! ->child (or pre-processed
+                                                  state))]
+        ;; This will update recent.
+        ;; In the reference implementation, that happens immediately
+        ;; after trying to read from the child.
+        ;; Q: Am I setting up any problems for myself by waiting
+        ;; this long?
+        ;; i.e. Is it worth doing that at the top of the trigger
+        ;; functions instead?
+        (trigger-output state'))
+      (catch RuntimeException ex
+        (log/error ex
+                   (str prelog
+                        "Trying to cope with a message arriving from parent"))))))
+
+(defn trigger-from-timer
+  [{:keys [::specs/message-loop-name]
+    :as state}]
+  ;; It's really tempting to move this to to-parent.
+  ;; But (at least in theory) it could also trigger
+  ;; output to-child.
+  ;; So leave it be for now.
+  (log/debug (utils/pre-log message-loop-name) "I/O triggered by timer")
+  ;; I keep thinking that I need to check data arriving from
+  ;; the child, but the main point to this logic branch is
+  ;; to resend an outbound block that hasn't been ACK'd yet.
+  (trigger-output state))

 (defn choose-next-scheduled-time
   [{{:keys [::specs/n-sec-per-block
@@ -334,14 +523,7 @@
 ;;; Which...honestly also belongs in there.
 ;;; Q: How much more badly would this break things?
 ;;; TODO: Find out.
-(declare trigger-from-child
-         trigger-from-parent
-         trigger-from-timer)
-;; Those functions pretty much all require the
-;; full-blown state-wrapper parameter, since
-;; they recurse back into here.
-;; Pretty much nothing else anywhere should.
-;; TODO: Track that down and make it so.
+
 (s/fdef schedule-next-timeout!
         :args (s/cat :state-wrapper ::state-wrapper)
         :ret ::state-wrapper)
@@ -408,38 +590,45 @@
                                                       actual-next
                                                       (System/nanoTime)
                                                       success))
-                                (case tag
-                                  ::drained (do (log/warn prelog
-                                                          ;; Actually, this seems like a strong argument for
-                                                          ;; having a pair of streams. Child could still have
-                                                          ;; bytes to send to the parent after the latter's
-                                                          ;; stopped sending, or vice versa.
-                                                          ;; I'm pretty sure the complexity I haven't finished
-                                                          ;; translating stems from that case.
-                                                          ;; TODO: Another piece to revisit once the basics
-                                                          ;; work.
-                                                          "Stream closed. Surely there's more to do"))
-                                  ::timed-out (do
-                                                (log/debug prelog
-                                                           (cl-format nil
-                                                                      "~Timer for ~:d ms after ~:d timed out. Re-triggering Output"
-                                                                      delta_f
-                                                                      now))
-                                                (trigger-from-timer state))
-                                  ::parent-> (trigger-from-parent state (second success))
-                                  ::child-> (trigger-from-child state (second success)))
-                                (when (not= tag ::drained)
-                                        (log/debug prelog "Scheduling next timeout")
-                                        ;; This is taking a ludicrous amount of time.
-                                        (let [start (System/nanoTime)
-                                              ;; Q: How much should I blame on logging?
-                                              result (schedule-next-timeout! state-wrapper)
-                                              end (System/nanoTime)]
-                                          (log/debug prelog
-                                                     (cl-format nil
-                                                                "Scheduling next timeout took ~:d  nanoseconds"
-                                                                (- end start)))
-                                          result))))
+                                (let [updater
+                                      (case tag
+                                        ::drained (do (log/warn prelog
+                                                                ;; Actually, this seems like a strong argument for
+                                                                ;; having a pair of streams. Child could still have
+                                                                ;; bytes to send to the parent after the latter's
+                                                                ;; stopped sending, or vice versa.
+                                                                ;; I'm pretty sure the complexity I haven't finished
+                                                                ;; translating stems from that case.
+                                                                ;; TODO: Another piece to revisit once the basics
+                                                                ;; work.
+                                                                "Stream closed. Surely there's more to do")
+                                                      (constantly nil))
+                                        ::timed-out (do
+                                                      (log/debug prelog
+                                                                 (cl-format nil
+                                                                            "~Timer for ~:d ms after ~:d timed out. Re-triggering Output"
+                                                                            delta_f
+                                                                            now))
+                                                      trigger-from-timer)
+                                        ::parent-> (partial trigger-from-parent (second success))
+                                        ::child-> (partial trigger-from-child (second success)))]
+                                  (when (not= tag ::drained)
+                                    (log/debug prelog "Processing event")
+                                    (let [start (System/nanoTime)
+                                          _ (swap! state-atom updater)
+                                          mid (System/nanoTime)
+                                          ;; This is taking a ludicrous amount of time.
+                                          ;; Q: How much should I blame on logging?
+                                          result (schedule-next-timeout! state-wrapper)
+                                          end (System/nanoTime)]
+                                      (log/debug prelog
+                                                 (cl-format nil
+                                                            (str
+                                                             "Event handling took ~:d nanoseconds\n"
+                                                             "Scheduling next timeout took ~:d  nanoseconds")
+                                                            (- mid start)
+                                                            (- end mid)))
+                                      result)))))
                             (fn [failure]
                               (log/error failure
                                          prelog
@@ -486,194 +675,6 @@
     ;; This covers line 260
     (swap! state-atom assoc ::specs/recent recent)
     (schedule-next-timeout! (assoc state-wrapper ::stream io-stream))))
-
-(s/fdef trigger-output
-        :args (s/cat :state ::specs/state)
-        :ret ::specs/state)
-(defn trigger-output
-  [{{:keys [::specs/->child]} ::specs/incoming
-    {:keys [::specs/next-action]} ::specs/flow-control
-    :keys [::specs/message-loop-name]
-    :as state}]
-  (let [prelog (utils/pre-log message-loop-name)]
-    (log/debug prelog "Triggering Output")
-    ;; Originally, it seemed like it would make sense to cancel
-    ;; the timer here, to avoid duplicating the call when I
-    ;; get input from either the parent or the child.
-    ;; Doing it that way entails too much delay. If the
-    ;; timer is running in a tight loop, it might trigger
-    ;; several more times before they get around to
-    ;; actually calling this.
-    (let [state
-          (as-> state state
-            (assoc state ::specs/recent (System/nanoTime))
-            ;; It doesn't make any sense to call this if
-            ;; we were triggered by a message coming in from
-            ;; the parent.
-            ;; Even if there pending blocks are ready to
-            ;; send, outgoing messages are throttled by
-            ;; the flow-control logic.
-            ;; Likewise, there isn't a lot of sense in
-            ;; calling it from the child, due to the same
-            ;; throttling issues.
-            ;; This really only makes sense when the
-            ;; timer triggers to let us know that it's
-            ;; OK to send a new message.
-            ;; The timeout on that may completely change
-            ;; when the child schedules another send,
-            ;; or a message arrives from parent to
-            ;; update the RTT.
-            (to-parent/maybe-send-block! state))]
-      ;; At the end of the main ioloop in the refernce
-      ;; implementation, there's a block that closes the pipe
-      ;; to the child if we're done.
-      ;; I think the point is that we'll quit polling on
-      ;; that and start short-circuiting out of the blocks
-      ;; that might do the send, once we've hit EOF
-      ;; Q: What can I do here to
-      ;; produce the same effect?
-      ;; TODO: Worry about that once the basic idea works.
-
-      ;; If the child sent a big batch of data to go out
-      ;; all at once, don't waste time setting up a timeout
-      ;; scheduler. The poll in the original would have
-      ;; returned immediately anyway.
-      ;; Except that n-sec-per-block puts a hard limit on how
-      ;; fast we can send.
-      (comment
-        (let [unsent-blocks-from-child? (from-child/blocks-not-sent? state)]
-          (if unsent-blocks-from-child?
-            (recur state)
-            (schedule-next-timeout! state))))
-      state)))
-
-(s/fdef trigger-from-child
-        :args (s/cat :state ::specs/state
-                     :array-o-bytes bytes?)
-        :ret ::specs/state)
-(defn trigger-from-child
-  [{{:keys [::specs/strm-hwm]
-     :as outgoing} ::specs/outgoing
-    :keys [::specs/message-loop-name]
-    :as state}
-   array-o-bytes]
-  {:pre [array-o-bytes]}
-  (let [prelog (utils/pre-log message-loop-name)]
-    (log/info prelog
-              "trigger-from-child\nSent stream address: "
-              strm-hwm)
-    (let [state' (if (from-child/room-for-child-bytes? state)
-                   (do
-                     (log/debug prelog
-                                "There is room for another message")
-                     (let [result (from-child/consume-from-child state array-o-bytes)]
-                       result))
-                   ;; trigger-output does some state management, even
-                   ;; if we discard the incoming bytes because our
-                   ;; buffer is full.
-                   ;; TODO: Need a way to signal the child to
-                   ;; try again shortly
-                   (do
-                     (log/error prelog
-                                "Discarding incoming bytes, silently")
-                     state))]
-      ;; TODO: check whether we can do output now.
-      ;; It's pointless to call this if we just have
-      ;; to wait for the timer to expire.
-      (let [state'' (trigger-output
-                     state')]
-        (log/debug prelog
-                   "Truly updating agent state due to input from child")
-        state''))))
-
-(s/fdef trigger-from-parent
-        :args (s/cat :specs/state ::specs/state
-                     :array-o-bytes bytes?)
-        :ret ::specs/state)
-(defn trigger-from-parent
-  "Message block arrived from parent. Agent has been handed work"
-  ;; TODO: Move as much of this as possible into from-parent
-  ;; The only reason I haven't already moved the whole thing
-  ;; is that we need to use to-parent to send the ACK, and I'd
-  ;; really rather not introduce dependencies between those namespaces
-  [{{:keys [::specs/->child]
-     :as incoming} ::specs/incoming
-    :keys [::specs/message-loop-name]
-    :as state}
-   ^bytes message]
-  (let [prelog (utils/pre-log message-loop-name)]
-    (when-not ->child
-      (throw (ex-info (str prelog
-                           "Missing ->child")
-                      {::detail-keys (keys incoming)
-                       ::top-level-keys (keys state)
-                       ::details state})))
-
-    (log/debug prelog "Incoming from parent")
-
-    ;; This is basically an iteration of the top-level
-    ;; event-loop handler from main().
-    ;; I can skip the pieces that only relate to reading
-    ;; from the child, because I'm using an active callback
-    ;; approach, and this was triggered by a block of
-    ;; data coming from the parent.
-
-    ;; However, there *is* the need to handle packets that the
-    ;; child has buffered up to send to the parent.
-
-    ;; Except that we can't do this here/now. That part's
-    ;; limited by the flow-control logic (handled by the
-    ;; timer) and the callbacks arriving from the child.
-    ;; It seems like we probably should cancel/reschedule,
-    ;; since whatever ACK just arrived might adjust the RTT
-    ;; logic.
-    (try
-      (let [pre-processed (from-parent/try-processing-message!
-                           (assoc-in state
-                                     [::specs/incoming ::specs/parent->buffer]
-                                     message))
-            state' (to-child/forward! ->child (or pre-processed
-                                                  state))]
-        ;; This will update recent.
-        ;; In the reference implementation, that happens immediately
-        ;; after trying to read from the child.
-        ;; Q: Am I setting up any problems for myself by waiting
-        ;; this long?
-        ;; i.e. Is it worth doing that at the top of the trigger
-        ;; functions instead?
-        (trigger-output state'))
-      (catch RuntimeException ex
-        (log/error ex
-                   (str prelog
-                        "Trying to cope with a message arriving from parent"))))))
-
-(defn trigger-from-timer
-  [{:keys [::specs/message-loop-name]
-    :as state}]
-  ;; It's really tempting to move this to to-parent.
-  ;; But (at least in theory) it could also trigger
-  ;; output to-child.
-  ;; So leave it be for now.
-  (log/debug (utils/pre-log message-loop-name) "I/O triggered by timer")
-  ;; I keep thinking that I need to check data arriving from
-  ;; the child, but the main point to this logic branch is
-  ;; to resend an outbound block that hasn't been ACK'd yet.
-  (trigger-output state))
-
-(defn build-un-ackd-blocks
-  []
-  (sorted-set-by (fn [x y]
-                   (let [x-time (::specs/time x)
-                         y-time (::specs/time y)]
-                     (if (= x-time y-time)
-                       ;; Assume that we never have multiple messages with the
-                       ;; same timestamp.
-                       ;; We do hit this case when disj is trying to
-                       ;; remove an existing block.
-                       0
-                       (if (< x-time y-time)
-                         -1
-                         1))))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Public


(maint) add tests for handle-server-error body

--- test/unit/puppetlabs/services/ca/certificate_authority_core_test.clj
+++ test/unit/puppetlabs/services/ca/certificate_authority_core_test.clj
@@ -309,7 +309,9 @@
           (let [response (test-app
                           {:uri "/v1/certificate_statuses/"
                            :request-method :get})]
-            (is (= 400 (:status response)))))
+            (is (= 400 (:status response)))
+            (is (= "text/plain" (get-in response [:headers "Content-Type"])))
+            (is (= "Missing URL Segment" (:body response)))))

         (testing "allows special characters in ignored path segment"
           (let [response (test-app


Use Logger instead of prints

Use Logger instead of prints

--- src/discuss/communication/lib.cljs
+++ src/discuss/communication/lib.cljs
@@ -7,7 +7,8 @@
             [miner.strgen :as sg]
             [discuss.config :as config]
             [discuss.utils.common :as lib]
-            [discuss.parser :as parser]))
+            [discuss.parser :as parser]
+            [discuss.utils.logging :as log]))

 ;;;; Auxiliary functions
 (defn make-url
@@ -59,7 +60,7 @@
   "Make ajax call to dialog based argumentation system."
   ([url headers handler params]
    (lib/last-api! url)
-   (println "Request to:" (make-url url))
+   (log/debug "Request to:" (make-url url))
    (GET (make-url url)
         {:handler       handler
          :headers       (merge (token-header) headers)


Fix bug with the :subname key of the mysql database declaration.

--- src/mofficer/persistence/user_config_dao.clj
+++ src/mofficer/persistence/user_config_dao.clj
@@ -4,7 +4,7 @@
   (:import [mofficer.infrastructure.datastructures.either Either]))

 (def mysql-db {:subprotocol "mysql"
-               :subname "http://localhost:3306/mofficerdb"
+               :subname "//localhost:3306/mofficerdb"
                :user "mofficer"
                :password "mofficer1234"})


Generate URL from ticker symbol or company map (for parity with report).

--- src/open_company/representations/company.clj
+++ src/open_company/representations/company.clj
@@ -1,5 +1,6 @@
 (ns open-company.representations.company
-  (:require [cheshire.core :as json]
+  (:require [defun :refer (defun)]
+            [cheshire.core :as json]
             [open-company.representations.common :as common]
             [open-company.representations.report :as report-rep]
             [open-company.resources.report :as report]))
@@ -7,8 +8,9 @@
 (def media-type "application/vnd.open-company.company+json;version=1")
 (def collection-media-type "application/vnd.collection+vnd.open-company.company+json;version=1")

-(defn- url [company]
-  (str "/v1/companies/" (:symbol company)))
+(defun url
+  ([ticker :guard string?] (str "/v1/companies/" ticker))
+  ([company] (url (:symbol company))))

 (defn- self-link [company]
   (common/self-link (url company) media-type))


get generator to emit message to rabbit in docker-compose

--- generator/src/generator/core.clj
+++ generator/src/generator/core.clj
@@ -9,19 +9,12 @@
 (def ^{:const true}
   default-exchange-name "logs")

-(defn message-handler
-  [ch {:keys [content-type delivery-tag type] :as meta} ^bytes payload]
-  (println (format "[consumer] Received a message: %s, delivery tag: %d, content type: %s, type: %s"
-                   (String. payload "UTF-8") delivery-tag content-type type)))
-
 (defn -main
   [& args]
-  (let [conn (rmq/connect)
+  (let [conn (rmq/connect {:host "rabbit"})
         ch (lch/open conn)
         qname "langohr.examples.hello-world"]
     (println (format "[main] Connected. Channel id: %d" (.getChannelNumber ch)))
-    (lq/declare ch qname {:exclusive false :auto-delete true})
-    (lc/subscribe ch qname message-handler {:auto-ack true})
     (lb/publish ch default-exchange-name qname "Hello!" {:content-type "text/plain" :type "greetings.hi"})
     (Thread/sleep 2000)
     (println "[main] Disconnecting...")


Add forecast data

Add forecast data

--- src/clj_simple_chart/ncs/oilforecast/forecastdata.clj
+++ src/clj_simple_chart/ncs/oilforecast/forecastdata.clj
@@ -48,10 +48,12 @@

            "2016"
            ; Sokkelåret 2016 http://www.npd.no/Global/Norsk/1-Aktuelt/Nyheter/Sokkelaret-2016/Figurgrunnlag-Sokkelaret-2016.xlsx
-           {:prfPrdOilNetMillSm3       [93.88 88.05 83.30 91.27 98.90]
-            :prfPrdLiquidsNetMillMboed [1.98 1.88 1.80 1.92 2.04]}
-           ;:prfPrdGasNetBillSm3 [114.47 114.54 114.46 114.34 113.76]
-
+           {:prfPrdOilNetMillSm3        [93.88 88.05 83.30 91.27 98.90]
+            :prfPrdCondensateNetMillSm3 [1.83 2.37 2.61 2.30 2.22]
+            :prfPrdNGLNetMillSm3        [19.37 18.42 18.56 18.13 17.32]
+            :prfPrdLiquidsNetMillMboed  [1.98 1.88 1.80 1.92 2.04]
+            :prfPrdLiquidsNetMillSm3    [115.08 108.84 104.47 111.70 118.44]
+            :prfPrdGasNetBillSm3        [114.47 114.54 114.46 114.34 113.76]}
            })

 (defn process-prediction-year [[yr values]]


export application link or button

export application link or button

--- src/cljs/salava/extra/application/ui/application.cljs
+++ src/cljs/salava/extra/application/ui/application.cljs
@@ -377,6 +377,10 @@
                           [:img {:src (str "/" (:image_file application))}]]))
                  [:div] (take 5 (:applications @state)))])))

-(defn ^:export button []
+(defn ^:export button [opt]
   (fn []
-    [:div [:a.btn.button {:href (path-for "/badge/application")} (t :extra-application/Application)]]))
+   (case opt
+     "button" [:div [:a.btn.button {:href (path-for "/badge/application")} (t :extra-application/Application)]]
+     "link" [:a {:href (str (path-for "/badge/application"))}[:p (t :social/Iwanttoearnnewbadges)]]
+     [:div [:a.btn.button {:href (path-for "/badge/application")} (t :extra-application/Application)]])))
+


testing a small fix to cycle changes

testing a small fix to cycle changes

--- src/mafia_votecount/scraper/team_liquid.clj
+++ src/mafia_votecount/scraper/team_liquid.clj
@@ -153,7 +153,7 @@

 (defn- cycle-changes [indexed hosts]
   (filter #(and (is-host? % hosts) (is-cycle-change? (:message (val %))))
-          (rest indexed)))
+          indexed))

 (defn- dec-or-nil [num]
   (if (nil? num)


Add failure and expectation reporting to nested reporter

--- src/main/clojure/lazytest/report/nested.clj
+++ src/main/clojure/lazytest/report/nested.clj
@@ -1,42 +1,78 @@
 (ns lazytest.report.nested
   (:use lazytest.color
-	lazytest.suite))
+	lazytest.suite
+	clojure.pprint
+	[clojure.stacktrace :only (print-cause-trace)]))

-(defn identifier [result]
+(defn- identifier [result]
   (let [m (meta (:source result))]
     (or (:doc m) (:name m))))

+;;; Nested doc printout
+
 (declare report-result)

-(defn indent [n]
+(defn- indent [n]
   (dotimes [i n] (print "    ")))

-(defn report-suite-result [result depth]
+(defn- report-suite-result [result depth]
   (indent depth)
   (println (identifier result))
   (doseq [child (:children result)]
     (report-result child (inc depth))))

-(defn report-test-case-result [result depth]
+(defn- report-test-case-result [result depth]
   (indent depth)
   (println (colorize (identifier result) (if (:pass? result) :green :red))))

-(defn result-seq [result]
+(defn- result-seq [result]
   (tree-seq suite-result? :children result))

-(defn report-result [result depth]
+(defn- report-result [result depth]
   (if (suite-result? result)
     (report-suite-result result depth)
     (report-test-case-result result depth)))

-(defn summarize [results]
+;;; Failures
+
+(defn- print-expectation-failed [err]
+  (let [reason (. err reason)]
+    (println "at" (:file reason) "line" (:line reason))
+    (println "Expression:" (:form reason))
+    (println "Result:" (pr-str (:result reason)))
+    (when (:evaluated reason)
+      (println "Evaluated arguments:")
+      (pprint (zipmap (rest (:form reason)) (rest (:evaluated reason)))))
+    (println "Local bindings:")
+    (pprint (:locals reason))))
+
+(defn- report-test-case-failure [result docs]
+  (when (not (:pass? result))
+    (let [docs (conj docs (identifier result))
+	  docstring (interpose " " (remove nil? docs))
+	  error (:thrown result)]
+      (println (colorize (apply str "FAILURE: " docstring) :red))
+      (if (instance? lazytest.ExpectationFailed error)
+	(print-expectation-failed error)
+	(print-cause-trace error))
+      (newline))))
+
+(defn- report-failures [result docs]
+  (if (suite-result? result)
+    (doseq [child (:children result)]
+      (report-failures child (conj docs (identifier result))))
+    (report-test-case-failure result docs)))
+
+;;; Summary
+
+(defn- summarize [results]
   (let [test-case-results (remove suite-result? (mapcat result-seq results))
 	total (count test-case-results)
 	passed (count (filter :pass? test-case-results))
 	failed (- total passed)]
     {:total total, :pass passed, :fail failed}))

-(defn print-summary [summary]
+(defn- print-summary [summary]
   (let [count-msg (str "Ran " (:total summary) " tests.")]
     (println (if (zero? (:total summary))
 	       (colorize count-msg :yellow)
@@ -44,8 +80,11 @@
   (println (colorize (str (:fail summary) " failures.")
 		     (if (zero? (:fail summary)) :green :red))))

+;;; Entry point
+
 (defn report [results]
   (doseq [r results] (report-result r 0))
   (newline)
+  (doseq [r results] (report-failures r []))
   (print-summary (summarize results)))