Fixing identation

Fixing identation

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/base.clj
+++ src/conexp/base.clj
@@ -202,10 +202,10 @@

 (defn ensure-length
   "Fills given string with padding to have at least the given length."
-  ([string ^long length]
-     (ensure-length string length " "))
-  ([string ^long length padding]
-     (apply str string (repeat (- length (count string)) padding))))
+  ([string, ^long length]
+   (ensure-length string length " "))
+  ([string, ^long length, padding]
+   (apply str string (repeat (- length (count string)) padding))))

 (defn with-str-out
   "Returns string of all output being made in (flatten body)."


Fixed conexp-built-version

Fixed conexp-built-version

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/main.clj
+++ src/conexp/main.clj
@@ -41,7 +41,7 @@
   the conexp-clj jar file. Returns \"source\" if there is none in the
   classpath."
   []
-  (if-let [[_ date time] (re-find #"conexp-clj-(\d+).(\d+).jar"
+  (if-let [[_ date time] (re-find #"conexp-clj-.*-(\d+).(\d+).jar"
                                   (System/getProperty "java.class.path"))]
     (str date "." time)
     "source"))


Fix sorting in minimum-set-covers

Fix sorting in minimum-set-covers

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/util.clj
+++ src/conexp/util.clj
@@ -713,7 +713,7 @@
                    (when (covers? sets rest-base-set)
                      (let [counts (map-by-fn #(count (intersection rest-base-set %))
                                              sets),
-                           sets   (sort #(>= (counts %1) (counts %2))
+                           sets   (sort #(- (counts %2) (counts %1)) ; bah
                                         sets)],
                        (search (difference rest-base-set (first sets))
                                (conj current-cover (first sets))


Remove defmacro-

Remove defmacro-

it's already in clojure.core.incubator.

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/util.clj
+++ src/conexp/util.clj
@@ -25,11 +25,6 @@
   "Same as defvar but yields a private definition"
   [name & decls]
   (list* `defvar (with-meta name (assoc (meta name) :private true)) decls))
-
-(defmacro defmacro-
-  "Same as defmacro but yields a private definition"
-  [name & decls]
-  (list* `defmacro (with-meta name (assoc (meta name) :private true)) decls))

 (defmacro defonce-
   "Same as defonce but yields a private definition"


add to API, refactor code, delay driver to declutter compilation and uberjar

--- src/crison/core.clj
+++ src/crison/core.clj
@@ -15,53 +15,66 @@
 (def ^:dynamic *output-dir*)

 (def def-pause 1000)
-(def driver (wc/new-webdriver {:browser :phantomjs}))
+(def driver (delay (wc/new-webdriver {:browser :phantomjs})))
 (def built-in-formatter (f/formatters :basic-date-time))
+
+(defn int [s] (Integer. (re-find  #"\d+" s )))

 (defn date []
   (let [nlocal (t/to-time-zone (t/now) (t/time-zone-for-offset -0))]
     (f/unparse (f/formatter-local "yyyy-MM-dd_hh:mm")
                nlocal)))

+(defn render-pause [pause-ms]
+  (when-not (= pause-ms 0)
+    (println "pausing for : " pause-ms " ms")
+    (Thread/sleep pause-ms)))
+
 (defn screenshot
   ([name]
    (let [nm (if name (str "-" name) "")
          s-file (str *output-dir* "/" (date) "_" (.getName *crison-file*) "-screenshot" nm ".png")]
-      (wc/get-screenshot driver :file s-file)))
+      (wc/get-screenshot @driver :file s-file)))
   ([] (screenshot nil)))

 (defn source
   ([name]
    (let [nm (if name (str "-" name) "")
          s-file (str *output-dir* "/" (date) "_" (.getName *crison-file*) "-source" nm ".txt")]
-      (spit s-file (wc/page-source driver))))
+      (when name (spit s-file (wc/page-source @driver)))))
   ([] (source nil)))

-(defn title [] (wc/title driver))
+(defn title [] (wc/title @driver))

 (defn title? [x] (is (= x (title)) x))

-(defn go [x] (wc/to driver x))
+(defn go [x] (wc/to @driver x))

-(defn el [x] (-> driver (wc/find-element x)))
+(defn el [x] (-> @driver (wc/find-element x)))

 ;; currently a catchall from the multimethod
-(defn ? [x] (is (-> driver (wc/find-element x) wc/exists?) (str "Fail on : " x)))
+(defn ? [x] (is (-> @driver (wc/find-element x) wc/exists?) (str "Fail on : " x)))

 (defmulti decode (fn[x] (ffirst x)))

 (defmethod decode :url! [x]
   (go (:url! x))
-  (Thread/sleep (or (:pause x) def-pause))
+  (render-pause (or (:pause x) def-pause))
   (screenshot (:screenshot x))
   (source (:source x)))

 (defmethod decode :click! [x]
-  (let [e (:click! x)]
+  (println "x : " x)
+  (println ":click! x " (:click! x))
+  (let [e (:click! x)
+        orig-handles (count (wc/window-handles @driver))]
+    (println "e : " e)
     (if (string? e)
-      (-> driver (wc/find-element {:id e}) wc/click)
-      (-> driver (wc/find-element e) wc/click))
-    (Thread/sleep (or (:pause x) def-pause))
+      (-> @driver (wc/find-element {:id e}) wc/click)
+      (-> @driver (wc/find-element e) wc/click))
+    (render-pause (or (:pause x) def-pause))
+    (when (> (count (wc/window-handles @driver)) orig-handles)
+      (wc/switch-to-other-window @driver))
     (screenshot (:screenshot x))
     (source (:source x))))

@@ -70,24 +83,28 @@
     (doseq [e head]
       (if (:clear! e)
         (let [field (dissoc e :clear!)]
-          (-> driver (wc/find-element field) (wc/clear)))
+          (-> @driver (wc/find-element field) (wc/clear)))
         (let [txt-val (:text! e)
               field (dissoc e :text!)]
-          (-> driver (wc/find-element field) (wc/input-text txt-val)))))))
+          (-> @driver (wc/find-element field) (wc/input-text txt-val)))))))

 (defmethod decode :fill-submit! [{:keys [fill-submit! pause] :as x}]
   (if (seq (filter #(:text! %) (butlast fill-submit!)))
     (compute-fill x)
-    (wf/quick-fill-submit driver (:fill! x)))
-  (-> driver (wc/find-element (last fill-submit!)) wc/click)
-  (Thread/sleep (or pause def-pause))
+    (wf/quick-fill-submit @driver (:fill! x)))
+  (-> @driver (wc/find-element (last fill-submit!)) wc/click)
+  (println "pause x : " (:pause x))
+  (println "type pause x : " (type (:pause x)))
+  (println "def-pause : " def-pause)
+  (println "type def-pause : " (type def-pause))
+  (render-pause (or (:pause x) def-pause))
   (screenshot (:screenshot x)))

 (defmethod decode :fill! [{:keys [fill! pause] :as x}]
   (if (seq (filter #(:text! %) (butlast fill!)))
     (compute-fill x)
-    (wf/quick-fill-submit driver (:fill! x)))
-  (Thread/sleep (or pause def-pause))
+    (wf/quick-fill-submit @driver (:fill! x)))
+  (render-pause (or (:pause x) def-pause))
   (screenshot (:screenshot x)))

 (defmethod decode :title [x] (title? (:title x)))
@@ -95,8 +112,12 @@
 (defmethod decode :default [x] (? x))

 (deftest tests
-  (wc/resize driver {:width 1024 :height 800})
-  (let [fs (do/filter-exts (file-seq (file *input-dir*)) ["csn"])]
+  (let [width (env :crison-width 1024)
+        height (env :crison-height 800)
+        fs (do/filter-exts (file-seq (file *input-dir*)) ["csn"])]
+    (println "crison-width : " width)
+    (println "crison-height : " height)
+    (wc/resize @driver {:width (int width) :height (int height)})
     (doseq [f fs]
       (binding [*crison-file* f]
         (doseq [t (read-string (slurp f))] (decode t))


Fix some typos

Fix some typos

--- src/io/aviso/rook/async.clj
+++ src/io/aviso/rook/async.clj
@@ -152,9 +152,11 @@
   to interact with other resources as if via HTTP/HTTPs, but without the cost (in terms of processing time to
   encode and decode requests, and in terms of blocking the limited number of request servicing threads.

-  Request processing should be broken up into two phrases: a synchronous phase that is largely concerned with
-  standard protocol issues (such as converting the body from JSON or EDN text into Clojure data) and an
+  Request processing should be broken up into two phases: an initial synchronous phase that is largely concerned with
+  standard protocol issues (such as converting the body from JSON or EDN text into Clojure data) and a later,
   asynchronous phase (the routes provides to this function).
+
+  The loopback allows this later asynchronous phase to be re-entrant.

   The io.aviso.rook.client namespace is specifically designed to allow resources to communiate with each other
   via the loopback.


lergs

lergs

--- src/doctopus/db.clj
+++ src/doctopus/db.clj
@@ -1,12 +1,13 @@
 (ns doctopus.db
-  (:require [korma.db :refer [defdb postgres]]
-            [clojure.string :as string :refer [split-lines]]
-            [korma.core :refer :all]
+  (:require [camel-snake-kebab.core :refer [->snake_case_keyword ->kebab-case-keyword]]
+            [camel-snake-kebab.extras :refer [transform-keys]]
             [clj-time.coerce :refer [to-sql-time]]
             [clj-time.core :as clj-time]
-            [camel-snake-kebab.core :refer [->snake_case_keyword ->kebab-case-keyword]]
-            [camel-snake-kebab.extras :refer [transform-keys]]
-            [doctopus.configuration :refer [server-config]]))
+            [clojure.string :as string :refer [split-lines]]
+            [doctopus.configuration :refer [server-config]]
+            [korma.core :refer :all]
+            [korma.db :refer [defdb postgres]]
+            [taoensso.timbre :as log]))

 (defn- now
   []
@@ -111,17 +112,20 @@

 (defn save-tentacle!
   [tentacle]
+  (log/info "Saving tentacle:" tentacle)
   (insert tentacles
           (values tentacle)))

 (defn update-tentacle!
   [tentacle]
+  (log/info "Updating tentacle" (:name tentacle) "with values:" tentacle)
   (update tentacles
           (set-fields tentacle)
           (where {:name (:name tentacle)})))

 (defn delete-tentacle!
   [tentacle]
+  (log/warn "Deleting tentacle:" tentacle "!")
   (delete tentacles
           (where {:name (:name tentacle)})))

@@ -142,17 +146,20 @@

 (defn save-head!
   [head]
+  (log/info "Saving head:" head)
   (insert heads
           (values head)))

 (defn update-head!
   [head]
+  (log/info "Updating head" (:name head) "with values" head)
   (update heads
           (set-fields head)
           (where {:name (:name head)})))

 (defn delete-head!
   [head]
+  (log/warn "Deleting head" head "!")
   (delete heads
           (where {:name (:name head)})))

@@ -164,8 +171,18 @@
                                  (where {:head_name head-name
                                          :tentacle_name tentacle-name}))]
     (if (empty? existing-mapping)
-      (insert head-tentacle-mappings
-              (values {:head-name head-name :tentacle-name tentacle-name})))))
+      (do
+        (log/info "Creating mapping from head" head-name "to tentacle" tentacle-name)
+        (insert head-tentacle-mappings
+                (values {:head-name head-name :tentacle-name tentacle-name})))
+      (log/info "Mapping from" head-name "to" tentacle-name "already exists"))))
+
+(defn remove-mapping!
+  [head tentacle]
+  (log/warn "Removing mapping between head" (:name head) "and tentacle" (:name tentacle))
+  (delete head-tentacle-mappings
+          (where {:head-name (:name head)
+                  :tentacle-name (:name tentacle)})))

 (defn get-all-mappings
   []


Use telnet! internally to prevent spurious \r\n

--- src/rainboots/core.clj
+++ src/rainboots/core.clj
@@ -13,6 +13,8 @@

 (def ^:dynamic *svr*)

+(declare telnet!)
+
 (defn- make-client
   [stream]
   {:stream stream
@@ -30,7 +32,7 @@
     ;; the client can send term type! request it
     (= {:telnet :will
         :opt :term-type} pkt)
-    (send! cli {:telnet :term-type
+    (telnet! cli {:telnet :term-type
                 :opt [:send]})
     ;; the client is sending their term type
     (= :term-type (:telnet pkt))
@@ -39,7 +41,7 @@
         ;; another new term type; keep requesting until
         ;;  we know them all
         (swap! cli update :term-types conj (:opt pkt))
-        (send! cli {:telnet :term-type :opt [:send]}))
+        (telnet! cli {:telnet :term-type :opt [:send]}))
       ;; we've got 'em all (TODO preprocess for color?)
       (log "* Client term types: " (:term-types @cli)))
     ;; else, let the provided callback handle
@@ -84,8 +86,8 @@
     ;; TODO we could be more generic about this
     ;; (include a set of things we'll ":do" in
     ;; the server opts)
-    (send! client {:telnet :do
-                   :opt :term-type})))
+    (telnet! client {:telnet :do
+                     :opt :term-type})))

 ;;
 ;; Server control
