implement NetChip

implement NetChip

--- src/clj/game/cards-hardware.clj
+++ src/clj/game/cards-hardware.clj
@@ -361,6 +361,44 @@
                                         (has-subtype? % "Icebreaker"))}
                    :msg (msg "give " (:title target) " +1 strength")
                    :effect (effect (pump target 1 :all-run))}}}
+
+   "NetChip"
+   {:abilities [{:label "Install a program on NetChip"
+                 :cost [:click 1]
+                 :req (req (empty? (:hosted card)))
+                 :effect (req (let [n (count (filter #(= (:title %) (:title card)) (all-installed state :runner)))]
+                                (resolve-ability state side
+                                  {:prompt "Choose a program in your Grip to install on NetChip"
+                                   :choices {:req #(and (is-type? % "Program")
+                                                        (<= (:memoryunits %) n)
+                                                        (in-hand? %))}
+                                   :msg (msg "host " (:title target))
+                                   :effect (effect (gain :memory (:memoryunits target))
+                                                   (runner-install target {:host-card card})
+                                                   (update! (assoc (get-card state card)
+                                                                   :hosted-programs
+                                                                   (cons (:cid target) (:hosted-programs card)))))}
+                                 card nil)))}
+                {:label "Host an installed program on NetChip"
+                 :req (req (empty? (:hosted card)))
+                 :effect (req (let [n (count (filter #(= (:title %) (:title card)) (all-installed state :runner)))]
+                                (resolve-ability state side
+                                  {:prompt "Choose an installed program to host on NetChip"
+                                   :choices {:req #(and (is-type? % "Program")
+                                                        (<= (:memoryunits %) n)
+                                                        (installed? %))}
+                                   :msg (msg "host " (:title target))
+                                   :effect (effect (host card target)
+                                                   (gain :memory (:memoryunits target))
+                                                   (update! (assoc (get-card state card)
+                                                                   :hosted-programs
+                                                                   (cons (:cid target) (:hosted-programs card)))))}
+                                 card nil)))}]
+    :events {:card-moved {:req (req (some #{(:cid target)} (:hosted-programs card)))
+                          :effect (effect (update! (assoc card
+                                                          :hosted-programs
+                                                          (remove #(= (:cid target) %) (:hosted-programs card))))
+                                          (lose :memory (:memoryunits target)))}}}

    "Omni-Drive"
    {:recurring 1


Added mostly-complete support for Bug.

Added mostly-complete support for Bug.

--- src/clj/game/cards-programs.clj
+++ src/clj/game/cards-programs.clj
@@ -43,7 +43,11 @@
               :effect (effect (ice-strength-bonus -2))}}}

    "Bug"
-   {:req (req (some #{:hq} (:successful-run runner-reg)))}
+   {:req (req (some #{:hq :rd :archives} (:successful-run runner-reg)))
+    :events {:corp-draw {:optional
+                         {:prompt (msg "Pay 2 [Credits] to reveal card just drawn?") :player :runner
+                          :yes-ability {:msg (msg "reveal the card just drawn: " (:title (last (:hand corp))))
+                                        :cost [:credit 2]}}}}}

    "Cache"
    {:abilities [{:counter-cost 1 :effect (effect (gain :credit 1)) :msg "gain 1 [Credits]"}]


Check empty deck when fixing setless board

--- src/clj/ji/service/game_env.clj
+++ src/clj/ji/service/game_env.clj
@@ -39,7 +39,8 @@
   until at least 1 set exists on board"
   [game]
   (loop [game game]
-    (if (empty? (game/solve-board (:board game)))
+    (if (and (not (empty? (:deck game)))
+             (empty? (game/solve-board (:board game))))
       (recur (game/draw-cards 3 game))
       game)))


checkpoint

checkpoint

Signed-off-by: Gregg Reynolds <d0f77bc71a9867acdcb4f62f012b858edad79160@norc.org>

--- src/clj/main/hello/psk/core.clj
+++ src/clj/main/hello/psk/core.clj
@@ -9,6 +9,8 @@
             [compojure.route :as route]
             [ring.middleware.defaults :refer [wrap-defaults site-defaults]]))

+;;FIXME: make this a fwd declaration e.g. (declare iron/flex-layout)?
+;;Either that or require that defpage come first and forward declare components.
 (h/require '[polymer.iron :as iron :refer [flex-layout icons pages selector]]
            '[polymer.paper :as paper :refer [drawer-panel icon-button item material menu
                                              scroll-header-panel toast toolbar]]
@@ -157,35 +159,49 @@
             section-user-info
             section-contact))))

-
-
 (def homepage-html
-(h/html {:lang "en"}
- (h/head
-  (h/require '[polymer.iron :as iron :refer [flex-layout icons pages selector]]
-             '[polymer.paper :as paper :refer [drawer-panel icon-button item material menu
+  (h/html {:lang "en"} ;;FIXME: with defpage we do not need this elt
+          (h/head ;;FIXME: do we need an explicit head elt?
+           ;; with defpage this can be (:require ...)?
+           (h/require '[polymer.iron :as iron :refer [flex-layout icons pages selector]]
+                      '[polymer.paper :as paper :refer [drawer-panel icon-button item material menu
+                                                        scroll-header-panel toast toolbar]]
+                      ;; [polymer.platinum :as plat :refer [sw-cache sw-register]]
+                      '[hello.psk.components :as comp :refer [my-greeting my-list]])
+           ;; (h/link {:href "components/my-greeting-impl" :rel "import"})
+           (h/import '(styles main)              ;;FIXME use [ ] instead?
+                     '(styles.shared psk)
+                     '(themes app)
+                     '(scripts main
+                               polyfill-lite-min
+                               app
+                               page
+                               routing
+                               )))))
+
+(defpage homepage {:lang "en"}
+  (:require '[polymer.iron :as iron :refer [flex-layout icons pages selector]]
+            '[polymer.paper :as paper :refer [drawer-panel icon-button item material menu
                                               scroll-header-panel toast toolbar]]
-             ;; [polymer.platinum :as plat :refer [sw-cache sw-register]]
-             '[hello.psk.components :as comp :refer [my-greeting my-list]])
-  ;; (h/link {:href "components/my-greeting-impl" :rel "import"})
-  (h/import '(styles main)
-            '(styles.shared psk)
-            '(themes app)
-            '(scripts main
-                      polyfill-lite-min
-                      app
-                      page
-                      routing
-                      )))
-  (h/body ::.fullbleed.layout.vertical {:unresolved nil}
-   (h/span ::browser-sync-binding)
-   (h/template
+            '[hello.psk.components :as comp :refer [my-greeting my-list]])
+  (:import '(styles main)
+           '(styles.shared psk)
+           '(themes app)
+           '(scripts main
+                     polyfill-lite-min
+                     app
+                     page
+                     routing
+                     ))
+  (body ::.fullbleed.layout.vertical {:unresolved nil}
+   (span ::browser-sync-binding)
+   (template
     ::app {:is "dom-bind"}
     (paper/drawer-panel ::paperDrawerPanel
       header-panel
       main-area)
     (paper/toast ::toast
-      (h/span ::.toast-hide-button {:role "button"
+      (span ::.toast-hide-button {:role "button"
                                     :tabindex 0
                                     :onclick "app.$.toast.hide()"}
               "Ok"))


get matabadges and metabadges by badge id

--- src/clj/salava/metabadge/db.clj
+++ src/clj/salava/metabadge/db.clj
@@ -8,55 +8,73 @@
 (defn user-badge-by-assertion
   "in case of multiple hits return the most recent"
   [ctx assertion_url]
-  (some-> (select-user-badge-by-assertion-url {:assertion_url assertion_url} (u/get-db ctx)) first))
+  (some-> (select-user-badge-by-assertion-url {:assertion_url assertion_url} (u/get-db ctx))))

 (defn %completed [req gotten]
   (let [calc (Math/round (double (* (/ gotten req) 100)))]
     (if (> calc 100) 100 calc)))

-(defn get-completed-metabadges [ctx user_id]
+(defn get-required-badges
+  ([ctx user_id metabadge_id]
+   (let [received-required-badges (select-received-required-badges {:metabadge_id metabadge_id :user_id user_id} (u/get-db ctx))
+         not-received-required-badges (select-not-received-required-badges {:metabadge_id metabadge_id} (u/get-db ctx))]
+     {:received received-required-badges :not-received not-received-required-badges}))
+  ([ctx user_id metabadge_id option]
+   (case option
+     :in_progress  (let [required-badges-map (get-required-badges ctx user_id metabadge_id)]
+                     (assoc {} :required_badges (->> required-badges-map  vals concat flatten)
+                       :received-badge-count (->> required-badges-map :received count)))
+     :completed    (let [required-badges-map (get-required-badges ctx user_id metabadge_id)]
+                     (assoc {} :required_badges (remove (fn [m] (some #(identical? (:name m) (:name %)) (:not-received required-badges-map))) (->> required-badges-map vals concat flatten))
+                       :received-badge-count (->> required-badges-map :received count)
+                       )))))
+
+(defn expand-required-badges [ctx user_id option coll]
+  (reduce (fn [r m]
+            (let [required-badges-map (get-required-badges ctx user_id (or (:metabadge_id m) (:id m) ) option)]
+              (conj r (assoc m :required_badges (->> required-badges-map :required_badges)
+                        :completion_status (%completed (:min_required m) (->> required-badges-map :received-badge-count)))))) [] coll))
+
+;;test
+(declare get-metabadge)
+
+(defn completed-metabadges [ctx user_id]
+  (prn (get-metabadge ctx 514 12))
   (let [metabadges (select-completed-metabadges {:user_id user_id} (u/get-db ctx))]
-    (reduce (fn [r m]
-              (let [not-received-required-badges (select-not-received-required-badges {:metabadge_id (:metabadge_id m)} (u/get-db ctx))
-                    received-required-badges (select-received-required-badges {:metabadge_id (:metabadge_id m) :user_id user_id} (u/get-db ctx))
-                    required-badges (remove (fn [m] (some #(identical? (:name m) (:name %)) not-received-required-badges))
-                                            (concat received-required-badges not-received-required-badges))]
-                (conj r (assoc m :required_badges required-badges
-                          :completion_status (%completed (:min_required m) (count received-required-badges)))) )) [] metabadges)))
-;;TODO refactor
+    (get-metabadge ctx 454 209)
+    (->> metabadges (expand-required-badges ctx user_id :completed))))

-(defn get-metabadges-in-progress [ctx user_id]
-  (let [all-metabadges (reduce (fn [r m]
-                                 (let [not-received-required-badges (select-not-received-required-badges {:metabadge_id (:id m)} (u/get-db ctx))
-                                       received-required-badges (select-received-required-badges {:metabadge_id (:id m) :user_id user_id} (u/get-db ctx))
-                                       required-badges (concat received-required-badges not-received-required-badges) #_(remove (fn [m] (some #(identical? (:name m) (:name %)) not-received-required-badges))
-                                                                                (concat received-required-badges not-received-required-badges))]
-                                   (conj r (assoc m :required_badges required-badges
-                                             :completion_status (%completed (:min_required m) (count received-required-badges)))) )) [] (select-all-user-metabadges {:user_id user_id} (u/get-db ctx)))
-        completed-metabadges (get-completed-metabadges ctx user_id)]
-    (remove (fn [m] (some #(= (:metabadge_id %) (:id m)) completed-metabadges)) all-metabadges)))
+(defn metabadges-in-progress [ctx user_id]
+  (let [metabadges (->> (select-all-user-metabadges {:user_id user_id} (u/get-db ctx)) (expand-required-badges ctx user_id :in_progress))
+        completed-metabadges (completed-metabadges ctx user_id)]
+    (remove (fn [m] (some #(= (:metabadge_id %) (:id m)) completed-metabadges)) metabadges)))

 (defn all-metabadges [ctx user_id]
-  {:in_progress (get-metabadges-in-progress ctx user_id)
-   :completed (get-completed-metabadges ctx user_id)})
+  {:in_progress (metabadges-in-progress ctx user_id)
+   :completed (completed-metabadges ctx user_id)})

 (defn is-metabadge? [ctx user_badge_id]
-  (let [resp (some-> (select-metabadge-info-from-user-badge {:id user_badge_id} (u/get-db ctx)) first)]
+  (let [x (some-> (select-metabadge-info-from-user-badge {:id user_badge_id} (u/get-db ctx)) first)]
     (reduce-kv (fn [r k v]
-          (assoc r k (if (blank? v) false true))) {} resp)))
+                 (assoc r k (if (blank? v) false true))) {} x)))

-;;TODO
-#_(defn metabadge-helper [ctx user_badge_id user_id ids]
+(defn is-received-metabadge? [ctx user_id metabadge_id]
+  (let [check (select-user-received-metabadge-by-metabadge-id {:metabadge_id metabadge_id :user_id user_id} (u/get-db ctx))]
+    (if (empty? check) false true)))
+
+(defn metabadge-helper [ctx user_badge_id user_id metabadge_ids]
   (reduce (fn [r id]
-            (let [received-metabadge? ])
-            ) [] ids)
-  )
-;;TODO
-#_(defn get-metabadge [ctx user_badge_id user_id]
+            (conj r
+                  (if-let [received-metabadge? (is-received-metabadge? ctx user_id id)]
+                    (->> (select-completed-metabadge-by-metabadge-id {:user_id user_id :metabadge_id id} (u/get-db ctx)) (expand-required-badges ctx user_id :completed))
+                    (->> (select-factory-metabadge {:id id} (u/get-db ctx)) (expand-required-badges ctx user_id :in_progress))))) [] metabadge_ids))
+
+(defn get-metabadge [ctx user_badge_id user_id]
   (if-let [check (empty? (is-metabadge? ctx user_badge_id))]
     {}
-    (let [milestones (select-completed-metabadge-by-badge-id {:user_id user_id :user_badge_id user_badge_id} (u/get-db ctx))
-          required (select-required-metatabadge-by-badge-id {:id user_badge_id} (u/get-db ctx))])
-
-    )
-  )
+    (let [milestones (->> (select-completed-metabadge-by-badge-id {:user_id user_id :user_badge_id user_badge_id} (u/get-db ctx)) (expand-required-badges ctx user_id :completed))
+          required-in (->> (select-required-metatabadge-by-badge-id {:id user_badge_id} (u/get-db ctx))
+                           (map :metabadge_id)
+                           (metabadge-helper ctx user_badge_id user_id)
+                           flatten)]
+      {:milestones milestones :required-in required-in})))


clean up

clean up

--- src/cljs/searchbot/widgets.cljs
+++ src/cljs/searchbot/widgets.cljs
@@ -27,8 +27,8 @@

 (defn es-count []
   (let [c (chan)]
-    (go (let [{{avcCount :count} :body} (<! (http/get (es-url :count)))]
-          (>! c avcCount)))
+    (go (let [{{docCount :count} :body} (<! (http/get (es-url :count)))]
+          (>! c docCount)))
     c))

 (defn es-agg [post-body]
@@ -40,8 +40,8 @@
 (defcomponent header [app owner opts]
   (will-mount [_]
               (go (while true
-                    (let [avcCount (<! (es-count))]
-                      (om/update! app [:es-count] avcCount))
+                    (let [docCount (<! (es-count))]
+                      (om/update! app [:es-count] docCount))
                     (<! (timeout poll-interval)))))
   (render [_]
           (html [:h2 (:header-text app) " with " (-> app :es-count str commify) " raw data in ES"])))
@@ -160,126 +160,3 @@
                         {:on-click #(om/set-state! owner :n (dec n))}
                         "-"]])))

-;;;;;;;;;;;;;;;;
-;; widget editor
-
-
-(defn- class-names [elem] (-> elem .-className (clojure.string/split #" ") set))
-
-(defn- add-class! [elem a-class-name]
-  (let [names (class-names elem)]
-    (aset elem "className" (clojure.string/join " " (conj names a-class-name)))))
-
-(defn- remove-class! [elem a-class-name]
-  (let [names (class-names elem)]
-    (aset elem "className" (clojure.string/join " " (disj names a-class-name)))))
-
-(defn- toggle-sub-menu
-  [app & widget]
-  (let [sub-open? (get-in @app [:menu :sub-open?])]
-    (if sub-open?
-      (remove-class! js/document.body "show-submenu")
-      (add-class! js/document.body "show-submenu"))
-    (om/update! app [:menu :sub-open?] (not sub-open?))
-    (if widget (do
-                 (om/update! app [:menu :selected] (first widget))))))
-
-(defn- toggle-top-menu
-  [app]
-  (let [top-open? (get-in @app [:menu :top-open?])]
-    (if top-open?
-      (remove-class! js/document.body "show-menu")
-      (add-class! js/document.body "show-menu"))
-    (om/update! app [:menu :top-open?] (not top-open?))))
-
-(defn within? [elem-id]
-  (fn [ev]
-    (let [target (.-target ev)]
-      (-> (js/$ target) (.closest elem-id) .-length pos?))))
-
-
-(defn- widget-class
-  [widget]
-  (case (:type widget)
-    "es-chart" (case (:draw-fn widget)
-                 "draw-line" "fa fa-fw fa-line-chart"
-                 "draw-ring" "fa fa-fw fa-pie-chart")
-    "agg-table" "fa fa-fw fa-table"))
-
-(defcomponent widget-detail [app owner opts]
-  (render [_]
-          (html [:textarea#widget-detail
-                 {:rows "20" :cols "60"
-                  :value (.stringify js/JSON (clj->js (-> @app :menu :selected)) nil 4)}]))
-  (did-update [_ _ _]
-              (let [cm (-> @app :menu :cm)]
-                (.setValue cm (.stringify js/JSON (clj->js (-> @app :menu :selected)) nil 4))
-                ))
-  (did-mount [_]
-             (let [cm (.fromTextArea js/CodeMirror
-                                     (.getElementById js/document "widget-detail")
-                                     {:lineNumbers true
-                                      :mode: "javascript"})]
-               (om/update! app [:menu :cm] cm))))
-
-
-(defcomponent widgets-grid [app owner opts]
-  (will-mount
-   [_]
-   (.addEventListener js/window
-                      "mousedown" (fn [ev]
-                                    (let [target (.-target ev)
-                                          sub-open? (get-in @app [:menu :sub-open?])
-                                          close-sub? (and sub-open? (not ((within? "#sub-menu") ev)))]
-                                      (if close-sub? (toggle-sub-menu app))))))
-  (render [_]
-          (html [:div.grid-content.grid-five-rows
-                 [:div.grid-head
-                  [:div "COL 1"]
-                  [:div "COL 2"]
-                  [:div "COL 3"]
-                  [:div "COL 4"]]
-                 [:div.grid-body
-                  (for [widget-row (:widgets app)]
-                    [:div.grid-row
-                     (for [w widget-row]
-                       [:div {:on-click #(toggle-sub-menu app w)}
-                        [:span.grid-cell [:i {:class (widget-class w)}]]])])
-                  ]])))
-
-
-(defcomponent off-canvas [app owner opts]
-  (will-mount
-   [_]
-   (.addEventListener js/window
-                      "mousedown" (fn [ev]
-                                    (let [target (.-target ev)
-                                          top-open? (get-in @app [:menu :top-open?])
-                                          close-top? (and top-open?
-                                                          (not (or ((within? "#top-menu") ev)
-                                                                   ((within? "#sub-menu") ev))))]
-                                      (if close-top? (toggle-top-menu app))))))
-  (render [_]
-          (html [:div.container
-                 [:div#top-menu.menu-wrap {:data-level "1" }
-                  [:nav.menu
-                   [:h2 [:span "Widgets"]]
-                   [:div#top-menu-body.grid-container]]
-                  ]
-                 [:div#sub-menu.menu-wrap {:data-level "2" }
-                  [:nav.menu
-                   [:h2 "Widget Design"]
-                   (om/build widget-detail app)
-                   ]
-                  ]
-                 [:button#open-button.menu-button {:on-click #(toggle-top-menu app)}
-                  [:i.fa.fa-fw.fa-cogs]
-                  [:span "Open Menu"]]
-                 [:div.content-wrap
-                  [:div.content
-                   [:div.container-fluid {:style {:max-width "90%" :padding-left 10}}
-                    (om/build (:content opts) app)
-                    ]
-                   ]]
-                 ])))
-


Improved either ns docstring.

Improved either ns docstring.

--- src/cljx/cats/monad/either.cljx
+++ src/cljx/cats/monad/either.cljx
@@ -24,7 +24,19 @@
 ;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 (ns cats.monad.either
-  "The Either (Error) Monad."
+  "The Either monad implementation and helper functions
+  for working with either related types.
+
+  Also commonly known as Error monad.
+
+      (require '[cats.monad.either :as either])
+
+      (either/right 1)
+      ;; => #<Right [1]>
+
+      (either/left 1)
+      ;; => #<Left [1]>
+  "
   (:require [cats.protocols :as proto]))

 (declare either-monad)


Output set

Output set

--- src/analyze_runs/core.clj
+++ src/analyze_runs/core.clj
@@ -2,19 +2,31 @@
   (:require [analyze-runs.gpx :refer :all]
             [clojure.java.io :as io]
             [clojure.string :as s]
-            [compojure.core :refer :all]
-            [compojure.route :as route]
+            [clj-time.core :as t]
+            [clj-time.format :as tf]
             [clojure.core.async :as async :refer [>! <! >!! <!! go chan buffer close! thread
                                                   alts! alts!! timeout]])
   (:gen-class))

+(def week-formatter (tf/formatters :weekyear-week))
+(def date-formatter (tf/formatter "yyyy-MM-dd"))
+(def time-formatter (tf/formatter "HH:mm:ss"))
+
 (def gpx-files-channel (chan))
 (def output-channel (chan 20))

-(defn distance [file]
-  (-> file .getAbsolutePath get-points-from-file calculate-distance))
+(defn handle-file [file]
+  (let [points (-> file .getAbsolutePath get-points-from-file)
+        distance (format "%.2f" (calculate-distance points))
+        duration (calculate-time points)
+        start (:time (first points))
+        year-week (tf/unparse week-formatter start)
+        date (tf/unparse date-formatter start)
+        time (tf/unparse time-formatter start)
+        ]
+    {:year-week year-week :date date :time time :distance distance :duration duration}))

-(async/pipeline (.. Runtime getRuntime availableProcessors) output-channel (map distance) gpx-files-channel)
+(async/pipeline (.. Runtime getRuntime availableProcessors) output-channel (map handle-file) gpx-files-channel)

 (defn find-files [path]
   (let [all-direntries (file-seq (io/file path))
@@ -43,7 +55,7 @@

 (defn -main
   [& args]
-  (str (find-files)))
+  (test-pipeline))

                                         ; map => 53 s
                                         ; pmap => 20s


Make docstring grammatical

Make docstring grammatical

--- src/play_clj/g2d_physics.clj
+++ src/play_clj/g2d_physics.clj
@@ -193,7 +193,7 @@
   `(u/calls! ^EdgeShape (edge*) ~@options))

 (defmacro edge!
-  "Calls a single method on a `edge`"
+  "Calls a single method on an `edge`"
   [object k & options]
   `(u/call! ^EdgeShape ~object ~k ~@options))


remove 'unported' file from docset, since it's not linked anywhere right now in the docs

--- src/main/cljs_api_gen/docset.clj
+++ src/main/cljs_api_gen/docset.clj
@@ -142,7 +142,7 @@
        ;; insert sections
        {:name "Overview"                :type "Section" :path (resolve-path "INDEX.html")}
        {:name "History"                 :type "Section" :path (resolve-path "HISTORY.html")}
-       {:name "Not Ported From Clojure" :type "Section" :path (resolve-path "UNPORTED.html")}
+       #_{:name "Not Ported From Clojure" :type "Section" :path (resolve-path "UNPORTED.html")}
        )

     ;; insert namespaces


Make sure to load druid data (if applicable) before starting test suite

--- test/metabase/driver/event_query_processor_test.clj
+++ test/metabase/driver/event_query_processor_test.clj
@@ -16,6 +16,14 @@
   (let [def (delay (i/flatten-dbdef metabase.test.data.dataset-definitions/test-data "checkins"))]
     (fn []
       @def)))
+
+;; force loading of the flattened db definitions for the DBs that need it
+(defn- load-event-based-db-data!
+  {:expectations-options :before-run}
+  []
+  (doseq [engine event-based-dbs]
+    (datasets/with-engine-when-testing engine
+      (data/do-with-temp-db (flattened-db-def) (fn [& _])))))

 (defmacro ^:private expect-with-event-based-dbs
   {:style/indent 0}


Make test Logger return nil from logging functions.

Make the Logger used by with-test-logging and friends return nil from
functions like log/info.  This conforms to the normal logging API.
Previously, it was returning the value of its atom.

--- test/puppetlabs/trapperkeeper/testutils/logging.clj
+++ test/puppetlabs/trapperkeeper/testutils/logging.clj
@@ -53,7 +53,8 @@
          (write! [_ lvl ex msg]
            (let [entry [(str log-ns) lvl ex msg]]
              (when debug (log-to-console entry))
-             (swap! output-atom conj entry))))))))
+             (swap! output-atom conj entry)
+             nil)))))))

 (defn atom-appender
   "Creates a logback appender that writes log messages to the supplied atom"


Made the gui show itself even without an referer

--- src/ardoq/swagger/api.clj
+++ src/ardoq/swagger/api.clj
@@ -79,8 +79,7 @@
                                           :token-set (boolean token)
                                           :token token})
          :headers {"Content-Type" "text/html"}
-         :session (assoc session :referer (str "http://" (first (rest (rest (.split (get headers "referer") "/")))))
-                         )})
+         :session (assoc session :referer (if (get headers "referer") (str "http://" (first (rest (rest (.split (get headers "referer") "/"))))) ""))})
    (POST "/import" {{:strs [url token org wsname headers swag ignorer] :as params} :form-params session :session}
          (try
            (let [client (c/client {:url (:base-url config)


Removed two unused swing macros

Removed two unused swing macros

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

--- src/conexp/contrib/gui/util.clj
+++ src/conexp/contrib/gui/util.clj
@@ -59,6 +59,7 @@
     (.setDefaultCloseOperation frame JFrame/DISPOSE_ON_CLOSE)
     frame))

+
 ;;; Swing handmade concurrency

 (defn invoke-later
@@ -117,13 +118,6 @@
   [name dispatch-val params & body]
   `(defmethod ~name ~dispatch-val ~params (do-swing-return ~@body)))

-(defmacro fn-swing
-  "Returns a function that is surrounded by do-swing-return"
-  [name params & body]
-  (if (vector? name)
-    `(fn ~name (do-swing-return ~params ~@body))
-    `(fn ~name ~params (do-swing-return ~@body))))
-
 (defmacro defn-swing-threads*
   "Defines a function that is surrounded by with-swing-threads*"
   [name doc params & body]
@@ -136,13 +130,6 @@
   "Defines a multi function method that is surrounded by do-swing-return"
   [name dispatch-val params & body]
   `(defmethod ~name ~dispatch-val ~params (with-swing-threads* ~@body)))
-
-(defmacro fn-swing-threads*
-  "Returns a function that is surrounded by with-swing-threads*"
-  [name params & body]
-  (if (vector? name)                      ;anonymous function
-    `(fn ~name (with-swing-threads* ~params ~@body))
-    `(fn ~name ~params (with-swing-threads* ~@body)))) ;TODO: adic overloading

 ;;; type checking
@@ -242,6 +229,7 @@

 (defvar --- {}
   "Separator for menu entries used in add-menus.")
+
 (defvar === (Box/createHorizontalGlue)
   "Separator between menus used in add-menus.")


Improve debug output

Improve debug output

--- src/re_frame/middleware.cljs
+++ src/re_frame/middleware.cljs
@@ -43,7 +43,7 @@
     [db v]
     (if (satisfies? IReactiveAtom db)
       (str "re-frame: \"debug\" middleware used without prior \"pure\"."))
-    (group "event: " v)
+    (group "re-frame event: " v)
     (let [new-db  (handler db v)
           diff    (data/diff db new-db)]
       (log "only before: " (first diff))


Add status change handling

Add status change handling

--- src/riak_mesos/scheduler.clj
+++ src/riak_mesos/scheduler.clj
@@ -6,9 +6,9 @@
 (def garbage-hack "I hate this")

 (defn scheduler
+  [pending running]
   []
-  (let [pending (atom #{1 2})
-        used-hosts (atom #{})
+  (let [used-hosts (atom #{})
         ;;this contains pairs of [executor-id slave-id]
         active-executors (atom #{})
         executor-id->hostname (atom {})]
@@ -24,7 +24,15 @@
                               (println "sending command" command)
                               (clj-mesos.scheduler/send-framework-message driver executor-id slave-id (.getBytes (pr-str command))))))
                         (when (= :task-running (:state status))
-                          (swap! active-executors conj [(:executor-id status) (:slave-id status)])))))
+                          (swap! active-executors conj [(:executor-id status) (:slave-id status)]))
+                        (let [id-from status (comp #(Integer/parseInt %) str last :task-id)]
+                          (cond
+                            (= (:task-state status) :task-staging) nil
+                            (= (:task-state status) :task-starting) nil
+                            (= (:task-state status) :task-running)
+                            (swap! running conj (id-from-status status))
+                            true
+                            (swap! pending conj (id-from-status status)))))))
       (resourceOffers [driver offers]
                       (future
                         (locking garbage-hack
@@ -61,7 +69,6 @@
                                 (clj-mesos.scheduler/decline-offer driver (:id offer))))
                             (catch Exception e
                               (.printStackTrace e)))))))))
