Test keys in running controllers registry

--- test/keechma/test/controller_manager.cljs
+++ test/keechma/test/controller_manager.cljs
@@ -100,16 +100,21 @@
            (go
              (reset! app-instance (controller-manager/start route-chan commands-chan app-db controllers (fn [& args])))
              (is (= (get-log [0]) (:log @app-db)))
+             (is (= [:session] (keys (get-in @app-db [:internal :running-controllers]))))
              (<! (timeout 20))
              (is (= (get-log (range 2)) (:log @app-db)))

              (>! route-chan {:page "users"})
              (<! (timeout 20))
              (is (= (get-log (range 3)) (:log @app-db)))
+             (is (= [:users :session] (keys (get-in @app-db [:internal :running-controllers]))))
+

              (>! route-chan {:page "current-user" :user-id 1})
              (<! (timeout 20))
              (is (= (get-log (range 4)) (:log @app-db)))
+             (is (= [:current-user :session] (keys (get-in @app-db [:internal :running-controllers]))))
+

              (>! commands-chan [[:session :test-command] "some argument"])
              (<! (timeout 20))
@@ -119,6 +124,7 @@
              (>! route-chan {:page "current-user" :user-id 2})
              (<! (timeout 20))
              (is (= (get-log (range 6)) (:log @app-db)))
+             (is (= [:current-user :session] (keys (get-in @app-db [:internal :running-controllers]))))

              ((:stop @app-instance))
              (done)))))


Commas added to the format of the total problems solved count

--- src/foreclojure/static.clj
+++ src/foreclojure/static.clj
@@ -2,10 +2,17 @@
   (:use compojure.core
         [foreclojure problems utils]))

+(def df
+  (let [df (java.text.DecimalFormat.)
+        dfs (java.text.DecimalFormatSymbols.)]
+    (.setGroupingSeparator dfs \,)
+    (.setDecimalFormatSymbols df dfs)
+    df))
+
 (def-page welcome-page []
   [:div#welcome
    [:div#totalcount
-    (deref total-solved) " problems solved and counting!"]
+    (.format df (deref total-solved)) " problems solved and counting!"]
    [:div
     [:h3 "What is 4Clojure?"]
     [:p "4Clojure is a resource to help fledgling clojurians learn the language through interactive problems.  The first few problems are easy enough that even someone with no prior experience should find the learning curve forgiving.  See 'Getting Started' for more information."]]


user id added to session

user id added to session

--- src/cerber/form.clj
+++ src/cerber/form.clj
@@ -51,7 +51,7 @@
       (render-login-form (assoc req :failed? true))

       ;; login succeeded. redirect either to session-stored or default landing url.
-      (let [{:keys [login]} (::ctx/user result)]
+      (let [{:keys [id login]} (::ctx/user result)]
         (-> (get-in req [:session :landing-url] (:landing-url app-config))
             (redirect)
-            (assoc :session {:login login}))))))
+            (assoc :session {:id id :login login}))))))


check buffer length; if full, conj to rtn

--- ohack/src/ohack/core.clj
+++ ohack/src/ohack/core.clj
@@ -190,9 +190,13 @@
          ;; use a buffer to store incoming consecutive indexes
          buf []
          rtn []]
-    (if (empty? input)
-      rtn
-      (recur (rest input)
-             buf
-             (conj rtn (first input)))))
+    ;; we need to add buf to rtn if buf has 6 elements
+    (let [buf-full? (= 6 (count buf))
+          next-rtn (if buf-full? (conj rtn buf) rtn)]
+      (if (empty? input)
+        rtn
+        (let []
+          (recur (rest input)
+                 buf
+                 (conj rtn (first input)))))))
   )


Use raw data for expected value

Use raw data for expected value

Was relying on other functions.

--- test/datemo/arb_test.clj
+++ test/datemo/arb_test.clj
@@ -55,7 +55,7 @@
       (is (=
            {:arb/metadata [{:metadata/html-tag :div}]
             :arb/value [{:content/text "Text"}]}
-           (arb->tx (hiccup->arb (list [:div {} "Text"]))))))
+           (arb->tx [:arb {:original-tag :div} "Text"]))))
     (testing "arb with nested arb"
       (is (=
            {:arb/metadata [{:metadata/html-tag :div}]
@@ -63,16 +63,9 @@
                          :arb/value [{:content/text "Section Title"}]}
                         {:arb/metadata [{:metadata/html-tag :p}]
                          :arb/value [{:content/text "paragraph"}]}]}
-           (arb->tx (hiccup->arb (list [:div {}
-                                        [:h1 {} "Section Title"]
-                                        [:p {} "paragraph"]])))))))
-
-  (testing "html->tx"
-    (testing "single tag"
-      (is (=
-           {:arb/metadata [{:metadata/html-tag :div}]
-            :arb/value [{:content/text "text"}]}
-           (html->tx "
text
")))))
+           (arb->tx [:arb {:original-tag :div}
+                     [:arb {:original-tag :h1} "Section Title"]
+                     [:arb {:original-tag :p} "paragraph"]])))))

   (testing "tx->arb"
     (testing "with single node"


Make control-ugen a specific type rather than plain ugen to ease debugging. Ensure that control-ugen derives from ugen.

--- src/overtone/sc/machinery/ugen/fn_gen.clj
+++ src/overtone/sc/machinery/ugen/fn_gen.clj
@@ -161,17 +161,19 @@

 (defn mk-generic-control-ugen
   [name rate n-outputs offset]
-  (with-meta {:id (next-id ::ugen)
-              :name name
-              :rate (rate RATES)
+  (with-meta {:id        (next-id ::ugen)
+              :name      name
+              :rate      (rate RATES)
               :rate-name (REVERSE-RATES (rate RATES))
-              :special offset
-              :args nil
+              :special   offset
+              :args      nil
               :n-outputs n-outputs
-              :outputs (repeat n-outputs {:rate (rate RATES)})
-              :n-inputs 0
-              :inputs []}
-    {:type ::ugen}))
+              :outputs   (repeat n-outputs {:rate (rate RATES)})
+              :n-inputs  0
+              :inputs    []}
+    {:type ::control-ugen}))
+
+(derive ::control-ugen ::ugen)

 (defn control-ugen
   "Creates a new control ugen at control rate.


Update comment

Update comment

--- src/lister/persistence.clj
+++ src/lister/persistence.clj
@@ -149,7 +149,7 @@
   (far/delete-item (create-creds) environments-table {:name environment-name}))

 (defn create-environment
-  "Creates a new environment associated with the new account-id, doesn't set createRepo to true, assumes the new environment will be a limpet environment"
+  "Creates a new environment associated with the new account-id, doesn't set create-repo to true, assumes the new environment will be a limpet environment"
   [environment account-id]
   (far/put-item (create-creds) environments-table {:name environment
                                                    :metadata (cheshire/generate-string {:account-id account-id})})


empty commit

empty commit

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

 (enable-console-print!)
-

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


Send hints used to the server

Send hints used to the server

--- src/cljs/daveconservatoire/site/ui/exercises.cljs
+++ src/cljs/daveconservatoire/site/ui/exercises.cljs
@@ -118,14 +118,14 @@
          (swap! state update-in ref assoc ::streak-count 0 ::last-error true))))

    :remote
-   (let [{::keys [name streak-count ex-total-questions]} (get-in @state ref)]
+   (let [{::keys [name streak-count ex-total-questions hints-used]} (get-in @state ref)]
      (cond
        (= streak-count ex-total-questions)
-       (-> (om/query->ast `[(exercise/score-master {:url/slug ~name})])
+       (-> (om/query->ast `[(exercise/score-master {:url/slug ~name ::hints-used ~hints-used})])
            :children first)

        (> streak-count 0)
-       (-> (om/query->ast `[(exercise/score {:url/slug ~name})])
+       (-> (om/query->ast `[(exercise/score {:url/slug ~name ::hints-used ~hints-used})])
            :children first)))})

 (defn int-in [min max] (+ min (rand-int (- max min))))


Found another if nil

Found another if nil

--- src/cljs/kixi/hecuba/tabs/hierarchy/tapestry.cljs
+++ src/cljs/kixi/hecuba/tabs/hierarchy/tapestry.cljs
@@ -183,7 +183,7 @@
   [{:keys [width height data-chan fill-out-of-range-cells? x-label y-label]
     :or {width 800
          height 600}}]
-  (if (nil? data-chan)
+  (if-not data-chan
     (throw (js/Error. "Heatmap requires a data channel!"))
     (reset! chart-data-chan data-chan))
   (reset! chart-width width)


Fix docstring typo :pineapple: [ci skip]

--- src/metabase/api/setup.clj
+++ src/metabase/api/setup.clj
@@ -142,7 +142,7 @@

 (defn- add-next-step-info
   "Add `is_next_step` key to all the STEPS from `admin-checklist`.
-  The next step if the *first* step where `:triggered` is `true` and `:completed` is `false`."
+  The next step is the *first* step where `:triggered` is `true` and `:completed` is `false`."
   [steps]
   (loop [acc [], found-next-step? false, [step & more] steps]
     (if-not step


Fix bad timer trigger test exposed by fixed timer triggers.

--- test/onyx/windowing/aggregation_grouping_test.clj
+++ test/onyx/windowing/aggregation_grouping_test.clj
@@ -103,7 +103,6 @@
           :trigger/id :sync
           :trigger/refinement :onyx.refinements/accumulating
           :trigger/fire-all-extents? true
-          ; ^:broken, for some reason, timer trigger misses the last fire
           :trigger/on :onyx.triggers/timer
           :trigger/period [1 :seconds]
           :trigger/sync ::update-atom!}]
@@ -117,6 +116,7 @@
     (reset! in-chan (chan (inc (count input))))
     (reset! in-buffer {})
     (reset! out-chan (chan (sliding-buffer (inc (count input)))))
+    (reset! fire-count {})
     (reset! test-state {})

     (with-test-env [test-env [5 env-config peer-config]]
@@ -126,13 +126,21 @@
                                                    :lifecycles lifecycles
                                                    :windows windows
                                                    :triggers triggers
-                                                   :task-scheduler :onyx.task-scheduler/balanced})]
+                                                   :task-scheduler :onyx.task-scheduler/balanced})
+            start-time (System/currentTimeMillis)]
         (doseq [i input]
           (Thread/sleep 500)
           (>!! @in-chan i))
         (close! @in-chan)
         (let [_ (onyx.test-helper/feedback-exception! peer-config job-id)
+              end-time (System/currentTimeMillis)
+              max-n-extent-fires (apply max (vals @fire-count))
               results (take-segments! @out-chan 50)]
-          (is (#{2 3} (apply max (vals @fire-count))))
+          ;; allow some leniency in number of expected fires since it may take a while to start up
+          (is (#{(- max-n-extent-fires 2)
+                 (dec max-n-extent-fires)
+                 max-n-extent-fires
+                 ;; 1 per second plus final job complete event
+                 (inc max-n-extent-fires)} (int (/ (- end-time start-time) 1000))))
           (is (= (into #{} input) (into #{} results)))
           (is (= expected-windows @test-state)))))))


modify the scope deps for creation and resetting to ensure they get executed at the correct stage.

--- src/overtone/viz/scope.clj
+++ src/overtone/viz/scope.clj
@@ -25,7 +25,8 @@
 (defonce Y-PADDING 10)
 (defonce scope-group* (ref 0))

-(on-deps :connected ::create-scope-group #(dosync (ref-set scope-group* (group :tail ROOT-GROUP))))
+(on-deps :studio-setup-completed ::create-scope-group #(dosync (ref-set scope-group* (group :tail ROOT-GROUP))
+                                                               (satisfy-deps :scope-group-created)))

 (defn- update-scope-data [s]
   (let [{:keys [buf size width height panel y-arrays x-array panel]} s
@@ -177,7 +178,7 @@
                     {}
                     @scopes*))))

