RR: add show & remove hex bins

RR: add show & remove hex bins

--- src/hatti/map/utils.cljs
+++ src/hatti/map/utils.cljs
@@ -495,20 +495,6 @@
     (when (pos? (count features))
       (.fitBounds map bbox #js {:padding "15" :linear true}))))

-(defn generate-hexgrid
-  [map layer-id & [geojson]]
-  (let [features (or (:features geojson)
-                     (.queryRenderedFeatures
-                       map (clj->js {:layers [layer-id]})))
-        layer-data (or geojson
-                       (clj->js
-                         {:type "FeatureCollection" :features features}))
-        bbox (.bbox js/turf (clj->js layer-data))
-        cellWidth 20
-        units "miles"
-        hexgrid (.hexGrid js/turf bbox cellWidth units)]
-    hexgrid))
-
 (defn geotype->marker-style
   "Get marker style for field type."
   [field]
@@ -519,6 +505,61 @@
                          :layout {:line-join "round"
                                   :line-cap "round"}}
     :else {:layer-type "circle" :style :point}))
+
+(defn generate-hexgrid
+  "Generates hexbins with point count aggregation given rendered
+  layer-id or geojson"
+  [map layer-id & [geojson]]
+  (let [get-rendered-features #(.queryRenderedFeatures
+                                 map (clj->js {:layers [layer-id]}))
+        rendered-features (or geojson
+                              (clj->js
+                                {:type "FeatureCollection"
+                                 :features (get-rendered-features)}))
+        ;; Get bounding box for rendered features
+        bbox (.bbox js/turf (clj->js rendered-features))
+        cellWidth 2
+        units "kilometers"
+        ;; generete hexGrid with bounding box
+        hexgrid (.hexGrid js/turf bbox cellWidth units)
+        ;; collect point IDs within each polygon area
+        hex-collection (.collect js/turf hexgrid (clj->js rendered-features)
+                                 "_id" "points")
+        hexbins (js->clj hex-collection :keywordize-keys true)
+        ;; Count points on hexbins
+        features-w-count (for [{{:keys [points]} :properties :as feature}
+                               (:features hexbins)]
+                           (assoc feature :properties
+                                          {:point_count (count points)}))]
+    ;; return hexbins with updated point_count
+    (assoc hexbins :features features-w-count
+                   :properties {:total
+                                (-> rendered-features :features count)})))
+
+(defn show-hexbins
+  [map id_string geojson]
+  (let [id "hexgrid"
+        hexgrid (generate-hexgrid map id_string geojson)
+        _ (.log js/console (clj->js hexgrid))
+        total (-> hexgrid :properties :total)]
+    (add-mapboxgl-source map id {:geojson hexgrid})
+    (add-mapboxgl-layer map id
+                        "fill"
+                        :paint {:fill-outline-color
+                                              {:property "point_count"
+                                               :stops [[0 "transparent"]
+                                                       [total "#ccc"]]}
+                                :fill-color {:property "point_count"
+                                             :stops [[0 "transparent"]
+                                                     [1 "#eff3ff"]
+                                                     [total  "#08519c"]]}
+                                :fill-opacity 0.7})))
+
+(defn remove-hexbins
+  [map]
+  (let [id "hexgrid"]
+    (when (.getLayer map id) (.removeSource map id))
+    (when (.getLayer map id) (.removeLayer map id))))

 (defn map-on-load
   "Functions that are called after map is loaded in DOM."
@@ -533,24 +574,16 @@
       (register-mapboxgl-mouse-events owner map event-chan id_string style)
       (set-mapboxgl-paint-property
        map id_string (get-style-properties style :normal :stops stops))
+      ;; add layer that acts as border for point type layers,
+      ;; otherwise remove the layer if it exists
       (if (= :point style)
         (add-mapboxgl-layer map id_string layer-type
                             :layer-id circle-border
                             :paint {:circle-color "#fff" :circle-radius 6})
         (when (.getLayer map circle-border) (.removeLayer map circle-border)))
+      (show-hexbins map id_string geojson)
       (om/set-state! owner :style style)
-      (om/set-state! owner :loaded? true)
-
-      (add-mapboxgl-source map "hexgrid"
-                           {:geojson (generate-hexgrid map id_string geojson)})
-      (add-mapboxgl-layer map "hexgrid"
-                          "fill"
-                          :paint {:fill-outline-color "#ccc"
-                                  :fill-color {:property "point_count"
-                                               :stops [[0 "transparent"]
-                                                       [1 "#eff3ff"]
-                                                       [100 "#08519c"]]}
-                                  :fill-opacity 0.7}))))
+      (om/set-state! owner :loaded? true))))

 (defn clear-map-styles
   "Set default style"


Switch to explicit unit based preset intervals for x-axis grid spacing.

--- metlog-vault/src-client/metlog_client/tsplot.cljs
+++ metlog-vault/src-client/metlog_client/tsplot.cljs
@@ -27,11 +27,35 @@
                  [ 1 2 5 ]))
           (range -3 3)))

+(defn seconds [ seconds ] (* 1000 seconds))
+(defn minutes [ minutes ] (seconds (* 60 minutes)))
+(defn hours [ hours ] (minutes (* 60 hours)))
+(defn days [ days ] (hours (* 24 days)))
+
 (def x-line-intervals
-  (mapcat (fn [ scale ]
-            (map #(* % scale 1000)
-                 [ 1 2 3 6 12 ]))
-          [ 1 60 3600 86400 ]))
+  [(seconds 1)
+   (seconds 2)
+   (seconds 5)
+   (seconds 10)
+   (seconds 15)
+   (seconds 30)
+   (minutes 1)
+   (minutes 2)
+   (minutes 5)
+   (minutes 10)
+   (minutes 15)
+   (minutes 30)
+   (hours 1)
+   (hours 2)
+   (hours 3)
+   (hours 6)
+   (hours 12)
+   (days 1)
+   (days 2)
+   (days 3)
+   (days 7)
+   (days 14)
+   (days 30)])

 (def stroke-styles
   {:grid


add few rules for EN time

add few rules for EN time

--- resources/duckling/rules/en.time.clj
+++ resources/duckling/rules/en.time.clj
@@ -38,7 +38,7 @@
   (day-of-week 3)

   "named-day"
-  #"(?i)thursday|thu\.?"
+  #"(?i)thursday|thu(rs?)?\.?"
   (day-of-week 4)

   "named-day"


Require core.async in user ns.

Require core.async in user ns.

--- dev/user.clj
+++ dev/user.clj
@@ -1,5 +1,6 @@
 (ns user
   (:require
+    [clojure.core.async :as async :refer [<! <!! >! >!!]]
     [clojure.java.io :as io]
     [clojure.pprint :refer [pprint]]
     [clojure.repl :refer :all]


Moving repeat-last-request.

Moving repeat-last-request.

--- dev/user.clj
+++ dev/user.clj
@@ -5,7 +5,7 @@
             [cmr.common.log :refer (debug info warn error)]
             [cmr.common.api.web-server :as web]
             [cmr.search.api.routes :as routes]
-            [cmr.common.test.repeat-last-request :as repeat-last-request :refer (repeat-last-request)])
+            [cmr.common.dev.repeat-last-request :as repeat-last-request :refer (repeat-last-request)])
   (:use [clojure.test :only [run-all-tests]]
         [clojure.repl]
         [alex-and-georges.debug-repl]))


Invoking touch user.clj helper to avoid namespace refresh issues.

--- dev/user.clj
+++ dev/user.clj
@@ -2,7 +2,8 @@
   (:require [clojure.pprint :refer (pprint pp)]
             [clojure.tools.namespace.repl :refer (refresh refresh-all)]
             [cmr.dev-system.system :as system]
-            [cmr.common.log :as log :refer (debug info warn error)])
+            [cmr.common.log :as log :refer (debug info warn error)]
+            [cmr.common.dev.util :as d])
   (:use [clojure.test :only [run-all-tests]]
         [clojure.repl]
         [alex-and-georges.debug-repl]))
@@ -15,7 +16,8 @@
   (let [s (system/create-system)]
     (alter-var-root #'system
                     (constantly
-                      (system/start s)))))
+                      (system/start s))))
+  (d/touch-user-clj))

 (defn stop
   "Shuts down and destroys the current development system."


use only the monad... no need for when-valid too

--- src/midje/semi_sweet.clj
+++ src/midje/semi_sweet.clj
@@ -11,13 +11,14 @@
         midje.internal-ideas.file-position
         [midje.internal-ideas.fact-context :only [nested-descriptions within-fact-context]]
         [midje.util debugging form-utils namespace]
-        [midje.error-handling validation-errors semi-sweet-validations]
+        midje.error-handling.validation-errors
+        midje.error-handling.semi-sweet-validations
         [midje.error-handling.exceptions :only [user-error]]
         [midje.util.namespace :only [is-semi-sweet-keyword?]]
         [midje.util.ecosystem :only [line-separator]]
-        [midje.production-mode]
+        midje.production-mode
         [clojure.algo.monads :only [domonad]]
-        [clojure.pprint]
+        clojure.pprint
         [clojure.string :only [join]]))
 (immigrate 'midje.unprocessed)
 (immigrate 'midje.ideas.arrow-symbols)
@@ -160,9 +161,9 @@
   [& _]
   (when (user-desires-checking?)
     (domonad syntax-validate-m [[call-form arrow expected-result & fakes+overrides] (validate &form)
-                                [fakes overrides] (separate-by a-fake? fakes+overrides)]
-      (when-valid fakes
-        (expect-expansion call-form arrow expected-result fakes overrides)))))
+                                [fakes overrides] (separate-by a-fake? fakes+overrides)
+                                _ (validate fakes)]
+      (expect-expansion call-form arrow expected-result fakes overrides))))

 (def ^{:dynamic true
        :doc (str "For Midje tool creators. Hooks into Midje's internal compiler results.


arbitrary high limit

arbitrary high limit

--- src/org/spootnik/cyanite/store.clj
+++ src/org/spootnik/cyanite/store.clj
@@ -152,14 +152,12 @@
          insert!
          :values [ttl data tenant rollup period path time]))
       (fetch [this agg paths tenant rollup period from to]
-        (debug "fetching paths from store: " paths rollup period from to
-               (max-points paths rollup from to))
+        (debug "fetching paths from store: " paths rollup period from to)
         (if-let [data (and (seq paths)
                            (->> (alia/execute
                                  session fetch!
                                  {:values [paths (int rollup) (int period)
-                                           from to
-                                           (max-points paths rollup from to)]})
+                                           from to Integer/MAX_VALUE]})
                                 (map (partial aggregate-with (keyword agg)))
                                 (seq)))]
           (let [min-point  (:time (first data))


Fix typo in footer

Fix typo in footer

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -282,7 +282,7 @@
             (when digest?
               [:tr [:th {:class "small-12 lrge-12"}
                 [:p {:class "footer-paragraph bottom-footer"}
-                  (str "You received this digest because you are part f the " (:org-name data) " team.")]]])
+                  (str "You received this digest because you are part of the " (:org-name data) " team.")]]])
             (when digest?
               [:tr [:th {:class "small-12 lrge-12"}
                 [:p {:class "footer-paragraph bottom-footer underline-link"}


Avoid division by 0 if the previous value is 0.

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -133,7 +133,7 @@
         prior-date (when (and interval prior-period) (utils/format-period interval prior-period))
         formatted-prior-date (when prior-date (s/join " " (butlast (s/split prior-date #" ")))) ; drop the year
         prior-value (when prior-metric (:value prior-metric))
-        metric-delta (when (and value prior-value) (- value prior-value))
+        metric-delta (when (and value prior-value (not= prior-value 0)) (- value prior-value))
         metric-delta-percent (when metric-delta (* 100 (float (/ metric-delta prior-value))))
         formatted-metric-delta (when metric-delta-percent (format-delta metric-delta-percent formatted-prior-date))
         sparkline-metric (when (>= (count spark-periods) 3) (sl/sparkline-html (map :value spark-periods) :blue))


Remove go to digest button and not used read post button var.

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -50,8 +50,6 @@
 (def digest-daily-title "Your daily brief")
 (def digest-message "Hi %s, here are the new posts from your team.")
 (def digest-message-no-name "Here are the new posts from your team.")
-(def digest-go-to-digest-button "go_to_digest")
-(def digest-read-post-button "read_post")

 ;; ----- HTML Fragments -----

@@ -299,8 +297,6 @@
       (h1 title)
       (spacer 24)
       (paragraph subtitle)
-      (spacer 16)
-      (left-button digest-go-to-digest-button digest-url)
       (spacer 40)
       (mapcat post posts)
       (spacer 56)


Fix digest email headline.

Fix digest email headline.

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -50,7 +50,8 @@
 (def verify-instructions-2 "Please click the link below to verify your account.")
 (def verify-button-text "verify_email")

-(def digest-title "The latest from Carrot")
+(def digest-weekly-title "Your weekly brief")
+(def digest-daily-title "Your daily brief")
 (def digest-message "Hi %s, here are the latest posts from your team.")
 (def digest-message-no-name "Hi, here are the latest posts from your team.")

@@ -319,6 +320,9 @@
         posts (mapcat :posts boards)
         digest-url (s/join "/" [config/web-url (:org-slug digest) "all-posts"])
         first-name (:first-name digest)
+        title (if weekly?
+               digest-weekly-title
+               digest-daily-title)
         subtitle (if (s/blank? first-name)
                     digest-message-no-name
                     (format digest-message first-name))]
@@ -331,7 +335,7 @@
                                :org-logo-height (:logo-height digest)
                                :align "center"}))
         (when logo? (spacer 32))
-        (h1 digest-title "center-align")
+        (h1 title "center-align")
         (spacer 16)
         (paragraph subtitle "" "center-align")
         (spacer 16)


Add further node arg checks - make sure there's an even number and that each pair is a string and a float.

--- src/overtone/sc/node.clj
+++ src/overtone/sc/node.clj
@@ -26,11 +26,16 @@
        col))

 (defn- check-node-args!
-  "Throw an error if one of the arg values is not a float."
+  "Throw an error if one of the arg values is not a float or one of the arg
+  names isn't a string or if the count isn't even."
   [args]
+  (when (not (even? (count args)))
+    (throw (Exception. (str "Incorrect number of args. Was expecting an even number, got " (count args) ". Full arg list: " (vec args)))))
+
   (doall
-   (map #(if (not (float? (last %)))
-           (throw (Exception. (str "Incorrect param type. Was expecting a float, got " (with-out-str (pr (last %))) ". Full arg list: " (vec args)) )))
+   (map #(if (not (and (string? (first %))
+                       (float? (last %))))
+           (throw (Exception. (str "Incorrect param pair. Was expecting a string and a float, got " (vec %)". Full arg list: " (vec args)) )))
         (partition 2 args))))

 ;; ### Node