-

 (defn -main
   [master]
@@ -80,10 +87,10 @@
 (comment
   (try
     (clj-mesos.marshalling/map->proto org.apache.mesos.Protos$ContainerInfo {:type :docker
-                                                                    :docker "rtward/riak-mesos"
-                                                                    :volumes [{:container-path "/usr/local/lib/mesos"
-                                                                               :host-path "/usr/local/lib"
-                                                                               :mode :ro}]})
+                                                                             :docker "rtward/riak-mesos"
+                                                                             :volumes [{:container-path "/usr/local/lib/mesos"
+                                                                                :host-path "/usr/local/lib"
+                                                                                :mode :ro}]})
     (catch Exception e
       (println e)
       (println (.getFullName (:field (ex-data e))))
@@ -99,32 +106,19 @@
   (let [node 1
         offer {:slave-id "aoeu"}
         ] (clj-mesos.marshalling/map->proto org.apache.mesos.Protos$TaskInfo {:name "Riak"
-<<<<<<< HEAD
-                                        :task-id (str "riak-node-" node)
-                                        :slave-id (:slave-id offer)
-                                        :resources {:cpus 2.0
-                                                    :mem 2000.0}
-                                        ;:container {:type :docker :docker "rtward/riak-mesos"}
-                                        ;:command {:shell false}
-                                        :executor {:executor-id (str "riak-node-executor-" node)
-                                                        :container {:type :docker
-                                                                    :docker "rtward/riak-mesos"
-                                                                    :volumes [{:container-path "/usr/local/lib/mesos"
-                                                                               :host-path "/usr/local/lib"
-                                                                               :mode :ro}]}
-                                                        :command {:shell false}}
-                                        }))
-=======
                                                                               :task-id (str "riak-node-" node)
                                                                               :slave-id (:slave-id offer)
-                                                                              :resources {:cpus 1.0
-                                                                                :mem 200.0}
-                                                                              :container {:type :docker :Docker {:image "rtward/riak-mesos"}}
-                                                                              :command {}
-                                                                              ;:executor-info {:executor-id (str "riak-node-executor-" node)
-                                                                              ;                :container {:image "rtward/riak-mesos"}
-                                                                              ;                :command {}}
+                                                                              :resources {:cpus 2.0
+                                                                                :mem 2000.0}
+                                                                              ;:container {:type :docker :docker "rtward/riak-mesos"}
+                                                                              ;:command {:shell false}
+                                                                              :executor {:executor-id (str "riak-node-executor-" node)
+                                                                                :container {:type :docker
+                                                                                :docker "rtward/riak-mesos"
+                                                                                :volumes [{:container-path "/usr/local/lib/mesos"
+                                                                                :host-path "/usr/local/lib"
+                                                                                :mode :ro}]}
+                                                                                :command {:shell false}}
                                                                               }))