@@ -210,7 +212,10 @@
 (defn telnet!
   "Send a telnet map (like thsoe received in :on-telnet)
   or a vector of raw bytes as a telnet instruction. Telnet
-  maps can also be sent using (send!) for convenience."
+  maps can also be sent using (send!) for convenience;
+  note, however, that send! appends an '\\r\\n' sequence
+  to whatever is passed, so if you ONLY want to send a
+  telnet sequence, this is the way to go."
   [cli telnet]
   (when-let [s (:stream @cli)]
     (cond


Clean up h-box demo for what it coming

Clean up h-box demo for what it coming

--- src/re_demo/h_box.cljs
+++ src/re_demo/h_box.cljs
@@ -11,11 +11,9 @@
                           {:background-color "#fff4f4"
                            :border           "1px solid lightgray"
                            :border-radius    "4px"
-                           :margin           "4px"
-                           :padding          "8px"}))
+                           :padding          "4px"}))

-(def h-box-style {:border-right  "dashed 1px blue" :overflow "hidden"})
-(def v-box-style {:border-bottom "dashed 1px blue" :overflow "hidden"})
+(def h-box-style {}) ;{ :overflow "hidden"})

 (def size-options [{:id :inital :label "initial"}
                    {:id :auto   :label "auto"}
@@ -23,57 +21,137 @@
                    {:id :px     :label "px"}
                    {:id :%      :label "%"}])

-(defn box-controls
-  [box-name control]
-  [h-box
-   :align    :center
-   :width    "630px"
-   :gap      "8px"
-   :padding  "4px"
-   :style    {:background-color "#f8f8f8"}
-   :children [[box :align :start :child [:span box-name " " [:code ":size"]]]
-              [checkbox
-               :model     (:show? @control)
-               :on-change #(swap! control assoc :show? %)]
-              [horizontal-bar-tabs
-               :model     (:size @control)
-               :tabs      size-options
-               :on-change #(swap! control assoc :size %)]
-              (when (= (:size @control) :%)
-                [h-box
-                 :gap "5px"
-                 :children [[slider
-                             :model     (:% @control)
-                             :min       0
-                             :max       100
-                             :width     "200px"
-                             :on-change #(swap! control assoc :% %)]
-                            [:span (str (:% @control) "%")]]])
-              (when (= (:size @control) :px)
-                [h-box
-                 :gap "5px"
-                 :children [[slider
-                             :model     (:px @control)
-                             :min       0
-                             :max       500
-                             :width     "200px"
-                             :on-change #(swap! control assoc :px %)]
-                            [:span (str (:px @control) "px")]]])]])
+(def config (reagent/atom
+              {:hbox {:width   "500px"
+                     :height  "100px"
+                     :justify :start
+                     :gap     "4px"}
+               :box1 {:size "auto"
+                      :min-width "200px"
+                      ; :height  "20px"
+                      :align-self :end
+                      :text "Box1"}
+               :box2 {:size "0 1 100px"

-(defn box-size
-  "Works out what to pass to :size from a map like: {:size :%  :px 100 :% 60 :show? true}"
-  [control]
-  (cond (= (:size control) :%)  (str (:% control) "%")
-        (= (:size control) :px) (str (:px control) "px")
-        :else                   (name (:size control))))
+                      :text "Box2"}
+               :box3 {:size "0 1 100px"
+                      :text "Box3"}
+               :box4 {:size "0 1 100px"
+                     :text "Box4"}}))

-  (defn panel
+(defn merge-named-params
+  "given a hiccup vector v, and a map m containing named parameters, add the named parameters to v
+      (merge-named-params [box :a 1] {:b 2  :c 3})
+      ;; =>  [box :a 1 :b 2  :c 3]
+  "
+  [v m]
+  (let [not-nil-value #(identity (second %))]
+    (->> m
+         (filter not-nil-value)
+         (reduce concat [])
+         (into v)
+         vec)))
+
+
+(defn make-box
+  "produces something like:
+     [box
+        :size      \"0 1 100px\"
+        :style     h-box-style
+        :min-width \"200px\"
+        :child [:div {:style rounded-panel} \"Box 1\"]]
+  "
+  [box-parameters]
+  (-> [box :style h-box-style]
+      (merge-named-params  (dissoc box-parameters :text))
+      (conj :child)
+      (conj [:div {:style rounded-panel} (:text box-parameters)])))
+
+
+(defn demo
+  []
+  [v-box
+   :gap      "10px"
+   :children [[title2 "Demo"]
+              (-> [h-box
+                    :padding  "4px"
+                    :style {:border "dashed 1px red"}]
+                  (merge-named-params (:hbox @config))
+                  (conj :children)
+                  (conj [(make-box (:box1 @config))
+                         (make-box (:box2 @config))
+                         (make-box (:box3 @config))
+                         (make-box (:box4 @config))]))]])
+
+
+
+#_(defn demo
   []
   (let [container-size (reagent/atom 500)
         gap-size       (reagent/atom 0)
         box1-db        (reagent/atom {:size :%  :px 100 :% 60 :show? true})
         box2-db        (reagent/atom {:size :px :px 100 :% 50 :show? true})
         box3-db        (reagent/atom {:size :%  :px 100 :% 40 :show? true})]
+    [v-box
+     :gap      "10px"
+     :children [[title2 "Demo"]
+                #_[p "Descriptions removed for now."]
+                [p "An h-box is normally invisible, but for this demo we've styled it with a dashed red border."]
+                ;[p "Each child box component (which includes an 4px magin) describes it's own settings and allows you to modify them."]
+                #_[p "Dashed red lines have been added between the boxes."]
+                [title :level :level3 :label "Container (h-box/v-box) - red border"]
+                [h-box
+                 :gap      "10px"
+                 :children [[box :align :start :width "100px" :child [:span "h/v-box " [:code ":w/:h"]]]
+                            [slider
+                             :model     container-size
+                             :min       0
+                             :max       800
+                             :width     "200px"
+                             :on-change #(reset! container-size %)]
+                            [:span @container-size "px"]]]
+                [h-box
+                 :gap      "10px"
+                 :children [[box :align :start :width "100px" :child [:span "gap " [:code ":size"]]]
+                            [slider
+                             :model     gap-size
+                             :min       0
+                             :max       50
+                             :width     "200px"
+                             :on-change #(reset! gap-size %)]
+                            [:span @gap-size "px"]]]
+                [gap :size "10px"]
+                [title :level :level3 :label "Children (box) - blue border at end of box"]
+                [box-controls "Box1" box1-db]
+                [box-controls "Box2" box2-db]
+                [box-controls "Box3" box3-db]
+                [gap :size "10px"]
+                [h-box
+                 :width    (px @container-size)
+                 :height   "100px"
+                 :gap      (px @gap-size)
+                 :style    {:border "dashed 1px red"}
+                 :children [(when (:show? @box1-db)
+                              [box
+                               :size (box-size @box1-db)
+                               :style h-box-style
+                               :child [:div {:style rounded-panel} "Box 1" [:br] ":size " (box-size @box1-db)]])
+                            (when (:show? @box2-db)
+                              [box
+                               :size (box-size @box2-db)
+                               :style h-box-style
+                               :child [:div {:style rounded-panel} "Box 2" [:br] ":size " (box-size @box2-db)]])
+                            (when (:show? @box3-db)
+                              [box
+                               :size (box-size @box3-db)
+                               :style h-box-style
+                               :child [:div {:style rounded-panel} "Box 3" [:br] ":size " (box-size @box3-db)]])]]
+                ]]))
+
+
+  (defn panel
+    []
+
     (fn
       []
       [v-box
@@ -102,82 +180,5 @@
                                           [p "Todo: Nestability with v-box"]

                                           [args-table h-box-args-desc]]]
-                              [v-box
-                               :gap      "10px"
-                               :children [[title2 "Demo"]
-                                          [p "Descriptions removed for now."]
-                                          ;[p "The h-box, which is normally invisible, has been styled with a dashed red border to make it visible."]
-                                          ;[p "Each child box component (which includes an 4px magin) describes it's own settings and allows you to modify them."]
-                                          #_[p "Dashed red lines have been added between the boxes."]
-                                          [title :level :level3 :label "Container (h-box/v-box) - red border"]
-                                          [h-box
-                                           :gap      "10px"
-                                           :children [[box :align :start :width "100px" :child [:span "h/v-box " [:code ":w/:h"]]]
-                                                      [slider
-                                                       :model     container-size
-                                                       :min       0
-                                                       :max       800
-                                                       :width     "200px"
-                                                       :on-change #(reset! container-size %)]
-                                                      [:span @container-size "px"]]]
-                                          [h-box
-                                           :gap      "10px"
-                                           :children [[box :align :start :width "100px" :child [:span "gap " [:code ":size"]]]
-                                                      [slider
-                                                       :model     gap-size
-                                                       :min       0
-                                                       :max       50
-                                                       :width     "200px"
-                                                       :on-change #(reset! gap-size %)]
-                                                      [:span @gap-size "px"]]]
-                                          [gap :size "10px"]
-                                          [title :level :level3 :label "Children (box) - blue border at end of box"]
-                                          [box-controls "Box1" box1-db]
-                                          [box-controls "Box2" box2-db]
-                                          [box-controls "Box3" box3-db]
-                                          [gap :size "10px"]
-                                          [h-box
-                                           :width    (px @container-size)
-                                           :height   "100px"
-                                           :gap      (px @gap-size)
-                                           :style    {:border "dashed 1px red"}
-                                           :children [(when (:show? @box1-db)
-                                                        [box
-                                                         :size (box-size @box1-db)
-                                                         :style h-box-style
-                                                         :child [:div {:style rounded-panel} "Box 1" [:br] ":size " (box-size @box1-db)]])
-                                                      (when (:show? @box2-db)
-                                                        [box
-                                                         :size (box-size @box2-db)
-                                                         :style h-box-style
-                                                         :child [:div {:style rounded-panel} "Box 2" [:br] ":size " (box-size @box2-db)]])
-                                                      (when (:show? @box3-db)
-                                                        [box
-                                                         :size (box-size @box3-db)
-                                                         :style h-box-style
-                                                         :child [:div {:style rounded-panel} "Box 3" [:br] ":size " (box-size @box3-db)]])]]
-
-                                          [:br]
-                                           [p "Now here is a v-box with exactly the same children."]
-                                          [v-box
-                                           :width    "100px"
-                                           :height   (px @container-size)
-                                           :gap      (px @gap-size)
-                                           :style    {:border "dashed 1px red"}
-                                           :children [
-                                                      (when (:show? @box1-db)
-                                                        [box
-                                                         :size (box-size @box1-db)
-                                                         :style v-box-style
-                                                         :child [:div {:style rounded-panel} "Box 1" [:br] ":size " (box-size @box1-db)]])
-                                                      (when (:show? @box2-db)
-                                                        [box
-                                                         :size (box-size @box2-db)
-                                                         :style v-box-style
-                                                         :child [:div {:style rounded-panel} "Box 2" [:br] ":size " (box-size @box2-db)]])
-                                                      (when (:show? @box3-db)
-                                                        [box
-                                                         :size (box-size @box3-db)
-                                                         :style v-box-style
-                                                         :child [:div {:style rounded-panel} "Box 3" [:br] ":size " (box-size @box3-db)]])]]]]]]
-                  [gap :size "30px"]]])))
+                              [demo]]]
+                  [gap :size "30px"]]]))