turn ugens into a callable map in addition to just a function (this allows us to query them for information at runtime)

--- src/overtone/sc/ugen.clj
+++ src/overtone/sc/ugen.clj
@@ -555,8 +555,16 @@
   "Returns a function representing the given ugen that will fill in default
   arguments, rates, etc."
   [spec rate special]
-  (let [expand-flags (map #(:expands? %) (:args spec))]
-    (make-expanding (ugen-base-fn spec rate special) expand-flags)))
+  (let [expand-flags (map #(:expands? %) (:args spec))
+        ugen-fn (make-expanding (ugen-base-fn spec rate special) expand-flags)]
+    (callable-map {:name (:name spec)
+                   :doc (:doc spec)
+                   :full-doc (:full-doc spec)
+                   :categories (:categories spec)
+                   :rate rate
+                   :src "Implemented in C code"
+                   :type :ugen}
+                  ugen-fn)))

 ;; TODO: Figure out the complete list of control types
 ;; This is used to determine the controls we list in the synthdef, so we need


Typo in email text

Typo in email text

--- src/polismath/server.clj
+++ src/polismath/server.clj
@@ -186,7 +186,7 @@
          " conversation " [:a {:href conv-url} conv-url] " that has just completed. "
          "You can download the results for this conversation at the following url:"]
      [:p [:a {:href download-url} download-url]]
-     [:p "Please let us know if you have any questons about the data"]
+     [:p "Please let us know if you have any questons about the data."]
      [:p "Thanks for using " polis-link "!"]
      [:p "Christopher Small" [:br] "Chief Data Scientist"]]))


Implement the "choose one" game

Implement the "choose one" game

--- src/randometer/core.cljs
+++ src/randometer/core.cljs
@@ -36,14 +36,63 @@
 (defn shuffle-boards [boards]
   (zipmap (range) (shuffle (range (count boards)))))

-;; define your app data so that it doesn't get over-written on reload
+(defn board-element [board]
+  [:div.board {:style {:display "inline-block"
+                       :vertical-align "middle"
+                       :margin "0.5em"}}
+   (for [row board]
+     [:div.row (apply str (map show-trial row))])])