->>>>>>> daac222f5b2b6c3fd0b29abb9da7df084cc22eae
   (-main)
   )


send hmac header to bot

send hmac header to bot

--- src/braid/server/bots.clj
+++ src/braid/server/bots.clj
@@ -13,9 +13,9 @@

 (defn send-notification
   [bot message]
-  ; TODO: need some sort of signing/verification
-  (let [body (->transit message)]
+  (let [body (->transit message)
+        hmac (crypto/hmac (bot :token) body)]
     (http/put (bot :webhook-url)
               {:headers {"Content-Type" "application/transit+msgpack"
-                         "X-Braid-Signature" ""}
+                         "X-Braid-Signature" hmac}
                :body body})))


allow localhost urls for bots

allow localhost urls for bots

--- src/braid/server/util.clj
+++ src/braid/server/util.clj
@@ -11,7 +11,9 @@
   ([s] (valid-url? s ["http" "https"]))
   ([s schemes]
    (and (string? s)
-     (.isValid (UrlValidator. (into-array schemes)) s))))
+     (or
+       (string/starts-with? s "http://localhost:")
+       (.isValid (UrlValidator. (into-array schemes)) s)))))

 (defn map->query-str
   [m]


cleaner

cleaner

--- src/client/dashboard.cljs
+++ src/client/dashboard.cljs
@@ -234,13 +234,10 @@
 (def page-state (atom []))

 (defn- update-board-canvas! [id itm place]
-  (when (<= place 3)
-    (size-canvas! (str id "-canvas") (:board itm) large-board-cell-size rows-cutoff)
-    (draw-board! (str id "-canvas") (:board itm) large-board-cell-size (:theme itm) rows-cutoff))
-  (when (> place 3)
-    (size-canvas! (str id "-canvas") (:board itm) small-board-cell-size rows-cutoff)
-    (draw-board! (str id "-canvas") (:board itm) small-board-cell-size (:theme itm) rows-cutoff))
-  )
+  (let [cell-size (if (<= place 3) large-board-cell-size small-board-cell-size)
+        canvas-id (str id "-canvas")]
+    (size-canvas! canvas-id (:board itm) cell-size rows-cutoff)
+    (draw-board! canvas-id (:board itm) cell-size (:theme itm) rows-cutoff)))

 ;; NOTE: does NOT apply to places 1, 2, 3
 (defn- place->row


update time left on dashboard

update time left on dashboard

--- src/client/dashboard.cljs
+++ src/client/dashboard.cljs
@@ -186,10 +186,10 @@
   (pieces-table)
   [:div.line-8975a]
   [:div.label-39b9c "Lines:"]
-  [:div.metric-b93a8 "1,214"]
+  [:div#totalLines.metric-b93a8 "1,214"]
   [:div.line-8975a]
   [:div.label-39b9c "Time Left:"]
-  [:div.metric-b93a8 "2:45"])
+  [:div#timeLeft.metric-b93a8])

 (hiccups/defhtml page-shell []
   [:div.wrapper-2ba66
@@ -356,7 +356,6 @@
   (let [data (read-string str-data)]
     (reset! page-state data)))

-;; TODO: where to put this on the new dashboard page?
 (defn on-time-left
   "Called when receiving time-left update from server."
   [total-seconds]
@@ -364,7 +363,7 @@
         s (mod total-seconds 60)
         s-str (if (< s 10) (str "0" s) s)
         time-str (str m ":" s-str)]
-    (.html ($ ".time-left-eb709") (str "Time Left: " time-str))))
+    (dom/set-html! "timeLeft" time-str)))

 (defn- shuffle-page-state []
   (reset! page-state (shuffle test-state)))