-(on-deps #{:synthdefs-loaded} ::reset-scopes reset-scopes)
+(on-deps #{:synthdefs-loaded :scope-group-created} ::reset-scopes reset-scopes)

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


Add some more of the helper functions

Add some more of the helper functions

--- src/petulant_life/life.clj
+++ src/petulant_life/life.clj
@@ -5,6 +5,20 @@

 ;; Copyright 2012 Chas Emerick, Brian Carper, and Christophe Grand,
 ;; 978-1-449-39470-7.
+
+(defn empty-board
+  "Creates a rectangular empty board of the specified width
+   and height."
+  [w h]
+  (vec (repeat w (vec (repeat h nil)))))
+
+(defn populate
+  "Turns :on each of the cells specified as [y, x] coordinates."
+  [board living-cells]
+  (reduce (fn [board coordinates]
+            (assoc-in board coordinates :on))
+          board
+          living-cells))

 (defn hex-neighbours
   [[x y]]
@@ -18,9 +32,9 @@

 (defn stepper
   "Returns a step function for Life-like cell automata.
-   neighbours takes a location and return a sequential collection
-   of locations. survive? and birth? are predicates on the number
-   of living neighbours."
+  neighbours takes a location and return a sequential collection
+  of locations. survive? and birth? are predicates on the number
+  of living neighbours."
   [neighbours birth? survive?]
   (fn [cells]
     (set (for [[loc n] (frequencies (mapcat neighbours cells))


Add profiling wrapper

Add profiling wrapper

--- src/search/graph_utils.clj
+++ src/search/graph_utils.clj
@@ -1,8 +1,10 @@
 (ns search.graph-utils
   (:require [schema.core :as s]
             [plumbing.core :refer [fnk]]
+            [taoensso.timbre.profiling :as profiling]

-            [search.utils :as utils]))
+            [search.utils :as utils]
+            [search.core :as search]))

 (defn println-level
   "Like println but indents by `indent` first."
@@ -25,3 +27,23 @@
           (utils/wrap-before (fn [& _] (println-level @indent "Calling" ks) (swap! indent inc)))
           (utils/wrap-after (fn [_] (swap! indent dec) (println-level @indent "Finished" ks)))))
       g)))
+
+(def profile-fns-wrap
+  "Add timbre profile to each function"
+  (partial utils/map-leaf-fns
+    (fnk profile-wrap-inner [f ks]
+      (utils/wrap f (fn [& args] (profiling/p (str ks) (apply f args)))))))
+
+(s/defn print-profile-gen-wrap :- search/SearchGraph
+  "Prints the total profiling after each generation"
+  [{->gens :generations :as g} :- search/SearchGraph]
+  (assoc g :generations
+    (utils/wrap ->gens
+      (fn [m]
+        (let [f (fn profile-fns-inner [gens]
+                  (let [first-g (profiling/profile :info :Generation (first gens))]
+                    (if (nil? first-g)
+                      nil
+                      (lazy-seq (cons first-g
+                                      (profile-fns-inner (rest gens)))))))]
+          (f (->gens m)))))))


Remove unnecessary nil

Remove unnecessary nil

--- ui-gallery/desktop/src-common/ui_gallery/core.clj
+++ ui-gallery/desktop/src-common/ui_gallery/core.clj
@@ -37,8 +37,7 @@
     (render! screen entities))
   :on-resize
   (fn [screen entities]
-    (height! screen 400)
-    nil)
+    (height! screen 400))
   :on-ui-changed
   (fn [screen entities]
     (println (:actor screen))))


if-not -> when-not

if-not -> when-not