-(defonce app-state (atom {:text "Hello world!"}))
+(defn board-chooser [{:keys [on-guess on-reset flavortext answertext]} boards keymap guess]
+  [:fieldset {:on-click #(when (some? guess) (on-reset))}
+   [:legend flavortext]
+   (for [ix (range (count boards))]
+     ^{:key ix}
+     [:div {:style {:background-color (when (some? guess)
+                                        (cond
+                                         (= 0 (keymap ix)) "#efe"
+                                         (= guess ix) "#fee"))}}
+      [:label
+       [:input {:type :radio
+                :name "guess"
+                :checked (= ix guess)
+                :disabled (some? guess)
+                :on-click #(on-guess ix)
+                :style {:display "inline-block"
+                        :vertical-align "middle"}}]
+       [board-element (nth boards (keymap ix))]
+       [:span {:style {:display (when (nil? guess) "none")}}
+        (nth answertext (keymap ix))]]])
+   (when (some? guess)
+     [:button {:on-click #(on-reset) :style {:margin-top "0.5em"}}
+      "play again"])])

-(defn hello-world []
-  [:h1 (:text @app-state)])
+(defn choose-one [x xs]
+  (let [game-state (atom {})
+        init-game! (fn []
+                     (let [boards (map #(puzzle muted-generator %) (cons x xs))
+                           keymap (shuffle-boards boards)]
+                      (swap! game-state assoc
+                             :boards boards
+                             :keymap keymap
+                             :guess nil)))
+        guess! (fn [ix]
+                 (swap! game-state assoc :guess ix))]
+    (init-game!)
+    (fn []
+      (let [{:keys [boards keymap guess]} @game-state]
+        [board-chooser {:on-guess #(guess! %)
+                        :on-reset #(init-game!)
+                        :flavortext "Which is truly random?"
+                        :answertext (map #(str % " switch") (cons x xs))}
+         boards keymap guess]))))

-(reagent/render-component [hello-world]
+(defn main-page []
+  [:div
+   [:h1 "Randometer"]
+   [choose-one 0.5 [0.25 0.33 0.67 0.75]]])
+
+(reagent/render-component [main-page]
                           (. js/document (getElementById "app")))


adapt existing tests to last commit and add test for java.net.URL instance

--- test/selmer/core_test.clj
+++ test/selmer/core_test.clj
@@ -562,11 +562,17 @@

 (deftest custom-resource-path-setting
   (is nil? @custom-resource-path)
-  (is (= "/some/path/" (set-resource-path! "/some/path")))
-  (is (= "/any/other/path/" (set-resource-path! "/any/other/path/")))
+  (is (= "file:////some/path/" (set-resource-path! "/some/path")))
+  (is (= "file:////any/other/path/" (set-resource-path! "/any/other/path/")))
+  (is (= "file:////any/other/path/" (set-resource-path! "file:////any/other/path/")))
   (set-resource-path! nil)
-  (is nil? @custom-resource-path)
-  )
+  (is nil? @custom-resource-path))
+
+(deftest custom-resource-path-setting-url
+  (set-resource-path! (clojure.java.io/resource "templates/inheritance"))
+  (is (string? @custom-resource-path))
+  (is (= "Hello, World!\n"  (render-file "foo.html" {:name "World"})))
+  (set-resource-path! nil))

 (deftest safe-filter
   (add-filter! :foo  (fn [^String x] [:safe (.toUpperCase x)]))


Re-use vector create-board & allow on-click to move tiles

--- src/tile_game/grid.cljs
+++ src/tile_game/grid.cljs
@@ -1,5 +1,6 @@
 (ns tile-game.grid
-  (:require [reagent.core :as r]))
+  (:require [reagent.core :as r]
+            [tile-game.board :as b]))

 (enable-console-print!)

@@ -9,13 +10,14 @@
              "#000080" "#0000FF" "#800080" "#FF00FF"])

 (defonce app-state
-  (r/atom {:board (range 0 16)
+  (r/atom {:board (b/create-board 4)
            :dim 4}))

 (defn render-tile [[x y] tile]
   (if-not (zero? tile)
     (let [fill-color (colors tile)]
-      [:g {:key (str "tile-" tile) :on-click #(println tile)}
+      [:g {:key (str "tile-" tile)
+           :on-click #(swap! app-state update-in [:board] b/slide-tile tile)}
        [:rect {:x (+ x 0.05) :y (+ y 0.05) :width 0.9 :height 0.9 :fill fill-color}]
        [:text {:x (+ 0.5 x) :y (+ 0.65 y)
                :font-family "Verdana" :font-size 0.4 :text-anchor "middle"}


Fix typo in blob.core.

Fix typo in blob.core.

--- src/vault/blob/core.clj
+++ src/vault/blob/core.clj
@@ -109,10 +109,8 @@

 (defmethod print-method Blob
   [v ^java.io.Writer w]
-  (->> w
-       (dissoc :content)
-       prn-str
-       (.write w)))
+  (let [v (dissoc v :content)]
+    (.write w (prn-str v))))

 (defn load


Fix race condition on points translation.

This happens sometimes on first workspace load.

--- src/uxbox/ui/workspace/canvas.cljs
+++ src/uxbox/ui/workspace/canvas.cljs
@@ -185,12 +185,12 @@
               (gpt/subtract pt brect)))

           (translate-point-to-canvas [pt]
-            (let [viewport (mx/get-ref-dom own "viewport")
-                  canvas (dom/get-element-by-class "page-canvas" viewport)
-                  brect (.getBoundingClientRect canvas)
-                  brect (gpt/point (parse-int (.-left brect))
-                                   (parse-int (.-top brect)))]
-              (gpt/subtract pt brect)))
+            (let [viewport (mx/get-ref-dom own "viewport")]
+              (when-let [canvas (dom/get-element-by-class "page-canvas" viewport)]
+                (let [brect (.getBoundingClientRect canvas)
+                      brect (gpt/point (parse-int (.-left brect))
+                                       (parse-int (.-top brect)))]
+                  (gpt/subtract pt brect)))))

           (on-key-down [event]
             (when (kbd/space? event)


Changed def int/str to atoms.

Changed def int/str to atoms.

--- comment-breaker/src/comment_breaker/core.clj
+++ comment-breaker/src/comment_breaker/core.clj
@@ -2,31 +2,32 @@
   (:gen-class))
 (use '[clojure.tools.cli :only[cli]])

-(def line-length 80)
-(def sep-char "\r\n")
+(def line-length (atom 80))
+(def sep-char (atom "\r\n"))

 (defn suffix-file [fstr suffix]
   (let [splits (clojure.string/split fstr #"\.")]
     (str (apply str (butlast splits)) suffix "." (last splits))))

 (defn build-line [lines nxt]
-  (if (> (+ (count (last lines)) (inc (count nxt))) line-length)
+  (if (> (+ (count (last lines)) (inc (count nxt))) @line-length)
     (conj lines (str ";; " nxt))
     (conj (into [] (butlast lines)) (str (last lines) \space nxt))))

 (defn eat-line [line]
-  (if (and (> (count line) line-length) (.startsWith line ";;"))
+  (if (and (> (count line) @line-length) (.startsWith line ";;"))
     (clojure.string/replace-first
-      (clojure.string/join sep-char
+      (clojure.string/join @sep-char
         (reduce build-line [""] (clojure.string/split line #"\s")))
       #"\s\;\;\s+"
       ";;   ")
     line))

 (defn process-file [contents]
-  (clojure.string/join sep-char
-    (map eat-line (clojure.string/split contents (re-pattern sep-char)))))
+  (clojure.string/join @sep-char
+    (map eat-line (clojure.string/split contents (re-pattern @sep-char)))))

+;; Should catch exceptions on I/O!
 (defn -main
   [& args]
   (let [cli-vec
@@ -37,10 +38,10 @@
                ["-l" "--line-length" "The desired line length."
                  :default 80 :parse-fn #(Integer. %)])
         cli-map (first cli-vec)
-        ifile (:in-file (first cli-vec))
-        ofile (if-let [o (:out-file (first cli-vec))] o
-                (suffix-file ifile "-broken"))]
+        ifile (:in-file cli-map)
+        ofile (if-let [o (:out-file cli-map)] o
+                (suffix-file ifile "-broken"))]		; causes a NPE if no in!
     (if-not ifile (prn (last cli-vec))
       (do
-        (def line-length (:line-length cli-map))
+        (reset! line-length (:line-length cli-map))
         (spit ofile (process-file (slurp ifile)))))))


Doc for various functions from db-interface module

--- src/zg/db_interface.clj
+++ src/zg/db_interface.clj
@@ -134,6 +134,7 @@
     (read-words-with-status :undeleted dictionary-type))

 (defn read-changes-statistic
+    "Read basic statistic about changes made by all users. For each user, number of changes is displayed."
     []
     (try
         (jdbc/query db-spec/zg-db
@@ -143,6 +144,7 @@
             [])))

 (defn read-changes
+    "Read all changes sorted by date and time the change has been made."
     []
     (try
         (jdbc/query db-spec/zg-db
@@ -152,6 +154,7 @@
             [])))

 (defn read-changes-for-user
+    "Read all changes for selected user sorted by date and time the change has been made."
     [user-name]
     (try
         (jdbc/query db-spec/zg-db


Modified resource extraction to use getProtocol

--- storm-core/src/clj/backtype/storm/daemon/supervisor.clj
+++ storm-core/src/clj/backtype/storm/daemon/supervisor.clj
@@ -533,7 +533,7 @@
               url
               (do
                 (log-message "Copying resources at " (str url) " to " target-dir)
-                (if (.startsWith (str url) "jar:file:" )
+                (if (= (.getProtocol url) "jar" )
                     (extract-dir-from-jar (.getFile (.getJarFileURL (.openConnection url))) RESOURCES-SUBDIR stormroot)
                     (FileUtils/copyDirectory (File. (.getFile url)) (File. target-dir)))
                 )


Releasing modular.bidi

Releasing modular.bidi

--- modules/bidi/project.clj
+++ modules/bidi/project.clj
@@ -1,12 +1,12 @@
 ;; Copyright © 2014 JUXT LTD.

-(defproject juxt.modular/bidi "0.7.3-SNAPSHOT"
+(defproject juxt.modular/bidi "0.7.3"
   :description "A modular extension that provides support for bidi routing"
   :url "https://github.com/juxt/modular/tree/master/modules/bidi"
   :license {:name "The MIT License"
             :url "http://opensource.org/licenses/MIT"}
   :dependencies [[com.stuartsierra/component "0.2.1"]
-                 [bidi "1.15.1"]
+                 [bidi "1.16.0"]
                  [juxt.modular/ring "0.5.2"]
                  [prismatic/schema "0.3.3"]
                  [prismatic/plumbing "0.3.5"]]


Add align to text and circle resize.

Add align to text and circle resize.

--- src/uxbox/util/geom.cljs
+++ src/uxbox/util/geom.cljs
@@ -141,12 +141,15 @@
 ;; --- Vertex Access

 (declare get-rect-vertext-point)
+(declare get-circle-vertext-point)

 (defn get-vertex-point
   [shape id]
   (case (:type shape)
     :icon (get-rect-vertext-point shape id)
-    :rect (get-rect-vertext-point shape id)))
+    :rect (get-rect-vertext-point shape id)
+    :circle (get-circle-vertext-point shape id)
+    :text (get-rect-vertext-point shape id)))

 (defn- get-rect-vertext-point
   [{:keys [x1 y1 x2 y2]} id]
@@ -155,6 +158,10 @@
     2 (gpt/point x2 y1)
     3 (gpt/point x1 y2)
     4 (gpt/point x2 y2)))
+
+(defn- get-circle-vertext-point
+  [{:keys [rx ry]} id]
+  (gpt/point rx ry))

 ;; --- Vertex Movement (Relative)


fix newdoc icon, better alignment

fix newdoc icon, better alignment


cleanup

cleanup

--- src/metabase/driver/query_processor/annotate.clj
+++ src/metabase/driver/query_processor/annotate.clj
@@ -82,7 +82,7 @@
 (defn- field-positiono [field v]
   (featurec field {:position v}))

-(defn- fields-sorted-by-nameo [{:keys [result-keys]} f1 f2]
+(defn- field-name< [{:keys [result-keys]} f1 f2]
   (fresh [n1 n2]
     (featurec f1 {:field-name n1})
     (featurec f2 {:field-name n2})
@@ -142,7 +142,7 @@
                                                   (special-type-groupo f1 t1)
                                                   (special-type-groupo f2 t2)
                                                   (conda ((ar/< t1 t2))
-                                                         ((== t1 t2) (fields-sorted-by-nameo query f1 f2)))))))))))))
+                                                         ((== t1 t2) (field-name< query f1 f2)))))))))))))

 ;;; ## Top-Level Resolution / Ordering


remove undo/redo button bindings for now

--- src/app/cljs/one/sample/view/editor.cljs
+++ src/app/cljs/one/sample/view/editor.cljs
@@ -25,8 +25,6 @@
   (let [field     (spawn-editor element)
         content   (doc-session :get :content)
         new       ($ "button#new")
-        undo      ($ "button#undo")
-        redo      ($ "button#redo")
         set-html! (fn [content] (. field (setHtml false (or content "") true)))]
     (do
       (set-html! content)
@@ -41,12 +39,6 @@
                               (do
                                 (doc-session :conj-history! content)
                                 (doc-session :reset-cursor!))))))
-    (event/listen undo
-                  CLICK
-                  (fn [e] (let [content (doc-session :undo)] (set-html! content))))
-    (event/listen redo
-                  CLICK
-                  (fn [e] (let [content (doc-session :redo)] (set-html! content))))
     (event/listen new
                   CLICK
                   (fn [e]


CMR-5423: Remove unnecessary ns require.

--- search-app/src/cmr/search/api/concepts_search.clj
+++ search-app/src/cmr/search/api/concepts_search.clj
@@ -5,7 +5,6 @@
    [clj-http.client :as client]
    [cmr.common-app.api.routes :as common-routes]
    [cmr.common-app.services.search :as search]
-   [cmr.common-app.site.pages :as common-pages]
    [cmr.common.cache :as cache]
    [cmr.common.config :refer [defconfig]]
    [cmr.common.log :refer (debug info warn error)]


Add reset route

Add reset route

--- router/src/router/core.clj
+++ router/src/router/core.clj
@@ -36,12 +36,17 @@
   (h/reload-haproxy! template-path bindings)
   (response {:status "ok"}))

+(defn reset-router! []
+  (reset! services {})
+  (response {:status "ok"}))
+
 (defroutes app-routes
   (GET "/status" [] (response (str @services)))
   (POST "/register" {body :body} (register-service body))
   (POST "/start"  [] (start! template-path @services))
   (POST "/stop"   [] (stop!))
   (POST "/reload" [] (reload! template-path @services))
+  (POST "/reset" [] (reset-router!))
   (route/not-found "Not Found"))

 (def app


It can walk..

It can walk..

--- ClojureScript/hello.cljs
+++ ClojureScript/hello.cljs
@@ -19,7 +19,9 @@
 (def tick-step (/ 1 100))
 (def render-step (/ 1 25))
 (def gravity-strength 300)
-(def ground-strength 100)
+(def ground-rebound-strength 200)
+(def ground-grip-strength 50)
+(def drag-factor 5)

 (defn print-to-log [v]
     (.log js/console v))
@@ -37,7 +39,7 @@
 (defn rot-cw [[x y]] [y (- x)])
 (defn rot-ccw [[x y]] [(- y) x])

-(defn make-node [x y] {:pos [x y] :vel [0 0]})
+(defn make-node [x y m] {:pos [x y] :vel [0 0] :mass m})
 (defn make-spring [a b] {:node-a a :node-b b})
 (defn make-hinge [a b c min-a max-a] {:node-a a :node-b b :node-c c :min-modifier-angle min-a :max-modifier-angle max-a})
 (defn make-state [nodes springs hinges] {
@@ -60,18 +62,23 @@

 (def initial-game-state (make-state
     {
-        :head (make-node 250 150)
-        :tail (make-node 50 150)
-        :h-l-k (make-node 260 75)
-        :h-l-f (make-node 250 0)
-        :h-t-k (make-node 260 75)
-        :h-t-f (make-node 250 0)
-        :t-l-k (make-node 40 75)
-        :t-l-f (make-node 50 0)
-        :t-t-k (make-node 40 75)
-        :t-t-f (make-node 50 0)
+        :hump (make-node 200 225 2)
+        :head (make-node 300 150 2)
+        :tail (make-node 100 150 2)
+
+        :h-l-k (make-node 310 75 0.5)
+        :h-l-f (make-node 300 0 0.5)
+        :h-t-k (make-node 310 75 0.5)
+        :h-t-f (make-node 300 0 0.5)
+
+        :t-l-k (make-node 90 75 0.5)
+        :t-l-f (make-node 100 0 0.5)
+        :t-t-k (make-node 90 75 0.5)
+        :t-t-f (make-node 100 0 0.5)
     }
     (map (partial apply make-spring) [
+        [:hump :head]
+        [:hump :tail]
         [:head :tail]
         [:head :h-l-k]
         [:h-l-k :h-l-f]
@@ -146,26 +153,37 @@
             hinges)))

 (defn calculate-gravity-forces [nodes]
-    (zipmap (keys nodes) (repeat [0 (- gravity-strength)])))
+    (zipmap (keys nodes)
+        (map (fn [{m :mass}]
+            [0 (- (* gravity-strength m))])
+            (vals nodes))))

 (defn calculate-ground-forces [nodes]
     (zipmap (keys nodes)
         (map (fn [{[ x y ] :pos [ xv yv ] :vel }]
             (if (< y 0)
-                (vec* [(- xv) (+ (Math/max 0 (- yv)) (- y))] ground-strength)
+                (vec+
+                    (vec* [(- xv) (Math/max 0 (- yv))] ground-grip-strength)
+                    (vec* [0 (- y)] ground-rebound-strength))
                 [0 0])) (vals nodes))))
+
+(defn calculate-drag-forces [nodes]
+    (zipmap (keys nodes)
+        (map (fn [{v :vel m :mass}] (vec* v (- (* m drag-factor))))
+            (vals nodes))))

 (defn calculate-all-node-forces [{:keys [nodes springs hinges]}]
     (merge-with vec+
         (calculate-spring-forces nodes springs)
         (calculate-hinge-forces nodes hinges)
         (calculate-gravity-forces nodes)
-        (calculate-ground-forces nodes)))
+        (calculate-ground-forces nodes)
+        (calculate-drag-forces nodes)))

 (defn update-node-velocities [nodes forces time-step]
     (merge-with (fn [n f]
         (assoc n
-            :vel (vec+ (:vel n) (vec* f time-step))))
+            :vel (vec+ (:vel n) (vec* f (/ time-step (:mass n))))))
         nodes
         forces))

@@ -193,30 +211,30 @@
     (assoc state
         :hinges
             (let
-                [[q w i o a s k l] (map (:keys input-state) [
-                    KeyCodes/Q KeyCodes/W KeyCodes/I KeyCodes/O
-                    KeyCodes/A KeyCodes/S KeyCodes/K KeyCodes/L
+                [[fca fcb fka fkb rca rcb rka rkb] (map (:keys input-state) [
+                    KeyCodes/I KeyCodes/O KeyCodes/K KeyCodes/L
+                    KeyCodes/Q KeyCodes/W KeyCodes/A KeyCodes/S
                     ])]
                 (map (fn [h] (let [hn (hinge-nodes h)]
                     (assoc h :modifier-angle
                         (clamp (+ (:modifier-angle h)
                             (cond
                                 (= hn [:tail :head :h-l-k])
-                                    (+ (if q 0.05 0.0) (if w -0.05 0.0))
+                                    (+ (if fca 0.05 0.0) (if fcb -0.05 0.0))
                                 (= hn [:head :h-l-k :h-l-f])
-                                    (+ (if i 0.05 0.0) (if o -0.05 0.0))
+                                    (+ (if fka 0.05 0.0) (if fkb -0.05 0.0))
                                 (= hn [:tail :head :h-t-k])
-                                    (+ (if q -0.05 0.0) (if w 0.05 0.0))
+                                    (+ (if fca -0.05 0.0) (if fcb 0.05 0.0))
                                 (= hn [:head :h-t-k :h-t-f])
-                                    (+ (if i -0.05 0.0) (if o 0.05 0.0))
+                                    (+ (if fka -0.05 0.0) (if fkb 0.05 0.0))
                                 (= hn [:head :tail :t-l-k])
-                                    (+ (if a 0.05 0.0) (if s -0.05 0.0))
+                                    (+ (if rca 0.05 0.0) (if rcb -0.05 0.0))
                                 (= hn [:tail :t-l-k :t-l-f])
-                                    (+ (if k 0.05 0.0) (if l -0.05 0.0))
+                                    (+ (if rka 0.05 0.0) (if rkb -0.05 0.0))
                                 (= hn [:head :tail :t-t-k])
-                                    (+ (if a -0.05 0.0) (if s 0.05 0.0))
+                                    (+ (if rca -0.05 0.0) (if rcb 0.05 0.0))
                                 (= hn [:tail :t-t-k :t-t-f])
-                                    (+ (if k -0.05 0.0) (if l 0.05 0.0))
+                                    (+ (if rka -0.05 0.0) (if rkb 0.05 0.0))
                                 :else
                                     0.0))
                             (:min-modifier-angle h) (:max-modifier-angle h)))))
@@ -268,7 +286,6 @@
         game-state-ref (atom initial-game-state)
         input-state-ref (atom {:keys (set)})
         canvas (dom/createDom "div" {} "")
-        button (dom/createDom "button" {} "Click!")
         tick-timer (goog.Timer. (Math/round (* 1000 tick-step)))
         render-timer (goog.Timer. (Math/round (* 1000 render-step)))
         ]
@@ -276,14 +293,13 @@
             (. tick-timer (start))
             (. render-timer (start))
             (dorun (map (partial apply events/listen) [
-                [button EventType/CLICK (partial input-event input-state-ref)]
                 [document.body EventType/KEYDOWN (partial input-event input-state-ref) true]
                 [document.body EventType/KEYUP (partial input-event input-state-ref) true]
                 [tick-timer Timer/TICK #(tick game-state-ref (deref input-state-ref))]
                 [render-timer Timer/TICK #(rerender canvas (deref game-state-ref))]]))
             (dom/appendChild document.body (dom/createDom "div" {}
-                (dom/createDom "h1" {} "Work in progress..")
-                (dom/createDom "div" {} "Try clicking the button, or pressing keys.")
+                (dom/createDom "h1" {} "QWASIOKL!!")
+                (dom/createDom "div" {} "Try pressing keys Q, W, A, S, I, O, K, and L.")
                 (dom/createDom "div" {}
                     (dom/createTextNode "My code lives here: ")
                     (dom/createDom "a" (.strobj {"href" my-code-url}) my-code-url))


good enough instrumentation for chrome dev tools

--- spinning/src/app/core.cljs
+++ spinning/src/app/core.cljs
@@ -261,20 +261,16 @@
   "Returns a channel containing a single map of the next generation of cells."
   (go
     (console/time-start "neighborhood")
-    (let [generation (chan 1 (keep (partial cell-fate cells)))
-          neighborhood (mapcat neighbors (keys cells))]
+    (let [neighborhood  (mapcat neighbors (keys cells))
+          neighbor-freq (frequencies neighborhood)]
       (console/time-end "neighborhood")
-      (console/time-start "cell-neighbor-freq")
-      (let [cell-neighbor-freq (frequencies neighborhood)]
-        (console/time-end "cell-neighbor-freq")
-        ;(<! (timeout 0))
-        (<! (yield))
-        (console/time-start "onto-chan generation")
-        (onto-chan generation cell-neighbor-freq)
-        (console/time-end "onto-chan generation")
-        ;(<! (timeout 0))
-        (<! (yield))
-        (<! (async/into {} generation))))))
+      (<! (yield))
+      (console/time-start "generation-ch")
+      (let [generation-ch (chan 1 (keep (partial cell-fate cells)))]
+        (onto-chan generation-ch neighbor-freq)
+        (let [new-cells (<! (async/into {} generation-ch))]
+          (console/time-end "generation-ch")
+          new-cells)))))

 (defn setup-gol! []
   (swap! state assoc-in [:gol :cells] (create-cells acorn)))
@@ -285,14 +281,14 @@
   (swap! state assoc-in [:gol :generation] 0))

 (defn swap-gol! [cells]
-  (console/time-end (str "Generation " (get-in @state [:gol :generation])))
+  (console/time-end (str "Generation " (inc (get-in @state [:gol :generation]))))
   (swap! state assoc-in [:gol :cells] cells)
   (swap! state update-in [:gol :generation] inc)
   (swap! state assoc-in [:gol :busy?] false))

 (defn update-gol! []
   (when-not (get-in @state [:gol :busy?])
-    (console/time-start (str "Generation " (get-in @state [:gol :generation])))
+    (console/time-start (str "Generation " (inc (get-in @state [:gol :generation]))))
     (swap! state assoc-in [:gol :busy?] true)
     (take! (step-chan (get-in @state [:gol :cells])) swap-gol!)))

@@ -343,8 +339,14 @@
   (render-cells! (app-context) state))

 (defn animate! [timestamp]
+  (when (= 0 (get-in @state [:gol :generation]))
+    (console/time-start "gen-100"))
   (update!)
   (render! timestamp @state)
+  (when (= 100 (get-in @state [:gol :generation]))
+    (stop-gol!)
+    (console/time-end "gen-100")
+    (console/info (str "Frame " (get-in @state [:env :frame-count]))))
   (get-in @state [:app :rendering?]))

 (defn start-rendering! []


gamepad functionality

gamepad functionality

--- src/cljs/infinitelives/utils/events.cljs
+++ src/cljs/infinitelives/utils/events.cljs
@@ -286,3 +286,22 @@
 (install-key-handler)
 (install-frame-handler)
 (install-resize-handler)
+
+;;
+;; gamepad wrapper
+;;
+
+;; define game controller functions
+(defn make-get-gamepads []
+  (cond
+   (.-getGamepads js/navigator)
+   #(.getGamepads js/navigator %)
+
+   (.-webkitGetGamepads js/navigator)
+   #(.webkitGetGamepads js/navigator %)
+
+   :default
+   #()))
+
+(def get-gamepads (make-get-gamepads))
+


webcam set image fx

webcam set image fx

--- src/cljs/re_form/inputs/webcam_impl.cljs
+++ src/cljs/re_form/inputs/webcam_impl.cljs
@@ -59,6 +59,22 @@
                           (when-let [on-image-ev (:on-image opts)]
                             (rf/dispatch (into on-image-ev [photo-name]))))))))

+(rf/reg-fx
+ :webcam/set-images
+ (fn [args]
+   (doall
+    (for [[photo-name src] (partition 2 args)]
+      (do
+        (let [{:keys [video canvas opts]} (get @widget-state photo-name)
+              context (.getContext canvas "2d")
+              img (js/Image.) ]
+          (set! (.-crossOrigin img) "anonymous")
+          (set! (.-onload img)
+                #(do (.drawImage context img 0 0 (:width opts) (:height opts))
+                     (set! (.. video -style -display) "none")
+                     (set! (.. canvas -style -display) "block")))
+          (set! (.-src img) src)))))))
+
 (rf/reg-event-fx
  :webcam/photo
  (fn [{db :db} [_ photo-name]]


small fix

small fix

--- src/cljs/salava/social/ui/dashboard.cljs
+++ src/cljs/salava/social/ui/dashboard.cljs
@@ -326,7 +326,7 @@
           (when (pos? (:pending-endorsements @state)) [:span.badge (:pending-endorsements @state)])
           [:div.text
            [:p.num (:endorsers @state)]
-           [:p.desc (t :badge/Endorsing)]
+           [:p.desc (t :badge/Endorsers)]
            ]]]]]]]]])

 (defn profile-block [state]


add fast-car-tab from extraction result

add fast-car-tab from extraction result

--- ohack/src/ohack/core.clj
+++ ohack/src/ohack/core.clj
@@ -161,12 +161,10 @@
 ;; we're going to fetch the tab from
 ;; http://tabs.ultimate-guitar.com/t/tracy_chapman/fast_car_ver8_tab.htm
 (def fast-car-html (slurp "http://tabs.ultimate-guitar.com/t/tracy_chapman/fast_car_ver8_tab.htm"))
-;; verify we grabbed some html?
-(print (.substring fast-car-html 2000 3000))
-;; we're just going to extract the tab section by visual inspection...
-(print
- (-> fast-car-html
-     (.split "Tabbed by")
-     second
-     (.split "hammer-on")
-     first))
+;; ok, it's working, now save the tab
+(def fast-car-tab
+  (-> fast-car-html
+      (.split "Tabbed by")
+      second
+      (.split "hammer-on")
+      first))


add buffer

add buffer

--- ohack/src/ohack/core.clj
+++ ohack/src/ohack/core.clj
@@ -186,12 +186,13 @@
   ;; blocks of 6 lines must occur with consecutive line
   ;; indexes, so lets detect that.

-  ;; set up our recursion skeleton.
-  ;; it returns a copy of the original list
   (loop [input (map first index-line-list)
+         ;; use a buffer to store incoming consecutive indexes
+         buf []
          rtn []]
     (if (empty? input)
       rtn
       (recur (rest input)
+             buf
              (conj rtn (first input)))))
   )