Remove :metric_f from user-facing event representation

Before this change, the event maps the user would be working with contained both
:metric and :metric_f.

This is confusing when using something like (default ...) because it's not clear
which one you need to set (or even if you need to set *both*).

:metric_f serves no real purpose at this point, because it's overwritten with
the value of :metric in pre-dump-event anyway.

This change removes :metric_f from the user-facing events, so users always work
with :metric in their riemann.config files.  The fact that "metric_f" is a thing
becomes an implementation detail.

--- src/riemann/common.clj
+++ src/riemann/common.clj
@@ -56,6 +56,7 @@
   [e]
   (let [e (apply hash-map (apply concat e))
         e (if (:metric_f e) (assoc e :metric (:metric_f e)) e)
+        e (dissoc e :metric_f)
         e (if (:time e) e (assoc e :time (unix-time)))]
     e))


Adding in runit

Adding in runit

--- config/projects/chef-server-full.clj
+++ config/projects/chef-server-full.clj
@@ -18,8 +18,10 @@
 ;;

 (project "chef-server-full" "0.10.4" "1"
-         :build-order [ "prep" "autoconf" "zlib" "libiconv" "db" "gdbm" "ncurses" "openssl"
-                        "libxml2" "libxslt" "ruby" "rsync" "gecode" "chef" "chef-server"
-                        "erlang" "icu" "spidermonkey" "curl" "couchdb" "rabbitmq" "jre"])
+         :build-order [
+                     "prep" "autoconf" "zlib" "libiconv" "db" "gdbm"
+                     "ncurses" "openssl" "libxml2" "libxslt" "ruby" "rsync"
+                     "gecode" "erlang" "icu" "spidermonkey" "curl" "couchdb"
+                     "rabbitmq" "runit" "jre" "chef" "chef-server"])


Return 404 response on k/v miss

Return 404 response on k/v miss

--- src/poky/protocol/http/jdbc/text.clj
+++ src/poky/protocol/http/jdbc/text.clj
@@ -20,7 +20,9 @@

 (defn- wrap-get
   [kvstore k params headers body]
-  (response (get (kv/get* kvstore k) k)))
+  (if-let [v (get (kv/get* kvstore k))]
+    (response v)
+    (not-found "")))

 (defn- wrap-put
   [kvstore k params headers body]


small webpage correction

small webpage correction

--- src/fxc/webpage.clj
+++ src/fxc/webpage.clj
@@ -68,8 +68,9 @@
         [:ul {:class "nav navbar-nav"}
          [:li [:a {:href "https://github.com/PIENews/secrets"} "About Secrets"]]
          [:li {:role "separator" :class "divider"} ]
-         [:li [:a {:href "/"} "Split PIN" [:span {:class "sr-only"}"(current)"]]]
-         [:li [:a {:href "/recover"} "Recover PIN" ]]
+         [:li [:a {:href "/"} "Split Secret"
+               [:span {:class "sr-only"}"(current)"]]]
+         [:li [:a {:href "/recover"} "Recover Secret" ]]
          [:li {:role "separator" :class "divider"} ]
          ]]]


CMR-5889: Update preview gem commit

CMR-5889: Update preview gem commit

--- collection-renderer-lib/project.clj
+++ collection-renderer-lib/project.clj
@@ -12,7 +12,7 @@
   {:repo "https://git.earthdata.nasa.gov/scm/cmr/cmr_metadata_preview.git"
    :version "cmr_metadata_preview-0.1.1"
    :commit-id (or (System/getenv "CMR_METADATA_PREVIEW_COMMIT")
-                  "64ca91d374f")})
+                  "eed78761d70")})

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


fix(backend): fix incorrect raise on users service.

--- backend/src/uxbox/services/users.clj
+++ backend/src/uxbox/services/users.clj
@@ -54,7 +54,8 @@
       (ex/raise :type :validation
                 :code ::email-already-exists))
     (when (:val (sc/fetch-one conn sqlv2))
-      (ex/raise ::username-already-exists))))
+      (ex/raise :type :validation
+                :code ::username-already-exists))))

 (defn- update-profile
   [conn {:keys [id username email fullname metadata] :as params}]


Improved doc string for graph

Improved doc string for graph

--- src/grafter/rdf.clj
+++ src/grafter/rdf.clj
@@ -105,7 +105,21 @@

 (defn graph
   "Takes a graph-uri and a turtle-like template of vectors and returns
-  a lazy-sequence of quad Statements."
+  a lazy-sequence of quad Statements.  A turtle-like template should
+  be structured like this:
+
+  [subject [predicate1 object1]
+           [predicate2 object2]
+           [predicate3 [[blank-node-predicate blank-node-object]]]]
+
+  Subjects, predicates and objects can be strings, URI's or URL's,
+  whilst objects can also be literal types such as java numeric types,
+  Dates etc.
+
+  For convenience strings in these templates are assumed to be URI's
+  and are cast as such, as URI's are the most common type in linked
+  data.  If you want an RDF string you should use the s function to
+  build one."
   [graph-uri & triples]
   (map (partial quad graph-uri)
        (apply triplify triples)))


Load icons service on main services ns.

Load icons service on main services ns.

--- src/uxbox/services.clj
+++ src/uxbox/services.clj
@@ -19,6 +19,7 @@
 (load "services/projects")
 (load "services/pages")
 (load "services/images")
+(load "services/icons")
 (load "services/colors")

 ;; --- Implementation


Change to Raster Calculation text

Change to Raster Calculation text

--- src/clj/popchange/views/raster_calculation.clj
+++ src/clj/popchange/views/raster_calculation.clj
@@ -158,7 +158,7 @@
   [:div.container
    [:div.page-header
     [:h1 "Raster Calculation Visualisation"]]
-   [:p.lead "Generate a visualisation based on the calculation between two data sets (" [:code "[set 1] - [set 2]"] "). The visualisation can be used to identity areas of positive or negative growth by looking for \"hot spots\" and vice-versa. Set 1 should be the most recent date (e.g. 2011) and set 2 should be the older date (e.g. 1991). Then positive values are increases and negative values are decreases."]
+   [:p.lead "To compute a map of differences between two years enter the most recent year (e.g., 2011) first (" [:code "[set 1]"] ") and the older year (e.g., 1991) second (" [:code "[set 2]"] "). Negative values will represent decreases and positive values will represent increases."]

    [:div.col-md-4
     [:div.non-js


* handler.clj (toolserver-url): Use the props parameter to limit the search results to the data we use.

--- src/wlmmap/handler.clj
+++ src/wlmmap/handler.clj
@@ -121,7 +121,8 @@
 73, ["ad" 	   "ca"]
 })

-(def toolserver-url "http://toolserver.org/~erfgoed/api/api.php?action=search&format=json&limit=5000")
+(def toolserver-url
+  "http://toolserver.org/~erfgoed/api/api.php?action=search&format=json&limit=5000&props=lat|lon|name|registrant_url|id|image|lang|monument_article")

 (def db-options
   (sort (map #(str (first (val %)) "/" (last (val %))) lang-pairs)))


core: keep-indexed

core: keep-indexed

--- core/data/core.clj
+++ core/data/core.clj
@@ -3573,6 +3573,34 @@
                   (cons (f idx (first s)) (mapi (inc idx) (rest s))))))]
     (mapi 0 coll)))

+(defn keep
+  "Returns a lazy sequence of the non-nil results of (f item). Note,
+  this means false return values will be included.  f must be free of
+  side-effects."
+  {:added "1.0"}
+  [f coll]
+  (lazy-seq
+   (when-let [s (seq coll)]
+     (let [x (f (first s))]
+       (if (nil? x)
+         (keep f (rest s))
+         (cons x (keep f (rest s))))))))
+
+(defn keep-indexed
+  "Returns a lazy sequence of the non-nil results of (f index item). Note,
+  this means false return values will be included.  f must be free of
+  side-effects."
+  {:added "1.0"}
+  [f coll]
+  (let [keepi (fn keepi [idx coll]
+                (lazy-seq
+                 (when-let [s (seq coll)]
+                   (let [x (f idx (first s))]
+                     (if (nil? x)
+                       (keepi (inc idx) (rest s))
+                       (cons x (keepi (inc idx) (rest s))))))))]
+    (keepi 0 coll)))
+
 (defmacro cond->
   "Takes an expression and a set of test/form pairs. Threads expr (via ->)
   through each form for which the corresponding test
@@ -3646,16 +3674,3 @@
        ~(if (empty? steps)
           g
           (last steps)))))
-
-(defn keep
-  "Returns a lazy sequence of the non-nil results of (f item). Note,
-  this means false return values will be included.  f must be free of
-  side-effects."
-  {:added "1.0"}
-  [f coll]
-  (lazy-seq
-   (when-let [s (seq coll)]
-     (let [x (f (first s))]
-       (if (nil? x)
-         (keep f (rest s))
-         (cons x (keep f (rest s))))))))


Update nth-prime in response to PR feedback

Replace `(when (not` with `when-not`, update `cond` to instead use `or`.