--- src/demo/http_kit.clj
+++ src/demo/http_kit.clj
@@ -28,7 +28,7 @@
     {:on-message (fn [channel data]
                    (async/send! channel data))
      :on-open    (fn [channel]
-                   (if-not (:websocket? ring-request)
+                   (when-not (:websocket? ring-request)
                      (async/send! channel {:status 200
                                            :headers {"Content-Type" "text/plain"}
                                            :body    "Long polling?"}


Formatting long lines

Formatting long lines

--- src/braid/client/ui/views/pages/search.cljs
+++ src/braid/client/ui/views/pages/search.cljs
@@ -38,8 +38,10 @@
              "Try again"]]]

           (:done-results :loading)
-          (let [loaded-threads (reaction (vals (select-keys @threads (@page :thread-ids))))
-                sorted-threads (reaction (->> @loaded-threads ; sort-by last reply, newest first
+          (let [loaded-threads (reaction (vals (select-keys @threads
+                                                 (@page :thread-ids))))
+                sorted-threads (reaction (->> @loaded-threads
+                                              ; sort-by last reply, newest first
                                               (sort-by
                                                 (comp (partial apply max)
                                                       (partial map :created-at)
@@ -51,7 +53,8 @@
               [:div.description
                (if (= status :loading)
                  "Loading more results..."
-                 (str "Displaying " (count @loaded-threads) "/" (count (@page :thread-ids))))]]
+                 (str "Displaying " (count @loaded-threads) "/"
+                      (count (@page :thread-ids))))]]
              [:div.threads
               {:ref "threads-div"
                :on-scroll ; page in more results as the user scrolls


Fixing typo which brake test

Fixing typo which brake test

--- test/larva/test_data.clj
+++ test/larva/test_data.clj
@@ -160,7 +160,7 @@
                   {:name "name" :type :str :gui-label "name"}
                   {:name "provider" :type :str :gui-label "provider"}]}]})

-(def standard-pfrogram-with-meta
+(def standard-program-with-meta
   {:about
    {:name "Pilot model"
     :author "Novak Boskov"


Use new generators for false pred tests.

--- test/onyx/generative/flow_conditions_gen_test.clj
+++ test/onyx/generative/flow_conditions_gen_test.clj
@@ -99,74 +99,39 @@
     (is (thrown? clojure.lang.ExceptionInfo
                  (t/route-data nil nil wrapped-e nil [:a :b])))))

-(deftest limit-downstream-results
+(deftest conj-downstream-tasks-together
   (checking
-   "The matching flow condition limits the downstream selection"
+   "It joins the :flow/to tasks together and limits selection"
    (times 50)
-   [fcs (gen/vector (->> :a
+   [flow-conditions (gen/vector (->> :a
                          (flow-condition-gen)
                          (flow-to-tasks-gen)
-                         (true-flow-condition-gen))
-                    1)
+                         (true-flow-condition-gen)))
     other-downstream-tasks (gen/vector gen/keyword)]
-   (let [task :a
-         target-tasks (mapcat :flow/to fcs)
+   (let [compiled (c/compile-fc-norms flow-conditions :a)
+         target-tasks (mapcat :flow/to flow-conditions)
          downstream (into other-downstream-tasks target-tasks)
-         compiled (c/compile-fc-norms fcs task)
-         results
-         (t/route-data
-          {:onyx.core/compiled-norm-fcs compiled} nil nil fcs downstream)]
+         event {:onyx.core/compiled-norm-fcs compiled}
+         results (t/route-data event nil nil flow-conditions downstream)]
      (is (= (into #{} target-tasks) (:flow results)))
      (is (nil? (:action results))))))
-
-(deftest conj-downstream-tasks-together
-  (checking
-   "It joins the :flow/to tasks together"
-   (times 50)
-   [downstream (gen/not-empty (gen/vector gen/keyword))
-    size (gen/choose 0 (count downstream))
-    flow-conditions (gen/not-empty
-                     (gen/vector
-                      (gen/hash-map
-                       :flow/from (gen/return :a)
-                       :flow/to (gen/fmap #(vec (take size %)) (gen/shuffle downstream))
-                       :flow/predicate (gen/return ::true-pred))))]
-   (let [compiled (c/compile-fc-norms flow-conditions :a)
-         results
-         (t/route-data
-          {:onyx.core/compiled-norm-fcs compiled} nil nil flow-conditions downstream)]
-     (is (= (into #{} (mapcat :flow/to flow-conditions)) (:flow results)))
-     (is (nil? (:action results))))))
-
-
-
-

 (deftest no-false-predicate-picks
   (checking
    "It doesn't pick any downstream tasks with false predicates"
    (times 50)
-   [true-downstream (gen/fmap (fn [xs] (map (comp keyword str) xs)) (gen/not-empty (gen/vector gen/uuid)))
-    false-downstream (gen/fmap (fn [xs] (map (comp keyword str) xs)) (gen/not-empty (gen/vector gen/uuid)))
-    size (gen/choose 0 (count true-downstream))
-    true-flow-conditions (gen/not-empty
-                          (gen/vector
-                           (gen/hash-map
-                            :flow/from (gen/return :a)
-                            :flow/to (gen/fmap #(vec (take size %)) (gen/shuffle true-downstream))
-                            :flow/predicate (gen/return ::true-pred))))
-    false-flow-conditions (gen/not-empty
-                           (gen/vector
-                            (gen/hash-map
-                             :flow/from (gen/return :a)
-                             :flow/to (gen/fmap #(vec (take size %)) (gen/shuffle false-downstream))
-                             :flow/predicate (gen/return ::false-pred))))]
-   (let [flow-conditions (into true-flow-conditions false-flow-conditions)
-         downstream (into true-downstream false-downstream)
+   [true-fcs (gen/vector (->> :a
+                              (flow-condition-gen)
+                              (flow-to-tasks-gen)
+                              (true-flow-condition-gen)))
+    false-fcs (gen/vector (->> :a
+                               (flow-condition-gen)
+                               (flow-to-tasks-gen)
+                               (false-flow-condition-gen)))]
+   (let [flow-conditions (into true-fcs false-fcs)
+         downstream (mapcat :flow/to true-fcs false-fcs)
          compiled (c/compile-fc-norms flow-conditions :a)
-         results
-         (t/route-data
-          {:onyx.core/compiled-norm-fcs compiled} nil nil flow-conditions downstream)]
-     (is (= (into #{} (mapcat :flow/to true-flow-conditions)) (:flow results)))
-     (is (nil? (some (into #{} (mapcat :flow/to false-flow-conditions)) (:flow results))))
+         event {:onyx.core/compiled-norm-fcs compiled}
+         results (t/route-data event nil nil flow-conditions downstream)]
+     (is (= (into #{} (mapcat :flow/to true-fcs)) (into #{} (:flow results))))
      (is (nil? (:action results))))))


Update game.clj

Update game.clj

--- airesources/Clojure/src/halite_clj/game.clj
+++ airesources/Clojure/src/halite_clj/game.clj
@@ -17,7 +17,7 @@
                 :north (mod (dec (:y site)) height)
                 :south (mod (inc (:y site)) height)
                 (:y site))]
-    (get-in game-map new-y new-x)))
+    (get-in game-map [new-y new-x])))

 (defn single-dimension-distance
   "Computes the distance between two integers mod m"


list class

list class

--- src/cljs/material/component/list/basic.cljs
+++ src/cljs/material/component/list/basic.cljs
@@ -57,10 +57,11 @@
        :onClick #(onclick-handler-fn item)}
       (cmp/list-item-text
         (merge
-          {:key     (str "list-item-text-" index)
-           :classes {:primary   "Swarmpit-list-item-text-primary"
-                     :secondary "Swarmpit-list-item-text-secondary"}
-           :primary (primary-key item)}
+          {:key       (str "list-item-text-" index)
+           :className "Swarmpit-list-item-text"
+           :classes   {:primary   "Swarmpit-list-item-text-primary"
+                       :secondary "Swarmpit-list-item-text-secondary"}
+           :primary   (primary-key item)}
           (when secodary-key
             {:secondary (secodary-key item)})))
       (when status-fn


fixed arity in handlers/security

fixed arity in handlers/security

--- src/clojure/catacumba/handlers/security.clj
+++ src/clojure/catacumba/handlers/security.clj
@@ -95,9 +95,9 @@
   https://developer.mozilla.org/en-US/docs/Web/Security/CSP"
   ([] (csp-headers {}))
   ([options]
-   (let [options' (select-keys options :default-src :frame-ancestors :frame-src
+   (let [options' (select-keys options [:default-src :frame-ancestors :frame-src
                                :child-src :connect-src :font-src :form-action
-                               :img-src :media-src :object-src :reflected-xss)
+                               :img-src :media-src :object-src :reflected-xss])
          value (reduce (fn [acc [key value]]
                          (conj acc (str (name key) value)))
                        [] (seq options'))]


gen-instance-expr -- working on better symbol naming logic

--- src/com/billpiel/sayid/nrepl_middleware.clj
+++ src/com/billpiel/sayid/nrepl_middleware.clj
@@ -453,6 +453,54 @@
                            s))]
     (into [kw'] (mapv str->sym idx))))

+;; WIP ===== gen-instance-expr helpers
+
+
+(defn tt1
+  ([a] 1)
+  ([a [b c]] 2)
+  ([a b & c] 3))
+
+(-> #'tt1 meta :arglists last count)
+
+(defn find-arg-list-by-length
+  [n [first-list & rest-lists]]
+  (let [cfl (count first-list)]
+    (cond (nil? first-list) nil
+
+          (or (= n cfl)
+              (and (-> first-list reverse rest first (= '&))
+                   (>= n (dec cfl))))
+          first-list
+
+          :else (recur n rest-lists))))
+
+(find-arg-list-by-length 2 (-> #'tt1 meta :arglists))
+
+(defn find-available-sym
+  [ns-sym prefix & [init-taken]]
+  (let [taken (set (or init-taken
+                       (-> ns-sym
+                           create-ns
+                           ns-interns
+                           keys)))]
+    (loop [n 0]
+      (let [suffix (if (= n 0) "" n)
+            candidate (symbol (str prefix suffix))]
+        (if-not (taken candidate)
+          candidate
+          (recur (inc n)))))))
+
+(defn lazy-find-available-sym
+  [prefix-seq init-taken]
+  (let [next (find-available-sym nil (first prefix-seq) init-taken)]
+    (lazy-cat [next]
+              (lazy-find-available-sym (rest prefix-seq)
+                                       (conj init-taken next)))))
+
+
+;; END WIP ===== gen-instance-expr helpers
+

 (defn gen-instance-expr
   [tree]


accent

accent

--- src/styles/nossal/core.clj
+++ src/styles/nossal/core.clj
@@ -68,7 +68,7 @@
        :padding "0.3em 0.5em 0.2em"
        :display "inline-block"}]]

-  [:.accent {:color "#7250af"}]
+  [:.accent {:color "#3f229c"}]
   [:.about-line {:font-size (em 1.1)
                  :font-weight 300
                  :color "#535d6d"


Full realtime Oracle working now!

Full realtime Oracle working now!

Update and delete working now

--- src/webapp/framework/server/systemfns.clj
+++ src/webapp/framework/server/systemfns.clj
@@ -414,7 +414,16 @@
           (str "CREATE TRIGGER trigger_afterUpdate AFTER UPDATE ON " table-name " FOR EACH ROW EXECUTE PROCEDURE trigger_function_afterUpdate();")

           (= *database-type* "oracle")
-          "")
+          (str "create or replace trigger U" table-name " AFTER UPDATE ON " table-name " "
+                                " FOR EACH ROW "
+                                   "BEGIN "
+                                   "INSERT INTO coils_realtime_log  (record_timestamp, record_table_name, record_id, record_id_type, record_operation,  record_status) "
+                                   "values \n"
+                                   "(LOCALTIMESTAMP, '" table-name "', :NEW.id, "
+                                   " (SELECT data_type FROM user_tab_columns WHERE table_name = 'COILS_TODO_ITEMS' AND column_name = 'ID') , "
+                                   " 'UPDATE',  'WAITING'); "
+                                   "END;"
+               ))

         sql-to-create-delete-trigger
         (cond
@@ -422,7 +431,16 @@
           (str "CREATE TRIGGER trigger_afterDelete AFTER DELETE ON " table-name " FOR EACH ROW EXECUTE PROCEDURE trigger_function_afterDelete();")

           (= *database-type* "oracle")
-          "")
+          (str "create or replace trigger D" table-name " AFTER DELETE ON " table-name " "
+                                " FOR EACH ROW "
+                                   "BEGIN "
+                                   "INSERT INTO coils_realtime_log  (record_timestamp, record_table_name, record_id, record_id_type, record_operation,  record_status) "
+                                   "values \n"
+                                   "(LOCALTIMESTAMP, '" table-name "', :OLD.id, "
+                                   " (SELECT data_type FROM user_tab_columns WHERE table_name = 'COILS_TODO_ITEMS' AND column_name = 'ID') , "
+                                   " 'DELETE',  'WAITING'); "
+                                   "END;"
+               ))
         ]
     ;(println "Coils trigger table exists: " coils-trigger-exists)
     (println "sql-to-create-insert-trigger: " sql-to-create-insert-trigger)
@@ -431,8 +449,8 @@
     (if (not coils-trigger-exists)
       (do
         (. (. jdbc-conn createStatement) execute  sql-to-create-insert-trigger)
-        ;(korma.core/exec-raw   [sql-to-create-update-trigger []])
-        ;(korma.core/exec-raw   [sql-to-create-delete-trigger []])
+        (. (. jdbc-conn createStatement) execute  sql-to-create-update-trigger)
+        (. (. jdbc-conn createStatement) execute  sql-to-create-delete-trigger)
         ;(korma.core/exec-raw   [sql-to-insert-trigger-row [table-name  coils-tables-trigger-version]])

         )


Validate nodes order-by against strings

Validate nodes order-by against strings

--- src/com/puppetlabs/puppetdb/query/nodes.clj
+++ src/com/puppetlabs/puppetdb/query/nodes.clj
@@ -46,7 +46,7 @@
    :post [(map? %)
           (vector? (:result %))
           (every? #(= (set node-columns) (keyset %)) (:result %))]}
-    (validate-order-by! node-columns paging-options)
+    (validate-order-by! (map name node-columns) paging-options)
     (execute-query filter-expr paging-options)))

 (def v1-query->sql


remove unused code

remove unused code

--- ssclj/jar/src/main/clojure/com/sixsq/slipstream/ssclj/middleware/logger.clj
+++ ssclj/jar/src/main/clojure/com/sixsq/slipstream/ssclj/middleware/logger.clj
@@ -1,8 +1,7 @@
 (ns com.sixsq.slipstream.ssclj.middleware.logger
   (:require
     [clojure.string :as str]
-    [clojure.tools.logging :as log]
-    [clojure.pprint :refer [pprint]]))
+    [clojure.tools.logging :as log]))

 (defn- display-querystring
   [request]
@@ -17,8 +16,6 @@

 (defn request-to-str
   [request]
-      #_(with-out-str
-        (pprint request))
   (str
     (-> request :request-method)
     " "


Playing with how to transform list of transactions into list of entries.

--- src/wealthpulse/parser.clj
+++ src/wealthpulse/parser.clj
@@ -1,6 +1,14 @@
 (ns wealthpulse.parser
 	(:require [instaparse.core :as insta]
 		[clojure.string :as string]))
+
+
+(defn transform-transaction-part-deux
+	"Hm, playing with transform now..."
+	[transaction]
+	(insta/transform
+		{:transaction (fn [header entries] (map (fn [entry] (concat entry [header])) (rest entries)))}
+		transaction))

 ; Should use java.util.Date instead of java.text.SimpleDateFormat?


Fixed compilation error

Fixed compilation error

--- src/gozer/db/core.clj
+++ src/gozer/db/core.clj
@@ -26,6 +26,7 @@

 (defn apply-db-schema
   "Sets up the schema in datomic for the application."
+  []
   (let [schemas (us/new-loader)]
     (doseq [s schemas]
-      (sl/load-schema s (:datomic-conn @conn)))))
+      (load/load-schema s (:datomic-conn @conn)))))


Check in WIP.

Check in WIP.

--- src/vault/search/graph.clj
+++ src/vault/search/graph.clj
@@ -25,11 +25,11 @@
   "Projects a blob into a node record."
   [blob]
   (when-let [{:keys [id content]} blob]
-    [{:blob id
-      :size (count content)
-      :type (:data/type blob)
-      ; TODO: label pgp keys
-      :stored-at (time/now)}]))
+    {:blob id
+     :size (count content)
+     :type (:data/type blob)
+     ; TODO: label pgp keys
+     :stored-at (time/now)}))

 (defn node->stats
@@ -42,21 +42,6 @@
     :data/type (:type node)))

-(defn get-node
-  "Looks up a node record by hash-id."
-  [graph id]
-  (index/lookup (:nodes graph)
-                {:id id}))
-
-
-(defn find-nodes
-  "Find node records by type keyword and label."
-  [graph & [data-type label]]
-  (index/find (:node-types graph)
-              {:type data-type
-               :label label}))
-
-

 ;; ## Blob Graph Links

@@ -64,6 +49,7 @@
   "Schema for blob graph link records."
   {:source HashID     ; source hash-id
    :type   Keyword    ; source blob type
+   :key    Keyword    ; if the blob is a map, top-level key the link was found under
    :target HashID})   ; target hash-id

@@ -76,16 +62,84 @@
     []))

-(defn links-from
-  "Look up data links by source hash-id."
-  [graph & [source-id]]
-  (index/find (:links-from graph)
-              {:source source-id}))
+
+;; ## Graph Protocol
+
+(defprotocol GraphCatalog
+  "Graph catalogs store records about the nodes and the links among them in the
+  blob graph."
+
+  (get-node
+    [graph id]
+    "Looks up a node record by hash-id.")
+
+  (find-nodes
+    [graph data-type label]
+    "Find node records by type keyword and optional label string.")
+
+  (links-from
+    [graph source-id]
+    "Look up data links by source hash-id.")
+
+  (links-to
+    [graph target-id data-type]
+    "Look up data sorted by target hash-id and source blob type."))

-(defn links-to
-  "Look up data sorted by target hash-id and source blob type."
-  [graph & [target-id data-type]]
-  (index/find (:links-reverse graph)
-              {:target target-id
-               :type data-type}))
+;; The brute-force graph catalog iterates over all the blobs in a store to
+;; determine the answers to the graph queries.
+(defrecord BruteGraphCatalog
+  [store]
+
+  GraphCatalog
+
+  (get-node
+    [this id]
+    (some->> id (store/get* store) blob->node))
+
+
+  (find-nodes
+    [this data-type label]
+    nil)
+
+
+  (links-from
+    [this source-id]
+    nil)
+
+
+  (links-to
+    [this target-id data-type]
+    nil))
+
+
+;; An indexed graph catalog stored blob node and link records in sorted index
+;; data structures, which makes lookups much more efficient.
+(defrecord IndexGraphCatalog
+  [nodes node-types forward-links reverse-links]
+
+  GraphCatalog
+
+  (find-node
+    [this id]
+    (index/lookup nodes {:id id}))
+
+
+  (find-nodes
+    [this data-type label]
+    (index/find node-types
+                {:type data-type
+                 :label label}))
+
+
+  (links-from
+    [this source-id]
+    (index/find forward-links
+                {:source source-id}))
+
+
+  (links-to
+    [this target-id data-type]
+    (index/find reverse-links
+                {:target target-id
+                 :type data-type})))


Remove field-key from hatti app-state.

Remove field-key from hatti app-state.

Signed-off-by: Njagi Mwaniki <b6a4ba60ad861b9c9afb6daea7294be4be68f44c@urbanslug.com>

--- src/hatti/shared.cljs
+++ src/hatti/shared.cljs
@@ -66,7 +66,6 @@
                  :chart-data {}}
     :dataset-info {}
     :data []
-    :field-key :label
     :status {:total-records 0 :loading? true}
     :languages {:current nil :all []}
     :api-url "//api.ona.io/api/v1/"}))


enable update;disable add permissions to normal user for misc

--- src_cljs/rrm/corecljs.cljs
+++ src_cljs/rrm/corecljs.cljs
@@ -2133,12 +2133,12 @@
      [:h3 "List of Misc Records"]]
     [:div.row
      [:div.col-md-12
-      [:div.form-group
-       [:input {:type "button" :value "Add"
-                :class "btn btn-primary" :on-click misc-add}]
-       ;; [:input {:id "getall" :type "button" :value "Refresh"
-       ;;          :class "btn btn-primary" :on-click get-all-click}]
-       ]
+      (when (is-admin-or-super-admin)[:div.form-group
+                                      [:input {:type "button" :value "Add"
+                                               :class "btn btn-primary" :on-click misc-add}]
+                                      ;; [:input {:id "getall" :type "button" :value "Refresh"
+                                      ;;          :class "btn btn-primary" :on-click get-all-click}]
+                                      ])
       [:div {:class "box-body"}

        [:table {:class "table table-bordered table-striped dataTable"}
@@ -2150,7 +2150,7 @@
           [:th "Remarks"]
           [:th "Dispatched Date"]
           [:th "Received Date"]
-          (when (is-admin-or-super-admin) [:th " "])
+          [:th ""]
           (when (is-admin-or-super-admin) [:th " "])
           ]]
         [:tbody
@@ -2162,9 +2162,9 @@
                                      [:td (.-remarks mt)]
                                      [:td (.-dispatcheddate mt)]
                                      [:td (.-receiveddate mt)]
-                                     (when (is-admin-or-super-admin)[:td [:a {:href "javascript:;"
-                                                                              :on-click  #(misc-update(.-id mt))
-                                                                              :class "btn btn-success btn-sm glyphicon glyphicon-edit"}]])
+                                     [:td [:a {:href "javascript:;"
+                                               :on-click  #(misc-update(.-id mt))
+                                               :class "btn btn-success btn-sm glyphicon glyphicon-edit"}]]
                                      (when (is-admin-or-super-admin)[:td  [:a {:href "javascript:;" :on-click #(misc-delete(.-id mt))
                                                                                :class "btn btn-danger btn-sm glyphicon glyphicon-remove"}]])]))]]
        [:div{:class "col-xs-6 col-centered col-max"} [shared-state 0]]]]]]])


scheduler: Read query-params rather than just params in API.

--- scheduler/src/cook/mesos/api.clj
+++ scheduler/src/cook/mesos/api.clj
@@ -486,8 +486,8 @@
                       (condp contains? (get-in ctx [:request :request-method])
                         #{:get :delete}
                         (try
-                          (let [jobs (get-in ctx [:request :params "job"])
-                                instances (get-in ctx [:request :params "instance"])]
+                          (let [jobs (get-in ctx [:request :query-params "job"])
+                                instances (get-in ctx [:request :query-params "instance"])]
                             (if (or jobs instances)
                               (let [instances (if (or (nil? instances) (vector? instances))
                                                 instances


Add try-expectations macro

Add try-expectations macro

--- src/main/clojure/lazytest/runnable_test.clj
+++ src/main/clojure/lazytest/runnable_test.clj
@@ -1,5 +1,6 @@
 (ns lazytest.runnable-test
-  (:use [lazytest.test-result :only (skip pending)]))
+  (:use [lazytest.test-result :only (pass fail thrown skip pending)])
+  (:import (lazytest ExpectationFailed)))

 (defprotocol RunnableTest
   (run-tests [this]
@@ -15,3 +16,14 @@
     (if-let [reason (:pending (meta t))]
       (pending t reason)
       nil)))
+
+(defmacro try-expectations
+  "Executes body, catching all exceptions.  Returns a TestResult
+  indicating pass, failure, or thrown."
+  [t & body]
+  `(try ~@body
+	(pass ~t)
+	(catch ExpectationFailed e#
+	  (fail ~t (.reason e#)))
+	(catch Throwable e#
+	  (thrown ~t e#))))


updated init test

updated init test

--- test/clj/swarmpit/couchdb/client_test.clj
+++ test/clj/swarmpit/couchdb/client_test.clj
@@ -11,7 +11,6 @@
     (is (some? (db-version))))

   (testing "some? db"
-    (is (not (empty? (users))))
     (is (some? (get-secret))))

   (testing "dns error"


Update bootraped objects

Update bootraped objects


(maint) fix validate-certname test

(maint) fix validate-certname test

We had an incorrectly bracketed expression, so we were testing (is (= x)) which
is always true.    Fix this mistake and fix the tests.

--- test/puppetlabs/cthun/validation_test.clj
+++ test/puppetlabs/cthun/validation_test.clj
@@ -23,11 +23,11 @@
     (try+
      (validate-certname "cth://lolcathost/agent" "remotecat")
      (catch map? m
-       (is (= :puppet.cthun.validation/identity-invalid) (:type m)))
+       (is (= :puppetlabs.cthun.validation/identity-invalid (:type m))))
      (else (is (not true) "Expected an exception for remotecat"))))
   (testing "accidental regex collisions"
     (try+
      (validate-certname "cth://lolcathost/agent" "remotecat")
      (catch map? m
-       (is (= :puppet.cthun.validation/identity-invalid) (:type m)))
+       (is (= :puppetlabs.cthun.validation/identity-invalid (:type m))))
      (else (is (not true) "Expected an exception for lol.athost")))))


optimize bootstrap target to avoid unnecessary writes

was writing all files on every compile which makes watch a bit
slower than it needs to be. should only write actually changed
files now.

--- src/main/shadow/build/targets/bootstrap.clj
+++ src/main/shadow/build/targets/bootstrap.clj
@@ -191,6 +191,8 @@
                        :requires (into #{} resolved-deps)
                        :deps resolved-deps
                        :ns ns
+                       :timestamp (or (:compiled-at output)
+                                      (:last-modified output))
                        :source-name source-name
                        :source source
                        :source-file source-file
@@ -233,15 +235,27 @@
     (doseq [{:keys [type
                     source-file source
                     js-file js
-                    ana-file ana-json] :as x}
+                    ana-file ana-json
+                    timestamp] :as x}
             output-data]

-      (spit source-file source)
-      (spit js-file js)
-
-      (when (= type :cljs)
-        (spit ana-file ana-json)
-        )))
+      (when (or (not (.exists js-file))
+                (not (.exists source-file))
+                (not timestamp)
+                (zero? timestamp)
+                ;; timestamp
+                (> timestamp (.lastModified js-file))
+                (> timestamp (.lastModified source-file))
+                (and (= type :cljs)
+                     (or (not (.exists ana-file))
+                         (> timestamp (.lastModified ana-file)))))
+
+        (spit source-file source)
+        (spit js-file js)
+
+        (when (= type :cljs)
+          (spit ana-file ana-json)
+          ))))

   state)


remove debug statements

remove debug statements

--- src/overtone/sc/machinery/server/native.clj
+++ src/overtone/sc/machinery/server/native.clj
@@ -178,8 +178,6 @@
    (set! (.mRestrictedPath ptr) (:mRestrictedPath option-map))
    (set! (.mSharedMemoryID ptr) (:mSharedMemoryID option-map)))

-(use 'clojure.pprint)
-
 (defn scsynth
   "Load libscsynth and start the synthesis server with the given options.  Returns
   the World pointer."
@@ -193,7 +191,6 @@
                                  (recv-fn (.order byte-buf ByteOrder/BIG_ENDIAN)))))

            args    (merge-native-sc-args options-map)]
-       (pprint args)
        (set-world-options! options args)
        {:world (world-new options)
         :callback cb})))


improves test-scheduler-broken-services-gc by adding state tracking for failed assertions (#1571)

--- waiter/test/waiter/scheduler_test.clj
+++ waiter/test/waiter/scheduler_test.clj
@@ -33,7 +33,8 @@
             [waiter.status-codes :refer :all]
             [waiter.util.async-utils :as au]
             [waiter.util.client-tools :as ct]
-            [waiter.util.date-utils :as du])
+            [waiter.util.date-utils :as du]
+            [waiter.util.utils :as utils])
   (:import (java.net ConnectException SocketTimeoutException)
            (java.util.concurrent TimeoutException)
            (org.eclipse.jetty.client HttpClient)
@@ -222,62 +223,69 @@

 (deftest test-scheduler-broken-services-gc
   (let [leader? (constantly true)
-        state-store (atom {})
-        read-state-fn (fn [name] (get @state-store name))
-        write-iteration-counter (atom 0)
-        write-state-fn (fn [name state] (swap! state-store assoc name state) (swap! write-iteration-counter inc))
+        state-store (atom [])
+        read-state-fn (fn [name] (-> @state-store (last) (get name)))
+        max-iterations 20
+        iteration-counter (atom 0)
+        test-start-time (t/now)
+        clock (fn [] (-> test-start-time
+                         (t/plus (t/minutes @iteration-counter))
+                         (t/plus (t/millis @iteration-counter))))
+        write-state-fn (fn [name state]
+                         (swap! iteration-counter #(min max-iterations (inc %)))
+                         (swap! state-store conj {name state
+                                                  :iteration @iteration-counter
+                                                  :time (clock)}))
         service-id->service-description-fn (fn [service-id]
                                              (let [id (str/replace service-id #"[^0-9]" "")
                                                    id-int (Integer/parseInt id)]
                                                {"grace-period-secs" (* 60 id-int)}))]
-    (let [available-services-atom (atom #{"service5broken" "service6faulty" "service7" "service8stayalive" "service9stayalive"
-                                          "service10broken" "service11broken" "service12broken"})
+    (let [available-services-atom (atom #{"service5broken" "service6faulty" "service7" "service8stayalive"
+                                          "service10broken" "service11broken" "service14broken"})
           deleted-services-atom (atom #{})
           scheduler (reify ServiceScheduler
                       (delete-service [_ service-id]
                         (swap! available-services-atom disj service-id)
                         (swap! deleted-services-atom conj service-id)))
-          scheduler-state-chan (async/chan 1)
-          iteration-counter (atom 0)
-          test-start-time (t/now)
-          clock (fn [] (t/plus test-start-time (t/minutes @iteration-counter)))
+          scheduler-state-atom (atom nil)
           service-gc-go-routine (partial core/service-gc-go-routine read-state-fn write-state-fn leader? clock)]
       (testing "scheduler-broken-services-gc"
         (let [timeout-interval-ms 10
               broken-service-timeout-mins 5
               broken-service-min-hosts 3
-              query-state-fn (fn [] (async/<!! scheduler-state-chan))
+              query-state-fn (fn [] @scheduler-state-atom)
               channel-map (scheduler-broken-services-gc service-gc-go-routine query-state-fn service-id->service-description-fn scheduler
                                                         {:broken-service-min-hosts broken-service-min-hosts
                                                          :broken-service-timeout-mins broken-service-timeout-mins
                                                          :scheduler-gc-broken-service-interval-ms timeout-interval-ms})
               service-gc-exit-chan (:exit channel-map)]
-          (dotimes [iteration 20]
-            (async/>!!
-              scheduler-state-chan
-              {:all-available-service-ids (set @available-services-atom)
-               :service-id->failed-instances
-               (pc/map-from-keys
-                 (fn [service-id]
-                   (cond
-                     (str/includes? service-id "broken")
-                     (map (fn [index] {:id (str service-id ".failed" index) :host (str "failed" index "-host.example.com")})
-                          (range (inc (mod iteration 4))))
-                     (str/includes? service-id "faulty")
-                     (map (fn [index] {:id (str service-id ".faulty" index) :host "faulty-host.example.com"})
-                          (range (mod iteration 4)))
-                     :else []))
-                 @available-services-atom)
-               :service-id->healthy-instances
-               (pc/map-from-keys
-                 (fn [service-id]
-                   (if (str/includes? service-id "broken") [] [{:id (str service-id ".unhealthy")}]))
-                 @available-services-atom)})
-            (swap! iteration-counter inc)
-            (while (> @iteration-counter @write-iteration-counter) nil))
+          (while (< @iteration-counter 20)
+            (let [iteration (min (dec max-iterations) @iteration-counter)]
+              (reset!
+                scheduler-state-atom
+                {:all-available-service-ids (set @available-services-atom)
+                 :service-id->failed-instances
+                 (pc/map-from-keys
+                   (fn [service-id]
+                     (cond
+                       (str/includes? service-id "broken")
+                       (map (fn [index] {:id (str service-id ".failed" index) :host (str "failed" index "-host.example.com")})
+                            (range (inc (mod iteration 4))))
+                       (str/includes? service-id "faulty")
+                       (map (fn [index] {:id (str service-id ".faulty" index) :host "faulty-host.example.com"})
+                            (range (mod iteration 4)))
+                       :else []))
+                   @available-services-atom)
+                 :service-id->healthy-instances
+                 (pc/map-from-keys
+                   (fn [service-id]
+                     (if (str/includes? service-id "broken") [] [{:id (str service-id ".unhealthy")}]))
+                   @available-services-atom)})
+              (utils/sleep timeout-interval-ms)))
           (async/>!! service-gc-exit-chan :exit)
-          (is (= #{"service5broken" "service10broken" "service11broken"} @deleted-services-atom))
-          (is (= #{"service6faulty" "service7" "service8stayalive" "service9stayalive" "service12broken"} @available-services-atom)))))))
+          (let [assertion-msg (str @state-store)]
+            (is (= #{"service5broken" "service10broken" "service11broken"} @deleted-services-atom) assertion-msg)
+            (is (= #{"service6faulty" "service7" "service8stayalive" "service14broken"} @available-services-atom) assertion-msg)))))))

 (deftest test-scheduler-syncer
   (let [clock t/now


Test fix :wrench:

Test fix :wrench:

--- test/metabase/query_processor/parameters_test.clj
+++ test/metabase/query_processor/parameters_test.clj
@@ -314,7 +314,7 @@
 ;;; +-------------------------------------------------------------------------------------------------------+

 ;; for some reason param substitution tests fail on Redshift so just don't run those for now
-(def ^:private ^:const params-test-engines (set/difference non-timeseries-engines #{:redshift}))
+(def ^:private ^:const params-test-engines (set/difference non-timeseries-engines #{:redshift :crate}))

 ;; check that date ranges work correctly
 (datasets/expect-with-engines params-test-engines


minor tweaks for increased readability

minor tweaks for increased readability

--- src/io/aviso/rook.clj
+++ src/io/aviso/rook.clj
@@ -84,11 +84,13 @@
   [namespace]
   (when-not (find-ns namespace)
     (require namespace))
-  (concat
-    (remove nil?
-            (map function-entry
-                 (filter symbol-for-function? (map second (ns-publics namespace)))))
-    default-mappings))
+  (->> namespace
+   ns-publics
+   (map second)
+   (filter symbol-for-function?)
+   (map function-entry)
+   (remove nil?)
+   (concat default-mappings)))

 (defn- get-function-meta
   "Get meta for route-mapping and namespace."
@@ -228,8 +230,7 @@
   ([namespace]
    (namespace-middleware rook-handler namespace))
   ([path namespace & handlers]
-   (let [handler (if (empty? handlers)
-                   rook-handler
-                   (apply compojure/routes (concat handlers [rook-handler])))
+   (let [handler (if (empty? handlers) rook-handler
+                   (apply compojure/routes (conj handlers rook-handler)))
          handler' (namespace-middleware handler namespace)]
-     (compojure/context path [] handler'))))+     (compojure/context path [] handler'))))


Improved Performance and Code

Improved Performance and Code

--- src/lens/import.clj
+++ src/lens/import.clj
@@ -77,91 +77,102 @@
     (->> (async/chan 1 (assoc-xf :type :item-ref))
          (async/pipe (api/create-item-ref! item-group-def ref)))))

-(defn- constrain-jobs [jobs n parse-ch]
-  (if (< (:count jobs) n) [parse-ch] []))
+(defn- handle-item-ref [state val]
+  (update state :refs #(collect-item-ref % val)))
+
+(defn- handle-item-def [state val]
+  (let [job (submit-job! api/upsert-item-def! :item-def (:parent state) val)]
+    (update state :jobs #(add-job % :item job))))

 (defn import! [service-document n parse-ch]
-  (go-loop [ports [parse-ch]
-            jobs {:count 0}
-            study service-document
-            defs {}
-            refs {}]
-    (log/debug "--------------------------------------------------")
-    (log/debug "Parent:" (:data study))
-    (log/debug "Defs:  " defs)
-    (log/debug "Refs:  " refs)
-    (log/debug "Jobs:  " (map-vals count (dissoc jobs :count)))
-    (log/debug "--------------------------------------------------")
-    (let [[val port] (async/alts! (into ports (select-jobs jobs)))]
-      (if val
-        (if (= parse-ch port)
-          (do (log/debug "Parsed" (:type val) (:id val))
+  (let [constrain-jobs
+        (fn [state]
+          (if (< (:count (:jobs state)) n) [parse-ch] []))]
+    (go-loop [ports [parse-ch]
+              state {:parent service-document
+                     :jobs {:count 0}
+                     :defs {}
+                     :refs {}}]
+      (log/debug "--------------------------------------------------")
+      (log/debug "Parent:" (:data (:parent state)))
+      (log/debug "Jobs:  " (map-vals count (dissoc (:jobs state) :count)))
+      (log/debug "--------------------------------------------------")
+      (let [[val port] (async/alts! (into ports (select-jobs (:jobs state))))]
+        (if val
+          (if (= parse-ch port)
+            (do (log/debug "Parsed" (:type val) (:id val))
+                (case (:type val)
+                  :study
+                  (let [job (async/pipe (api/upsert-study! (:parent state) val)
+                                        (async/chan 1 (assoc-xf :type :study)))]
+                    (recur [] (update state :jobs #(add-job % :study job))))
+
+                  :form-ref
+                  (recur (constrain-jobs state)
+                         (update state :refs #(collect-form-ref % val)))
+
+                  :form-def
+                  (let [job (submit-job! api/upsert-form-def! :form-def (:parent state) val)]
+                    (recur (constrain-jobs state)
+                           (update state :jobs #(add-job % :form job))))
+
+                  :item-group-ref
+                  (recur (constrain-jobs state)
+                         (update state :refs #(collect-item-group-ref % val)))
+
+                  :item-group-def
+                  (let [job (submit-job! api/upsert-item-group-def! :item-group-def (:parent state) val)]
+                    (recur (constrain-jobs state)
+                           (update state :jobs #(add-job % :item-group job))))
+
+                  :item-ref
+                  (recur (constrain-jobs state) (handle-item-ref state val))
+
+                  :item-def
+                  (recur (constrain-jobs state) (handle-item-def state val))))
+
+            ;; jobs
+            (do
+              (log/debug "Finished" (:type val) (:id (:data val)))
               (case (:type val)
                 :study
-                (let [job (async/pipe (api/upsert-study! study val)
-                                      (async/chan 1 (assoc-xf :type :study)))]
-                  (recur [] (add-job jobs :study job) nil defs refs))
-
-                :form-ref
-                (recur (constrain-jobs jobs n parse-ch) jobs
-                       study defs (collect-form-ref refs val))
+                (recur (constrain-jobs state)
+                       (-> (update state :jobs #(remove-job % :study port))
+                           (assoc :parent val)))

                 :form-def
-                (let [job (submit-job! api/upsert-form-def! :form-def study val)]
-                  (recur (constrain-jobs jobs n parse-ch)
-                         (add-job jobs :form job) study defs refs))
+                (recur (constrain-jobs state)
+                       (-> (update state :jobs #(remove-job % :form port))
+                           (update :defs #(collect-form-def % val))))

                 :item-group-ref
-                (recur (constrain-jobs jobs n parse-ch) jobs study defs
-                       (collect-item-group-ref refs val))
+                (recur (constrain-jobs state)
+                       (update state :jobs #(remove-job % :item-group port)))

                 :item-group-def
-                (let [job (submit-job! api/upsert-item-group-def! :item-group-def
-                                       study val)]
-                  (recur (constrain-jobs jobs n parse-ch) (add-job jobs :item-group job) study defs refs))
+                (let [create-ref (map #(create-item-group-ref-job (get-in state [:defs (:study-id val)]) %))
+                      ref-vec [(:study-id val) :item-group-refs (:id (:data val))]
+                      ref-jobs (eduction create-ref (get-in state [:refs ref-vec]))]
+                  (recur (constrain-jobs state)
+                         (-> (update state :jobs #(-> (remove-job % :item-group port)
+                                                      (add-jobs :item-group ref-jobs)))
+                             (update :defs #(collect-item-group-def % val))
+                             (update :refs #(dissoc-in % ref-vec)))))

                 :item-ref
-                (recur (constrain-jobs jobs n parse-ch) jobs study defs (collect-item-ref refs val))
+                (recur (constrain-jobs state)
+                       (update state :jobs #(remove-job % :item port)))

                 :item-def
-                (let [job (submit-job! api/upsert-item-def! :item-def study val)]
-                  (recur (constrain-jobs jobs n parse-ch) (add-job jobs :item job) study defs refs))
+                (let [create-ref (map #(create-item-ref-job (get-in state [:defs (:study-id val)]) %))
+                      ref-vec [(:study-id val) :item-refs (:id (:data val))]
+                      ref-jobs (eduction create-ref (get-in state [:refs ref-vec]))]
+                  (recur (constrain-jobs state)
+                         (-> (update state :jobs #(-> (remove-job % :item port)
+                                                      (add-jobs :item ref-jobs)))
+                             (update :refs #(dissoc-in % ref-vec))))))))

-                (recur (constrain-jobs jobs n parse-ch) jobs study defs refs)))
+          (if (= 0 (:count (:jobs state)))
+            (log/info "Finished!")
+            (recur [] state)))))))

-          ;; jobs
-          (do
-            (log/debug "Finished" (:type val) (:id (:data val)))
-            (case (:type val)
-              :study
-              (recur (constrain-jobs jobs n parse-ch) (remove-job jobs :study port) val defs refs)
-
-              :form-def
-              (recur (constrain-jobs jobs n parse-ch) (remove-job jobs :form port) study (collect-form-def defs val) refs)
-
-              :item-group-ref
-              (recur (constrain-jobs jobs n parse-ch) (remove-job jobs :item-group port) study defs refs)
-
-              :item-group-def
-              (let [create-ref (map #(create-item-group-ref-job (defs (:study-id val)) %))
-                    ref-vec [(:study-id val) :item-group-refs (:id (:data val))]
-                    ref-jobs (eduction create-ref (get-in refs ref-vec))
-                    jobs (-> (remove-job jobs :item-group port)
-                             (add-jobs :item-group ref-jobs))]
-                (recur (constrain-jobs jobs n parse-ch) jobs study (collect-item-group-def defs val) (dissoc-in refs ref-vec)))
-
-              :item-ref
-              (recur (constrain-jobs jobs n parse-ch) (remove-job jobs :item port) study defs refs)
-
-              :item-def
-              (let [create-ref (map #(create-item-ref-job (defs (:study-id val)) %))
-                    ref-vec [(:study-id val) :item-refs (:id (:data val))]
-                    ref-jobs (eduction create-ref (get-in refs ref-vec))
-                    jobs (-> (remove-job jobs :item port)
-                             (add-jobs :item ref-jobs))]
-                (recur (constrain-jobs jobs n parse-ch) jobs study defs (dissoc-in refs ref-vec))))))
-
-        (if (= 0 (:count jobs))
-          (log/info "Finished!")
-          (recur [] jobs study defs refs))))))
-


:tada: Add clipboard related functions to webapi utils.

--- frontend/src/uxbox/util/webapi.cljs
+++ frontend/src/uxbox/util/webapi.cljs
@@ -7,8 +7,10 @@
 (ns uxbox.util.webapi
   "HTML5 web api helpers."
   (:require
+   [promesa.core :as p]
    [beicon.core :as rx]
-   [cuerdas.core :as str]))
+   [cuerdas.core :as str]
+   [uxbox.util.transit :as t]))

 (defn read-file-as-text
   [file]
@@ -65,4 +67,19 @@
 ;;     (rx/create on-subscribe)))

+(defn write-to-clipboard
+  [data]
+  (let [cboard (unchecked-get js/navigator "clipboard")]
+    (.writeText cboard (uxbox.util.transit/encode data))))

+(defn- read-from-clipboard
+  []
+  (let [cboard (unchecked-get js/navigator "clipboard")]
+    (-> (.readText cboard)
+        (p/then (fn [data]
+                  (try
+                    (t/decode data)
+                    (catch :default e
+                      nil)))))))
+
+


fibo perfs

fibo perfs

--- src/clj/algorithms_clj/perf_fibo.clj
+++ src/clj/algorithms_clj/perf_fibo.clj
@@ -7,18 +7,18 @@
 (set! *warn-on-reflection* true)

 (defn fibo-iterate
-  [n]
+  [^long n]
   (let [next-fib (fn [[a b]] [b (+ a b)])
         fibs (iterate next-fib [0N 1N])]
     (first (nth fibs n))))

 (defn fibo-lazy-seq
-  [n]
+  [^long n]
   (letfn [(fibs [a b] (cons a (lazy-seq (fibs b (+ a b)))))]
     (nth (fibs 0N 1N) n)))

 (defn fibo-recur
-  [n]
+  [^long n]
   (loop [curr 0N
          next 1N
          n n]
@@ -27,8 +27,8 @@
       curr)))

 (defn fibo-trampoline
-  [n]
-  (letfn [(fibs [curr next n]
+  [^long n]
+  (letfn [(fibs [curr next ^long n]
             (if-not (zero? n)
               #(fibs next (+ curr next) (dec n))
               curr))]
@@ -43,7 +43,7 @@
 ; -----------------------------------------------

 (defn fibo-local-vars
-  [n]
+  [^long n]
   (with-local-vars [curr 0N
                     next 1N
                     iter n]
@@ -51,12 +51,11 @@
       (let [nnext (+ @curr @next)]
         (var-set curr @next)
         (var-set next nnext)
-        (var-set iter (dec @iter))
-        ))
+        (var-set iter (dec @iter))))
     @curr))

 (defn fibo-volatile
-  [n]
+  [^long n]
   (let [curr (volatile! 0N)
         next (volatile! 1N)
         iter (volatile! n)]
@@ -76,24 +75,32 @@
                    ^:unsynchronized-mutable next]
   Advance
   (advance [_ n]
-    (loop [n n]
+    (loop [^long n n]
       (if-not (zero? n)
         (let [nnext (+ curr next)]
           (set! curr next)
           (set! next nnext)
-          (recur (dec n))
-          )))
+          (recur (dec n)))))
     curr))

 (defn fibo-with-type
-  [n]
+  [^long n]
   (advance (FiboType. 0N 1N) n))

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

 (defn fibo-with-java
-  [n]
+  [^long n]
   (javaalg.algorithms.PerfFiboJava/fibs n))
+
+(defn fibo-recur-java-bigint
+  [^long n]
+  (loop [curr (BigInteger/valueOf 0)
+         next (BigInteger/valueOf 1)
+         n n]
+    (if-not (zero? n)
+      (recur next (.add curr next) (dec n))
+      curr)))

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

@@ -117,5 +124,6 @@
     (run-bench (fibo-volatile n))
     (run-bench (fibo-with-type n))
     (run-bench (fibo-with-java n))
+    (run-bench (fibo-recur-java-bigint n))
     #_(perf/quick-bench (fibo-lazy-cat n))
     ))


test some dynamic expansions

test some dynamic expansions

--- src/clj/ceres_analytics/measures.clj
+++ src/clj/ceres_analytics/measures.clj
@@ -22,6 +22,7 @@
     :publications "pubs"
     :cascades cascades
     :assignments "tagrefs"
+    :unknown "unknown"
     :unrelated))

@@ -59,8 +60,15 @@
 (defn lifetime
   "Computes lifetime of contact set"
   [cs]
-  (let [sorted-cs (sort-by :ts cs)]
-    (t/in-seconds (t/interval (last cs) (first cs)))))
+  (zipmap
+   (keys cs)
+   (map
+    #(let [sorted-cs (sort-by :ts %)]
+       (-> (t/interval (-> % first :ts) (-> % last :ts))
+           t/in-seconds
+           (/ 3600)
+           float))
+    (vals cs))))

 (defn density
@@ -71,6 +79,25 @@
       ((comp float /) (reduce + (map #(mc/count @db % {:ts {$lt t0}}) contacts))
          (* node-count (dec node-count))))))

+(defn subset-size
+  "Computes size of given contact set"
+  [cs]
+  (zipmap
+   (keys cs)
+   (map count (vals cs))))
+
+
+(defn intercontact-times
+  "Computes average inter-contact times"
+  [cs]
+  (zipmap
+   (keys cs)
+   (map
+    (fn [sub-cs]
+      (let [sorted-cs (sort-by :ts sub-cs)]
+        (reduce + #(t/in-seconds (t/interval (:ts %1) (:ts %2))))))
+    (vals cs))))
+

 (comment

@@ -79,13 +106,23 @@
       first
       count)

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

+  (-> (dynamic-expansion :contacts (t/date-time 2015 4 3) (t/date-time 2015 4 28))
+      subset-size
+      aprint)
+
+  (-> (dynamic-expansion :unknown (t/date-time 2015 4 3) (t/date-time 2015 4 28))
+      lifetime
+      aprint)
+
+  (-> (dynamic-expansion :nodes (t/date-time 2015 4 3) (t/date-time 2015 4 28))
+      lifetime
+      aprint)

   )


[REFACTOR] Add `reset-ModulesSelected!` function

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

--- src/cljs/cljs_nusmods/timetable.cljs
+++ src/cljs/cljs_nusmods/timetable.cljs
@@ -247,6 +247,11 @@
   [moduleCode affectedDaysSet]
   (set! ModulesSelected (dissoc ModulesSelected moduleCode))
   (update-ModulesSelected-for-affected-days! affectedDaysSet))
+
+(defn- reset-ModulesSelected!
+  "Resets `ModulesSelected`."
+  []
+  (set! ModulesSelected {}))

 (def ^{:doc     "Vector containing module code strings in the order the modules
                  were added."
@@ -1544,7 +1549,7 @@
                  ($ Timetable-Row-TD-HTML-String)))
       (attr (.find $dayElem "tr > th") "rowspan" 2)))
   (timetable-create!)
-  (set! ModulesSelected {})
+  (reset-ModulesSelected!)
   (set! ModulesSelectedOrder [])
   (select2-box-update-modules)
   (set-document-location-hash! ""))


Store module information instead of true for in-memory repr of Timetable

This information will allow us to access the appropriate <div> element
in the `ModulesSelected` global variable when module removal or shifting
occurs.

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

--- src/cljs/cljs_nusmods/timetable.cljs
+++ src/cljs/cljs_nusmods/timetable.cljs
@@ -160,10 +160,20 @@
        {
          :nrLessonGroups (integer representing the number of lesson groups
                           occupying the current row)
-         :occupied       (a vector of timeslots from 0800 to 2330 (inclusive)
-                          in 30 min intervals. Each slot is a boolean value.
-                          A value of `True` indicates that the slot is occupied.
-                          A value of `False` indicates that the slot is free.)
+         :occupied        a vector of timeslots from 0800 to 2330 (inclusive)
+                          in 30 min intervals. Each slot is one of:
+                          - nil. The means that the slot is free
+                          - a map of module information:
+                            {
+                              :moduleCode -> module code string
+                              :lessonType -> lesson type string (long form),
+                              :lessonGroup -> Lesson group string (lesson label)
+                              :index       -> index to the list of lessons for
+                                              that lesson group.
+                            }
+                            This information can be used to access the <div> in
+                            the `ModulesSelected` global during module removal
+                            or lesson shifting.
        }"
   []
   {
@@ -251,20 +261,18 @@
 (defn- timetable-mark-lesson-slots-occupied
   "Given a 0-indexed row number obtained by `find-free-row-for-lesson`, marks
    the timeslots for the lesson in that row as occupied."
-  [rowNum lesson]
-  (let [day       (:day lesson)
-        startTime (:startTime lesson)
-        endTime   (:endTime lesson)]
-    (set! Timetable
-          (update-in Timetable [day rowNum]
-                     (fn [ttRow]
-                       {
-                         :nrLessonGroups (inc (:nrLessonGroups ttRow))
-                         :occupied       (reduce (fn [occupiedVec idx]
-                                                   (assoc occupiedVec idx true))
-                                                 (:occupied ttRow)
-                                                 (range startTime endTime))
-                       })))))
+  [day rowNum startTime endTime modInfo]
+  (set! Timetable
+        (update-in
+          Timetable [day rowNum]
+          (fn [ttRow]
+            {
+              :nrLessonGroups (inc (:nrLessonGroups ttRow))
+              :occupied       (reduce (fn [occupiedVec idx]
+                                        (assoc occupiedVec idx modInfo))
+                                      (:occupied ttRow)
+                                      (range startTime endTime))
+            }))))

 (defn- find-free-row-for-lesson
   "Returns the 0-indexed row which can accomodate the given lesson (timeslots
@@ -285,7 +293,7 @@
             (zero? (:nrLessonGroups row))
             (assoc result :foundFreeRow true)

-            (not (some true?
+            (not (some (fn [x] (not (nil? x)))
                        (map (fn [timeIdx] (nth (:occupied row) timeIdx))
                             (range startTime endTime))))
             (assoc result :foundFreeRow true)
@@ -310,7 +318,8 @@
 (defn- add-module-lesson
   "Adds a single lesson of a module (obtained from the `ModulesMap` global) to
    the timetable, and returns its jQuery div element."
-  [moduleCode moduleName lessonType lessonLabel lesson bgColorCssClass]
+  [moduleCode moduleName lessonType lessonLabel lesson lessonIdx
+   bgColorCssClass]
   (let [rowNum      (find-free-row-for-lesson lesson)
         day         (:day lesson)
         startTime   (:startTime lesson)
@@ -322,7 +331,12 @@
     ; Create new row if necessary
     (if (= rowNum (get-nr-rows-in-timetable-day day))
         (add-new-row-to-timetable-day day))
-    (timetable-mark-lesson-slots-occupied rowNum lesson)
+
+    ; Update in-memory representation of timetable
+    (timetable-mark-lesson-slots-occupied
+      day rowNum startTime endTime
+      {:moduleCode moduleCode, :lessonType lessonType, :lessonGroup lessonLabel,
+       :index lessonIdx})

     ; add background color css class
     (.addClass divElem bgColorCssClass)
@@ -358,14 +372,16 @@
                                        lessonLabel])]
     (if (and moduleName lessons)
         (let [lessonInfoSeq (doall
-                              (map (fn [lesson]
+                              (map (fn [[lessonIdx lesson]]
                                      (add-module-lesson moduleCode
                                                         moduleName
                                                         lessonType
                                                         lessonLabel
                                                         lesson
+                                                        lessonIdx
                                                         bgColorCssClass))
-                                   lessons))]
+                                   (map vector
+                                        (range 0 (count lessons)) lessons)))]
           ; Update ModulesSelected with the lesson group
           (set! ModulesSelected
                 (assoc-in ModulesSelected [moduleCode lessonType]


fix name

fix name

--- src/cljs/just_married/home/gift.cljs
+++ src/cljs/just_married/home/gift.cljs
@@ -17,7 +17,7 @@
          :sort-code "09-01-29"}})

 (def gift-dict
-  {:en {:gift   "Your company in this special day will be the greatest gift. If you would like to contribute to our Honeymoon trip to the Seychelles you can do use these bank coordinates:"
+  {:en {:gift   "Your company in this special day will be the greatest gift. If you would like to contribute to our Honeymoon trip to the Seychelles you can use the bank details provided below:"
         :pounds "British Pounds"
         :title  "Wedding Registry"}


badge route fix

badge route fix

--- src/cljs/salava/badge/ui/routes.cljs
+++ src/cljs/salava/badge/ui/routes.cljs
@@ -38,8 +38,7 @@
               (str (base-path context) "/badge/mybadges") {:weight 20 :title (t :badge/Mybadges) :site-navi true :breadcrumb (t :badge/Badges " / "  :badge/Mybadges)}
               (str (base-path context) "/badge/import") {:weight 22 :title (t :badge/Import) :site-navi false :breadcrumb (t :badge/Badges " / " :badge/Import)}
               (str (base-path context) "/badge/info/\\d+") {:breadcrumb   (t :badge/Badges " / " :badge/Badgeinfo)}}]
-    ;(if app-handler
+    (if app-handler
       (merge navi {(str (base-path context) "/badge/application") {:weight 45 :title (t :extra-application/Application)  :site-navi true :breadcrumb (t :badge/Badges  " / " :extra-application/Application)}})
-  )
-    );)
+      navi)))


[#843] Set all monitoring urls to "unknown"

There is no way to get the full compojure matched path, so instead of
having thousands of urls (due to the REST urls), prefer to have just one
stat, so at least we can see the traffic and error rates.

Compojure has a wrap-routes function to do this, but it doesnt work as
we need when using compojure/context. When using context, we can just
capture the latest bit of the matched api. For example:

(context "/visualization/:id"
  (GET "/meta"...

We are just able to get the "/meta" part, when what we actually want is
"/visualization/:id/meta".

--- backend/src/akvo/lumen/lumen_monitoring.clj
+++ backend/src/akvo/lumen/lumen_monitoring.clj
@@ -16,7 +16,7 @@

 (defmethod ig/init-key ::middleware [_ {:keys [collector]}]
   #(-> %
-       (ring/wrap-metrics collector)))
+       (ring/wrap-metrics collector {:path-fn (constantly "unknown")})))

 (comment
   (slurp "http://localhost:3000/metrics")


[#3856] Keep url in browser if no change

--- src/status_im/ui/screens/browser/views.cljs
+++ src/status_im/ui/screens/browser/views.cljs
@@ -33,7 +33,7 @@
   (reader/read-string (slurp "./src/status_im/utils/browser_config.edn")))

 (defn toolbar-content [{:keys [url] :as browser}]
-  (let [url-text (atom nil)]
+  (let [url-text (atom url)]
     [react/view
      [react/view (styles/toolbar-content false)
       [react/text-input {:on-change-text    #(reset! url-text %)


Finer grained timing.

Finer grained timing.

--- src/algebolic/evolution/core.clj
+++ src/algebolic/evolution/core.clj
@@ -35,16 +35,22 @@
         rabble (:rabble zeitgeist)
         elite (or (:elite zeitgeist) [])
         new-elite (elite-selector rabble elite)
+        elite-selected-time (System/currentTimeMillis)
         mating-pool (mating-pool-selector rabble new-elite)
         new-rabble (reproduction/reproduce reproduction-config mating-pool)
         transformed-rabble (if (nil? transformations)
                              new-rabble
                              ((apply comp transformations) new-rabble))
+        rabble-ready-time (System/currentTimeMillis)
         scored-transformed-rabble (scoring/update-scores transformed-rabble score-functions)
         evolved-zg (assoc (assoc zeitgeist :rabble scored-transformed-rabble) :elite new-elite)
         end-time (System/currentTimeMillis)
         ;; update some stats on the zg
-        stats {:age (+ 1 (or (:age evolved-zg) 0)) :time (- end-time start-time)}
+        stats {:age (+ 1 (or (:age evolved-zg) 0))
+               :time (- end-time start-time)
+               :selection-time (- elite-selected-time start-time)
+               :reproduction-time (- rabble-ready-time elite-selected-time)
+               :scoring-time (- end-time rabble-ready-time)}
         final-zg (merge evolved-zg stats)
         _ (when reporting-function (reporting-function final-zg))]
     final-zg))


DM + GR - #46 Make sure integration flag applies to bearer-token tests

--- integration/objective8/db/bearer_tokens_test.clj
+++ integration/objective8/db/bearer_tokens_test.clj
@@ -12,10 +12,10 @@
                                 (s/pg-store! {:entity :bearer-token
                                               :bearer-name "mr api"
                                               :bearer-token "12345"})))
-          (after :facts (helpers/truncate-tables))])
+          (after :facts (helpers/truncate-tables))]

        (fact "Gets a bearer token from a bearer-name"
              (bt/token-provider "mr api") => "12345")

        (fact "Returns nil if the token does not exist for a given name"
-             (bt/token-provider "some other guy") => nil))
+             (bt/token-provider "some other guy") => nil)))


Refactor benchmark

Refactor benchmark

--- benchmarks/caesium/crypto/secretbox_benchmark.clj
+++ benchmarks/caesium/crypto/secretbox_benchmark.clj
@@ -7,45 +7,34 @@
             [caesium.bench-utils :refer [fmt-bytes]])
   (:import [java.nio ByteBuffer]))

-;; secretbox to-buf! macros vs fn vs no casts with indirect byte bufs
+(def sizes (map (partial bit-shift-left 1) [6 8 10 12 20 24]))

-(def random-direct-byte-buf (comp bc/->direct-byte-buf randombytes))
-(def random-indirect-byte-buf (comp bc/->indirect-byte-buf randombytes))
+(defmacro bench-secretnonce
+  [fs converter]
+  `(doseq [[size msg] (map (juxt identity (comp converter randombytes)) sizes)
+           f ~fs]
+     (let [rand-buf (comp converter randombytes)
+           key (rand-buf s/keybytes)
+           nonce (randbuf s/noncebytes)
+           out (randbuf (+ s/macbytes size))]
+       (println f (fmt-bytes size))
+       (spy (mapv type [out msg nonce key]))
+       (bench (f out msg nonce key)))))

 (deftest ^:benchmark to-buf!-benchmarks
-  (let [sizes (map (partial bit-shift-left 1) [6 8 10 12 20 24])]
-    (println "secretbox to-buf! with direct bufs")
-    (println "these bufs already exist, so there is no allocation")
-    (doseq [[size msg] (map (juxt identity random-direct-byte-buf) sizes)
-            f [s/secretbox-easy-to-direct-byte-bufs-with-macros!
-               s/secretbox-easy-to-direct-byte-bufs!
-               s/secretbox-easy-to-byte-bufs-nocast!
-               s/secretbox-easy-refl!]]
-      (let [key (random-direct-byte-buf s/keybytes)
-            nonce (random-direct-byte-buf s/noncebytes)
-            out (ByteBuffer/allocateDirect (+ s/macbytes size))]
-        (println f (fmt-bytes size) (mapv type [out msg nonce key]))
-        (bench (f out msg nonce key))))
+  (println "secretbox to-buf! with direct bufs, pre-allocation")
+  (bench-secretnonce [s/secretbox-easy-to-direct-byte-bufs-with-macros!
+                      s/secretbox-easy-to-direct-byte-bufs!
+                      s/secretbox-easy-to-byte-bufs-nocast!
+                      s/secretbox-easy-refl!]
+                     bc/->direct-byte-buf)

-    (println "secretbox to-buf! with indirect bufs")
-    (println "these bufs already exist, so there is no allocation")
-    (doseq [[size msg] (map (juxt identity random-indirect-byte-buf) sizes)
-            f [s/secretbox-easy-to-indirect-byte-bufs-with-macros!
-               s/secretbox-easy-to-indirect-byte-bufs!
-               s/secretbox-easy-to-byte-bufs-nocast!
-               s/secretbox-easy-refl!]]
-      (let [key (random-indirect-byte-buf s/keybytes)
-            nonce (random-indirect-byte-buf s/noncebytes)
-            out (ByteBuffer/allocate (+ s/macbytes size))]
-        (println f (fmt-bytes size) (mapv type [out msg nonce key]))
-        (bench (f out msg nonce key))))
+  (println "secretbox to-buf! with indirect bufs, pre-allocation")
+  (bench-secretnonce [s/secretbox-easy-to-indirect-byte-bufs-with-macros!
+                      s/secretbox-easy-to-indirect-byte-bufs!
+                      s/secretbox-easy-to-byte-bufs-nocast!
+                      s/secretbox-easy-refl!]
+                     bc/->indirect-byte-buf)

-    (println "secretbox to-buf! with byte arrays")
-    (println "these bufs already exist, so there is no allocation")
-    (doseq [[size msg] (map (juxt identity randombytes) sizes)
-            f [s/secretbox-easy-to-buf!]]
-      (let [key (randombytes s/keybytes)
-            nonce (randombytes s/noncebytes)
-            out (byte-array (+ s/macbytes size))]
-        (println f (fmt-bytes size) (mapv type [out msg nonce key]))
-        (bench (f out msg nonce key))))))
+  (println "secretbox to-buf! with byte arrays, pre-allocation")
+  (bench-secretnonce [s/secretbox-easy-to-buf!] identity))


Use an atom instead of a Ref for *repls*

--- src/main/clojure/vimclojure/repl.clj
+++ src/main/clojure/vimclojure/repl.clj
@@ -30,13 +30,13 @@
   #^{:doc
   "A map holding the references to all running repls indexed by their repl id."}
   *repls*
-  (ref {}))
+  (atom {}))

-(let [id (ref 0)]
+(let [id (atom 0)]
   (defn repl-id
     "Get a new Repl id."
     []
-    (dosync (alter id inc))))
+    (swap! id inc)))

 (def
   #^{:doc
@@ -81,16 +81,15 @@
   ; Make sure user namespace exists.
   (let [id       (repl-id)
         the-repl (make-repl id nspace)]
-    (dosync (commute *repls* assoc id the-repl))
+    (swap! *repls* assoc id the-repl)
     id))

 (defn stop
   "Stop the Repl with the given id."
   [id]
-  (dosync
-    (when-not (@*repls* id)
-      (throw (Exception. "Not Repl of that id or Repl currently active: " id)))
-    (commute *repls* dissoc id)))
+  (when-not (@*repls* id)
+    (throw (Exception. "Not Repl of that id or Repl currently active: " id)))
+  (swap! *repls* dissoc id))

 (defn root-cause
   "Drill down to the real root cause of the given Exception."
@@ -111,13 +110,12 @@
   to use a one-shot context. Sets the file line accordingly."
   [id nspace file line thunk]
   (let [the-repl (if (not= id -1)
-                   (dosync
-                     (let [the-repls (deref *repls*)
-                           the-repl  (the-repls id)]
-                       (when-not the-repl
-                         (throw (Exception. (str "No Repl of that id: " id))))
-                       (alter *repls* dissoc id)
-                       the-repl))
+                   (locking *repls*
+                     (if-let [the-repl (get @*repls* id)]
+                       (do
+                         (swap! *repls* dissoc id)
+                         the-repl)
+                       (throw (Exception. (str "No Repl of that id: " id)))))
                    (make-repl -1))
         line     (if (= line 0)
                    (the-repl :line)
@@ -143,24 +141,23 @@
       (thunk)
       (finally
         (when (not= id -1)
-          (dosync
-            (commute *repls* assoc id
-                     (struct-map repl
-                                 :id                 id
-                                 :ns                 *ns*
-                                 :warn-on-reflection *warn-on-reflection*
-                                 :print-meta         *print-meta*
-                                 :print-length       *print-length*
-                                 :print-level        *print-level*
-                                 :compile-path       *compile-path*
-                                 :command-line-args  *command-line-args*
-                                 :expr1              *1
-                                 :expr2              *2
-                                 :expr3              *3
-                                 :exception          *e
-                                 :print-pretty       vimclojure.repl/*print-pretty*
-                                 :line               (dec (.getLineNumber *in*))))))
-        (Var/popThreadBindings)))))
+          (swap! *repls* assoc id
+                 (struct-map repl
+                             :id                 id
+                             :ns                 *ns*
+                             :warn-on-reflection *warn-on-reflection*
+                             :print-meta         *print-meta*
+                             :print-length       *print-length*
+                             :print-level        *print-level*
+                             :compile-path       *compile-path*
+                             :command-line-args  *command-line-args*
+                             :expr1              *1
+                             :expr2              *2
+                             :expr3              *3
+                             :exception          *e
+                             :print-pretty       vimclojure.repl/*print-pretty*
+                             :line               (dec (.getLineNumber *in*))))))
+        (Var/popThreadBindings))))

 (defmacro with-repl
   "Executes body in the context of the Repl with the given id. id may be -1


start fsworker with future

start fsworker with future

--- src/brainbot/nozzle/fsworker.clj
+++ src/brainbot/nozzle/fsworker.clj
@@ -79,6 +79,6 @@
     (when (empty? filesystems)
       (misc/die (str "no filesystems defined in section " section)))

-    (mqhelper/connect-loop-with-thread-pool
-      rmq-settings
-      (build-handle-connection filesystems))))
+    (future (mqhelper/connect-loop-with-thread-pool
+              rmq-settings
+              (build-handle-connection filesystems)))))


Enable alphabetic labels in Czech

Enable alphabetic labels in Czech

--- src/cljs/db_quiz/components.cljs
+++ src/cljs/db_quiz/components.cljs
@@ -338,8 +338,10 @@

 (defn dbpedia-options
   []
-  [:div [selector-picker]
-        [difficulty-picker]])
+  (let [czech? (= (:language @app-state) :cs)]
+    [:div [selector-picker]
+     [difficulty-picker]
+     (when czech? [field-labelling])]))

 (def advanced-options
   (let [id [:options :data-source]


fixes

fixes

--- src/cljs/dbquery/db_console.cljs
+++ src/cljs/dbquery/db_console.cljs
@@ -8,7 +8,7 @@
             [cljsjs.mousetrap]
             [ajax.core :refer [GET POST]]))

-(deftype ConsoleControl [data-tabs active-tab q-id]
+(deftype ConsoleControl [data-tabs active-tab q-id out-text]
   Object
   (preview [_ tbl]
     (when-not (some #(= tbl (:id %)) @data-tabs)
@@ -16,9 +16,9 @@
       (swap! data-tabs conj {:id tbl :raw-sql (str "select * from " tbl)}))
     (reset! active-tab tbl))

-  (exec-sql [_ sql & opts]
+  (exec-sql [_ sql data]
     (let [id (str "Query #" (swap! q-id inc))]
-      (swap! data-tabs conj (merge opts {:id id :raw-sql sql}))
+      (swap! data-tabs conj {:id id :raw-sql sql :data data})
       (reset! active-tab id)))

   (delete-tab [_ t]
@@ -30,7 +30,19 @@
     (let [id (str tbl "*")]
       (when-not (some #(= id (:id %)) @data-tabs)
         (swap! data-tabs conj {:id id :table tbl}))
+      (reset! active-tab id)))
+
+  (output [_ text]
+    (let [id "output"]
+      (reset! out-text text)
+      (when-not (some #(= id (:id %)) @data-tabs)
+        (swap! data-tabs #(vec (cons {:id id :text @out-text} %))))
       (reset! active-tab id))))
+
+(defn mk-console-control [data-tabs active-tab]
+  (let [q-id (atom 0)
+        out-text (atom nil)]
+    (ConsoleControl. data-tabs active-tab q-id out-text)))

 (defn retrieve-db-objects [db resp-atom error-atom & {:keys [refresh]}]
   (GET (str "/ds/" (db "id") "/tables?refresh=" refresh) :response-format :json
@@ -100,10 +112,11 @@
         (fn[]
           (let [sql (if (empty? (.getSelection @cm))
                       (.getValue @cm) (.getSelection @cm))]
-            (execute-query db sql #(if-let [data (% "data")]
-                                     (.exec-sql sql {:data data})
-                                     (reset! status (str "rows affected :" (% "rowsAffected"))))
-                           #(reset! status (error-text %)))))]
+            (execute-query db {:raw-sql sql}
+                           #(if-let [data (% "data")]
+                              (.exec-sql ops sql data)
+                              (.output ops (str "rows affected :" (% "rowsAffected"))))
+                           #(.output ops (error-text %)))))]
     (fn[db ops]
       (when active?
         (doto js/Mousetrap
@@ -116,13 +129,8 @@
           [:i.fa.fa-play]]
          [c/button [:i.fa.fa-save]]
          [c/button [:i.fa.fa-file-o]]]]
-       [:div.panel-body {:style {:padding "0px" :overflow "scroll" :height "calc(100% - 56px)"}}
-        [code-mirror cm {:mode "text/x-sql"}]]
-       [:div.panel-footer @status]])))
-
-(defn mk-console-control [data-tabs active-tab]
-  (let [q-id (atom 0)]
-    (ConsoleControl. data-tabs active-tab q-id)))
+       [:div.panel-body {:style {:padding "0px" :overflow "scroll" :height "calc(100% - 46px)"}}
+        [code-mirror cm {:mode "text/x-sql"}]]])))

 (defn retrieve-table-meta [db tbl data-fn error-fn]
   (GET (str "/ds/" (db "id") "/tables/" tbl) :response-format :json
@@ -137,6 +145,9 @@
     (refresh-fn)
     (fn[db tbl]
       [data-table data sort-fn refresh-fn identity])))
+
+(defn sql-output [v]
+  [:div (:text v)])

 (defn db-console [db active?]
   (let [active-tab (atom nil)
@@ -156,6 +167,7 @@
                    :title (r/as-element
                            [:span {:title (:title t)} id
                             [c/close-button #(.delete-tab ops t)]])}
-            (if-let [tbl (:table t)]
-              [table-meta db tbl]
-              [query-table db t])])]]])))
+            (cond
+              (:raw-sql t) [query-table db t]
+              (:table t) [table-meta db (:table t)]
+              :else [sql-output t])])]]])))


removed copy-paste js comments

removed copy-paste js comments

--- src/clojure/contrib/humanize.clj
+++ src/clojure/contrib/humanize.clj
@@ -150,26 +150,6 @@
                                                        ]
                                        (str (clojure.string/join (interpose ", " display-coll))
                                                 " and " last-item))
+
      ;; TODO: shouldn't reach here, throw exception
-     :else coll-length)
-    ))
-
-;; Humanize.oxford = (items, limit, limitStr) ->
-;;     numItems = items.length
-
-;;     if numItems < 2
-;;         return "#{items}"
-
-;;     else if numItems is 2
-;;         return items.join ' and '
-
-;;     else if limit? and numItems > limit
-;;         extra = numItems - limit
-;;         limitIndex = limit
-;;         limitStr ?= ", and #{extra} #{Humanize.pluralize(extra, 'other')}"
-
-;;     else
-;;         limitIndex = -1
-;;         limitStr = ", and #{items[numItems - 1]}"
-
-;;     items.slice(0, limitIndex).join(', ') + limitStr
+     :else coll-length)))


Use of pre-defined header-extension

Use of pre-defined header-extension

--- src/clojure_fabric/chaincode.clj
+++ src/clojure_fabric/chaincode.clj
@@ -201,8 +201,7 @@
         (get-system-chaincode-request-parts chaincode-key :args args)]
     (proto/make-proposal :header
                          (make-header channel-name user
-                                      (assoc opts
-                                             :extension (proto/make-chaincode-header-extension :chaincode-id chaincode-id)))
+                                      (assoc opts :extension header-extension))
                          :payload proposal-payload)))

 (defn make-chaincode-signed-proposal


fixing ordering issue.

fixing ordering issue.

--- src/overtone/sc.clj
+++ src/overtone/sc.clj
@@ -440,15 +440,15 @@
      :id id
      :size size}))

+(defn buffer? [buf]
+  (and (map? buf) (= (:type buf) :buffer)))
+
 (defn buffer-free
   "Free an audio buffer and the memory it was consuming."
   [buf]
   (assert (buffer? buf))
   (free-id :audio-buffer (:id buf))
   (snd "/b_free" (:id buf)))
-
-(defn buffer? [buf]
-  (and (map? buf) (= (:type buf) :buffer)))

 (defn buffer-read [buf start len]
   (assert (buffer? buf))


Swapped X/Y in the code for now (making up for swapped X/Y in UMM-Var).

--- src/cmr/opendap/ous/variable.clj
+++ src/cmr/opendap/ous/variable.clj
@@ -176,8 +176,12 @@

 (defn parse-dimensions
   [dim]
-  [(:Size (first (filter #(= "XDim" (:Name %)) dim)))
-   (:Size (first (filter #(= "YDim" (:Name %)) dim)))])
+  ;; XXX It seems that the X and Y have been swapped for at least
+  ;;     on collection's variables; Simon and I are looking into this
+  ;;     for now, we're just gonna pretend ... by changing the order
+  ;;     below :-(
+  [(:Size (first (filter #(= "YDim" (:Name %)) dim)))
+   (:Size (first (filter #(= "XDim" (:Name %)) dim)))])

 (defn extract-dimensions
   [entry]
@@ -275,3 +279,5 @@
      :bounds bounds
      :opendap (create-opendap-bounds dims bounds)
      :size (get-in entry [:umm :Characteristics :Size])}))
+
+


ring 0.3.6

ring 0.3.6

--- example/project.clj
+++ example/project.clj
@@ -4,11 +4,11 @@
                  [org.clojure/clojure-contrib "1.2.0"]
                  [log4j/log4j "1.2.16"]
 		 [compojure "0.5.3"]
-		 [ring/ring-core "0.3.5"]
-		 [ring/ring-servlet "0.3.5"]]
+		 [ring/ring-core "0.3.6"]
+		 [ring/ring-servlet "0.3.6"]]
   :dev-dependencies [[swank-clojure "1.2.1"]
-		     [ring/ring-devel "0.3.5"]
+		     [ring/ring-devel "0.3.6"]
   		     [uk.org.alienscience/leiningen-war "0.0.12"]
-                     [ring/ring-jetty-adapter "0.3.5"]]
+                     [ring/ring-jetty-adapter "0.3.6"]]
   :war {:name "example.war"}
   :aot [example.servlet])


more cleanup

more cleanup

--- src/moomoo/rooms.cljs
+++ src/moomoo/rooms.cljs
@@ -13,9 +13,7 @@
 (defn get-all-users [room callback]
   (letfn [(users-to-list [err reply]
             (let [user-hash (js->clj reply)]
-              (vec (map #(val %) user-hash))))
-          (c [err reply]
-            (callback err (users-to-list err reply)))]
+              (vec (map #(val %) user-hash))))]
   (.hgetall redis-client (string/join [room ":users"])
     (fn [err reply]
-      (c err reply)))))
+      (callback err (users-to-list err reply))))))


Fix error plugin for cljs

Fix error plugin for cljs

--- src/com/wsscode/pathom/core.cljc
+++ src/com/wsscode/pathom/core.cljc
@@ -233,9 +233,10 @@
       (reader env)
       (try
         (reader env)
-        (catch Exception e
+        (catch #?(:clj Exception :cljs :default) e
           (swap! errors* assoc path (if process-error (process-error env e)
-                                                      (Throwable->map e)))
+                                                      #?(:clj (Throwable->map e)
+                                                         :cljs e)))
           ::reader-error)))))

 (defn wrap-parser-exception [parser]


Simplify 'process-wildcards'.

Simplify 'process-wildcards'.

--- src/org/spootnik/cyanite/es_path.clj
+++ src/org/spootnik/cyanite/es_path.clj
@@ -66,38 +66,19 @@
 (defn process-wildcards
   "Convert Graphite wildcards to regular expression"
   [path]
-  (let [p (reduce (fn [s r] (str/replace s (first r) (second r)))
-                      path [["." "\\."]
-                            ["*" ".*"]
-                            ["{" "("]
-                            ["}" ")"]
-                            ["," "|"]])
-        r (doseq [m (re-seq #"\[(\d+)-(\d+)\]" p)]
-            (let [r1 (int (m 2))
-                  r2 (int (m 3))
-                  rbeg (min [r1 r2])
-                  rend (max [r1 r2])
-                  n (format "(%s)"(str/join "|"(range rbeg (inc rend))))]
-              [(m 1) n]))]
-    (reduce #(replace ))
-    ))
-
-(defn process-wildcards
-  "Convert Graphite wildcards to regular expression"
-  [path]
-  (let [p (reduce (fn [s r] (str/replace s (first r) (second r)))
-                  path [["." "\\."]
-                        ["*" ".*"]
-                        ["{" "("]
-                        ["}" ")"]
-                        ["," "|"]])]
-    (str/repalce p #"\[(\d+)-(\d+)\]"
-                 (fn [[_ r1s r2s]]
-                   (let [r1 (Integer/parseInt r1s)
-                         r2 (Integer/parseInt r2s)
-                         rbeg (apply min [r1 r2])
-                         rend (apply max [r1 r2])]
-                     (format "(%s)" (str/join "|" (range rbeg (inc rend)))))))))
+  (-> path
+      ;; Wildcards
+      (str/replace #"\\.|\\*" {"." "\\." "*" ".*" })
+      ;; Lists
+      (str/replace #"\{|\}|," {"{" "(" "}" ")" "," "|"})
+      ;; Ranges
+      (str/repalce #"\[(\d+)-(\d+)\]"
+                   (fn [[_ r1s r2s]]
+                     (let [r1i (Integer/parseInt r1s)
+                           r2i (Integer/parseInt r2s)
+                           r1 (apply min [r1i r2i])
+                           r2 (apply max [r1i r2i])]
+                       (format "(%s)" (str/join "|" (range r1 (inc r2)))))))))

 (defn build-es-filter
   "generate the filter portion of an es query"


fix spelling of tan in unary ugen list

fix spelling of tan in unary ugen list

--- src/overtone/sc/ugen/special_ops.clj
+++ src/overtone/sc/ugen/special_ops.clj
@@ -26,7 +26,7 @@
    "log10" 27      ; base 10 logarithm
    "sin" 28        ; sine
    "cos" 29        ; cosine
-   "tam" 30        ; tangent
+   "tan" 30        ; tangent
    "asin" 31       ; arcsine
    "acos" 32       ; arccosine
    "atan" 33       ; arctangent