fix redesigned registry v2 edit form

fix redesigned registry v2 edit form

--- src/cljs/swarmpit/component/registry_v2/edit.cljs
+++ src/cljs/swarmpit/component/registry_v2/edit.cljs
@@ -42,7 +42,7 @@
      :onChange        #(state/update-value [:url] (-> % .-target .-value) state/form-value-cursor)}))

 (defn- form-custom [value]
-  (comp/checkbox
+  (comp/switch
     {:name     "custom"
      :label    "Custom"
      :color    "primary"
@@ -91,6 +91,7 @@
   (comp/switch
     {:checked  value
      :value    (str value)
+     :color    "primary"
      :onChange #(state/update-value [:public] (-> % .-target .-checked) state/form-value-cursor)}))

 (defn- registry-handler


Uncomment the error-build test

Uncomment the error-build test

--- test/fm/land/arachne/sass_test.clj
+++ test/fm/land/arachne/sass_test.clj
@@ -77,12 +77,12 @@
         result     (slurp (io/file output-dir "css/application.css"))]
     (is (re-find #"background-color: #0000FF;" result))))

-;; (deftest error-build
-;;   (let [output-dir (fs/tmpdir!)
-;;         cfg        (arachne/build-config [:fm.land/arachne-sass]
-;;                                          `(fm.land.arachne.sass-test/build-cfg "error.scss" ~(.getCanonicalPath output-dir) false))]
-;;     (is (thrown? arachne.ArachneException
-;;                  (component/start (rt/init cfg [:arachne/id :test/rt]))))))
+(deftest error-build
+  (let [output-dir (fs/tmpdir!)
+        cfg        (arachne/build-config [:fm.land/arachne-sass]
+                                         `(fm.land.arachne.sass-test/build-cfg "error.scss" ~(.getCanonicalPath output-dir) false))]
+    (is (thrown? arachne.ArachneException
+                 (component/start (rt/init cfg [:arachne/id :test/rt]))))))

 ;;
 ;; Test a more complicated build


Scheme validation

Scheme validation

--- test/icecap/handlers/http_test.clj
+++ test/icecap/handlers/http_test.clj
@@ -3,7 +3,7 @@
             [manifold.deferred :as d]
             [icecap.handlers.core :refer [execute]]
             [icecap.schema :refer [check-plan]]
-            [icecap.handlers.http]
+            [icecap.handlers.http :refer [valid-scheme?]]
             [icecap.test-data :refer [simple-http-step simple-https-step]]
             [aleph.http :as h]
             [clojure.test :refer :all]))
@@ -53,6 +53,16 @@
          '{:url (invalid-scheme
                  (not (#{:http :https} :bogus)))})))

+(deftest valid-scheme?-tests
+  (testing "valid schemes"
+    (are [url] (valid-scheme? url)
+         "http://example.test"
+         "https://example.test"))
+  (testing "invalid schemes"
+    (are [url] (not (valid-scheme? url))
+         "bogus://example.test"
+         "ftp://example.test")))
+
 (def fake-response
   ::my-fake-response)


daily message expansion

daily message expansion

--- src/clj/ceres_analytics/measures.clj
+++ src/clj/ceres_analytics/measures.clj
@@ -79,8 +79,13 @@
       first
       count)

-  (aprint (map #(density :full (t/date-time 2015 4 %)) (range 3 20)))

-  (aprint (mc/find-maps @db "users" {:name "SZ"}))
+  (aprint (zipmap
+           (range 2 28)
+           (map
+            #(mc/count @db "messages" {:ts {$gt (t/date-time 2015 4 %)
+                                            $lt (t/date-time 2015 4 (inc %))}})
+            (range 2 28))))
+

   )


get user badge endorsements

get user badge endorsements

--- src/clj/salava/badge/endorsement.clj
+++ src/clj/salava/badge/endorsement.clj
@@ -51,7 +51,9 @@

 (defn user-badge-endorsements
   [ctx user-badge-id]
-  (select-user-badge-endorsements {:user_badge_id user-badge-id} (get-db ctx)))
+  (reduce (fn [r e]
+            (conj r (-> e (update :content md->html)))
+            ) [] (select-user-badge-endorsements {:user_badge_id user-badge-id} (get-db ctx))))

 (defn received-pending-endorsements [ctx user-id]
   (map (fn [e]
@@ -61,13 +63,9 @@
 (defn all-given-endorsements [ctx endorser-id])

-;;Endorse a badge earner
-;Accept or decline endorsement
+
 ;Send information to obf
-;Pick from suggested phrases or write own endorsement
 ;Endorsements show in user profile
-;Notifications for new endorsements in stream where user can accept or reject.
-;User cannot endorse themselves
 ;Delete endorsement?
 ;GDPR
 ;badge-pdf


Refactoring: use predicates zero? and one? instead of ugly comparators

--- src/clj_calendar/format_datetime.clj
+++ src/clj_calendar/format_datetime.clj
@@ -13,6 +13,11 @@
 (ns clj-calendar.format-datetime
     "Namespace that contains various functions for handling calendar and dates.")

+(defn one?
+    "Predicate that is especially useful in this namespace."
+    [n]
+    (== n 1))
+
 (defn format-time
     "Format a given time unit into human readable format."
     [amount unit]
@@ -21,15 +26,15 @@
 (defn format-time-
     "Format time into human readable format."
     [amount1 amount2 unit1 unit2]
-    (if (= amount1 1)
+    (if (one? amount1)
         (cond
-            (= amount2 0) (format "one %s ago" unit1)
-            (= amount2 1) (format "one %s and one %s ago" unit1 unit2)
-            :else         (format "one %s and %d %ss ago" unit1 amount2 unit2))
+            (zero? amount2) (format "one %s ago" unit1)
+            (one? amount2)  (format "one %s and one %s ago" unit1 unit2)
+            :else           (format "one %s and %d %ss ago" unit1 amount2 unit2))
         (cond
-            (= amount2 0) (format "%d %ss ago" amount1 unit1)
-            (= amount2 1) (format "%d %ss and one %s ago" amount1 unit1 unit2)
-            :else         (format "%d %ss and %d %ss ago" amount1 unit1 amount2 unit2))))
+            (zero? amount2) (format "%d %ss ago" amount1 unit1)
+            (one? amount2)  (format "%d %ss and one %s ago" amount1 unit1 unit2)
+            :else           (format "%d %ss and %d %ss ago" amount1 unit1 amount2 unit2))))

 (defn format-month
@@ -38,9 +43,9 @@
     (if (> months 1)
         (format "%d months ago" months)
         (cond
-            (== days 0) "one month ago"
-            (>  days 1) (format "one month and %d days ago" days)
-            :else       (format "one month and one day ago"))))
+            (zero? days) "one month ago"
+            (>  days 1)  (format "one month and %d days ago" days)
+            :else        (format "one month and one day ago"))))

 (defn format-day
     "Format days/hours in case the given build is younger than one month."
@@ -60,7 +65,7 @@
 (defn format-seconds
     "Format seconds into human readable format."
     [seconds]
-    (if (= seconds 1)
+    (if (one? seconds)
         (format "one second ago")
         (format "%d seconds ago" seconds)))


ENH: chapter 5, part 3: collection abstraction

--- src/clj_prj03/ch5_core_functions.clj
+++ src/clj_prj03/ch5_core_functions.clj
@@ -199,3 +199,46 @@
 (take 10 (even-numbers))

 (cons 0 '(2 4 6))
+
+; ------------------------------------
+; 3. The collection abstraction
+; ------------------------------------
+
+(empty? [])
+(empty? ["no!"])
+
+(map identity {:sunlight-reaction "Glitter!"}) ; returns a seq (not map)
+(into {} (map identity {:sunlight-reaction "Glitter!"}))  ; now into a map
+
+
+;; conversion back into vector
+(map identity [:garlic :sesame-oil :fried-eggs])
+;; -> seq
+
+(into [] (map identity [:garlic :sesame-oil :fried-eggs]))
+;; -> into vector
+
+;; conversion back into list
+(map identity [:garlic-clove :garlic-clove]) ; -> seq
+
+;; conversion into unique values
+(into #{} (map identity [:garlic-clove :garlic-clove])) ; -> set with unique
+
+;; the first element of into doesn't have to be empty
+(into {:favorite-emotion "gloomy"} [[:sunlight-reaction "Glitter!"]])
+(into ["cherry"] '("pine" "spruce"))
+(into {:favorite-animal "kitty"} {:least-favorite-smell "dog"
+                                  :relationship-with-teenager "creepy"})
+
+; 3.2 conj function
+(conj [0] [1]) ;; -> [0 [1]]
+(into [0] [1]) ;; -> [0 1]
+
+(conj [0] 1 2 3 4)
+(conj {:time "midnight"} [:place "ye olde cemetarium"])
+
+(defn my-conj
+  [target & additions]
+  (into target additions))
+
+(my-conj [0] 1 2 3)


Add draggable for <div> whose lesson type has more than 1 lesson group

Since a lesson type with only 1 choice of lesson group must use that
lesson group and have no other choices.

Signed-off-by: Pang Yan Han <22594c345857f664c61cd411f607c4d40a9d4af9@gmail.com>

--- src/cljs/cljs_nusmods/timetable.cljs
+++ src/cljs/cljs_nusmods/timetable.cljs
@@ -531,7 +531,6 @@
       (timetable-prune-empty-rows affectedDaysSet)
       (set! Lessons-Created-By-Draggable nil))))

-; TODO: Make lesson type with only a single lessongroup non-draggable
 (defn- make-added-lessons-draggable
   "Makes the <div> elements of selected lessons draggable."
   [$divElemSeq moduleCode lessonType lessonLabel bgColorCssClass]
@@ -600,8 +599,14 @@
                         select2/$Select2-Box
                         (get-selected-module-codes-as-js-array))))

-                (make-added-lessons-draggable $divElemSeq moduleCode lessonType
-                                              lessonLabel bgColorCssClass)))
+                ; Only lesson types with more than 1 option of lesson group
+                ; will be draggable
+                (if (> (count (get-in ModulesMap [moduleCode "lessons"
+                                                  lessonType]))
+                       1)
+                    (make-added-lessons-draggable $divElemSeq moduleCode
+                                                  lessonType lessonLabel
+                                                  bgColorCssClass))))
           augLessonInfoSeq))))

 (defn add-module


`timetable-day-get-nr-rows` - dispatch to true

Because that seems to be the more common use case

Signed-off-by: Pang Yan Han <22594c345857f664c61cd411f607c4d40a9d4af9@gmail.com>

--- src/cljs/cljs_nusmods/timetable.cljs
+++ src/cljs/cljs_nusmods/timetable.cljs
@@ -440,7 +440,7 @@
   (nth ttDay rowNum))

 ; Returns the total number of rows for a given day in the Timetable.