--- exercises/nth-prime/src/example.clj
+++ exercises/nth-prime/src/example.clj
@@ -16,10 +16,8 @@
   (empty? (for [n (range 3 (inc (sqrt number)) 2) :when (divides? number n)] n)))

 (defn prime? [number]
-  (cond
-    (= 2 number) true
-    (even? number) false
-    :else (prime-by-trial-division? number)))
+  (or (= 2 number)
+      (and (odd? number) (prime-by-trial-division? number))))

 (defn next-prime [start]
   (loop [n (inc start)]
@@ -30,6 +28,6 @@
 (def primes (iterate next-prime 1))

 (defn nth-prime [index]
-  (when (not (pos? index))
+  (when-not (pos? index)
     (throw (IllegalArgumentException. "nth-prime expects a positive integer for an argument")))
   (nth primes index))


Make starts-with-vowel private

Make starts-with-vowel private

--- exercises/pig-latin/src/example.clj
+++ exercises/pig-latin/src/example.clj
@@ -7,7 +7,7 @@
 (defn- starts-with-vowel-like? [word]
   (starts-with-any #{"yt" "xr"} word))

-(defn starts-with-vowel? [word]
+(defn- starts-with-vowel? [word]
   (starts-with-any #{"a" "e" "i" "o" "u"} word))

 (defn- starts-with-two-letter-prefix? [word]


remove prn

remove prn

--- cloc-webapp/src-cljs/dash/dash.cljs
+++ cloc-webapp/src-cljs/dash/dash.cljs
@@ -51,7 +51,6 @@
   (reify
     om/IRender
     (render [this]
-      (prn (:registered-states (om/root-cursor app-state)))
       (let [index (:index state)
             current-state (nth (om/observe owner (registered-state-cur index)) 0)
             current-repo (nth (:repos @app-state) index)]


Remove strategy as argument

Remove strategy as argument

--- src/main/clojure/com/stuartsierra/lazytest.clj
+++ src/main/clojure/com/stuartsierra/lazytest.clj
@@ -29,14 +29,14 @@

 ;; Internal generic Test/Assertion invocation.
 (defprotocol TestInvokable
-  (invoke-test [t states strategy active]
+  (invoke-test [t states active]
                "(private) Executes the TestCase or Assertion."))

 (declare AssertionPassed AssertionFailed AssertionThrown)

 ;; Fn is assumed to be an assertion predicate
 (extend-class clojure.lang.Fn TestInvokable
-  (invoke-test [f states strategy active]
+  (invoke-test [f states active]
     (try (if (apply f states)
            (AssertionPassed f states)
            (AssertionFailed f states))
@@ -63,11 +63,10 @@
 (deftype TestCase [contexts children] :as this
   clojure.lang.IFn
   (invoke [] (run-test-case this))
-  (invoke [strategy] (run-test-case this strategy))
-  (invoke [strategy active] (run-test-case this strategy active))
+  (invoke [active] (run-test-case this active))
   TestInvokable
-  (invoke-test [states strategy active]
-    (run-test-case this strategy active)))
+  (invoke-test [states active]
+    (run-test-case this active)))

 ;; TestResult represents the result of executing a TestCase.  source
 ;; is the TestCase.  children is a sequence of results from child
@@ -191,17 +190,16 @@
   "Executes a test case in context.  active is the map of currently
   active Contexts, empty by default.  strategy is a function that
   determines how tests are executed, default-strategy by default."
-  ([t] (run-test-case t default-strategy))
-  ([t strategy] (run-test-case t strategy {}))
-  ([t strategy active]
+  ([t] (run-test-case t {}))
+  ([t active]
      {:pre [(= ::TestCase (type t))
             (every? #(= ::Context (type %)) (:contexts t))]}
      (try
-      (let [[mapper child-strategy] (strategy)
+      (let [[mapper child-strategy] (default-strategy)
             merged (reduce open-context active (:contexts t))
             states (map merged (:contexts t))
             results (mapper
-                     #(invoke-test % states child-strategy merged)
+                     #(invoke-test % states merged)
                      (:children t))]
         ;; Force non-lazy execution to handle shutdown properly:
         (when (some has-after? (:contexts t))


(PE-27515) Allow sign requests to specify ttl

This change adds in the additional optional key `cert_ttl` for the
`certificate_status` endpoint that will override the `ca-ttl` CA
setting.

--- src/clj/puppetlabs/services/ca/certificate_authority_core.clj
+++ src/clj/puppetlabs/services/ca/certificate_authority_core.clj
@@ -102,6 +102,12 @@
   [context]
   (keyword (get-in context [::json-body :desired_state])))

+(defn merge-request-settings
+  [settings context]
+  (if-let [cert-ttl (get-in context [::json-body :cert_ttl])]
+    (assoc settings :ca-ttl cert-ttl)
+    settings))
+
 (defn invalid-state-requested?
   [context]
   (when (= :put (get-in context [:request :request-method]))
@@ -263,7 +269,10 @@
   (fn [context]
     (let [desired-state (get-desired-state context)]
       (locking crl-write-serializer
-        (ca/set-certificate-status! settings subject desired-state)))))
+       (ca/set-certificate-status!
+        (merge-request-settings settings context)
+        subject
+        desired-state)))))

 (defresource certificate-statuses
   [settings]


:sparkles: Improve tasks reporting.

:sparkles: Improve tasks reporting.

--- backend/src/uxbox/tasks/impl.clj
+++ backend/src/uxbox/tasks/impl.clj
@@ -47,7 +47,7 @@

 (defn- reschedule
   [conn task error]
-  (let [explain (string-strack-trace error)
+  (let [explain (ex-message error)
         sqlv [sql:mark-as-retry explain (:id task)]]
     (-> (db/query-one conn sqlv)
         (p/then' (constantly nil)))))
@@ -61,8 +61,8 @@

 (defn- mark-as-failed
   [conn task error]
-  (let [error (string-strack-trace error)
-        sqlv [sql:mark-as-failed error (:id task)]]
+  (let [explain (ex-message error)
+        sqlv [sql:mark-as-failed explain (:id task)]]
     (-> (db/query-one conn sqlv)
         (p/then' (constantly nil)))))

@@ -117,7 +117,8 @@
           (p/then decode-task-row)
           (p/then (fn [item]
                     (when item
-                      (log/debug "Execute task " (:name item))
+                      (log/info "Execute task" (:name item)
+                                "with props" (pr-str (:props item)))
                       (-> (p/do! (handle-task tasks item))
                           (p/handle (fn [v e]
                                       (if e
@@ -153,7 +154,7 @@
   [ctx {:keys [tasks] :as options}]
   (vt/schedule! ctx (assoc options
                            ::vt/fn #'event-loop-handler
-                           ::vt/delay 3000
+                           ::vt/delay 5000
                            ::vt/repeat true)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -273,7 +274,9 @@
 ;; --- Schedule API

 (s/def ::name ::us/string)
-(s/def ::delay ::us/integer)
+(s/def ::delay
+  (s/or :int ::us/integer
+        :duration tm/duration?))
 (s/def ::queue ::us/string)
 (s/def ::task-options
   (s/keys :req-un [::name]
@@ -284,8 +287,11 @@
          :or {delay 0 props {} queue "default"}
          :as options}]
   (us/verify ::task-options options)
-  (let [duration (-> (tm/duration delay)
-                     (duration->pginterval))
+  (let [duration (tm/duration delay)
+        pginterval (duration->pginterval duration)
         props (blob/encode props)]
-    (-> (db/query-one conn  [sql:insert-new-task name props queue duration])
+    (log/info "Schedule task" name
+              ;; "with props" (pr-str props)
+              "to be executed in" (str duration))
+    (-> (db/query-one conn  [sql:insert-new-task name props queue pginterval])
         (p/then' (fn [task] (:id task))))))


Fix needs to return state.

Fix needs to return state.

--- src/onyx/log/commands/prepare_join_cluster.clj
+++ src/onyx/log/commands/prepare_join_cluster.clj
@@ -90,9 +90,11 @@
          ;; peer that hasn't been evicted for whatever reason.
          (= (:id state) (:subject diff))
          (if (not (extensions/peer-exists? (:log state) (:observer diff)))
-           (extensions/write-log-entry
-            (:log state)
-            {:fn :leave-cluster :args {:id (:subject diff)}})
+           (do
+             (extensions/write-log-entry
+              (:log state)
+              {:fn :leave-cluster :args {:id (:subject diff)}})
+             state)
            state)
          (= (:id state) (:instant-join diff))
          (do (extensions/open-peer-site (:messenger state)


Remove unused imports from workspace.

Remove unused imports from workspace.

--- src/uxbox/ui/workspace.cljs
+++ src/uxbox/ui/workspace.cljs
@@ -3,20 +3,13 @@
   (:require [sablono.core :as html :refer-macros [html]]
             [rum.core :as rum]
             [beicon.core :as rx]
-            [lentes.core :as l]
             [uxbox.rstore :as rs]
-            [uxbox.state :as st]
-            [uxbox.state.project :as stpr]
             [uxbox.data.workspace :as dw]
-            [uxbox.data.projects :as dp]
             [uxbox.data.pages :as udp]
             [uxbox.data.history :as udh]
-            [uxbox.util.lens :as ul]
             [uxbox.util.dom :as dom]
             [uxbox.util.geom.point :as gpt]
             [uxbox.util.data :refer (classnames)]
-            [uxbox.ui.core :as uuc]
-            [uxbox.ui.icons :as i]
             [uxbox.ui.mixins :as mx]
             [uxbox.ui.messages :as uum]
             [uxbox.ui.confirm]
@@ -148,5 +141,7 @@
     :will-unmount workspace-will-unmount
     :did-mount workspace-did-mount
     :name "workspace"
-    :mixins [mx/static rum/reactive wshortcuts/mixin
+    :mixins [mx/static
+             rum/reactive
+             wshortcuts/mixin
              (mx/local)]}))


Trigger start-ble-manager after requesting permission

--- src/re_natal_esp32control_app/devices/ble.cljs
+++ src/re_natal_esp32control_app/devices/ble.cljs
@@ -37,6 +37,7 @@
                        (start-ble-manager)
                        (-> (.request permissions-android access-permission)
                            (.then (fn [result]
+                                    (start-ble-manager)
                                     #_(js/alert (str "requested " result)))))))))))))

 (defn scan []


CMR-1436 Adds docstring.

CMR-1436 Adds docstring.

--- common-lib/src/cmr/common/config.clj
+++ common-lib/src/cmr/common/config.clj
@@ -122,6 +122,7 @@
     :else (throw (Exception. (str "Unexpected value [" (pr-str s) "] for parsing a boolean.")))))

 (defn maybe-long
+  "Returns a Long parsed from s when s is not nil, otherwise nil."
   [s]
   (when s
     (Long. s)))


function renaming and whitespace adjustment

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/method_configs/method_config_editor.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/method_configs/method_config_editor.cljs
@@ -17,9 +17,6 @@

 (defn- filter-empty [list]
   (vec (remove blank? (map trim list))))
-
-
-

 (defn- create-section-header [text]
   [:div {:style {:fontSize "125%" :fontWeight 500}} text])
@@ -102,13 +99,12 @@
                      (swap! state assoc :loaded-method (get-parsed-response))
                      (swap! state assoc :error status-text)))}))})

-(defn- render-top-bar [config]
+(defn- render-top-bar-method [config]
   [MethodDetailsViewer
    {:name (get-in config ["methodRepoMethod" "methodName"])
     :namespace (get-in config ["methodRepoMethod" "methodNamespace"])
     :snapshotId (get-in config ["methodRepoMethod" "methodVersion"])
-    :config config
-    }])
+    :config config}])

 (defn- render-side-bar [state refs config editing? props]
@@ -217,7 +213,7 @@

      [comps/Blocker {:banner (:blocker @state)}]
      [:div {:style {:padding "0em 2em"}}
-      (render-top-bar config)
+      (render-top-bar-method config)
       [:div {:style {:padding "1em 0em"}}
        (render-side-bar state refs config editing? props)
        (when-not editing?
@@ -264,5 +260,4 @@
      (.addEventListener js/window "scroll" (.-onScrollHandler this)))
    :component-will-unmount
    (fn [{:keys [this]}]
-     (.removeEventListener js/window "scroll" (.-onScrollHandler this)))})
-
+     (.removeEventListener js/window "scroll" (.-onScrollHandler this)))})


Extract common code from *-locations functions

--- src/clj/comic_reader/comic_repository/scraper.clj
+++ src/clj/comic_reader/comic_repository/scraper.clj
@@ -14,25 +14,24 @@
                (page-seq process scraper site (rest chapters))))
      nil)))

+(defn- locations-for [scraper site direction chapters chapter page n]
+  (let [processing-fn {:forward identity
+                       :backward reverse}]
+    (cond->> chapters
+      chapter (drop-while #(not= % chapter))
+      :always (page-seq (processing-fn direction) scraper site)
+      page (drop-while #(not= (:page %) page))
+      page (drop 1)
+      :always (take n))))
+
 (defrecord ScraperRepository [scraper]
   protocol/ComicRepository
   (previous-locations [this site comic-id {:keys [chapter page]} n]
     (when chapter
-      (cond->> (site-scraper/list-chapters scraper site comic-id)
-        :always reverse
-        :always (drop-while #(not= % chapter))
-        :always (page-seq reverse scraper site)
-        page (drop-while #(not= (:page %) page))
-        page (drop 1)
-        :always (take n))))
+      (locations-for scraper site :backward (reverse (site-scraper/list-chapters scraper site comic-id)) chapter page n)))

   (next-locations     [this site comic-id {:keys [chapter page]} n]
-    (cond->> (site-scraper/list-chapters scraper site comic-id)
-      chapter (drop-while #(not= % chapter))
-      :always (page-seq identity scraper site)
-      page (drop-while #(not= (:page %) page))
-      page (drop 1)
-      :always (take n))))
+    (locations-for scraper site :forward (site-scraper/list-chapters scraper site comic-id) chapter page n)))

 (defn new-scraper-repo []
   (map->ScraperRepository {}))


empty commit

empty commit

--- src/cljs/cljs_react_material_ui_example/core.cljs
+++ src/cljs/cljs_react_material_ui_example/core.cljs
@@ -14,6 +14,7 @@
             [print.foo :as pf :include-macros true]))

 (enable-console-print!)
+

 (defn get-step-content [step-index]
   (case step-index


Fixed reference to clojure.java.shell in (with-repo-sandbox)

--- test/clj_git/test_util.clj
+++ test/clj_git/test_util.clj
@@ -1,6 +1,5 @@
 (ns clj-git.test-util
   (:require [clojure.test :refer :all]
-            [clojure.java.shell :refer :all]
             [clj-git.repo :refer :all]
             [clj-git.util :refer :all])
   (:gen-class))
@@ -12,7 +11,7 @@
       (list 'assert (list '.mkdir (list 'clojure.java.io/as-file sandbox-pathname)))
       (list 'ok-sh "cp" "-rf" bare-repo-path (str sandbox-pathname "/.git/"))
       (list 'with-redefs ['repo-root (list 'fn [] (str sandbox-pathname "/"))]
-        (list 'with-sh-dir (list 'repo-root)
+        (list 'clojure.java.shell/with-sh-dir (list 'repo-root)
           (list 'ok-sh "git" "checkout" ".")
           (list 'let ['res (cons 'do body)]
             (list 'ok-sh "rm" "-rf" (str "../" sandbox-pathname))


Sample web UI: request snippets to display cross-references properly

Reviewers: #core_team, fromberger

Reviewed By: #core_team, fromberger

Subscribers: #core_team

Differential Revision: https://phabricator-dot-kythe-repo.appspot.com/D1949

--- kythe/web/ui/src-cljs/ui/service.cljs
+++ kythe/web/ui/src-cljs/ui/service.cljs
@@ -78,6 +78,7 @@
      {:params (merge {:definition_kind    "BINDING_DEFINITIONS"
                       :declaration_kind   "ALL_DECLARATIONS"
                       :reference_kind     "ALL_REFERENCES"
+                      :snippets           "DEFAULT"
                       :filter [schema/node-kind-fact]
                       :anchor_text true
                       :page_size 20}


Finish converting tests from cucumber to midje for item_create.clj. 3 tests fail.

--- test/fcms/integration/api/item/item_create.clj
+++ test/fcms/integration/api/item/item_create.clj
@@ -34,6 +34,7 @@
   ([body]
      (api-request :post "/e/" {:headers
                                 {:Accept (mime-type :item)
+                                 :Accept-Charset "utf-8"
                                  :Content-Type (mime-type :item)}
                                 :body body}))
   ([headers body]
@@ -220,7 +221,8 @@
     ;; curl -i --header "Accept-Charset: utf-8" --header "Content-Type: application/vnd.fcms.item+json;version=1" -X POST -d '{"name":"i"}' http://localhost:3000/c/
     (fact "creating an item without an Accept header"
       (let [response (create-item-with-api
-                       {:Content-Type (mime-type :item)}
+                       {:Content-Type (mime-type :item)
+                        :Accept-Charset "utf-8"}
                        {:name i})]
         (:status response) => 201
         (response-mime-type response) => (mime-type :item)
@@ -258,7 +260,8 @@
     ;; curl -i --header "Accept: application/vnd.fcms.item+json;version=1" --header "Accept-Charset: utf-8" -X POST -d '{"name":"i"}' http://localhost:3000/c/
     (fact "create an item without a Content-Type header"
       (let [response (create-item-with-api
-                       {:Accept (mime-type :item)}
+                       {:Accept (mime-type :item)
+                        :Accept-Charset "utf-8"}
                        {:name i})]
         (:status response) => 201
         (response-mime-type response) => (mime-type :item)
@@ -273,10 +276,13 @@
         (collection/item-count e) => 1))

     ;; wrong content type - 415 Unsupported Media Type
-    ;; curl -i --header "Accept: application/vnd.fcms.item+json;version=1" --header "Accept-Charset: utf-8" --header "Content-Type: application/vnd.fcms.collection+json;version=1" -X POST -d '{"name":"i"}' http://localhost:3000/c/
+    ;; curl -i --header "Accept: application/vnd.fcms.item+json;version=1" --header "Accept-Charset: utf-8" --header "Content-Type: application/vnd.fcms.collection+json;version=1" -X POST -d '{"name":"i"}' http://localhost:3000/c/
+
+    ;; FAILS
     (fact "create an item with the wrong Content-Type header"
       (let [response (create-item-with-api
                        {:Accept (mime-type :item)
+                        :Accept-Charset "utf-8"
                         :Content-Type (mime-type :collection)}
                        {:name i})]
         (:status response) => 415
@@ -290,4 +296,136 @@
                                                   {:Accept (mime-type :item)}})]
           (:status response) => 404
           (body? response) => false)
+        (collection/item-count e) => 0))
+
+    ;; no charset - 201 Created
+    ;; curl -i --header "Accept: application/vnd.fcms.item+json;version=1" --header "Content-Type: application/vnd.fcms.item+json;version=1" -X POST -d '{"name":"i"}' http://localhost:3000/c/
+    (fact "create an item without an Accept-Charset header"
+      (let [response (create-item-with-api {:name i})]
+        (:status response) => 201
+        (response-mime-type response) => (mime-type :item)
+        (response-location response) => "/e/i"
+        (json? response) => true
+        ;; Get the created item and make sure it's right
+        (item/get-item e i) => (contains
+                                 {:collection e
+                                   :name i
+                                   :slug i
+                                   :version 1})
+        (let [response (api-request :get "/e/i" {:headers
+                                                  {:Accept (mime-type :item)}})]
+          (:status response) => 200
+          (json? response) => true)
+        (collection/item-count e) => 1))
+    ;; wrong charset - 406 Not Acceptable
+    ;; curl -i --header "Accept: application/vnd.fcms.item+json;version=1" --header "Accept-Charset: utf-8" --header "Content-Type: application/vnd.fcms
+    (fact "create an item the wrong Accept-Charset header"
+      (let [response (create-item-with-api
+                       {:Accept-Charset "iso-8859-1"
+                        :Accept (mime-type :item)
+                        :Content-Type (mime-type :item)}
+                       {:name i})]
+        (:status response) => 406
+        (response-mime-type response) => (mime-type :text)
+        (response-location response) => nil
+        (let [body (body-from-response response)]
+          (.contains body "Acceptable media type: application/vnd.fcms.item+json;version=1") => true
+          (.contains body "Acceptable charset: utf-8") => true)
+        (let [response (api-request :get "/e/i" {:headers
+                                                  {:Accept (mime-type :item)}})]
+          (:status response) => 404
+          (body? response) => false)
+        (collection/item-count e) => 0))
+    ;; no body - 400 Bad Request
+    ;; curl -i --header "Accept: application/vnd.fcms.item+json;version=1" --header "Content-Type: application/vnd.fcms.item+json;version=1" --header "Charset: UTF-8" -X POST http://localhost:3000/c/
+
+    ;; FAILS
+    (fact "create an item with no body"
+      (let [response (create-item-with-api {})]
+        (:status response) => 400
+        (response-mime-type response) => (mime-type :text)
+        (let [body (body-from-response response)]
+          (.contains body "Bad request.") => true)
+        (collection/item-count e) => 0))
+
+    ;; body, but not valid JSON - 400 Bad Request
+    ;; curl -i --header "Accept: application/vnd.fcms.item+json;version=1" --header "Content-Type: application/vnd.fcms.item+json;version=1" --header "Charset: UTF-8" -X POST -d 'Hi Mom!' http://localhost:3000/c/
+    ;; curl -i --header "Accept: application/vnd.fcms.item+json;version=1" --header "Content-Type: application/vnd.fcms.item+json;version=1" --header "Charset: UTF-8" -X POST -d '{"name":"g' http://localhost:3000/c/'
+    (fact "create an item with an invalid body"
+      (let [response (create-item-with-api "Hi Mom!")]
+        (:status response) => 400
+        (response-mime-type response) => (mime-type :text)
+        (response-location response) => nil
+        (let [body (body-from-response response)]
+          (.contains body "Bad request.") => true)
+        (collection/item-count e) => 0)
+      (let [response (create-item-with-api "{'name': 'i'")]
+        (:status response) => 400
+        (response-mime-type response) => (mime-type :text)
+        (response-location response) => nil
+        (let [body (body-from-response response)]
+          (.contains body "Bad request.") => true)
+        (collection/item-count e) => 0))
+
+    ;; collection doesn't exist - 404 Not Found
+    ;; curl -i --header "Accept: application/vnd.fcms.item+json;version=1" --header "Content-Type: application/vnd.fcms.item+json;version=1" --header "Charset: UTF-8" -X POST -d '{"name":"i"}' http://localhost:3000/not-here/
+
+    ;; FAILS (wrong status)
+    (fact "create an item in a collection that doesn't exist"
+      (let [response (api-request :post "/not-here/" {:headers
+                                                       {:Accept (mime-type :item)
+                                                         :Accept-Charset "utf-8"
+                                                         :Content-Type (mime-type :item)}
+                                                       :body {:name i}})]
+        (:status response) => 404
+        (response-mime-type response) => (mime-type :text)
+        (let [body (body-from-response response)]
+          (.contains body "Collection not found.") => true)
+        (collection/item-count e) => 0))
+
+    ;; no "name" in body - 422 Unprocessable Entity
+    ;; curl -i --header "Accept: application/vnd.fcms.item+json;version=1" --header "Content-Type: application/vnd.fcms.item+json;version=1" --header "Charset: UTF-8" -X POST -d '{"slug":"i"}' http://localhost:3000/c/
+    (fact "create an item without a name"
+      (let [response (create-item-with-api {:slug i})]
+        (:status response) => 422
+        (response-mime-type response) => (mime-type :text)
+        (let [body (body-from-response response)]
+          (.contains body "Name is required.") => true)
+        (collection/item-count e) => 0))
+
+    ;; slug specified in body is already used - 422 Unprocessable Entity
+    ;; curl -i --header "Accept: application/vnd.fcms.item+json;version=1" --header "Content-Type: application/vnd.fcms.item+json;version=1" --header "Charset: UTF-8" -X POST -d '{"name":"another-i", "slug":"i"}' http://localhost:3000/c/
+    (fact "create an item with a slug that's already used in the collection"
+      (let [response (create-item-with-api {:name i})]
+        (:status response) => 201
+        (response-mime-type response) => (mime-type :item)
+        (response-location response) => "/e/i"
+        (json? response)
+        ;; Get the created item and make sure it's right
+        (item/get-item e i) => (contains
+                                 {:collection e
+                                   :name i
+                                   :slug i
+                                   :version 1})
+        (collection/item-count e) => 1)
+      (let [response (api-request :get "/e/i" {:headers
+                                                {:Accept (mime-type :item)}})]
+        (:status response) => 200
+        (json? response) => true)
+      (let [response (create-item-with-api {:name "another-i" :slug i})]
+        (:status response) => 422
+        (response-mime-type response) => (mime-type :text)
+        (response-location response) => nil
+        (let [body (body-from-response response)]
+          (.contains body "Slug already used in collection.") => true)
+        (collection/item-count e) => 1))
+    ;; slug specified in body is invalid - 422 Unprocessable Entity
+    ;; curl -i --header "Accept: application/vnd.fcms.item+json;version=1" --header "Content-Type: application/vnd.fcms.item+json;version=1" --header "Charset: UTF-8" -X POST -d '{"name":"i", "slug":"I i"}' http://localhost:3000/c/
+    (fact "create an item with a slug that's invalid"
+      (let [response (create-item-with-api {:name i :slug "I i"})]
+        (:status response) => 422
+        (response-mime-type response) => (mime-type :text)
+        (response-location response) => nil
+        (let [body (body-from-response response)]
+          (.contains body "Invalid slug.") => true)
         (collection/item-count e) => 0))))


Fixed tests for new arg order.

Fixed tests for new arg order.

--- test/hxgm30/language/tests/syntagmata/core.clj
+++ test/hxgm30/language/tests/syntagmata/core.clj
@@ -22,7 +22,7 @@
           ["" "ng" "n" "r"]
           ["t" "ls"]
           ["t" "n"]]
-         (syntagmata/pseudo-syllables :english test-word-list))))
+         (syntagmata/pseudo-syllables test-word-list :english))))

 (deftest pseudo-syllable-counts
   (is (= [1
@@ -33,14 +33,14 @@
           4
           2
           2]
-         (syntagmata/pseudo-syllable-counts :english test-word-list))))
+         (syntagmata/pseudo-syllable-counts test-word-list :english))))

 (deftest pseudo-syllable-freqs
   (is (= {1 1
           2 4
           5 2
           4 1}
-         (syntagmata/pseudo-syllable-freqs :english test-word-list))))
+         (syntagmata/pseudo-syllable-freqs test-word-list :english))))

 (deftest sound-transitions
   (is (= [["a"]
@@ -51,7 +51,7 @@
           ["e" "ngi" "nee" "r"]
           ["too" "ls"]
           ["tu" "ne"]]
-         (syntagmata/sound-transitions :english test-word-list))))
+         (syntagmata/sound-transitions test-word-list :english))))

 (deftest flat-sound-transitions
   (is (= ["a"
@@ -62,10 +62,10 @@
           "e" "ngi" "nee" "r"
           "too" "ls"
           "tu" "ne"]
-         (syntagmata/flat-sound-transitions :english test-word-list))))
+         (syntagmata/flat-sound-transitions test-word-list :english))))

 (deftest positional-sound-transitions
-  (let [trans (syntagmata/sound-transitions :english test-word-list)]
+  (let [trans (syntagmata/sound-transitions test-word-list :english)]
     (is (= ["a" "a" "a" "ca" "e" "e" "too" "tu"]
            (syntagmata/positional-sound-transitions :initial trans)))
     (is (= ["ppli" "ca" "tio" "ncy" "clo" "poe" "ngi" "nee"]
@@ -74,7 +74,7 @@
            (syntagmata/positional-sound-transitions :final trans)))))

 (deftest positional-sound-transition-freqs
-  (let [trans (syntagmata/sound-transitions :english test-word-list)]
+  (let [trans (syntagmata/sound-transitions test-word-list :english)]
     (is (= {"a" 3, "ca" 1, "e" 2, "too" 1, "tu" 1}
            (syntagmata/positional-sound-transition-freqs :initial trans)))
     (is (= {"ppli" 1, "ca" 1, "tio" 1, "ncy" 1, "clo" 1, "poe" 1, "ngi" 1, "nee" 1}


Kill a racy test

Kill a racy test

--- test/eulalie/test/sns.cljc
+++ test/eulalie/test/sns.cljc
@@ -97,35 +97,6 @@
           (<? (sns! :delete-platform-application
                     {:platform-application-arn arn})))))))

-(defn with-subscription! [f]
-  (with-transient-app!
-    (fn [p-arn]
-      (go-catching
-        (let [e-arn (<? (create-platform-endpoint! p-arn))]
-          (-> (sns!
-               :subscribe
-               {:topic-arn (<? (create-topic!))
-                :protocol  :application
-                :endpoint  e-arn})
-              <?
-              f
-              <?))))))
-
-(deftest ^:integration ^:aws list-subscriptions
-  (with-subscription!
-    (fn [s-arn]
-      (go-catching
-        (is (some map? (<? (sns! :list-subscriptions {}))))))))
-
-(deftest ^:integration ^:aws get-subscription-attributes
-  (with-subscription!
-    (fn [s-arn]
-      (go-catching
-        (is (= "application"
-               (:protocol
-                (<? (sns! :get-subscription-attributes
-                          {:subscription-arn s-arn})))))))))
-
 (deftest ^:integration ^:aws publish
   (go-catching
     (is (string?


some reformatting

some reformatting

--- exercises/isbn-verifier/src/example.clj
+++ exercises/isbn-verifier/src/example.clj
@@ -8,6 +8,10 @@
 (defn isbn? [isbn]
   (let [chars (isbn-chars isbn)
         nums  (map #(if (= \X %) 10 (Character/digit % 10)) chars)]
-    (and (not (is-in? (butlast chars) \X))
+    (and (-> chars butlast (is-in? \X) not)
          (= 10 (count chars))
-         (zero? (mod (reduce + (map #(* %1 %2) (range 10 0 -1) nums)) 11)))))
+         (as-> nums x
+               (map #(* %1 %2) (range 10 0 -1) x)
+               (reduce + x)
+               (mod x 11)
+               (zero? x)))))


dev changes

dev changes

--- figwheel-main/devel/exproj/core.cljs
+++ figwheel-main/devel/exproj/core.cljs
@@ -1,8 +1,9 @@
-(ns ^:figwheel-hooks exproj.core
+(ns exproj.core
   (:require
    [goog.events]
    [goog.object :as gobj]
-   [clojure.string :as string]))
+   [clojure.string :as string]
+   [cljs.test :refer [deftest is]]))

 (enable-console-print!)

@@ -15,6 +16,12 @@
 (defn ^:before-load befor-hook [& args]
   (js/console.log "Called the before hook!!!"))

+(deftest this-is-a-test
+  (prn "hello")
+  (is false))
+
+
+
 #_(d)

 ;; stable reference
@@ -26,8 +33,6 @@
 ;; idempotent with stable reference
 #_(.addEventListener js/document.body "figwheel.before-load" before-load)

-
-
 #_(defonce after-css-load (fn [e] (prn :after-css-load (.. e -data))))
 ;; idempotent with stable reference
 #_(.addEventListener js/document.body "figwheel.after-css-load" after-css-load)


:gen-class for .jar deployments

:gen-class for .jar deployments

--- src/laogai/core.clj
+++ src/laogai/core.clj
@@ -1,4 +1,5 @@
 (ns laogai.core
+  (:gen-class)
   (:require [laogai
              [tv :as tv]
              [plex :as plex]


CMR-3490: Fix broken legacy-services build

--- common-lib/src/cmr/common/api/web_server.clj
+++ common-lib/src/cmr/common/api/web_server.clj
@@ -85,7 +85,7 @@
                                                  (+ total-bytes-read bytes-read)))))
               (recur (+ total-bytes-read bytes-read)))))))))

-(defn- create-access-log-handler
+(defn create-access-log-handler
   "Setup access logging for each application. Access log entries will go to stdout similar to
   application logging. As a result the access log entries will be in the same log as the
   application log."


s/verbcoach/babel/

s/verbcoach/babel/

--- src/babel/korma.clj
+++ src/babel/korma.clj
@@ -20,8 +20,8 @@
                       (do
                         (log/warn
                          (str "DATABASE_URL not set in your environment: defaulting to:"
-                              "postgres://verbcoach@localhost:5432/verbcoach"))
-                        (str "postgres://verbcoach@localhost:5432/verbcoach")))]
+                              "postgres://babel@localhost:5432/babel"))
+                        (str "postgres://babel@localhost:5432/babel")))]

     ;; this constructs the actual database connection which is used throughout the code base.
     (postgres


Added the custom 'wrap-version' middleware, verified that it is working. Also added an external 'home-handler' handler function.

--- src/blaagh/core.clj
+++ src/blaagh/core.clj
@@ -4,8 +4,16 @@
             [ring.middleware.reload :as reload]
             [ring.middleware.defaults :refer :all]))

+(defn home-handler
+    [request]
+    (str "Blaagh version " (:app-version request)))
+
+(defn wrap-version [handler]
+    (fn [request]
+        (handler (assoc request :app-version "0.1"))))
+
 (defroutes all-routes
-    (GET "/" [] "Hello World!\n")
+    (GET "/" [request] home-handler)
     ; (GET "/" [] "Show something")
     (POST "/" [] "Create something")
     (PUT "/" [] "Replace something")
@@ -15,4 +23,5 @@
     (HEAD "/" [] "Preview something"))

 (defn -main []
-  (run-server (reload/wrap-reload #'all-routes) {:port 5000}))
+    (run-server (reload/wrap-reload (wrap-version #'all-routes)) {:port 5000}))
+    ; (run-server (reload/wrap-reload #'all-routes) {:port 5000}))


Do not catch "foreign" exceptions.

Do not catch "foreign" exceptions.

--- src/bltool/core.clj
+++ src/bltool/core.clj
@@ -106,8 +106,5 @@
           (show-help (:help opts))
           (execute))
         (catch String _
-          (println (:object &throw-context)))
-        (catch Object _
-          (println (:message &throw-context))
-          (dorun (map println (:stack-trace &throw-context)))))
+          (println (:object &throw-context))))
       (.flush (:output *opts*)))))


Move throwing an exception out of the try block - it's supposed to catch errors in the callee, not the caller.

--- src/circle/ruby.clj
+++ src/circle/ruby.clj
@@ -190,8 +190,8 @@
 (defn send
   "Call a method on a ruby object"
   [obj method & args]
+  (throw-if-not obj "Can't call methods on nil")
   (try
-    (throw-if-not obj "Can't call methods on nil")
     (.callMethod obj (name method) (into-array org.jruby.runtime.builtin.IRubyObject (map ->ruby args)))
     (catch org.jruby.exceptions.RaiseException e
       (throw (Exception. (capture-exception-data e))))))


no update-filters chan

no update-filters chan

means no component state in results-view either

--- src-cljs/core.cljs
+++ src-cljs/core.cljs
@@ -115,8 +115,8 @@
                     sorted (sorted-tracks tracks)]
                 (om/update! results (vec sorted))
                 (recur))))))
-    om/IRenderState
-    (render-state [this {:keys [update-filters]}]
+    om/IRender
+    (render [this]
       (let [tracks (om/observe owner (search-results))
             button (dom/button
                     #js {:onClick
@@ -125,8 +125,7 @@
                     "+")
             track-components
             (om/build-all results-track-view tracks
-                          {:init-state
-                           {:update-filters update-filters }})]
+                          )]
         (if (mobile?)
           (apply dom/div #js {:className "results tracks" }
                  (dom/div #js {:className "track"}
@@ -237,7 +236,6 @@
     (init-state [_]
       {:search-term ""
        :new-results (chan)
-       :update-filters (chan)
        })
     om/IRenderState
     (render-state [this state]


simple example even more simplified.

simple example even more simplified.

--- examples/simple/src/simple/core.cljs
+++ examples/simple/src/simple/core.cljs
@@ -55,7 +55,7 @@

 ;; -- Domino 5 - View Functions ----------------------------------------------

-(def template (alive/select [:#/app] (alive/load-template-from-path "public/example.html")))
+(def template (alive/load-template-from-path "public/example.html"))

 (alive/defsnippet clock [] template [:./example-clock]
   [:./example-clock]


Complete re-naming in main.

Complete re-naming in main.

--- src/dsbdp/main.clj
+++ src/dsbdp/main.clj
@@ -115,7 +115,7 @@
                                            [(fn [i _] (pcap-fn i))])
                          "pcap-json" (let [pcap-fn (create-proc-fn sample-pcap-processing-definition-json)]
                                        [(fn [i _] (pcap-fn i))])
-                         "pcap-json-inc" (create-mapped-proc-fns-vec
+                         "pcap-json-inc" (combine-proc-fns-vec
                                            fn-mapping
                                            sample-pcap-processing-definition-json))
                        out-fn))


Making slightly more idiomatic

Making slightly more idiomatic

--- jvm-runner/test/codewars/test/utils.clj
+++ jvm-runner/test/codewars/test/utils.clj
@@ -5,7 +5,7 @@
 (defmacro with-java-out-str
   "A version of clojure.core/with-out-str suitable for wrapping java's System.out"
   [& body]
-  `(let [original-out# (PrintStream. (. System out))
+  `(let [original-out# (PrintStream. System/out)
          byte-out# (ByteArrayOutputStream.)]
      (-> byte-out# (PrintStream.) System/setOut)
      ~@body


rework renderer to play nicer with reagent

--- figwheel-browser/src/zajal/core.cljs
+++ figwheel-browser/src/zajal/core.cljs
@@ -4,13 +4,14 @@
 (enable-console-print!)

 (defn sketch [start update draw]
-  (let [state (atom start)]
-    (letfn [(render-loop [t]
+  (let [state (reagent/atom start)]
+    (letfn [(component [] [draw @state])
+            (render-loop [t]
+                         (.begin js/stats)
                          (swap! state update)
-                         (.begin js/stats) ;; TODO generalize this hack
-                         (reagent/render-component
-                          [draw @state]
-                          (. js/document (getElementById "app")))
-                         (.end js/stats) ;; TODO generalize this hack
+                         (.end js/stats)
                          (.requestAnimationFrame js/window render-loop))]
+      (reagent/render-component
+        [component]
+        (. js/document (getElementById "app")))
       (render-loop 0))))


figwheel.main: fix partial analysis problem from incremental compiles

--- figwheel-main/src/figwheel/main.cljc
+++ figwheel-main/src/figwheel/main.cljc
@@ -946,6 +946,8 @@
       (update-in [:options :closure-defines] assoc
                  'figwheel.repl/print-output
                  (string/join "," (distinct (map name (:client-print-to config)))))
+      (and conn? (not-empty (:watch-dirs config)))
+      (update-in [:repl-options :analyze-path] (comp vec concat) (:watch-dirs config))
       (and conn? (not-empty connect-id))
       (assoc-in [:repl-env-options :connection-filter]
                 (let [kys (keys connect-id)]


simplify promise usage

simplify promise usage

--- figwheel-repl/src/figwheel/repl.cljc
+++ figwheel-repl/src/figwheel/repl.cljc
@@ -51,7 +51,7 @@
 (defn debug [msg]
   (glog/log logger goog.debug.Logger.Level.FINEST msg))

-;; dev
+;; TODO dev
 (.setLevel logger goog.debug.Logger.Level.FINE #_ST )

 ;; --------------------------------------------------------------
@@ -215,8 +215,7 @@

 ;; TODO fix figwheel-core to use this
 (defn ^:export after-reloads [f]
-  ;; TODO simplify and verify it works
-  (swap! reload-promise-chain #(.then % (fn [_] (Promise. (fn [r _] (f) (r true)))))))
+  (swap! reload-promise-chain #(.then % (fn [_] (Promise. f)))))

 ;; --------------------------------------------------------------
 ;; Websocket REPL
@@ -454,9 +453,6 @@
                   (rand-nth (seq (available-names connections))))]
     [sid sname]))

-;; TODO if connection exists ensure connection is open
-;; or perhaps filter all connections to list of open connections
-;; here
 (defn create-connection! [ring-request options]
   (let [[sess-id sess-name] (negotiate-id ring-request @*connections*)
         conn (merge (select-keys ring-request [:server-port :scheme :uri :server-name :query-string :request-method])
@@ -517,10 +513,6 @@
   {:status 200
    :headers {"Content-Type" "application/json"}
    :body json-body})
-
-;; TODO perhaps all responses should return connection type
-;; TODO figure out is-open-function for http long and short polling
-;; TODO long polling timeout

 (defn http-polling-send [conn data]
   (swap! (::comm-atom conn) update :messages (fnil conj []) data))
@@ -574,12 +566,6 @@
 ;; http async polling - long polling
 ;; ------------------------------------------------------------------

-;; TODO explore shorter long polling timeouts
-;; TODO make long polling client reconnect when server isn't present
-;; TODO perhaps different endpoint for long polling?
-
-;; TODO probably better to base the simple polling on a similar pattern
-
 ;; agents would be easier but heavier and agent clean up is harder
 (defn long-poll-send [comm-atom msg]
   (let [data (volatile! nil)
@@ -604,7 +590,7 @@
                        (assoc comm :respond respond)))
     (when @has-messages (long-poll-send comm-atom nil))))

-;; TODO this si an abstract part of sending a message and getting a
+;; TODO this is an abstract part of sending a message and getting a
 ;; response
 (defn ping [conn]
   (let [prom (promise)
@@ -634,6 +620,7 @@
         ;; keep alive
         ;; TODO this behavior should be configurable
         ;; this might not be needed at all
+        ;; TODO abstract this to a fn
         (doto (Thread.
                (let [connections *connections*]
                  (fn []
@@ -698,8 +685,6 @@
            (open-connections))))

 (defn wait-for-connection [repl-env]
-  ;; TODO ensure all connections are open here
-  ;; end remove closed connections
   (loop []
     (when (empty? (connections-available repl-env))
       (Thread/sleep 500)


Fix some requires

Fix some requires

--- src/icecap/api.clj
+++ src/icecap/api.clj
@@ -6,7 +6,8 @@
             [clojure.core.async :refer [<!! <! go] :as async]
             [icecap.handlers.core :refer [execute]]
             [icecap.crypto :as crypto]
-            [icecap.store.api :refer [create! retrieve delete!]]))
+            [icecap.store.api :refer [create! retrieve delete!]]
+            [taoensso.timbre :refer [info spy]]))

 (defn create-cap
   "Creates a capability."


regen

regen

--- src/java_time.cljc
+++ src/java_time.cljc
@@ -1,5 +1,5 @@
 ;; NOTE: This namespace is generated by java-time.dev.gen
-(ns java-time (:refer-clojure :exclude (zero? range iterate max min contains? format abs)) (:require [java-time.util :as jt.u] java-time.clock java-time.util))
+(ns java-time (:refer-clojure :exclude (zero? range iterate max min contains? format abs)) (:require java-time.clock java-time.util))
 (let [lock (the-ns 'java-time) do-load (delay (locking lock (require 'java-time.adjuster 'java-time.amount 'java-time.chrono 'java-time.clock 'java-time.convert 'java-time.core 'java-time.format 'java-time.interval 'java-time.joda 'java-time.local 'java-time.pre-java8 'java-time.properties 'java-time.seqs 'java-time.single-field 'java-time.sugar 'java-time.temporal 'java-time.zone #?@(:bb [] :default ['java-time.mock]))))]
   (defn load-java-time "Load java-time implementation" [] @do-load))
 (if *compile-files* (load-java-time) (when-not (= "true" (System/getProperty "java-time.no-async-load")) (.start (Thread. (fn [] (load-java-time))))))
@@ -135,15 +135,15 @@
 (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.interval/abuts?))))] (defn abuts? {:doc "True if this interval abut with the other one"} ([i oi] ((deref +impl+) i oi))))
 (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.interval/overlap))))] (defn overlap {:doc "Gets the overlap between this interval and the other one or `nil`"} ([i oi] ((deref +impl+) i oi))))
 (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.interval/gap))))] (defn gap {:doc "Gets the gap between this interval and the other one or `nil`"} ([i oi] ((deref +impl+) i oi))))
-(jt.u/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.interval/interval))))] (defn interval {:doc "Constructs an interval out of a string, start and end instants or a start\n    + duration:\n\n    (j/interval \"2010-01-01T00:00:00Z/2013-01-01T00:00:00Z\")\n    => #<Interval 2010-01-01T00:00:00Z/2013-01-01T00:00:00Z>\n\n    (j/interval (j/instant 100000) (j/instant 1000000))\n    => #<Interval 1970-01-01T00:01:40Z/1970-01-01T00:16:40Z>\n\n    (j/interval (j/instant 100000) (j/duration 15 :minutes))\n    => #<Interval 1970-01-01T00:01:40Z/1970-01-01T00:16:40Z>\n\n    Requires the optional `threeten-extra` dependency.", :tag org.threeten.extra.Interval} ([o] ((deref +impl+) o)) ([a b] ((deref +impl+) a b)))))
-(jt.u/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.interval/interval?))))] (defn interval? {:doc "True if `Interval`"} ([o] ((deref +impl+) o)))))
-(jt.u/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/am-pm))))] (defn am-pm {:doc "Returns the `AmPm` for the given keyword name (`:am` or `:pm`),\n    ordinal or entity. Current AM/PM if no arguments given.", :tag org.threeten.extra.AmPm} ([] ((deref +impl+))) ([v____auto__0] ((deref +impl+) v____auto__0)) ([fmt____auto__0 arg____auto__1] ((deref +impl+) fmt____auto__0 arg____auto__1)))))
-(jt.u/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/am-pm?))))] (defn am-pm? ([o____auto__0] ((deref +impl+) o____auto__0)))))
-(jt.u/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/quarter))))] (defn quarter {:doc "Returns the `Quarter` for the given quarter keyword name (e.g. `:q1`),\n    ordinal or entity. Current quarter if no arguments given.", :tag org.threeten.extra.Quarter} ([] ((deref +impl+))) ([v____auto__0] ((deref +impl+) v____auto__0)) ([fmt____auto__0 arg____auto__1] ((deref +impl+) fmt____auto__0 arg____auto__1)))))
-(jt.u/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/quarter?))))] (defn quarter? ([o____auto__0] ((deref +impl+) o____auto__0)))))
-(jt.u/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/day-of-month))))] (defn day-of-month {:doc "Returns the `DayOfMonth` for the given entity, clock, zone or day of month.\n    Current day of month if no arguments given.", :tag org.threeten.extra.DayOfMonth} ([] ((deref +impl+))) ([G__0] ((deref +impl+) G__0)) ([fmt____auto__0 arg____auto__1] ((deref +impl+) fmt____auto__0 arg____auto__1)))))
-(jt.u/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/day-of-month?))))] (defn day-of-month? ([o____auto__0] ((deref +impl+) o____auto__0)))))
-(jt.u/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/day-of-year))))] (defn day-of-year {:doc "Returns the `DayOfYear` for the given entity, clock, zone or day of year.\n    Current day of year if no arguments given.", :tag org.threeten.extra.DayOfYear} ([] ((deref +impl+))) ([G__0] ((deref +impl+) G__0)) ([fmt____auto__0 arg____auto__1] ((deref +impl+) fmt____auto__0 arg____auto__1)))))
-(jt.u/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/day-of-year?))))] (defn day-of-year? ([o____auto__0] ((deref +impl+) o____auto__0)))))
-(jt.u/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/year-quarter))))] (defn year-quarter {:doc "Returns the `YearQuarter` for the given entity, clock, zone or year with quarter.\n    Current year quarter if no arguments given.", :tag org.threeten.extra.YearQuarter} ([] ((deref +impl+))) ([G__0] ((deref +impl+) G__0)) ([a____auto__0 b____auto__1] ((deref +impl+) a____auto__0 b____auto__1)))))
-(jt.u/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/year-quarter?))))] (defn year-quarter? ([o____auto__0] ((deref +impl+) o____auto__0)))))
+(java-time.utils/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.interval/interval))))] (defn interval {:doc "Constructs an interval out of a string, start and end instants or a start\n    + duration:\n\n    (j/interval \"2010-01-01T00:00:00Z/2013-01-01T00:00:00Z\")\n    => #<Interval 2010-01-01T00:00:00Z/2013-01-01T00:00:00Z>\n\n    (j/interval (j/instant 100000) (j/instant 1000000))\n    => #<Interval 1970-01-01T00:01:40Z/1970-01-01T00:16:40Z>\n\n    (j/interval (j/instant 100000) (j/duration 15 :minutes))\n    => #<Interval 1970-01-01T00:01:40Z/1970-01-01T00:16:40Z>\n\n    Requires the optional `threeten-extra` dependency.", :tag org.threeten.extra.Interval} ([o] ((deref +impl+) o)) ([a b] ((deref +impl+) a b)))))
+(java-time.utils/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.interval/interval?))))] (defn interval? {:doc "True if `Interval`"} ([o] ((deref +impl+) o)))))
+(java-time.utils/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/am-pm))))] (defn am-pm {:doc "Returns the `AmPm` for the given keyword name (`:am` or `:pm`),\n    ordinal or entity. Current AM/PM if no arguments given.", :tag org.threeten.extra.AmPm} ([] ((deref +impl+))) ([v____auto__0] ((deref +impl+) v____auto__0)) ([fmt____auto__0 arg____auto__1] ((deref +impl+) fmt____auto__0 arg____auto__1)))))
+(java-time.utils/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/am-pm?))))] (defn am-pm? ([o____auto__0] ((deref +impl+) o____auto__0)))))
+(java-time.utils/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/quarter))))] (defn quarter {:doc "Returns the `Quarter` for the given quarter keyword name (e.g. `:q1`),\n    ordinal or entity. Current quarter if no arguments given.", :tag org.threeten.extra.Quarter} ([] ((deref +impl+))) ([v____auto__0] ((deref +impl+) v____auto__0)) ([fmt____auto__0 arg____auto__1] ((deref +impl+) fmt____auto__0 arg____auto__1)))))
+(java-time.utils/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/quarter?))))] (defn quarter? ([o____auto__0] ((deref +impl+) o____auto__0)))))
+(java-time.utils/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/day-of-month))))] (defn day-of-month {:doc "Returns the `DayOfMonth` for the given entity, clock, zone or day of month.\n    Current day of month if no arguments given.", :tag org.threeten.extra.DayOfMonth} ([] ((deref +impl+))) ([G__0] ((deref +impl+) G__0)) ([fmt____auto__0 arg____auto__1] ((deref +impl+) fmt____auto__0 arg____auto__1)))))
+(java-time.utils/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/day-of-month?))))] (defn day-of-month? ([o____auto__0] ((deref +impl+) o____auto__0)))))
+(java-time.utils/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/day-of-year))))] (defn day-of-year {:doc "Returns the `DayOfYear` for the given entity, clock, zone or day of year.\n    Current day of year if no arguments given.", :tag org.threeten.extra.DayOfYear} ([] ((deref +impl+))) ([G__0] ((deref +impl+) G__0)) ([fmt____auto__0 arg____auto__1] ((deref +impl+) fmt____auto__0 arg____auto__1)))))
+(java-time.utils/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/day-of-year?))))] (defn day-of-year? ([o____auto__0] ((deref +impl+) o____auto__0)))))
+(java-time.utils/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/year-quarter))))] (defn year-quarter {:doc "Returns the `YearQuarter` for the given entity, clock, zone or year with quarter.\n    Current year quarter if no arguments given.", :tag org.threeten.extra.YearQuarter} ([] ((deref +impl+))) ([G__0] ((deref +impl+) G__0)) ([a____auto__0 b____auto__1] ((deref +impl+) a____auto__0 b____auto__1)))))
+(java-time.utils/when-threeten-extra (let [+impl+ (delay (load-java-time) (deref (resolve (quote java-time.single-field/year-quarter?))))] (defn year-quarter? ([o____auto__0] ((deref +impl+) o____auto__0)))))