CLJS-605: Allow alias target to change when re-compiling ns-form.

--- src/clj/cljs/analyzer.clj
+++ src/clj/cljs/analyzer.clj
@@ -714,6 +714,7 @@
                                    ;; for resolving keywords like ::f/bar
                                    (binding [*ns* (create-ns name)]
                                      (let [^clojure.lang.Namespace ns (create-ns lib)]
+                                       (ns-unalias *ns* alias)
                                        (clojure.core/alias alias (.name ns))))
                                    (let [alias-type (if macros? :macros :fns)]
                                      (assert (not (contains? (alias-type @aliases)


CLJS-413: add null to list of reserved JST keywords

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -30,7 +30,8 @@
     "return" "short" "static" "super" "switch"
     "synchronized" "this" "throw" "throws"
     "transient" "try" "typeof" "var" "void"
-    "volatile" "while" "with" "yield" "methods"})
+    "volatile" "while" "with" "yield" "methods"
+    "null"})

 (def ^:dynamic *position* nil)
 (def ^:dynamic *emitted-provides* nil)


* src/clj/cljs/compiler.clj: first pass at propagating booleans through let bindings

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -312,7 +312,8 @@
     (emit-wrap env (emit-constant form))))

 (defn bool-expr? [e]
-  (= (:tag e) clojure.core$boolean))
+  (or (= (-> e :tag) clojure.core$boolean)
+      (= (-> e :info :tag) clojure.core$boolean)))

 (defmethod emit :if
   [{:keys [test then else env]}]
@@ -795,7 +796,10 @@
              (do
                (assert (not (or (namespace name) (.contains (str name) "."))) (str "Invalid local name: " name))
                (let [init-expr (analyze env init)
-                     be {:name (gensym (str (munge name) "__")) :init init-expr}]
+                     be {:name (gensym (str (munge name) "__"))
+                         :init init-expr
+                         :tag (or (-> name meta :tag)
+                                  (-> init-expr :tag))}]
                  (recur (conj bes be)
                         (assoc-in env [:locals name] be)
                         (next bindings))))


Renamed IApp protocol name to Application.

--- src/clj/pfrt/core/app.clj
+++ src/clj/pfrt/core/app.clj
@@ -2,13 +2,13 @@
   (:require [pfrt.core.lifecycle :as lifecycle])
   (:require [swiss.arrows :refer [-<>]]))

-(defprotocol IApp
+(defprotocol Application
   (init [_] "Initialize method")
   (start [_] "Start service")
   (stop [_] "Stop service"))

 (defrecord App [components]
-  IApp
+  Application
   (init [this]
     (-<> this (reduce #(lifecycle/init %2 %1) <> components)))
   (start [this]


cleanup

cleanup

--- src/cljs/weasel/repl.cljs
+++ src/cljs/weasel/repl.cljs
@@ -5,11 +5,6 @@
             [weasel.impls.websocket :as ws]))

 (def ws-connection (atom nil))
-
-;;; TODO: needs to connect to something that implements cljs.repl/IJavaScriptEnv
-;;; see repl/browser.clj
-;;; repl/server.clj
-;;; repl.clj

 (defmulti process-message :op)

@@ -30,16 +25,18 @@
   [repl-server-url]
   (let [repl-connection (ws/websocket-connection)]
     (swap! ws-connection (constantly repl-connection))
+
     (event/listen repl-connection :opened
       (fn [evt]
-        (.log js/console "Opened WS connection!")))
+        (.info js/console "Opened WS connection!")))
+
     (event/listen repl-connection :message
       (fn [evt]
         (let [{:keys [op] :as message} (read-string (.-message evt))
               response (-> message process-message pr-str)]
-          #_(println "got a message" op "from" message "... dispatching ...")
-          #_(println "sending to server:" response)
           (net/transmit repl-connection response))))
+
     (event/listen repl-connection :error
       (fn [evt] (.error js/console "WebSocket error" evt)))
+
     (net/connect repl-connection repl-server-url)))


closure the variable 'current-song' in song-player

--- src/cljs_douban/view.cljs
+++ src/cljs_douban/view.cljs
@@ -13,33 +13,29 @@
        ^{:key (channel "channel_id")}
        [:li (channel "name")])]))