-(defmulti timetable-day-get-nr-rows number? :default false)
+(defmulti timetable-day-get-nr-rows number? :default true)

 ; Argument argument is a a 0-indexed integer representing the day, where
 ; 0 = Monday, 1 = Tuesday, until 4 = Friday


removed counter example | fs / sg | #0

removed counter example | fs / sg | #0

--- src/cljs/conference_rating/core.cljs
+++ src/cljs/conference_rating/core.cljs
@@ -18,12 +18,6 @@
   [:div [:h2 "About conference-rating"]
    [:div [:a {:href "#/"} "go to the home page"]]])

-(def counter (atom 0))
-
-(defn counting []
-  [:div [:h2 "Some counter"]
-   [:span {:on-click (fn [] (swap! counter inc)) } @counter]])
-
 (defn current-page []
   [:div [(session/get :current-page)]])

@@ -36,9 +30,6 @@

 (secretary/defroute "/about" []
   (session/put! :current-page #'about-page))
-
-(secretary/defroute "/count" []
-                    (session/put! :current-page #'counting))

 (secretary/defroute "/conference/:id" [id]
                     (session/put! :current-page #'conference/conference-page)


clean up

clean up

--- src/cljs/phonecat_re_frame/core.cljs
+++ src/cljs/phonecat_re_frame/core.cljs
@@ -86,13 +86,13 @@
               :response-format :json
               :keywords? true})))

-(re-frame/register-pure-handler
-   :initialise-db             ;; usage: (dispatch [:initialise-db])
-   (fn
-     [_ _]                   ;; Ignore both params (db and v).
-     {:phones []
-      :search-input ""
-      :order-prop "name"}))
+(re-frame/register-handler
+ :initialise-db             ;; usage: (dispatch [:initialise-db])
+ (fn
+   [_ _]                   ;; Ignore both params (db and v).
+   {:phones []
+    :search-input ""
+    :order-prop "name"}))

 (defn handle-search-input-entered
   [app-state [_ search-input]]


working on Italian present progressive

working on Italian present progressive

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -16,7 +16,7 @@
    #?(:clj [clojure.repl :refer [doc]])
    [clojure.string :as string]
    [clojure.set :as set]
-   [dag_unify.core :refer [copy fail? get-in strip-refs unifyc]]))
+   [dag_unify.core :refer [copy fail? get-in strip-refs unify]]))

 (def medium (italiano/medium))
 (def np-grammar (italiano/np-grammar))
@@ -583,4 +583,24 @@
 (deftest bisogno
   (is (not (empty? (:parses (first (parse "io ho bisogno di il caffè")))))))

-
+(deftest present-progressive-vs-present-simple
+  (let [base-spec {:modified false
+                   :synsem {:cat :verb
+                            :subcat ()
+                            :sem {:pred :eat
+                                  :tense :present
+                                  :subj {:pred :I}
+                                  :obj :unspec}}}
+        progressive (unify base-spec
+                           {:synsem {:sem {:aspect :progressive}}})
+        simple (unify base-spec
+                      {:synsem {:sem {:aspect :simple}}})]
+    ;; default should be simple present:
+    (is (= "io mangio" (morph (generate base-spec))))
+
+    ;; explicitly set to simple present:
+    (is (= "io sto mangiando" (morph (generate simple))))
+
+    ;; explicitly set to progressive present:
+    (is (= "io sto mangiando" (morph (generate progressive))))))
+


edit comment

edit comment

--- src/cljs/salava/core/ui/popover.cljs
+++ src/cljs/salava/core/ui/popover.cljs
@@ -2,7 +2,7 @@
   (:require [reagent.core :refer [create-class]]
             [salava.core.i18n :refer [t]]))