Enable datatable in catalog view

Enable datatable in catalog view

--- src/mdr2/views.clj
+++ src/mdr2/views.clj
@@ -148,8 +148,8 @@
      [:h1 "Productions"]
      (when error
        [:p [:ul.alert.alert-danger [:li error]]])
-     [:table.table.table-striped
-      [:thead [:tr [:th "Title"] [:th "Author"] [:th "Product Number"] [:th "Library Number"] [:th "Total time"] [:th "Number of CDs"] [:th "Depth"] [:th "Narrator"] [:th "Date of Production"] [:th "Libary signature"]]]
+     [:table#productions.table.table-striped
+      [:thead [:tr [:th "Title"] [:th "Author"] [:th "Product Number"] [:th "Library Number"] [:th "Total time"] [:th "Number of CDs"] [:th "Depth"] [:th "Narrator"] [:th "Date of Production"] [:th.orderable-false "Libary signature"]]]
       [:tbody
        (for [{:keys [id title creator product_number library_number
                      total_time volumes depth narrator produced_date]}


Have to check if prefix changes on .next

--- src/aurora/btree.cljs
+++ src/aurora/btree.cljs
@@ -477,12 +477,18 @@
               iterator (aget iterators (- (alength iterators) 1))]
           (when (< old-var (alength var->iterators))
             (aset seek-key old-var least))
-          (.next iterator)
-          (if (.end? iterator)
-            (do
-              (.undo iterator)
-              (.up this new-var))
-            (.search this new-var)))))
+          (let [old-key (.inner-key iterator)]
+            (.next iterator)
+            (if (.end? iterator)
+              (do
+                (.undo iterator)
+                (.up this new-var))
+              (let [new-key (.inner-key iterator)]
+                (if (prefix-not= old-key new-key new-var)
+                  (do
+                    (.undo iterator)
+                    (.up this new-var))
+                  (.search this new-var))))))))
   (down [this old-var old-key]
         ;; assumes prefixes all equal, nothing at end
         (debug :down old-var old-key seek-key)


Fix assoc bug

Fix assoc bug

--- src/aurora/btree.cljs
+++ src/aurora/btree.cljs
@@ -64,16 +64,14 @@
   (assoc! [this key val max-keys]
           (when (lt key lower) (set! lower key))
           (when (gt key upper) (set! upper key))
-          (let [ix (.seek this key 0)]
-            (if (nil? children)
-              (if (== key (aget keys ix))
-                (do
-                  (aset vals ix val)
-                  true)
-                (do
-                  (.insert! this ix key val nil max-keys)
-                  false))
-              (.assoc! (aget children ix) key val max-keys))))
+          (let [ix (.seek this key 0)
+                result (== key (aget keys ix))]
+            (if result
+              (aset vals ix val)
+              (if (nil? children)
+                (.insert! this ix key val nil max-keys)
+                (.assoc! (aget children ix) key val max-keys)))
+            result))
   (insert! [this ix key val right-child max-keys]
            (.splice keys ix 0 key)
            (.splice vals ix 0 val)
@@ -353,18 +351,16 @@
                 (and (or (lt key-a key-b) (gte key-a key-b))
                      (or (gt key-a key-b) (lte key-a key-b)))))