+;;; well, it seems that I can still hide the atom 'current-song'
+;;; why the (with-meat func meta-data) works and not (fn [] ^{meta-data} ;;; body)?
+(def song-player
+  "display songs and controls"
+  (let [current-song (atom {})]
+    (with-meta
+      (fn []
+        [:div#player
+         [:p "title: " (@current-song "title")]
+         [:audio#player-audio
+          {:autoPlay "true"
+           :controls "true"
+           :src (str (@current-song "url"))}]
+         [:input {:type "button"
+                  :value "Next Song"
+                  :on-click #(go (reset! current-song (<! (model/skip-song))))}]
+         [:input {:type "button"
+                  :value "Play/Stop"
+                  :on-click #(let [player (sel1 :#player-audio)]
+                               (if (.-paused player)
+                                 (.play player)
+                                 (.pause player)))}]])
+      {:component-did-mount
+       (fn [this]
+         (dom/listen! (sel1 :#player-audio) :ended #(go (reset! current-song (<! (model/end-song))))))})))

-(def current-song (atom {}))
-
-(defn song-player-plain []
-  "display songs and controls"
-  (fn []
-    [:div#player
-     [:p "title: " (@current-song "title")]
-     [:audio#player-audio
-      {:autoPlay "true"
-       :controls "true"
-       :src (str (@current-song "url"))}]
-     [:input {:type "button"
-              :value "Next Song"
-              :on-click #(go (reset! current-song (<! (model/skip-song))))}]
-     [:input {:type "button"
-              :value "Play/Stop"
-              :on-click #(let [player (sel1 :#player-audio)]
-                           (if (.-paused player)
-                             (.play player)
-                             (.pause player)))}]]))
-
-;;; react do not support 'onended' event and thus should manually bind it.
-;;; and this is not very 'reagent'-ish
-;;; Also I had to put 'current-song' into global in order to refer to it.
-(def song-player
-  (with-meta song-player-plain
-    {:component-did-mount
-     (fn [this]
-       (dom/listen! (sel1 :#player-audio) :ended #(go (reset! current-song (<! (model/end-song))))))}))


Add more examples

Add more examples

--- src/clojure/cfbt/ch10.clj
+++ src/clojure/cfbt/ch10.clj
@@ -86,4 +86,31 @@
 (swap! fred update-in [:percent-deteriorated] + 2)
 (swap! fred update-in [:cuddle-hunger-level] + 30)

-;; Validators :: p217
+;; Validators ::
+
+(defn percent-deteriorated-validator
+  [{:keys [percent-deteriorated]}]
+  (and (>= percent-deteriorated 0)
+       (<= percent-deteriorated 100)))
+
+;; Use validator at creation time
+(def boby
+  (atom
+   {:cuddle-hunger-level 0 :percent-deteriorated 0}
+    :validator percent-deteriorated-validator))
+
+;;(swap! boby update-in [:percent-deteriorated] + 200)
+;; => Throw "Invalid reference state!"
+
+(defn percent-deteriorated-validator
+  [{:keys [percent-deteriorated]}]
+  (or (and (>= percent-deteriorated 0)
+           (<= percent-deteriorated 100))
+      (throw (IllegalStateException. "That's not mathly"))))
+
+(def bobby
+  (atom
+   {:cuddle-hunger-level 0 :percent-deteriorated 0}
+   :validator percent-deteriorated-validator))
+
+(swap! bobby update-in [:percent-deteriorated] + 200)


Buffer input and output.

Buffer input and output.

--- src/clojurecraft/core.clj
+++ src/clojurecraft/core.clj
@@ -10,7 +10,7 @@
   (:require (clojurecraft.data))
   (:import [clojurecraft.data Location Entity Block Chunk World Bot])
   (:import (java.net Socket)
-           (java.io DataOutputStream DataInputStream)
+           (java.io DataOutputStream DataInputStream BufferedInputStream BufferedOutputStream)
            (java.util.concurrent LinkedBlockingQueue TimeUnit)))

 (def STARTING-LOC (Location. 0 0 0 0 0 0 false))
@@ -108,8 +108,8 @@
 (defn connect [server username]
   (let [username (or username (random-username))
         socket (Socket. (:name server) (:port server))
-        in (DataInputStream. (.getInputStream socket))
-        out (DataOutputStream. (.getOutputStream socket))
+        in (DataInputStream. (BufferedInputStream. (.getInputStream socket)))
+        out (DataOutputStream. (BufferedOutputStream. (.getOutputStream socket)))
         conn (ref {:in in :out out})
         outqueue ^LinkedBlockingQueue (LinkedBlockingQueue.)
         actionqueue (LinkedBlockingQueue.)


Moved where auxiliary stack is re-pushed for environments.

--- src/clojush/pushstate.clj
+++ src/clojush/pushstate.clj
@@ -89,13 +89,13 @@
    all stacks with those on the environment stack. Then, everything on the old
    :return stack is pushed onto the :exec stack."
   [state]
-  (let [new-env (assoc (top-item :environment state)
-                       :auxiliary
-                       (:auxiliary state))
+  (let [new-env (top-item :environment state)
         new-exec (concat (:exec state)
                          (:exec new-env))]
     (loop [old-return (:return state)
-           new-state (assoc new-env :exec new-exec)]
+           new-state (assoc new-env
+                            :exec new-exec
+                            :auxiliary (:auxiliary state))]
       (if (empty? old-return)
         new-state
         (recur (rest old-return)


Update mailserver node id

Update mailserver node id

Signed-off-by: Dmitry Novotochinov <161568b2835bcbfce0822b25de9311ab2cbff690@gmail.com>


Login/logout displays in header

Login/logout displays in header

--- src/swanson/views/layout.clj
+++ src/swanson/views/layout.clj
@@ -10,7 +10,14 @@
    [:div {:class "container" }
     [:div {:class "navbar-header" }
      [:a {:href "/" :class "navbar-brand"} "Swanson" ]
-     [:a {:href "/chart" :class "navbar-brand"} "Chart" ] ]]])
+     [:a {:href "/chart" :class "navbar-brand"} "Chart"]]]
+    (if-let [user (session/get :user)]
+      [:div.pull-right (link-to "/logout" (str "logout " user))]
+      [:div.pull-right (link-to "/register" "register")
+        (form-to [:post "/login"]
+                 (text-field {:placeholder "email"} "email")
+                 (password-field {:placeholder "password"} "pass")
+                 (submit-button {:class "btn btn-default btn-xs"} "login"))])])

 (defn panel-table [headline header-row rows]
   [:div {:class "panel panel-default"}
@@ -33,15 +40,8 @@
      (include-css "/css/bootstrap-theme.min.css")]
     [:body
      (header)
-     [:div {:class "container"} content ]]))
+     [:div {:class "container bs-docs-container"}]
+     [:div {:class "container"} content] ]))

 (defn common [& content]
-  (base
-    (if-let [user (session/get :user)]
-      [:div (link-to "/logout" (str "logout " user))]
-      [:div (link-to "/register" "register")
-        (form-to [:post "/login"]
-                 (text-field {:placeholder "email"} "email")
-                 (password-field {:placeholder "password"} "pass")
-                 (submit-button {:class "btn btn-default btn-xs"} "login"))])
-    content))
+  (base content))


Set the invite teammates button to medium

--- src-cljs/frontend/components/pages/team.cljs
+++ src-cljs/frontend/components/pages/team.cljs
@@ -283,6 +283,7 @@
                 :action [:div
                          (button/button
                           {:primary? true
+                           :size :medium
                            :on-click #(do
                                         (om/set-state! owner :show-invite-modal? true)
                                         ((om/get-shared owner :track-event)


Show loading spinner while loading team invite data

--- src-cljs/frontend/components/pages/team.cljs
+++ src-cljs/frontend/components/pages/team.cljs
@@ -120,56 +120,59 @@
                                 (element :body
                                          (html
                                           [:div
-                                           [:.header
-                                            "These are the people who are not using CircleCI yet ("
-                                            [:span
-                                             [:b count-with-email]
-                                             " of "
-                                             [:b count-users]
-                                             " users have emails, "
-                                             [:b count-selected]
-                                             " are selected):"]]
-                                           [:.table
-                                            (om/build table/table
-                                                      {:rows users
-                                                       :key-fn :login
-                                                       :columns [{:header "Username"
-                                                                  :cell-fn (fn [{:keys [login] :as user}]
-                                                                             (element :avatars
-                                                                                (html
-                                                                                [:div
-                                                                                [:img.invite-gravatar {:src (gh-utils/make-avatar-url user
-                                                                                :size 50)}]
-                                                                                (str "  " login)])))}
-                                                                 {:header "Email"
-                                                                  :cell-fn (fn [user]
-                                                                             (let [is-selected (selected? user)
-                                                                                email (get-email user)]
-                                                                               (om/build form/text-field
-                                                                                {:on-change (fn [event]
-                                                                                (let [input (.. event -target -value)]
-                                                                                (set-email! user input)
-                                                                                (when (or (and (not is-selected)
-                                                                                (not (empty? input)))
-                                                                                (utils/valid-email? input))
-                                                                                (select-user! user))))
-                                                                                :value email
-                                                                                :size :medium
-                                                                                :validation-error (when (and (or is-selected
-                                                                                (not (empty? email)))
-                                                                                (not (utils/valid-email? email)))
-                                                                                (str email " is not a valid email"))})))}
-                                                                 {:type :shrink
-                                                                  :cell-fn (fn [user]
-                                                                             (let [email (get-email user)]
-                                                                               [:input {:type "checkbox"
-                                                                                :disabled (and (not (utils/valid-email? email))
-                                                                                (not (empty? email)))
-                                                                                :checked (selected? user)
-                                                                                :on-click #(if-let [is-checked (-> % .-currentTarget .-checked)]
-                                                                                (select-user! user)
-                                                                                (deselect-user! user))}]))}]
-                                                       :striped? true})]]))
+                                           (if-not (contains? selected-org :vcs-users)
+                                             [:div.loading-spinner common/spinner]
+                                             (list
+                                              [:.header
+                                               "These are the people who are not using CircleCI yet ("
+                                               [:span
+                                                [:b count-with-email]
+                                                " of "
+                                                [:b count-users]
+                                                " users have emails, "
+                                                [:b count-selected]
+                                                " are selected):"]]
+                                              [:.table
+                                               (om/build table/table
+                                                         {:rows users
+                                                          :key-fn :login
+                                                          :columns [{:header "Username"
+                                                                     :cell-fn (fn [{:keys [login] :as user}]
+                                                                                (element :avatars
+                                                                                (html
+                                                                                [:div
+                                                                                [:img.invite-gravatar {:src (gh-utils/make-avatar-url user
+                                                                                :size 50)}]
+                                                                                (str "  " login)])))}
+                                                                    {:header "Email"
+                                                                     :cell-fn (fn [user]
+                                                                                (let [is-selected (selected? user)
+                                                                                email (get-email user)]
+                                                                                (om/build form/text-field
+                                                                                {:on-change (fn [event]
+                                                                                (let [input (.. event -target -value)]
+                                                                                (set-email! user input)
+                                                                                (when (or (and (not is-selected)
+                                                                                (not (empty? input)))
+                                                                                (utils/valid-email? input))
+                                                                                (select-user! user))))
+                                                                                :value email
+                                                                                :size :medium
+                                                                                :validation-error (when (and (or is-selected
+                                                                                (not (empty? email)))
+                                                                                (not (utils/valid-email? email)))
+                                                                                (str email " is not a valid email"))})))}
+                                                                    {:type :shrink
+                                                                     :cell-fn (fn [user]
+                                                                                (let [email (get-email user)]
+                                                                                [:input {:type "checkbox"
+                                                                                :disabled (and (not (utils/valid-email? email))
+                                                                                (not (empty? email)))
+                                                                                :checked (selected? user)
+                                                                                :on-click #(if-let [is-checked (-> % .-currentTarget .-checked)]
+                                                                                (select-user! user)
+                                                                                (deselect-user! user))}]))}]
+                                                          :striped? true})]))]))
                                 :actions [(button/button {:on-click close-fn} "Cancel")
                                           (forms/managed-button
                                            [:button.btn.btn-success {:data-success-text "Sent"


CMR-3309: Updated doc string on inbdex alias creation function

--- elastic-utils-lib/src/cmr/elastic_utils/index_util.clj
+++ elastic-utils-lib/src/cmr/elastic_utils/index_util.clj
@@ -198,6 +198,6 @@
   (doc/delete-by-query (:conn elastic-store) index-name type-name query))

 (defn create-index-alias
-  "Creates the alias for the collections index if it does not already exist."
+  "Creates the alias for the index."
   [conn index alias]
   (esi/update-aliases conn [{:add {:index index :alias alias}}]))


Made sure file has content before adding

--- src/video_server/watcher.clj
+++ src/video_server/watcher.clj
@@ -34,10 +34,11 @@
     #(deliver p "stop")))

 (defn stable?
-  "Returns true if the file has not been modified for at least thirty
-  seconds."
+  "Returns true if the file has has content and has not been modified
+  for at least thirty seconds."
   [file]
-  (< (.lastModified file) (- (System/currentTimeMillis) stable-time)))
+  (and (pos? (.length file))
+       (< (.lastModified file) (- (System/currentTimeMillis) stable-time))))

 (defn add-subtitles
   "Performs the initial scan for subtitles."


updating dependencies

updating dependencies

--- core/project.clj
+++ core/project.clj
@@ -7,15 +7,14 @@

   :plugins
   [[lein-monolith "1.0.1"]
-   [com.roomkey/lein-v "6.2.0"]
-   ]
+   [com.roomkey/lein-v "6.2.0"]]

   :dependencies [[mount "0.1.11"]
                  [gorillalabs/config "1.0.4"]
                  [org.clojure/data.json "0.2.6"]
                  [beckon "0.1.1"]
                  [environ "1.1.0"]
-                 [clj-time "0.13.0"]
+                 [clj-time "0.14.0"]
                  [joda-time "2.9.9"]                        ;; fix a version (otherwise we have version clashes)

@@ -32,18 +31,18 @@

                  ;; Authentication
                  [ring/ring-json "0.4.0"]
-                 [buddy "1.3.0"]
-                 [cheshire "5.7.1"]
-                 [org.clojure/tools.reader "0.10.0"]
+                 [buddy "2.0.0"]
+                 [cheshire "5.8.0"]
+                 [org.clojure/tools.reader "1.1.0"]

                  ;; io
-                 [ring/ring-core "1.6.0"]
-                 [ring/ring-defaults "0.2.3"]
-                 [bidi "2.0.17"]
+                 [ring/ring-core "1.6.2"]
+                 [ring/ring-defaults "0.3.1"]
+                 [bidi "2.1.2"]

                  ;; status
-                 [de.otto/status "0.1.0"]
+                 [de.otto/status "0.1.3"]

                  ;; metrics
                  [metrics-clojure "2.9.0"]
@@ -51,7 +50,7 @@
                  [io.riemann/metrics3-riemann-reporter "0.4.5"]

                  ;; telemetry
-                 [org.clojure/core.async "0.3.442"]
+                 [org.clojure/core.async "0.3.443"]
                  [riemann-clojure-client "0.4.5"]
                  [io.riemann/riemann-java-client "0.4.5"]
                  ]


Body global

Body global

--- src/wishlistd/cljs/main.cljs
+++ src/wishlistd/cljs/main.cljs
@@ -10,6 +10,7 @@
 (def $create  ($ "#create-wishlist"))
 (def $content ($ "#box"))
 (def $header  ($ "#title-box"))
+(def $body    ($ "body"))

 ; HTML PARTIALS


Iterate over messages without assuming :n key.

--- src/onyx/queue/hornetq_utils.clj
+++ src/onyx/queue/hornetq_utils.clj
@@ -20,11 +20,11 @@

     (let [producer (.createProducer session queue-name)]
       (.start session)
-      (doseq [m messages]
-        (when (zero? (mod (:n m) echo))
-          (info (format "[HQ Util] Wrote %s segments" (:n m))))
+      (doseq [n (range messages)]
+        (when (zero? (mod n echo))
+          (info (format "[HQ Util] Wrote %s segments" n)))
         (let [message (.createMessage session true)]
-          (.writeBytes (.getBodyBuffer message) (.array (fressian/write m)))
+          (.writeBytes (.getBodyBuffer message) (.array (fressian/write (nth messages n))))
           (.send producer message)))

       (let [sentinel (.createMessage session true)]


Increase expression timeout to 5 seconds

--- src/yetibot/core/handler.clj
+++ src/yetibot/core/handler.clj
@@ -46,7 +46,7 @@
       ;; enabled by default
       true)))

-(def expr-eval-timeout-ms 1000)
+(def expr-eval-timeout-ms 5000)

 (def ^:private exception-format "👮 %s 👮")


make sure we have the new schema

make sure we have the new schema

--- src/pc/admin/migrate_storage.clj
+++ src/pc/admin/migrate_storage.clj
@@ -99,7 +99,18 @@
   (Thread/sleep (* 1000 10 2))
   (reset-resolve-tempid))

+(defn ensure-premade-schema []
+  @(d/transact (pcd/conn) [{:db/doc "dummy attribute so that we can pre-generate entity ids for a migration"
+                            :db/cardinality :db.cardinality/one
+                            :db/id (d/tempid :db.part/db)
+                            :db/ident :pre-made
+                            :db/valueType :db.type/ref
+                            :db.install/_attribute :db.part/db}
+                           {:db/id (d/tempid :db.part/db)
+                            :db/ident :pre-made/free-to-postgres}]))
+
 (defn setup-old-server []
+  (ensure-premade-schema)
   (startup-premade-ids)
   (setup-transaction-queue)
   (setup-transaction-server))


turn off namespace map formatting

turn off namespace map formatting

--- src/wombats/sockets/messages.clj
+++ src/wombats/sockets/messages.clj
@@ -14,8 +14,19 @@
     (catch Exception e (prn (str "Invalid client message: " raw-message)))))

 (defn format-message
-  "Converts the msg into a string before sending it"
-  [msg] (prn-str msg))
+  "Converts the msg into a string before sending it
+
+  NOTE: As of 1.9.0-alpha14, prn-str automatically converts namespaced keywords into
+  namespaced maps.
+
+  https://github.com/clojure/clojure/commit/0b930f1e7e2bb2beef4ed1a12c51e4e17782666d#diff-fffb1aa81bef3f5238a444e036bec5cd
+
+  Currently the cljs reader does not support parsing this format
+
+  http://dev.clojure.org/jira/browse/CLJS-1706
+
+  For now we have to turn of the new feature until cljs adds support"
+  [msg] (binding [*print-namespace-maps* false] (prn-str msg)))

 (defn- get-message
   [msg-type payload]


clearing

clearing

--- test/celestial/test/sshj.clj
+++ test/celestial/test/sshj.clj
@@ -2,21 +2,3 @@
   (:use celestial.sshj clojure.test)
  )

-(def tasks
-  { :download {
-      :wget "wget,,," :tar "tar -xvzf"
-     }
-     :puppet ^{:depends #{:download :yml-up}} {
-        :cd "cd /tmp/~{module}" :run "./scripts/run"
-     }
-     :yml-up ^{:depends #{:download}}{
-        :cd "cd /tmp/~{module}" :run "./scripts/run"
-     }
-     :clean ^:last {
-      :rm "rm -rf /tmp/~{module}"
-     }
-   }
-  )
-
-(deftest deps
-  (is (= (sorted-deps tasks) [:download :yml-up :puppet :clean])))


Fixes test

Fixes test

--- test/expound/specs_test.cljc
+++ test/expound/specs_test.cljc
@@ -17,8 +17,6 @@

 should be a keyword with no namespace

-
-
 -------------------------
 Detected 1 error
 "


Wait for response between palette requests.

This avoids buffer overflow on the Push 2, and makes startup faster.

--- src/afterglow/controllers/ableton_push_2.clj
+++ src/afterglow/controllers/ableton_push_2.clj
@@ -75,62 +75,75 @@
   (midi/midi-sysex (:port-out controller)
                    (concat [0xf0 0x00 0x21 0x1d (:device-id controller) 0x01] command [0xf7])))

+(defn- request-led-palette-entry
+  "Ask the Push 2 for the LED palette entry with the specified index."
+  [controller index]
+  (send-sysex controller [0x04 index]))
+
 (defn- save-led-palette-entry
   "Record an LED palette entry we have received in response to our
   startup query, so we can preserve the white palette when setting RGB
   colors, and restore all LED palettes when we suspend or exit our
-  mapping."
-  [controller data]
-  (swap! (:led-palettes controller) assoc (first data) (vec (rest data))))
+  mapping.
+
+  Make a note of the fact that we received a palette response at the
+  current moment in time in `gather-timestamp`, and if this was not
+  the final palette entry, request the next one. If it was the final
+  one, deliver a true value to `gather-timestamp`."
+  [controller data gather-timestamp gather-promise]
+  (let [index (first data)]
+    (swap! (:led-palettes controller) assoc index (vec (rest data)))
+    (reset! gather-timestamp (at-at/now))
+    (if (< index 127)  ; Ask for the next entry unless we have received them all
+      (request-led-palette-entry controller (inc index))
+      (deliver gather-promise true))))

 (defn- sysex-received
   "Process a MIDI System Exclusive reply from the Push 2. The `msg`
-  argument is the raw data we have just received."
-  [controller msg]
-  (if (= (vec (take 5 (:data msg))) [0x00 0x21 0x1d (:device-id controller) 0x01])
-    (let [data (map int (butlast (drop 5 (:data msg))))
-          command (first data)
-          args (rest data)]
-      (case command
-        0x04 (save-led-palette-entry controller args)
-        (timbre/info "Ignoring SysEx message from Push 2 with command ID" command)))
-    (timbre/warn "Received unrecognized SysEx message from Push 2 port." (vec (:data msg)))))
-
-(defn- request-led-palettes
-  "Ask the Push 2 for the LED palettes with indices matching the
-  supplied sequence."
-  [controller indices]
-  (doseq [i indices]
-    (send-sysex controller [0x04 i])
-    (when (zero? (rem i 10))
-      (Thread/sleep 5))))
-
-(defn- startup-midi-received
-  "Called when a MIDI message is received during conroller setup. Used
-  to gather LED palette responses, and ignore other messages."
-  [controller message]
-  ;;(timbre/info message)
-  (if (= 0xf0 (:status message))
-    (sysex-received controller message)
-    (timbre/info "Ignoring non-sysex message received during Push 2 startup.")))
+  argument is the raw data we have just received. If
+  `gather-timestamp` and `gather-promise` were supplied, this reply
+  was received during startup when we are gathering LED palette
+  entries, so we should use them to record any palette response."
+  ([controller msg]
+   (sysex-received controller msg nil))
+  ([controller msg gather-timestamp gather-promise]
+   (if (= (vec (take 5 (:data msg))) [0x00 0x21 0x1d (:device-id controller) 0x01])
+     (let [data (map int (butlast (drop 5 (:data msg))))
+           command (first data)
+           args (rest data)]
+       (case command
+         0x04 (if (some? gather-timestamp)
+                (save-led-palette-entry controller args gather-timestamp gather-promise)
+                (timbre/warn "Ignoring Push 2 LED palette response when not gathering palette."))
+
+         (timbre/warn "Ignoring SysEx message from Push 2 with command ID" command)))
+     (timbre/warn "Received unrecognized SysEx message from Push 2 port." (vec (:data msg))))))

 (defn- gather-led-palettes
-  "Ask the Push 2 for all of its LED palettes, wait a bit, and see if
-  we got them all. Try up to two more times to request any missing
-  entries. Return a truthy value to indicate success."
-  [controller]
-  (let [startup-handler (partial startup-midi-received controller)]
+  "Ask the Push 2 for all of its LED palettes. We ask for the first,
+  then when we receive that, ask for the next, until we have got them
+  all, to avoid overflowing its buffers. We will wait for up to half a
+  second for this process to complete. If that elapses, and it has
+  been more than 100ms since we sent our last request, we give up.
+
+  Return a truthy value to indicate success."
+  [controller]
+  (let [gather-timestamp (atom (at-at/now))
+        gather-promise (promise)
+        startup-handler (fn [message]
+                          (if (= 0xf0 (:status message))
+                            (sysex-received controller message gather-timestamp gather-promise)
+                            (timbre/info "Ignoring non-sysex message received during Push 2 startup.")))]
     (try
       (amidi/add-device-mapping (:port-in controller) startup-handler)
-      (loop [needed (range 128)
-             tries 2]
-        (request-led-palettes controller needed)
-        (Thread/sleep 200)
-        (or (= 128 (count (keys @(:led-palettes controller))))
-            (if (zero? tries)
-              (timbre/error "Unable to gather all 128 LED palette entries for Push 2, giving up.")
-              (recur (clojure.set/difference (set needed) (set (keys @(:led-palettes controller))))
-                     (dec tries)))))
+      (loop []
+        (request-led-palette-entry controller 0)
+        (or (deref gather-promise 500 false)
+            (if (> (- (at-at/now) @gather-timestamp) 100)
+              (timbre/error "Failed to gather LED Palette entries for Push 2; giving up.")
+              (do
+                (timbre/warn "Gathering LED Palette entries for Push 2 is taking more than half a second.")
+                (recur)))))
       (finally (amidi/remove-device-mapping (:port-in controller) startup-handler)))))

 (defn- restore-led-palettes


[#84] Records are already vectors (via @jonase)

--- backend/src/org/akvo/dash/import/csv.clj
+++ backend/src/org/akvo/dash/import/csv.clj
@@ -72,7 +72,7 @@
   "Returns the first line CSV a file"
   [path separator]
   (with-open [r (io/reader path)]
-    (vec (first (csv/read-csv r :separator separator)))))
+    (first (csv/read-csv r :separator separator))))

 (defn get-num-cols
   "Returns the number of columns based on the


RR: add username on avatar menu

RR: add username on avatar menu

--- src/cljs/ona/utils/common_om_components.cljs
+++ src/cljs/ona/utils/common_om_components.cljs
@@ -9,7 +9,7 @@
             [ona.utils.dom :as dom-utils]
             [ona.utils.permissions :as p]
             [ona.utils.shared-dom :as shared-dom]
-            [ona.utils.string :refer [not-empty?]]
+            [ona.utils.string :refer [first-cap not-empty?]]
             [ona.utils.tags :refer [image]]
             [sablono.core :refer-macros [html]]))

@@ -44,12 +44,11 @@
               [:ul {:class "right" :id "user"}
                [:li {:class "header-user"} [:span {:class "bell-wrap"} [:i {:class "fa fa-bell-o"}]]
                 [:div {:class "dropdown drop-hover"}
-                 [:a {:id "user-avatar" :href "#"} [:span {:class "label label-initial pink"} "G "]
+                 [:a {:id "user-avatar" :href "#"} [:span {:class "label label-initial orange"} (first-cap username)]
                   [:i {:class "fa fa-angle-down"}]]
                  [:ul {:class "submenu" :id "user-dropdown"}
-                  [:li [:a {:href "#"} username]]
-                  [:li [:a {:href "#"} "Settings"]]
-                  [:li [:a {:href "#"} "Help"]]
+                  [:li [:a {:href (str "https://beta.ona.io/" username)
+                            :target "_blank"} username]]
                   [:li [:a {:href "/logout"} "Logout"]]]]]]
               [:ul {:class "right" :id "user"}
                [:li


Disable the Save button when a non-compliant method name is entered

--- src/cljs/main/broadfcui/page/workspace/method_configs/method_config_editor.cljs
+++ src/cljs/main/broadfcui/page/workspace/method_configs/method_config_editor.cljs
@@ -74,7 +74,8 @@
 (react/defc- Sidebar
   {:render
    (fn [{:keys [props state]}]
-     (let [{:keys [access-level workspace-id after-delete redacted? snapshots
+     (let [{:keys [access-level workspace-id after-delete
+                   redacted? name-validation-errors? snapshots
                    editing? locked? loaded-config body-id parent]} props
            can-edit? (common/access-greater-than? access-level "READER")
            config-id (ws-common/config->id (:methodConfiguration loaded-config))]
@@ -96,7 +97,9 @@
                {:data-test-id "save-edited-method-config-button"
                 :color :state-success
                 :text "Save" :icon :done
-                :disabled? (when redacted? "Choose an available snapshot")
+                :disabled? (cond redacted? "Choose an available snapshot"
+                                 ; We have a single validation error
+                                 name-validation-errors? (first name-validation-errors?))
                 :onClick #(parent :-commit)}]
               [buttons/SidebarButton
                {:data-test-id "cancel-edit-method-config-button"
@@ -168,7 +171,7 @@
         [mc-sync/SyncContainer (select-keys props [:workspace-id :config-id])]
         [:div {:style {:padding "1em 2em" :display "flex"}}
          [Sidebar (merge (select-keys props [:access-level :workspace-id :after-delete])
-                         (select-keys @state [:editing? :loaded-config :redacted?])
+                         (select-keys @state [:editing? :loaded-config :redacted? :name-validation-errors?])
                          (select-keys @locals [:body-id])
                          {:parent this :locked? locked? :snapshots (get methods (replace methodRepoMethod [:methodNamespace :methodName]))})]
          (this :-render-main locked?)]]))
@@ -206,7 +209,7 @@
                               :ref "confname" :style {:maxWidth 500 :width "100%" :fontSize "100%"}
                               :defaultValue (:name config)
                               :predicates [(input/nonempty-alphanumeric_-period "Config name")]
-                              :onChange #((@refs "confname") :validate)}]
+                              :onChange #(swap! state assoc :name-validation-errors? ((@refs "confname") :validate))}]
             (style/create-textfield-hint input/hint-alphanumeric_-period)]
            [:div {:style {:padding "0.5em 0 1em 0"}
                   :data-test-id "method-config-name"} (:name config)]))


fix swallow-erors

fix swallow-erors

--- frontend/intercom.cljs
+++ frontend/intercom.cljs
@@ -18,6 +18,5 @@
            "&filters%5B0%5D%5Bcomparison%5D=contains&filters%5B0%5D%5Bvalue%5D="
            (second path)))))

-(utils/swallow-errors
-  (defn track [event & [metadata]]
-    (js/Intercom "trackEvent" (name event) metadata)))
+(defn track [event & [metadata]]
+  (utils/swallow-errors (js/Intercom "trackEvent" (name event) metadata)))


Note that at-exit only works in-container

--- core/src/immutant/util.clj
+++ core/src/immutant/util.clj
@@ -123,9 +123,9 @@
   (not (System/getenv "LEIN_NO_DEV")))

 (defn at-exit
-  "Registers `f` to be called when the application is undeployed.
-   Used internally to shutdown various services, but can be used by
-   application code as well."
+  "Registers `f` to be called when the application is undeployed from
+  a container, e.g. WildFly. Used internally to shutdown various
+  services, but can be used by application code as well."
   [f]
   (wu/at-exit f))


Make the git clone test a little more specific

--- test/circle/backend/test_git.clj
+++ test/circle/backend/test_git.clj
@@ -16,4 +16,5 @@
     (fs/deltree test-repo-path)
     (repo-exists? test-repo-path) => false
     (clone test-git-url :ssh-key ssh-key :path test-repo-path)
-    (repo-exists? test-repo-path) => true))+    (repo-exists? test-repo-path) => true
+    (fs/exists? (fs/join test-repo-path "README.md")) => true))


refactor compiler tests ns

refactor compiler tests ns

--- test/clj/cljs/compiler_tests.clj
+++ test/clj/cljs/compiler_tests.clj
@@ -1,13 +1,13 @@
 (ns cljs.compiler-tests
   (:use clojure.test)
-  (:require [cljs.analyzer :as a])
-  (:require [cljs.compiler :as c])
-  (:require [cljs.env :as e])
-  (:require [cljs.util :as util]
-            [cljs.compiler :as comp])
-  (:import (java.io File)))
+  (:require [cljs.analyzer :as ana]
+            [cljs.compiler :as comp]
+            [cljs.env :as env]
+            [cljs.util :as util])
+  (:import [java.io File]))

-(def ns-env (assoc-in (a/empty-env) [:ns :name] 'cljs.user))
+(def aenv (assoc-in (ana/empty-env) [:ns :name] 'cljs.user))
+(def cenv (env/default-compiler-env))

 (deftest should-recompile
   (let [src (File. "test/hello.cljs")
@@ -15,33 +15,33 @@
         opt {:optimize-constants true}
         optmod {:optimize-constants true :elide-asserts false}]
     (with-redefs [util/*clojurescript-version* {:major 0 :minor 0 :qualifier 42}]
-      (e/with-compiler-env (e/default-compiler-env)
+      (env/with-compiler-env (env/default-compiler-env)
         (.setLastModified dst (- (.lastModified src) 100))
-        (is (c/requires-compilation? src dst opt))
-        (c/compile-file src dst opt)
-        (is (not (c/requires-compilation? src dst opt)))
-        (is (c/requires-compilation? src dst optmod))
-        (c/compile-file src dst optmod)
-        (is (not (c/requires-compilation? src dst optmod)))))))
+        (is (comp/requires-compilation? src dst opt))
+        (comp/compile-file src dst opt)
+        (is (not (comp/requires-compilation? src dst opt)))
+        (is (comp/requires-compilation? src dst optmod))
+        (comp/compile-file src dst optmod)
+        (is (not (comp/requires-compilation? src dst optmod)))))))

 (deftest fn-scope-munge
-  (is (= (c/munge
+  (is (= (comp/munge
            (get-in
-             (a/analyze ns-env
+             (ana/analyze aenv
                '(defn foo []
                   (fn bar [])))
              [:init :name]))
          'cljs$user$foo))
-  (is (= (c/munge
+  (is (= (comp/munge
            (get-in
-             (a/analyze ns-env
+             (ana/analyze aenv
                '(defn foo []
                   (fn bar [])))
              [:init :children 0 :children 0 :name]))
           'cljs$user$foo_$_bar))
-  (is (= (c/munge
+  (is (= (comp/munge
            (get-in
-             (a/analyze ns-env
+             (ana/analyze aenv
                '(fn []
                   (fn console [])))
              [:children 0 :children 0 :name]))
@@ -49,6 +49,6 @@

 (deftest test-js-negative-infinity
   (= (with-out-str
-       (c/emit
-         (a/analyze (assoc ns-env :context :expr) 'js/-Infinity)))
+       (comp/emit
+         (ana/analyze (assoc aenv :context :expr) 'js/-Infinity)))
      "-Infinity"))


Organise synthesis into sections.

Organise synthesis into sections.

--- src/klangmeister/synthesis.cljs
+++ src/klangmeister/synthesis.cljs
@@ -1,4 +1,9 @@
 (ns klangmeister.synthesis)
+
+; Plumbing
+
+(defn destination [context at duration]
+  (.-destination context))

 (defn plug [param input context at duration]
   "Plug an input into an audio parameter,
@@ -11,6 +16,9 @@
   (fn [context at duration]
     (doto (.createGain context)
       (-> .-gain (plug level context at duration)))))
+
+
+; Envelopes

 (defn line
   "Build a line out of [dx y] coordinates, starting at [0 0]."
@@ -40,6 +48,9 @@
 (defn percussive [attack decay]
   (line [attack 1.0] [decay 0.0]))

+
+; Combinators
+
 (defn connect
   [ugen1 ugen2]
   (fn [context at duration]
@@ -49,6 +60,16 @@

 (defn connect-> [& nodes]
   (reduce connect nodes))
+
+(defn add [& ugens]
+  (fn [context at duration]
+    (let [sink ((gain 1.0) context at duration)]
+      (doseq [ugen ugens]
+        (.connect (ugen context at duration) sink))
+      sink)))
+
+
+; Noise

 (defn noise [bit duration]
   (fn [context at duration]
@@ -63,6 +84,9 @@
         (.start at)))))

 (def white-noise (partial noise #(-> (js/Math.random) (* 2.0) dec)))
+
+
+; Oscillators

 (defn oscillator
   ([type freq detune]
@@ -82,6 +106,9 @@
 (def square (partial oscillator "square"))
 (def triangle (partial oscillator "triangle"))

+
+; Filters
+
 (defn biquad-filter [type freq]
   (fn [context at duration]
     (doto (.createBiquadFilter context)
@@ -90,6 +117,9 @@

 (def low-pass (partial biquad-filter "lowpass"))
 (def high-pass (partial biquad-filter "highpass"))
+
+
+; Effects

 (defn stereo-panner [pan]
   (fn [context at duration]
@@ -103,12 +133,3 @@
       (doto (.createDelay context maximum)
         (-> .-delayTime (plug time context at duration))))))

-(defn destination [context at duration]
-  (.-destination context))
-
-(defn add [& ugens]
-  (fn [context at duration]
-    (let [sink ((gain 1.0) context at duration)]
-      (doseq [ugen ugens]
-        (.connect (ugen context at duration) sink))
-      sink)))


Adds -r and -h options for run task

Adds -r and -h options for run task

--- src/leiningen/control.clj
+++ src/leiningen/control.clj
@@ -81,16 +81,19 @@

 (defn run
   "Run user-defined clojure-control tasks against certain cluster,
-      -p [--port] port, which control server port to connect for running"
+      -r [--[no-]remote],running commands on remote control server,default is false.
+      -p [--port] port, control server port,
+      -h [--host] host, control server host."
   [project & args]
   (let [[options extra-args]
         (cli args
-             ["-p" "--port" "Which port to connect."
-              :parse-fn #(Integer/parseInt %)])
-        {:keys [port]} options]
-    (if (nil? port)
+             ["-p" "--port" "Which port to connect." :default 8123 :parse-fn #(Integer/parseInt %)]
+             ["-r" "--[no-]remote" :default false]
+             [ "-h" "--host" "Which host to connect." :default "localhost"])
+        {:keys [port host remote]} options]
+    (if-not remote
       (run-control project args)
-      (let [^java.net.Socket sock (java.net.Socket. "localhost" port)]
+      (let [^java.net.Socket sock (java.net.Socket. host port)]
         (.setTcpNoDelay sock true)
         (let [rdr (reader sock)
               wtr (writer sock)]


Preliminary vertical bar chart for CPU load

Needs some heavy refactoring to make charts generic. Chart function
should be usable for memory usage or whatever.

--- Clojure-Websockets/MainApp/src/cljs/birdwatch/ui/jvmstats.cljs
+++ Clojure-Websockets/MainApp/src/cljs/birdwatch/ui/jvmstats.cljs
@@ -7,20 +7,36 @@
             [goog.string :as gstring]
             [goog.string.format]))

+(defn bar
+  "Renders a vertical bar."
+  [x y h w]
+  [:rect {:x x :y (- y h) :fill "steelblue" :width w :height h}])
+
 (defn reading-view
   ""
   [app]
   (let [state @app
         fmt #(gstring/format %1 %2)
         floor #(Math/floor %)
-        latest (last (:readings state))
+        readings (:readings state)
+        cpu-loads (map :system-load-avg readings)
+        last-n (take-last 60 cpu-loads)
+        mx 8 ; workaround for some problem with actual mx function, only accurate on quadcore machine with HT
+        indexed (vec (map-indexed vector last-n))
+        latest (last readings)
         sys-load-avg (:system-load-avg latest)
         available-cpus (:available-cpus latest)
         uptime (:uptime latest)
-        m 60000
-        s 1000]
+        m 60000 s 1000          ; minutes and seconds in milliseconds for uptime calculation
+        w 4 gap 1               ; bar width and gap between bars
+        chart-w 400 chart-h 40] ; chart dimensions
     [:div
      [:div [:strong "System Load Average: "] (fmt "%.2f" (-> sys-load-avg (/ available-cpus) (* 100))) "%"]
+     [:svg {:width chart-w :height chart-h}
+          [:g
+           (for [[idx v] indexed]
+             ^{:key (str idx v)} [bar (* idx w) chart-h (* (/ v mx) chart-h) (- w gap)])]]
+     [:hr]
      [:div [:strong "CPUs: "] available-cpus]
      [:div [:strong "Uptime: "] (floor (/ uptime m)) "m" (floor (/ (rem uptime m) s)) "s"]]))


normalizing format-type for consistent fetching from typefn map

--- pp-server/src/pp_server/core/fn_maps.clj
+++ pp-server/src/pp_server/core/fn_maps.clj
@@ -10,8 +10,13 @@
    "json"     format-json!
    "xml"      format-xml!})

+(defn- to-lower
+  [word]
+  (clojure.string/lower-case word))
+
 ;; TODO: try catch here in case the parser throws an error
 ;; capture things like basic error and line number if possible
 (defn mapfn
   [input tipe]
-  ((get typefn tipe) input tipe))+  (let [type-norm (to-lower tipe)]
+    ((get typefn type-norm) input type-norm)))


Not yet generated items appear as question marks

--- src/lolitemsets/core.cljs
+++ src/lolitemsets/core.cljs
@@ -217,9 +217,12 @@
                     stat-optimized? (as-> el [:b el]))]]))))

 (defn current-build []
-  (into [:div]
-        (for [i (:recommended @app)]
-          [item-image i])))
+  (let [n (:num-items @app)
+        build (:recommended @app)
+        build (concat build (repeat (- n (count build)) nil))]
+    (into [:div]
+          (for [i build]
+            [item-image i]))))

 (defn build-stats []
   [:div.panel.panel-primary


Fix tests

Fix tests

--- exercise3/test/de/haw/vs/networking/connector_test.clj
+++ exercise3/test/de/haw/vs/networking/connector_test.clj
@@ -57,15 +57,15 @@
                            (get-in status-map [:application :statusDetails :connector])))))))

 (def test-message
-  {:payload         "!#"
-   :payload-content ""
-   :send-time       0
-   :slot            0
+  {:payload         "!!!!!!!!!!!!!!!!!!!!!!!!"
+   :payload-content "!!!!!!!!!!!!!!"
+   :send-time       2387225703656530209
+   :slot            33
    :station-class   "B"
-   :station-name    "!#"})
+   :station-name    "!!!!!!!!!!"})

 (def test-message-datagram-bytes
-  (byte-array 34 [1 0x21 0x23]))
+  (byte-array 34 (conj (repeat 33 0x21) 1)))

 (deftest send-message-test
   (testing "send a message through the socket"


print line in cake log when server starts

--- dev/bake/io.clj
+++ dev/bake/io.clj
@@ -30,8 +30,10 @@
              *ins*  ~ins]
      ~@forms))

-(defmacro init-log []
+(defn init-log []
   (let [log (FileOutputStream. ".cake/log" true)]
+    (binding [*out* (OutputStreamWriter. log)]
+      (println (format "--- cake server started [%tc] ---" (System/currentTimeMillis))))
     (System/setOut (PrintStream. log))
     (System/setErr (PrintStream. log))))


[#2437] Refactor

[#2437] Refactor

--- backend/src/akvo/lumen/lib/transformation/derive.clj
+++ backend/src/akvo/lumen/lib/transformation/derive.clj
@@ -116,13 +116,17 @@
        (map (fn [[i]] (db.tx.derive/delete-row conn (merge {:rnum i} opts))))
        doall))

-(defn extend-row [row row-adapter columns]
-  (let [group-with-columns (->> (dissoc (group-by :groupName columns) nil)
-                                (reduce (fn [c [k v]] (assoc c k (map (comp keyword :columnName) v))) {}))]
-    (if-not (empty? group-with-columns)
-      (reduce (fn [c [group-name column-names]]
-                (assoc c group-name (row-adapter (select-keys c column-names)))) row group-with-columns)
-      row)))
+(defn columns-groups [columns]
+  (let [groups (group-by :groupName columns)]
+    (->> (dissoc groups nil)
+         (reduce (fn [c [k v]]
+                   (assoc c k (map (comp keyword :columnName) v))) {}))))
+
+(defn extend-row [row row-adapter columns-groups]
+  (if-not (empty? columns-groups)
+    (reduce (fn [c [group-name column-names]]
+              (assoc c group-name (row-adapter (select-keys c column-names)))) row columns-groups)
+    row))

 (defmethod engine/apply-operation "core/derive"
   [{:keys [tenant-conn]} table-name columns op-spec]
@@ -132,20 +136,16 @@
                   ::column-title
                   ::column-type]} (args op-spec)
           new-column-name         (engine/next-column-name columns)
-          ks-columns (walk/keywordize-keys columns)
-          adapter (js-engine/column-name->column-title columns)
+          columns-groups*         (columns-groups (walk/keywordize-keys columns))
+          adapter                 (js-engine/column-name->column-title columns)
           row-fn                  (js-engine/row-transform-fn {:adapter     adapter
                                                                :code        code
                                                                :column-type column-type})
-;;          _ (log/error ks-columns)
           js-execution-seq        (->> (db.tx.derive/all-data conn {:table-name table-name})
-                                       (map (fn [row] (let [res (extend-row row adapter ks-columns)]
-;;                                                        (log/error (keys res) res)
-                                                        res)))
                                        (map (fn [i]
                                               (try
-                                                (let [row (extend-row i adapter ks-columns)]
-                                                 [(:rnum row) :set-value! (row-fn row)])
+                                                (let [row (extend-row i adapter columns-groups*)]
+                                                  [(:rnum row) :set-value! (row-fn row)])
                                                 (catch Exception e
                                                   (condp = (engine/error-strategy op-spec)
                                                     "leave-empty" [(:rnum i) :set-value! nil]
@@ -154,9 +154,9 @@
                                                     ))))))
           base-opts               {:table-name  table-name
                                    :column-name new-column-name}]
-      (db.tx.engine/add-column conn {:table-name      table-name
-                        :column-type     (lumen->pg-type column-type)
-                        :new-column-name new-column-name})
+      (db.tx.engine/add-column conn {:table-name table-name
+                                     :column-type             (lumen->pg-type column-type)
+                                     :new-column-name         new-column-name})
       (set-cells-values! conn base-opts (js-execution>sql-params js-execution-seq :set-value!))
       (delete-rows! conn base-opts (js-execution>sql-params js-execution-seq :delete-row!))
       {:success?      true
@@ -172,6 +172,7 @@
   [applied-transformation columns]
   (let [code (-> applied-transformation :args :code)
         computed (compute-transformation-code code columns)]
+    (log/error :computed computed)
     (reduce (fn [c r]
               (conj c (if-let [column-name (:column-name r)]
                         column-name


[#3061] Restrict data-groups number in transformation payload

Co-authored-by: Emmanuel Mulo <bd234ba4276433f0e5fc7a8fa2d18274fa711567@akvo.org>

--- backend/src/akvo/lumen/lib/transformation/engine.clj
+++ backend/src/akvo/lumen/lib/transformation/engine.clj
@@ -151,11 +151,22 @@
        (filter (fn [dg] (seq (filter #(= column-name (get % "columnName")) (:columns dg)))))
        first))

+(defn ensure-one-data-group-related [transformation column-names data-groups]
+  (when (> (->> column-names
+                (map (partial datagroup-by-column data-groups))
+                set
+                count)
+           1)
+    (throw (ex-info "Failed to transform. Transformation can't have columns from more than one data-group specified"
+                    {:transformation transformation}))))
+
 (defn execute-transformation-2
   [{:keys [tenant-conn] :as deps} dataset-id job-execution-id transformation]
   (let [dataset-version (db.dataset-version/latest-dataset-version-2-by-dataset-id tenant-conn {:dataset-id dataset-id})
         data-groups (db.data-group/list-data-groups-by-dataset-version-id tenant-conn {:dataset-version-id (:id dataset-version)})
-        column-name (first (columns-used (w/keywordize-keys transformation) (reduce into [] (map :columns data-groups))))
+        columns-in-transformation (columns-used (w/keywordize-keys transformation) (reduce into [] (map :columns data-groups)))
+        _  (ensure-one-data-group-related transformation columns-in-transformation data-groups)
+        column-name (first columns-in-transformation)
         data-group (datagroup-by-column data-groups column-name)
         source-table (:table-name data-group)
         other-dgs-columns (db.data-group/get-all-columns-except-group-id tenant-conn {:dataset-version-id (:id dataset-version)


Added :periphery job to util.clj for wide-spaced retinas.

--- src/main/clojure/brainardlab/nben/retina/util.clj
+++ src/main/clojure/brainardlab/nben/retina/util.clj
@@ -70,6 +70,17 @@
                  :types [:dichromat :tetrachromat]
                  :samples [2500000]
                  :runs [0]
+                 :save-every 100000}
+     :periphery {:surrounds [[0.25 3.0] nil]
+                 :L-to-Ms [[16 1] [4 1] [1 1] [1 4] [1 16]]
+                 :M-lambda-maxs [530.3]
+                 :L-lambda-maxs [558.9]
+                 :S-lambda-maxs [420.7]
+                 :sizes [40]
+                 :spacings [2 4]
+                 :S-cone-flags [:human]
+                 :samples [2500000]
+                 :runs ["periphery"]
                  :save-every 100000}
      :LM-only   {:surrounds [[0.25 3.0] nil]
                  :L-to-Ms [[16 1] [4 1] [1 1] [1 4] [1 16]]
@@ -91,7 +102,12 @@
               L-lambda-max (get plan :L-lambda-maxs [558.9])
               S-lambda-max (get plan :S-lambda-maxs [420.7])
               A-lambda-max (get plan :A-lambda-maxs [545.0])]
-          {:L L-lambda-max :M M-lambda-max :S S-lambda-max :A A-lambda-max})]
+          {:L L-lambda-max :M M-lambda-max :S S-lambda-max :A A-lambda-max})
+        mosaics
+        (for [retina-size (get plan :sizes [20])
+              spacing (get plan :spacings [1])
+              blur (get plan :blurs)]
+          (mosaic :size retina-size :blur blur :spacing spacing))]
     (for [retina-type (get plan :types [:trichromat])
           surround (get plan :surrounds [[0.25 3.0]])
           L-to-M (cond (= retina-type :trichromat) (get plan :L-to-Ms [[1 1]])
@@ -99,8 +115,7 @@
                        (= retina-type :dichromat) [1]
                        :else (throw (IllegalArgumentException. "invalid type")))
           S-cone-flags (get plan :S-cone-flags [:human])
-          retina-size (get plan :sizes [20])
-          blur (get plan :blurs [nil])
+          mosaic mosaics
           lmaxs (loop [q cone-lambda-maxs, res #{}]
                   (if (nil? q)
                     (if (= S-cone-flags :none)
@@ -113,7 +128,7 @@
                                        (= retina-type :dichromat) (dissoc (first q) :A :M))))))]
       (retina :type retina-type
               :surround surround
-              :mosaic (mosaic :size retina-size :blur blur)
+              :mosaic mosaic
               :cones (cond (= retina-type :trichromat) [:L :M :S]
                            (= retina-type :tetrachromat) [:L :A :M :S]
                            (= retina-type :dichromat) [:L :S])