-;;placement options ["top" "bottom" "right" "left"]
+;;pop-up placement options ["top" "bottom" "right" "left"]
 (defn info [content placement]
   (create-class {:reagent-render (fn []
                                    [:a.popup-info {:tabIndex "0"


s/lightning-bolt/lightning-bolts/

s/lightning-bolt/lightning-bolts/

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -3,7 +3,7 @@
   (:require
    [babel.engine :as engine]
    [babel.generate :as generate]
-   [babel.italiano :refer [analyze generate lightning-bolt parse]]
+   [babel.italiano :refer [analyze generate lightning-bolts parse]]
    [babel.italiano.grammar :as grammar :refer [small medium np-grammar]]
    [babel.italiano.lexicon :refer [lexicon]]
    [babel.italiano.morphology :as morph :refer [analyze-regular fo replace-patterns]]


make sure to "fix" frame delays before they are returned

--- src/clojure/clj_image2ascii/core.clj
+++ src/clojure/clj_image2ascii/core.clj
@@ -137,7 +137,7 @@

            ; and append the converted frame's ascii to the list
            (swap! converted-frames conj {:image (:image converted)
-                                         :delay delay}))))
+                                         :delay (fix-gif-frame-delay delay)}))))
      (merge
        @image-props
        {:frames @converted-frames}))))
@@ -180,5 +180,5 @@
      (fn [^BufferedImage frame-image delay]
        (-> frame-image
            (convert-image scale-to-width color?)
-           (assoc :delay delay)
+           (assoc :delay (fix-gif-frame-delay delay))
            (f))))))


Added vector_set functions

Added vector_set functions

--- src/clojush/instructions/vectors.clj
+++ src/clojush/instructions/vectors.clj
@@ -350,6 +350,32 @@
 (define-registered vector_boolean_occurrencesof (with-meta (occurrencesofer :vector_boolean :boolean) {:stack-types [:vector_boolean :boolean :integer]}))
 (define-registered vector_string_occurrencesof (with-meta (occurrencesofer :vector_string :string) {:stack-types [:vector_string :string :integer]}))