-(defn run-the-prop [min-keys actions]
+(defn run-denotational-prop [min-keys actions]
   (let [tree (apply-to-tree (tree min-keys) actions)
         sorted-map (apply-to-sorted-map (sorted-map-by #(cond (== %1 %2) 0 (lt %1 %2) -1 (gt %1 %2) 1)) actions)]
     (and (= (seq (map vec tree)) (seq sorted-map))
          (or (empty? tree) (.valid! tree)))))

-(defn the-prop [gen]
+(defn denotational-prop [gen]
   (prop/for-all [min-keys gen/s-pos-int
                  actions (gen/vector gen)]
-                (run-the-prop min-keys actions)))
-
-(apply run-the-prop [1 [[:assoc! 19 0] [:assoc! "" 0] [:assoc! 0 0] [:assoc! 19 0]]])
+                (run-denotational-prop min-keys actions)))

 ;; TODO iterator tests

@@ -377,7 +373,7 @@
     (dc/quick-check 1000 transitive-prop)
     (dc/quick-check 1000 anti-symmetric-prop)
     (dc/quick-check 1000 total-prop)
-    (dc/quick-check 100 (the-prop gen-assoc))
-    (dc/quick-check 100 (the-prop gen-action)))
+    (dc/quick-check 100 (denotational-prop gen-assoc))
+    (dc/quick-check 100 (denotational-prop gen-action)))
  )