+(defn seter
+  "Returns a function that takes a state and replaces, in the top type vector,
+   item at index (from integer stack) with the first lit-type item."
+  [type lit-type]
+  (fn [state]
+    (if (or (empty? (type state))
+            (empty? (lit-type state))
+            (empty? (:integer state))
+            (and (= lit-type :integer) (empty? (rest (:integer state)))))
+      state
+      (let [item (if (= lit-type :integer)
+                   (stack-ref :integer 1 state)
+                   (top-item lit-type state))
+            index (mod (top-item :integer state) (count (top-item type state)))
+            result (assoc (top-item type state)
+                          index
+                          item)]
+        (push-item result
+                   type
+                   (pop-item lit-type (pop-item :integer (pop-item type state))))))))
+
+(define-registered vector_integer_set (with-meta (seter :vector_integer :integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_set (with-meta (seter :vector_float :float) {:stack-types [:vector_float :float :integer]}))
+(define-registered vector_boolean_set (with-meta (seter :vector_boolean :boolean) {:stack-types [:vector_boolean :boolean :integer]}))
+(define-registered vector_string_set (with-meta (seter :vector_string :string) {:stack-types [:vector_string :string :integer]}))
+
 (defn replaceer
   "Returns a function that takes a state and replaces all occurrences of the second lit-type item
    with the first lit-type item in the top type vector."


Failing tests

Failing tests

--- test/tick/api_test.cljc
+++ test/tick/api_test.cljc
@@ -311,8 +311,12 @@
   (testing "durations"
     (is (t/> (t/new-duration 20 :seconds) (t/new-duration 10 :seconds)))
     (is (t/>= (t/new-duration 20 :seconds) (t/new-duration 20 :seconds)))
+    (is (t/>= (t/new-duration 20 :seconds) (t/new-duration 19 :seconds)))
+    (is (not (t/>= (t/new-duration 19 :seconds) (t/new-duration 20 :seconds))))
     (is (t/< (t/new-duration 10 :seconds) (t/new-duration 20 :seconds)))
-    (is (t/<= (t/new-duration 20 :seconds) (t/new-duration 20 :seconds)))))
+    (is (t/<= (t/new-duration 20 :seconds) (t/new-duration 20 :seconds)))
+    (is (t/<= (t/new-duration 19 :seconds) (t/new-duration 20 :seconds)))
+    (is (not (t/<= (t/new-duration 20 :seconds) (t/new-duration 19 :seconds))))))

 (deftest comparison-test-date


checkpoint

checkpoint

--- src/main/java/org/dada/demo/core.clj
+++ src/main/java/org/dada/demo/core.clj
@@ -200,7 +200,11 @@
 	fields (make-fields src-class src-map props) ; selection ([type name ...])
    	tgt-types (map (fn [field] (nth field 0)) fields)
    	tgt-names (map (fn [field] (nth field 1)) fields)
+	src-getters (. src-metadata getAttributeGetters)
    	sel-getters (map (fn [field] (nth field 2)) fields)
+	;; we should be able to take src-getters directly from metadata
+	;; map them to name and then
+	;;sel-getters (map (fn [name] (src-getter-map name)) tgt-names)
 	tgt-props (map (fn [field] [(nth field 0) (nth field 1)]) fields) ; ([type name]..)
 	class-factory (new ClassFactory)
   	tgt-class (apply make-class class-factory tgt-class-name tgt-props)
@@ -240,6 +244,9 @@
   (. input-model getData)
   (. input-model getMetadata)

+;; TODO: output item & model should be automatic unless specifically overridden..
+;; & :class xxx :model yyy
+
   (def view
        (select
 	input-model


Fixing typos.

Fixing typos.

--- src/cljs/conference_rating/conference_detail_page/aggregated_ratings.cljs
+++ src/cljs/conference_rating/conference_detail_page/aggregated_ratings.cljs
@@ -52,7 +52,7 @@
 (def tags->sentence-fragment {:inspiring    "I am looking for inspiring talks to get awesome ideas for new projects."
                               :entertaining "I want to get entertained and have fun at an awesome after party."
                               :informative  "I am here to learn a lot and watch as many talks as possible."
-                              :hires        "I want to met potential future collegues and extend my network."
+                              :hires        "I want to meet potential future colleagues and extend my network."
                               :clients      "I am on the hunt for potential clients that are present at this confernece."})

 (def tags->badge-label {:inspiring    "Inspiring"


(PDB-1951) Drop factory/connection from cli.services

--- src/puppetlabs/puppetdb/cli/services.clj
+++ src/puppetlabs/puppetdb/cli/services.clj
@@ -159,8 +159,6 @@
   [{:keys [broker mq-factory mq-connection]}]
   (when broker
     (log/info "Shutting down the messsage queues.")
-    (.close mq-connection)
-    (.close mq-factory)
     (mq/stop-broker! broker)))

 (defn stop-puppetdb
@@ -176,7 +174,7 @@
     (.close ds))
   context)

-(defn- transfer-old-messages! [connection mq-endpoint]
+(defn- transfer-old-messages! [mq-endpoint]
   (let [[pending exists?]
         (try+
          [(mq/queue-size "localhost" "com.puppetlabs.puppetdb.commands") true]
@@ -259,19 +257,10 @@
                       "might be due to KahaDB corruption. Consult the "
                       "PuppetDB troubleshooting guide.")
                      (throw e)))
-          mq-factory (mq/activemq-connection-factory
-                      (conf/mq-broker-url config))
-          mq-connection (doto (.createConnection mq-factory)
-                          (.setExceptionListener
-                           (reify ExceptionListener
-                             (onException [this ex]
-                               (log/error ex "service queue connection error"))))
-                          .start)
           globals {:scf-read-db read-db
                    :scf-write-db write-db
-                   :catalog-hash-debug-dir catalog-hash-debug-dir
-                   :command-mq {:connection mq-connection}}]
-      (transfer-old-messages! mq-connection (conf/mq-endpoint config))
+                   :catalog-hash-debug-dir catalog-hash-debug-dir}]
+      (transfer-old-messages! (conf/mq-endpoint config))

       (when-not disable-update-checking
         (maybe-check-for-updates config read-db))
@@ -300,8 +289,6 @@
                        job-pool)))
       (assoc context
              :broker broker
-             :mq-factory mq-factory
-             :mq-connection mq-connection
              :shared-globals globals))))

 (defprotocol PuppetDBServer


(TK-443) Update docstring for jruby metric test

--- test/integration/puppetlabs/services/jruby/jruby_puppet_pool_int_test.clj
+++ test/integration/puppetlabs/services/jruby/jruby_puppet_pool_int_test.clj
@@ -414,8 +414,7 @@
              (testing "metric registry has no metrics when no http requests have been made"
                (is (= {:url [] :url-and-method [] :metric-id []}
                       (metrics/get-client-metrics-data metric-registry))))
-             (testing (str "metric registry has url and url-and-method metrics after http requests"
-                           " have been made without metric-id specified")
+             (testing "metric registry does not have any metrics by default"
                (testing "GET request"
                  (.runScriptlet container "$c.get('/hello', {})")
                  (let [metrics-data (metrics/get-client-metrics-data metric-registry)]


Updating docstring for extended-luxenburger-basis

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

--- src/conexp/contrib/experimental/extended_luxenburger_basis.clj
+++ src/conexp/contrib/experimental/extended_luxenburger_basis.clj
@@ -29,7 +29,8 @@
 (defn extended-luxenburger-basis
   "Computes a modified luxenburger basis, which is obtained from the
   original one by adding all implication of the stem-base of context
-  which have support greater or equal to minsupp."
+  which have support greater or equal to minsupp, and additionally
+  some trivial implications of the form C ==> C."
   [context minsupp minconf]
   (let [closures (set (extended-iceberg-intent-seq context minsupp)),
         LB+DG    (set-of ar


Very minor change to use an #() function macro instead of fn [x] for a sort-by function.

--- clojure/src/net/auxesia/population.clj
+++ clojure/src/net/auxesia/population.clj
@@ -75,12 +75,13 @@
 	   idx (inc elitism-size)]
       (if (>= idx size)
 	(assoc population :population
-	       (vec (sort-by (fn [x] (:fitness x)) (take size buffer))))
+	       (vec (sort-by #(:fitness %) (take size buffer))))
 	(if (<= (rand) (:crossover population))
 	  ;; Perform a crossover
 	  (let [c1 (tournament-selection chromosomes)
 		c2 (tournament-selection chromosomes)]
-	    (recur (into buffer (doall (map #(r-mutate %) (chromosome/mate c1 c2))))
+	    (recur (into buffer (doall (map #(r-mutate %)
+					    (chromosome/mate c1 c2))))
 		   (inc (inc idx))))
 	  ;; Perform a straight copy with mutation
 	  (recur (conj buffer (r-mutate (get chromosomes idx)))


Random stage correction/confirmation

Random stage correction/confirmation

Previous commits ...

This commit ...

--- src/test_utils/fracture_diagnostics.cljc
+++ src/test_utils/fracture_diagnostics.cljc
@@ -814,3 +814,13 @@
                     (repeat 12 :sliding-sleeve)
                     (repeat 5 :single-point-entry)
                     (repeat 3 :open-hole))))
+
+(defn rand-stage-correction []
+        (let [well (rand-nth [:demo-1h :demo-2h :demo-4h])
+              stage (rand-nth (well {:demo-1h (range 1 (inc 50))
+                                     :demo-2h (range 1 (inc 50))
+                                     :demo-4h (range 1 (inc 35))}))
+              status (rand-nth (concat (repeat 72 :confirmed)
+                                       (repeat 12 :unconfirmed)
+                                       (repeat 8 :new)))]
+          [well stage status]))


Change implementation prior to other qualifiers

--- src/test_utils/fracture_diagnostics.cljc
+++ src/test_utils/fracture_diagnostics.cljc
@@ -170,18 +170,6 @@
   ;; to the model for `typical-stage-completion-changeover`.
   (tuc/draw-normal 7454.19 2166.79))

-(defn typical-stage-time-range
-  "Calculates the typical time range for a stage."
-  ([]
-   (let [start-time (tuc/rand-timestamp 2018 2029)]
-     (typical-stage-time-range start-time)))
-  ([start-time]
-   (let [completion-time-in-seconds (typical-stage-completion-time)
-         completion-time (Duration/ofSeconds completion-time-in-seconds)
-         start-time (apply #(LocalDateTime/of %1 %2 %3 %4 %5 %6) start-time)
-         stop-time (.addTo completion-time start-time)]
-     [start-time stop-time])))
-
 (defn typical-stage-completion-changeover
   "Calculates the typical (empirically determined) time (in seconds) to change completion operationss from one stage to another"
   ([]
@@ -196,6 +184,22 @@
          noise (tuc/draw-normal 0 1555.5)]
      (+ (+ (* slope global-stage-seq-no) intercept)
         noise))))
+
+(defn typical-stage-time-range
+  "Calculates the typical time range for a stage."
+  ([]
+   (let [start-time (tuc/rand-timestamp 2018 2029)]
+     (typical-stage-time-range :starting-at start-time)))
+  ([qualifier reference-time]
+   (let [completion-time-in-seconds (typical-stage-completion-time)
+         java-completion-time (Duration/ofSeconds completion-time-in-seconds)
+         java-reference-time (tuc/timestamp->java-time reference-time)]
+     (case qualifier
+       :starting-at (let [start-time reference-time
+                          java-start-time java-reference-time
+                          java-stop-time (.addTo java-completion-time java-start-time)
+                          stop-time (tuc/java-time->timestamp java-stop-time)]))
+     [start-time stop-time])))

 (defn rand-easting []
   (let [minimum-easting 167000


Change the demo page for excepton reporting to be more involved

--- test/io/aviso/launch.clj
+++ test/io/aviso/launch.clj
@@ -1,21 +1,18 @@
 (ns io.aviso.launch
   (use io.aviso.twixt
        [io.aviso.twixt exceptions tracker]
-       ring.adapter.jetty)
-  (import [java.sql SQLException]))
+       ring.adapter.jetty))

-(defn handler [request]
-  (trace "Invoking handler (that throws exceptions)"
-         (throw
-           (->>
-             (SQLException. "Inner Exception" "SQL-STATE", 999)
-             (RuntimeException. "Middle Exception")
-             (IllegalArgumentException. "Outer Exception")))))
+(defn make-handler [twixt]
+  (fn [request]
+    (trace "Invoking handler (that throws exceptions)"
+           ;; This will fail at some depth:
+           (get-asset-uri twixt "invalid-coffeescript.coffee"))))

 (defn app []
   (let [twixt (new-twixt {:development-mode true})]
     (->
-      handler
+      (make-handler twixt)
       (wrap-with-twixt twixt)
       (wrap-with-exception-reporting twixt))))


Add some macro-based movement cues.

Add some macro-based movement cues.

--- src/afterglow/examples.clj
+++ src/afterglow/examples.clj
@@ -1010,6 +1010,176 @@
                    (cues/function-cue :snowball-pos :beams-fixed (show/fixtures-named "snowball")
                                       :effect-name "Snowball Fixed" :end-keys [:snowball-sound]))))

+(defn make-movement-cues
+  "Create a page of with some large scale and layered movement
+  effects. And miscellany which I'm not totally sure what to do with
+  yet."
+  [page-x page-y]
+  (let [x-base (* page-x 8)
+        y-base (* page-y 8)]
+
+    (show/set-cue! x-base (+ y-base 2)
+                   (cues/cue :bloom (fn [var-map]
+                                      (cues/apply-merging-var-map
+                                       var-map fun/bloom (show/all-fixtures)
+                                       :measure (tf/build-distance-measure 0 rig-height 0 :ignore-z true)))
+                             :variables [{:key "color" :type :color :start (colors/create-color :white)
+                                          :name "Color"}
+                                         {:key "fraction" :min 0 :max 1 :start 0 :velocity true}]
+                             :priority 1000 :color :purple))
+
+    (show/set-cue! (+ x-base 2) (+ y-base 1)
+                   (cues/cue :movement (fn [var-map]
+                                         (cues/apply-merging-var-map var-map fun/twirl
+                                                                     (concat (show/fixtures-named "blade")
+                                                                             (show/fixtures-named "torrent"))))
+                             :variables [{:key "beats" :min 1 :max 32 :type :integer :start 8 :name "Beats"}
+                                         {:key "cycles" :min 1 :max 10 :type :integer :start 1 :name "Cycles"}
+                                         {:key "radius" :min 0 :max 10 :start 0.25 :name "Radius"}
+                                         {:key "z" :min -10 :max 10 :start -1.0}
+                                         {:key "y" :min -10 :max 10 :start rig-height}
+                                         {:key "x" :min -10 :max 10 :start 0.0}]
+                             :color :green))
+
+    (show/set-cue! (+ x-base 2) (+ y-base 2)
+                   (cues/cue :movement (fn [var-map]
+                                         (cues/apply-merging-var-map var-map fun/aim-fan
+                                                                     (concat (show/fixtures-named "blade")
+                                                                             (show/fixtures-named "torrent"))))
+                             :variables [{:key "x-scale" :min -5 :max 5 :start 1 :name "X Scale"}
+                                         {:key "y-scale" :min -10 :max 10 :start 5 :name "Y Scale"}
+                                         {:key "z" :min 0 :max 20 :start 4}
+                                       {:key "y" :min -10 :max 10 :start rig-height}
+                                       {:key "x" :min -10 :max 10 :start 0.0}]
+                           :color :blue))
+
+    ;; A chase which overlays on other movement cues, gradually taking over the lights
+    (show/set-cue! (+ x-base 2) (+ y-base 3)
+                   (cues/cue :crossover (fn [var-map] (cues/apply-merging-var-map var-map crossover-chase))
+                             :variables [{:key "beats" :min 1 :max 8 :start 2 :type :integer :name "Beats"}
+                                         {:key "fade-fraction" :min 0 :max 1 :start 0 :name "Fade"}
+                                         {:key "cross-color" :type :color :start (colors/create-color :red)
+                                          :name "X Color"}
+                                         {:key "end-color" :type :color :start (colors/create-color :yellow)
+                                          :name "End Color"}]
+                             :color :cyan :priority 5))
+
+    ;; Some color cycle chases
+    (show/set-cue! (+ x-base 0) (+ y-base 7)
+                   (cues/cue :all-color (fn [_] (fun/iris-out-color-cycle-chase (show/all-fixtures)))))
+    (show/set-cue! (+ x-base 1) (+ y-base 7)
+                   (cues/cue :all-color
+                             (fn [_] (fun/wipe-right-color-cycle-chase
+                                      (show/all-fixtures)
+                                      :transition-phase-function rhythm/snapshot-bar-phase))))
+    (show/set-cue! (+ x-base 2) (+ y-base 7)
+                   (cues/cue :all-color (fn [_] (fun/wipe-right-color-cycle-chase
+                                                 (show/all-fixtures)
+                                                 :color-index-function rhythm/snapshot-beat-within-phrase
+                                                 :transition-phase-function rhythm/snapshot-beat-phase
+                                                 :effect-name "Wipe Right Beat"))))
+
+    ;; Some macro-based chases
+    (show/set-cue! (+ x-base 7) (+ y-base 1)
+                   (cues/cue :move-torrents
+                             (fn [_] (cues/compound-cues-effect
+                                      "Torrent Nod" *show*
+                                      [[17 15 {:pan-min 90.0 :pan-max 179.0 :pan-bars 2 :pan-phase 0.0
+                                               :tilt-min 148.0 :tilt-max 255.0 :tilt-bars 1, :tilt-phase 0.0}]
+                                       [16 15 {:pan-min 77.0 :pan-max 164.0 :pan-bars 2 :pan-phase 0.0
+                                               :tilt-min 148.0 :tilt-max 255.0, :tilt-bars 1, :tilt-phase 0.0}]]))))
+
+    (show/set-cue! (+ x-base 7) (+ y-base 2)
+                   (cues/cue :move-torrents
+                             (fn [_] (cues/compound-cues-effect
+                                      "Torrent Cross Nod" *show*
+                                      [[16 15 {:pan-min 77.0, :pan-max 164.0, :pan-bars 2, :pan-phase 0.5,
+                                               :tilt-min 148.0, :tilt-max 255.0, :tilt-bars 1, :tilt-phase 0.25}]
+                                       [17 15 {:pan-min 90.0, :pan-max 179.0, :pan-bars 2, :pan-phase 0.0,
+                                               :tilt-min 148.0, :tilt-max 255.0, :tilt-bars 1, :tilt-phase 0.0}]]))))
+
+    (show/set-cue! (+ x-base 6) (+ y-base 1)
+                   (cues/cue :move-blades
+                             (fn [_] (cues/compound-cues-effect
+                                      "Sync Can Can" *show*
+                                      [[22 15 {:pan-min 39.0, :pan-max 39.0, :pan-bars 1, :pan-phase 0.0,
+                                               :tilt-min 73.0, :tilt-max 248.0, :tilt-bars 1, :tilt-phase 0.0}]
+                                       [21 15 {:pan-min 42.0, :pan-max 42.0, :pan-bars 1, :pan-phase 0.0,
+                                               :tilt-min 0.0, :tilt-max 197.0, :tilt-bars 1, :tilt-phase 0.0}]
+                                       [20 15 {:pan-min 42.0, :pan-max 42.0, :pan-bars 1, :pan-phase 0.0,
+                                               :tilt-min 0.0, :tilt-max 197.0, :tilt-bars 1, :tilt-phase 0.0}]
+                                       [19 15 {:pan-min 42.0, :pan-max 42.0, :pan-bars 1, :pan-phase 0.0,
+                                               :tilt-min 0.0, :tilt-max 197.0, :tilt-bars 1, :tilt-phase 0.0}]
+                                       [18 15 {:pan-min 42.0, :pan-max 42.0, :pan-bars 1, :pan-phase 0.0,
+                                               :tilt-min 0.0, :tilt-max 216.0, :tilt-bars 1, :tilt-phase 0.0}]]))))
+
+    (show/set-cue! (+ x-base 6) (+ y-base 2)
+                   (cues/cue :move-blades
+                             (fn [_] (cues/compound-cues-effect
+                                      "Spread Can Can" *show*
+                                      [[18 15 {:pan-min 42.0, :pan-max 42.0, :pan-bars 1, :pan-phase 0.0,
+                                               :tilt-min 0.0, :tilt-max 216.0, :tilt-bars 1, :tilt-phase 0.0}]
+                                       [19 15 {:pan-min 42.0, :pan-max 42.0, :pan-bars 1, :pan-phase 0.0,
+                                               :tilt-min 0.0, :tilt-max 197.0, :tilt-bars 1, :tilt-phase 0.2}]
+                                       [20 15 {:pan-min 42.0, :pan-max 42.0, :pan-bars 1, :pan-phase 0.0,
+                                               :tilt-min 0.0, :tilt-max 197.0, :tilt-bars 1, :tilt-phase 0.4}]
+                                       [21 15 {:pan-min 42.0, :pan-max 42.0, :pan-bars 1, :pan-phase 0.0,
+                                               :tilt-min 0.0, :tilt-max 197.0, :tilt-bars 1, :tilt-phase 0.6}]
+                                       [22 15 {:pan-min 39.0, :pan-max 39.0, :pan-bars 1, :pan-phase 0.0,
+                                               :tilt-min 73.0, :tilt-max 248.0, :tilt-bars 1, :tilt-phase 0.8}]]))))
+
+    (show/set-cue! (+ x-base 6) (+ y-base 3)
+                   (cues/cue :move-blades
+                             (fn [_] (cues/compound-cues-effect
+                                      "Swing Can Can" *show*
+                                      [[22 15 {:pan-min 24.0, :pan-max 64.0, :pan-bars 4, :pan-phase 0.0,
+                                               :tilt-min 73.0, :tilt-max 248.0, :tilt-bars 1, :tilt-phase 0.8}]
+                                       [21 15 {:pan-min 24.0, :pan-max 64.0, :pan-bars 4, :pan-phase 0.0,
+                                               :tilt-min 0.0, :tilt-max 197.0, :tilt-bars 1, :tilt-phase 0.6}]
+                                       [20 15 {:pan-min 23.0, :pan-max 64.0, :pan-bars 4, :pan-phase 0.0,
+                                               :tilt-min 0.0, :tilt-max 197.0, :tilt-bars 1, :tilt-phase 0.4}]
+                                       [19 15 {:pan-min 23.0, :pan-max 64.0, :pan-bars 4, :pan-phase 0.0,
+                                               :tilt-min 0.0, :tilt-max 197.0, :tilt-bars 1, :tilt-phase 0.2}]
+                                       [18 15 {:pan-min 23.0, :pan-max 64.0, :pan-bars 4, :pan-phase 0.0,
+                                               :tilt-min 0.0, :tilt-max 216.0, :tilt-bars 1, :tilt-phase 0.0}]]))))
+
+    (show/set-cue! (+ x-base 6) (+ y-base 7)
+                   (cues/cue :center-rebel
+                             (fn [_] (cues/compound-cues-effect
+                                      "Center Rebel" *show*
+                                      [[22 15 {:pan-min 12.0, :pan-max 64.0, :pan-bars 4, :pan-phase 0.0,
+                                               :tilt-min 56.0, :tilt-max 182.0, :tilt-bars 1, :tilt-phase 0.8}]]))))
+
+    (show/set-cue! (+ x-base 6) (+ y-base 6)
+                   (cues/cue :move-blades
+                             (fn [_] (cues/compound-cues-effect
+                                      "Slow Ceiling LR" *show*
+                                      [[18 15 {:pan-min 12.0, :pan-max 66.0, :pan-bars 4, :pan-phase 0.0,
+                                               :tilt-min 170.0, :tilt-max 170.0, :tilt-bars 1, :tilt-phase 0.0}]
+                                       [19 15 {:pan-min 12.0, :pan-max 66.0, :pan-bars 4, :pan-phase 0.0,
+                                               :tilt-min 170.0, :tilt-max 170.0, :tilt-bars 1, :tilt-phase 0.2}]
+                                       [20 15 {:pan-min 12.0, :pan-max 66.0, :pan-bars 4, :pan-phase 0.0,
+                                               :tilt-min 170.0, :tilt-max 170.0, :tilt-bars 1, :tilt-phase 0.4}]
+                                       [21 15 {:pan-min 12.0, :pan-max 66.0, :pan-bars 4, :pan-phase 0.0,
+                                               :tilt-min 170.0, :tilt-max 170.0, :tilt-bars 1, :tilt-phase 0.6}]
+                                       [22 15 {:pan-min 12.0, :pan-max 66.0, :pan-bars 4, :pan-phase 0.0,
+                                               :tilt-min 230.0, :tilt-max 230.0, :tilt-bars 1, :tilt-phase 0.8}]]))))
+
+    (show/set-cue! (+ x-base 6) (+ y-base 5)
+                   (cues/cue :move-blades
+                             (fn [_] (cues/compound-cues-effect
+                                      "Slow Scan LR" *show*
+                                      [[22 15 {:pan-min 12.0, :pan-max 66.0, :pan-bars 4, :pan-phase 0.0,
+                                               :tilt-min 182.0, :tilt-max 182.0, :tilt-bars 1, :tilt-phase 0.8}]
+                                       [21 15 {:pan-min 12.0, :pan-max 66.0, :pan-bars 4, :pan-phase 0.4,
+                                               :tilt-min 130.0, :tilt-max 130.0, :tilt-bars 1, :tilt-phase 0.6}]
+                                       [20 15 {:pan-min 12.0, :pan-max 66.0, :pan-bars 4, :pan-phase 0.8,
+                                               :tilt-min 130.0, :tilt-max 130.0, :tilt-bars 1, :tilt-phase 0.4}]
+                                       [19 15 {:pan-min 12.0, :pan-max 66.0, :pan-bars 4, :pan-phase 0.2,
+                                               :tilt-min 130.0, :tilt-max 130.0, :tilt-bars 1, :tilt-phase 0.2}]
+                                       [18 15 {:pan-min 12.0, :pan-max 66.0, :pan-bars 4, :pan-phase 0.6,
+                                               :tilt-min 162.0, :tilt-max 162.0, :tilt-bars 1, :tilt-phase 0.0}]]))))))
+
 (defn- aim-cue-var-key
   "Determine the cue variable key value to use for a variable being
   created for an aim cue page cue. `base-name` is the name that will
@@ -1280,6 +1450,7 @@
   (make-main-color-dimmer-cues 0 0)  ; Creates a sigle 8x8 page at the origin
   (make-torrent-cues 0 2)  ; Creates 2 8x8 pages: two pages up from the origin, and the next page to the right
   (make-ambient-cues 1 0)  ; Creates a single 8x8 page to the right of the origin
+  (make-movement-cues 0 1)  ; Creates an 8x8 page above the origin
   (make-main-aim-cues 1 1)  ; Creates an 8x8 page above the ambient cues
   (make-main-direction-cues 2 1)  ; Creates an 8x8 page to the right of that

@@ -1287,7 +1458,7 @@
   ;; For now they are hardcoded to appear on the page above the origin.

   ;; Some basic moving head chases
-  (let [triangle-phrase (oscillators/build-oscillated-param ; Move back and forth over a phrase
+  #_(let [triangle-phrase (oscillators/build-oscillated-param ; Move back and forth over a phrase
                          (oscillators/triangle :interval :phrase) :min -90 :max 90)
         staggered-triangle-bar (params/build-spatial-param ; Bounce over a bar, staggered across grid x
                                 (show/all-fixtures)
@@ -1302,15 +1473,6 @@
     (show/set-cue! 1 9 (cues/cue :movement (fn [_]
                                              (move/pan-tilt-effect "P/T Can Can" can-can-p-t (show/all-fixtures))))))

-  (show/set-cue! 0 10 (cues/cue :bloom (fn [var-map]
-                                         (cues/apply-merging-var-map
-                                          var-map fun/bloom (show/all-fixtures)
-                                          :measure (tf/build-distance-measure 0 rig-height 0 :ignore-z true)))
-                                :variables [{:key "color" :type :color :start (colors/create-color :white)
-                                             :name "Color"}
-                                            {:key "fraction" :min 0 :max 1 :start 0 :velocity true}]
-                                :priority 1000 :color :purple))
-
   #_(show/set-cue! 3 8 (cues/function-cue :blade-speed :movement-speed (show/fixtures-named "blade")
                                         :color :purple :effect-name "Slow Blades"))

@@ -1356,44 +1518,6 @@
                                 :variables [{:key "phase" :min 0.0 :max 1.0 :start 0.0 :name "Fade"}]
                                 :color :orange))

-  ;; Some chases
-
-  (show/set-cue! 2 9
-                 (cues/cue :movement (fn [var-map]
-                                       (cues/apply-merging-var-map var-map fun/twirl
-                                                                   (concat (show/fixtures-named "blade")
-                                                                           (show/fixtures-named "torrent"))))
-                           :variables [{:key "beats" :min 1 :max 32 :type :integer :start 8 :name "Beats"}
-                                       {:key "cycles" :min 1 :max 10 :type :integer :start 1 :name "Cycles"}
-                                       {:key "radius" :min 0 :max 10 :start 0.25 :name "Radius"}
-                                       {:key "z" :min -10 :max 10 :start -1.0}
-                                       {:key "y" :min -10 :max 10 :start rig-height}
-                                       {:key "x" :min -10 :max 10 :start 0.0}]
-                           :color :green))
-  (show/set-cue! 2 10
-                 (cues/cue :movement (fn [var-map]
-                                       (cues/apply-merging-var-map var-map fun/aim-fan
-                                                                   (concat (show/fixtures-named "blade")
-                                                                           (show/fixtures-named "torrent"))))
-                           :variables [{:key "x-scale" :min -5 :max 5 :start 1 :name "X Scale"}
-                                       {:key "y-scale" :min -10 :max 10 :start 5 :name "Y Scale"}
-                                       {:key "z" :min 0 :max 20 :start 4}
-                                       {:key "y" :min -10 :max 10 :start rig-height}
-                                       {:key "x" :min -10 :max 10 :start 0.0}]
-                           :color :blue))
-
-  ;; A chase which overlays on other movement cues, gradually taking over the lights
-  (show/set-cue! 2 11
-                 (cues/cue :crossover (fn [var-map] (cues/apply-merging-var-map var-map crossover-chase))
-                           :variables [{:key "beats" :min 1 :max 8 :start 2 :type :integer :name "Beats"}
-                                       {:key "fade-fraction" :min 0 :max 1 :start 0 :name "Fade"}
-                                       {:key "cross-color" :type :color :start (colors/create-color :red)
-                                        :name "X Color"}
-                                       {:key "end-color" :type :color :start (colors/create-color :yellow)
-                                        :name "End Color"}]
-                           :color :cyan :priority 5))
-
-
   #_(show/set-cue! 0 13
                  (cues/cue :chase (fn [var-map]
                                     (fx/chase "Chase Test"
@@ -1417,18 +1541,7 @@
                                                (global-color-effect :white :fixtures (show/all-fixtures))]
                                               @step-param :beyond :loop))
                            :color :magenta))
-
-  ;; Some color cycle chases
-  (show/set-cue! 0 15 (cues/cue :all-color (fn [_] (fun/iris-out-color-cycle-chase (show/all-fixtures)))))
-  (show/set-cue! 1 15 (cues/cue :all-color
-                                (fn [_] (fun/wipe-right-color-cycle-chase
-                                         (show/all-fixtures)
-                                         :transition-phase-function rhythm/snapshot-bar-phase))))
-  (show/set-cue! 2 15 (cues/cue :all-color (fn [_] (fun/wipe-right-color-cycle-chase
-                                                    (show/all-fixtures)
-                                                    :color-index-function rhythm/snapshot-beat-within-phrase
-                                                    :transition-phase-function rhythm/snapshot-beat-phase
-                                                    :effect-name "Wipe Right Beat")))))
+)

 (defn use-push
   "A trivial reminder of how to connect the Ableton Push to run the


Add an integration test for validations (in the client).

--- test/wonko/core_test.clj
+++ test/wonko/core_test.clj
@@ -91,3 +91,23 @@
                     tu/prometheus-registry->map)))
         (consume/stop thread-pool)
         (tu/delete-topics events-topic alerts-topic)))))
+
+(deftest exceptions-and-validations
+  (testing "I get warned (via exception) if I change label names"
+    (let [service-name "wonko-test-validation-service"
+          {:keys [events-topic alerts-topic]} (tu/create-topics)]
+
+      (tu/init-client service-name events-topic alerts-topic)
+      (client/counter :validation-metric {:first 5})
+      (is (thrown? IllegalArgumentException (client/counter :validation-metric {:first 6 :second 7})))
+
+      (let [consumed-events (atom [])
+            thread-pool (consume/start {events-topic 1 alerts-topic 1}
+                                       (fn [event]
+                                         (process event)
+                                         (swap! consumed-events conj event)))]
+        (tu/wait-for #(= 1 (count @consumed-events)) :interval 1 :timeout 3)
+        (is (= (count @consumed-events) 1))
+
+        (consume/stop thread-pool)
+        (tu/delete-topics events-topic alerts-topic)))))


restart rpc on "Failed to connect to localhost/127.0.0.1:8545" (related to #607)

--- src/status_im/protocol/handlers.cljs
+++ src/status_im/protocol/handlers.cljs
@@ -407,5 +407,7 @@
   (u/side-effect!
     (fn [_ [_ error]]
       (.log js/console error)
-      (when (re-find (re-pattern "Could not connect to the server.") (.-message error))
-        (status/restart-rpc)))))
+      (let [message (.-message error)]
+        (when (or (re-find (re-pattern "Could not connect to the server.") message)
+                  (re-find (re-pattern "Failed to connect") message))
+          (status/restart-rpc))))))


[fix] missing cofx for ipfs/cat call in contenthash/cat

Signed-off-by: yenda <96f164ad4d9b2b0dacf8ebee2bb1eeb3aa69adf1@status.im>

--- src/status_im/utils/contenthash.cljs
+++ src/status_im/utils/contenthash.cljs
@@ -29,6 +29,7 @@
   [cofx {:keys [contenthash on-success on-failure]}]
   (let [{:keys [namespace hash]} (decode contenthash)]
     (when (= namespace :ipfs)
-      (ipfs/cat {:hash hash
+      (ipfs/cat cofx
+                {:hash hash
                  :on-success on-success
                  :on-failure on-failure}))))