Nicer log message in link-file!

Nicer log message in link-file!

--- src/pepa/model.clj
+++ src/pepa/model.clj
@@ -195,7 +195,7 @@
       (add-pages*! conn document (page-ids conn file)))))

 (defn link-file! [db document file]
-  (log/info db "Linking document" document "to" file)
+  (log/info db "Linking document" document "to file" file)
   (db/with-transaction [db db]
     (link-file*! db document file)
     (db/notify! db :documents/updated {:id document})))


Updated clj-stacktrace to 0.2.7

Updated clj-stacktrace to 0.2.7

--- ring-devel/project.clj
+++ ring-devel/project.clj
@@ -5,7 +5,7 @@
             :url "http://opensource.org/licenses/MIT"}
   :dependencies [[ring/ring-core "1.2.2"]
                  [hiccup "1.0.3"]
-                 [clj-stacktrace "0.2.5"]
+                 [clj-stacktrace "0.2.7"]
                  [ns-tracker "0.2.2"]]
   :profiles
   {:1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}


fix for 0.13.1 createlement breaking change

--- src/quiescent.cljs
+++ src/quiescent.cljs
@@ -82,9 +82,9 @@
         (wrapped-lifecycle-method (. f apply *component* args))))
     (let [react-component (.createClass js/React react-map)
           q-wrapper (fn [value & statics]
-                      (react-component (assemble-props value statics)))]
-      (when-some [displayName (.-displayName react-map)]
-        (set! (.-displayName q-wrapper) displayName))
+                      (.createElement js/React react-component (assemble-props value statics)))
+          (when-some [displayName (.-displayName react-map)]
+            (set! (.-displayName q-wrapper) displayName))]
       (when-some [example (:exampleArg m)]
         (set! (.-exampleArg q-wrapper) example))
       (when-some [doc (:doc m)]


case macro now optimizes keyword case

case macro now optimizes keyword case

--- src/clj/cljs/core.clj
+++ src/clj/cljs/core.clj
@@ -1160,12 +1160,23 @@
                            :else
                            (assoc-test m test expr env)))
                      {} (partition 2 clauses))
-             esym (gensym)]
-    (if (every? (some-fn core/number? core/string?) (keys pairs))
+             esym    (gensym)
+             tests   (keys pairs)]
+    (cond
+      (every? (some-fn core/number? core/string?) tests)
       (core/let [no-default (if (odd? (count clauses)) (butlast clauses) clauses)
                  tests      (mapv #(if (seq? %) (vec %) [%]) (take-nth 2 no-default))
                  thens      (vec (take-nth 2 (drop 1 no-default)))]
         `(let [~esym ~e] (case* ~esym ~tests ~thens ~default)))
+
+      (every? core/keyword? tests)
+      `(let [~esym ~e]
+         (cond
+           ~@(mapcat (fn [[m c]] `((cljs.core/keyword-identical? ~m ~esym) ~c)) pairs)
+           :else ~default))
+
+      ;; equality
+      :else
       `(let [~esym ~e]
          (cond
            ~@(mapcat (fn [[m c]] `((cljs.core/= ~m ~esym) ~c)) pairs)