* benchmark/cljs/benchmark_runner.cljs: decrease large vector by order of magnitude

--- benchmark/cljs/benchmark_runner.cljs
+++ benchmark/cljs/benchmark_runner.cljs
@@ -53,10 +53,10 @@
 (println)

 (println ";;; large vector ops")
-(simple-benchmark [] (reduce conj [] (range 40000)) 100)
-(simple-benchmark [coll (reduce conj [] (range (+ 32768 32)))] (conj coll :foo) 1000000)
-(simple-benchmark [coll (reduce conj [] (range 40000))] (assoc coll 123 :foo) 1000000)
-(simple-benchmark [coll (reduce conj [] (range (+ 32768 33)))] (pop coll) 1000000)
+(simple-benchmark [] (reduce conj [] (range 40000)) 10)
+(simple-benchmark [coll (reduce conj [] (range (+ 32768 32)))] (conj coll :foo) 100000)
+(simple-benchmark [coll (reduce conj [] (range 40000))] (assoc coll 123 :foo) 100000)
+(simple-benchmark [coll (reduce conj [] (range (+ 32768 33)))] (pop coll) 100000)
 (println)

 (println ";;; transients")


Simplify so that we do not need to map the ns-resolve methods.

--- src/fnx/meta/expose.clj
+++ src/fnx/meta/expose.clj
@@ -12,15 +12,13 @@
 ;; * First we load the ns with `require`
 ;; * Then we get the public functions (read from bottom to top):
 ;; * We want only functions, not the other vars: We can spot them because they have an `:arglists` in their meta.
-;; * Don't really know why, but we need to `ns-resolve` the symbols(?)
 ;; * Get the public vars with `ns-publics`
 ;;
 (defn ns-public-fn
   "Given a ns symbol, returns all the public fns of this ns."
   [ns] (do (require ns)
            (filter #(:arglists (meta %))
-                   (map #(ns-resolve ns %)
-                        (keys (ns-publics (find-ns ns)))))))
+                   (vals (ns-publics (find-ns ns))))))

 (fact "ns-public-fn"
       (second (ns-public-fn 'fnx.meta.example)) => (resolve 'fnx.meta.example/hello-noir))


fixed comments, cleaned code a bit

fixed comments, cleaned code a bit

--- src/frontend/todos.cljs
+++ src/frontend/todos.cljs
@@ -75,9 +75,6 @@
 (defn reconcile
   [model action]
   (match action
-         ; do nothing, only for a demo
-         :sample-action model
-
          [:update-field val]
          (assoc model :field val)

@@ -127,8 +124,8 @@

 ;;;;;;;;;;;;;;;;;;;;;;;; View model
 (def -visibility-spec
-  ; multiple tokens are supported mostly for :all case:
-  ; on navigating to base url the token is "", but on clicking the link the token becomes "/"
+  ; multiple tokens are supported mostly for :all case,
+  ; because on navigating to base url the token is "", but on clicking the link the token becomes "/"
   [{:key :all :title "All" :href "#/" :tokens #{"" "/"}}
    {:key :active :title "Active" :href "#/active" :tokens #{"/active"}}
    {:key :completed :title "Completed" :href "#/completed" :tokens #{"/completed"}}])
@@ -141,7 +138,7 @@
                        :key)]
     result
     (do
-      ; we don't use .error because PhantomJS somehow stops on it on running testing
+      ; we don't use .error because PhantomJS somehow stops on it on running tests
       (.log js/console "ERROR: Could not determine visibility for token" (pr-str (::routing/token model)) ". Will use some default visibility.")
       (-> -visibility-spec first :key))))

@@ -247,11 +244,10 @@
    [:ul.filters
     (for [{:keys [key title href]} -visibility-spec]
       ^{:key key}
-      [:li
-       [:a
-        {:href  href
-         :class (if (= visibility key) "selected")}
-        title]])]
+      [:li [:a
+            {:href  href
+             :class (if (= visibility key) "selected")}
+            title]])]

    (if has-completed-todos?
      [:button.clear-completed {:on-click #(dispatch :on-clear-completed)} "Clear completed"])])
@@ -262,7 +258,7 @@
   [:section.todoapp
    [-view-header @field dispatch]

-   (if @has-todos?
+   (when @has-todos?
      [:div
       [-view-todo-list @todos @all-completed? dispatch]
       [-view-footer @active-count @has-completed-todos? @visibility dispatch]])])


Pacify linter

Pacify linter

--- src/grimoire/things.clj
+++ src/grimoire/things.clj
@@ -126,7 +126,7 @@
 (defn thing->relative-path [t thing]
   (->> thing
        (iterate :parent)
-       (take-while #(not (= (:type %1) t)))
+       (take-while #(not= (:type %1) t))
        (reverse)
        (map :name)
        (interpose "/")
@@ -137,7 +137,7 @@
        (iterate :parent)
        (take-while identity)
        (reverse)
-       (take-while #(not (= (:type %1) t)))
+       (take-while #(not= (:type %1) t))
        (map :name)
        (interpose "/")
        (apply str)))


comments

comments

--- src/hangman/triples.clj
+++ src/hangman/triples.clj
@@ -54,8 +54,6 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (defrecord Graph [id indices triples])
-
-

 (defprotocol GraphContainer
   (id       [this])
@@ -119,8 +117,7 @@
      (-> (->Graph (uuid/the-uuid id) {} tuples)
        (add-index s p o)
        (add-index p o s)
-       (add-index o s p)
-       )))
+       (add-index o s p))))

 (defprotocol GraphBuilder
@@ -166,11 +163,7 @@
              (graph [this]
                (get @db this)))

-(assert (= (graph *context*) (graph nil) (graph uuid/+null+)))
-
-(defmacro with-context [designator & body]
-  `(binding [*context* (intern-graph (graph ~designator))]
-     ~@body))
+;; (assert (= (graph *context*) (graph nil) (graph uuid/+null+)))

 ;; (graph #{[1 2 3]})
 ;;  => #<Graph 2d1b48b0-723d-1195-8101-7831c1bbb832 (1 triples)>
@@ -184,6 +177,10 @@
 ;;  => #<Graph 6d863860-723d-1195-8101-7831c1bbb832 (1 triples)>
 ;;  => #<Graph 6d863860-723d-1195-8101-7831c1bbb832 (1 triples)>
 ;;  => #<Graph 6d863860-723d-1195-8101-7831c1bbb832 (1 triples)>
+
+(defmacro with-context [designator & body]
+  `(binding [*context* (intern-graph (graph ~designator))]
+     ~@body))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -195,10 +192,10 @@
 ;; specific Graph implementation.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(defn supplied-constituents [graph subj pred obj]
+(defn supplied-constituents [g subj pred obj]
   (vec (conj (for [c [subj pred obj]]
                (not (nil? c)))
-         (class graph))))
+         (class g))))

 (defmulti query supplied-constituents)

@@ -260,20 +257,31 @@
                      (query (graph *context*) subj pred obj))))))

+;;;
+;;; Identity and Context: examples.
+;;;

 ;; (select (graph #{[1 2 3] [4 5 6]}) [nil nil nil])
-;;
 ;;   => #<Graph e9a62310-7238-1195-8101-7831c1bbb832 (2 triples)>

 ;; (with-context #{[1 2 3]}
 ;;   (query (graph *context*) 1 2 nil))
-;;
-;;  => #{[1 2 3]}
+;;   => #{[1 2 3]}

 ;; (with-context (select (graph #{[1 2 3] [4 5 6]}) [nil nil nil])
 ;;   (triples (select (graph nil) [nil nil nil])))
-;;
-;;  => #{[4 5 6] [1 2 3]}
+;;   => #{[4 5 6] [1 2 3]}
+
+;; (select (graph #{[1 2 3] [4 5 6]}) [nil nil nil])
+;;   => #<Graph 0322eb40-723c-1195-8101-7831c1bbb832 (2 triples)>
+;;   => #<Graph 0322eb40-723c-1195-8101-7831c1bbb832 (2 triples)>
+;;   => #<Graph 0322eb40-723c-1195-8101-7831c1bbb832 (2 triples)>
+
+;; (with-context (select (graph #{[1 2 3] [4 5 6]}) [nil nil nil])
+;;   (select (graph nil) [nil nil nil]))
+;;   => #<Graph 0322eb40-723c-1195-8101-7831c1bbb832 (2 triples)>
+;;   => #<Graph 0322eb40-723c-1195-8101-7831c1bbb832 (2 triples)>
+;;   => #<Graph 0322eb40-723c-1195-8101-7831c1bbb832 (2 triples)>

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


Style changes in problem54.clj

Style changes in problem54.clj

--- euler_clojure/src/euler/problem54.clj
+++ euler_clojure/src/euler/problem54.clj
@@ -9,7 +9,7 @@
   ;; hands are given as vectors of strings of rank, suit
   ;; e.g. ["AC" "8D" "8H" "3C" "2S"] => [\C \D \H \C \S]
   [hand]
-  (for [h hand] (get h 1)))
+  (vec (map second hand)))

 (defn ranks
   "Return the ranks of a given poker hand."
@@ -19,10 +19,10 @@
   ;; This allows us to correctly judge that the second hand > the first.
   ;; Also, an ace is played 'low' i.e. with rank 1 if it makes a straight.
   [hand]
-  (let [rs (for [h hand] (get h 0))
+  (let [rs (map first hand)
         trans {\A 14, \K 13, \Q 12, \J 11, \T 10}
         convert #(for [x %] (get trans x (Character/digit x 10)))
-        reverse-sort #(reverse (sort %))
+        reverse-sort (comp reverse sort)
         modify-ace #(if (= % [14 5 4 3 2]) [5 4 3 2 1] %)
         sort-by-freq #(sort-by (frequencies %) > %)]
     (-> rs convert reverse-sort modify-ace sort-by-freq vec)))
@@ -79,7 +79,7 @@

 (defn problem54 []
   (with-open [rdr (clojure.java.io/reader "resources/poker.txt")]
-    ;; How many hands did Player 1 win?
-    (count (filter true? (for [row (line-seq rdr)]
-                           (let [cards (clojure.string/split row #" ")]
-                             (player1-wins? (deal-two-hands cards))))))))
+    (let [rows (line-seq rdr)
+          cards (map #(clojure.string/split % #" ") rows)]
+      ;; How many hands did Player 1 win?
+      (count (filter player1-wins? (map deal-two-hands cards))))))


Fix typo on event handler attr on messages ns.

--- src/uxbox/main/ui/messages.cljs
+++ src/uxbox/main/ui/messages.cljs
@@ -28,7 +28,7 @@
     (html
      [:div.message {:class classes}
       [:div.message-body
-       [:span.close {:on-clock close}
+       [:span.close {:on-click close}
         i/close]
        [:span (:content message)]]])))


New fix for displaying dates correctly

New fix for displaying dates correctly

It is still uncertain whether this fix works or not. It can only be
verified after being deployed to OpenShift.

--- src/ktra_indexer/db.clj
+++ src/ktra_indexer/db.clj
@@ -186,13 +186,15 @@
          {:status "error"})))))

 (defn format-as-local-date
-  "Format a date from the database as a local date. This avoids problems
-  with time zones."
-  [db-date]
-  (f/unparse date-formatter
-             (t/to-time-zone (c/from-sql-date db-date)
-                             (t/time-zone-for-id
-                              (cfg/get-conf-value :time-zone)))))
+  "Returns the given SQL date as a formatted string in local time"
+  [sql-date]
+  (binding [l/*local-formatters* {:local
+                                  (DateTimeFormat/forPattern "d.M.y")}]
+    (l/format-local-time (t/to-time-zone
+                          (c/from-sql-date sql-date)
+                          (t/time-zone-for-id (cfg/get-conf-value
+                                               :time-zone)))
+                         :local)))

 (defn get-episodes
   "Returns all the episodes in the database. Returns episode number, name


Return connect reader code

Return connect reader code

--- src/com/wsscode/pathom/connect.cljc
+++ src/com/wsscode/pathom/connect.cljc
@@ -2,6 +2,7 @@
   (:require [clojure.spec.alpha :as s]
             [com.wsscode.pathom.core :as p]
             [com.wsscode.spec-inspec :as si]
+            [com.wsscode.common.async :refer [let-chan]]
             [clojure.set :as set]))

 (s/def ::sym symbol?)
@@ -180,25 +181,25 @@
     (if-let [{:keys [e s]} (pick-resolver env)]
       (let [{::keys [cache?] :or {cache? true} :as resolver}
             (resolver-data env s)
-            env      (assoc env ::resolver-data resolver)]
-        (let [response (if cache?
-                         (p/cached env [s e] (call-resolver env e))
-                         (call-resolver env e))]
-          (let [env'     (get response ::env env)
-                response (dissoc response ::env)]
-            (if-not (or (nil? response) (map? response))
-              (throw (ex-info "Response from reader must be a map." {:sym s :response response})))
-            (p/swap-entity! env' #(merge % response))
-            (let [x (get response k)]
-              (cond
-                (sequential? x)
-                (->> x (map atom) (p/join-seq env'))
-
-                (nil? x)
-                x
-
-                :else
-                (p/join (atom (get response k)) env'))))))
+            env      (assoc env ::resolver-data resolver)
+            response (if cache?
+                       (p/cached env [s e] (call-resolver env e))
+                       (call-resolver env e))
+            env'     (get response ::env env)
+            response (dissoc response ::env)]
+        (if-not (or (nil? response) (map? response))
+          (throw (ex-info "Response from reader must be a map." {:sym s :response response})))
+        (p/swap-entity! env' #(merge % response))
+        (let [x (get response k)]
+          (cond
+            (sequential? x)
+            (->> x (map atom) (p/join-seq env'))
+
+            (nil? x)
+            x
+
+            :else
+            (p/join (atom (get response k)) env'))))
       ::p/continue)))

 (def index-reader


Fix async reader2 batch

Fix async reader2 batch

--- src/com/wsscode/pathom/connect.cljc
+++ src/com/wsscode/pathom/connect.cljc
@@ -745,7 +745,7 @@
                                          (pt/tracing env (assoc trace-data ::pt/event ::call-resolver-batch)
                                            (let [_              (pt/trace env (assoc trace-data ::pt/event ::call-resolver-with-cache))
                                                  items          (->> processing-sequence
-                                                                     (map-async-serial #(entity-select-keys env % input))
+                                                                     (map-async-serial #(entity-select-keys env % input)) <?
                                                                      (filterv #(all-values-valid? % input))
                                                                      (distinct))
                                                  _              (pt/trace env {::pt/event ::batch-items-ready


Some code cleanup

Some code cleanup

--- src/livewator/core.cljs
+++ src/livewator/core.cljs
@@ -9,6 +9,7 @@
 ;;(println "This text is printed from src/livewator/core.cljs. Go ahead and edit it and see reloading in action.")

 ;; define your app data so that it doesn't get over-written on reload
+

 (defn buildrow
@@ -17,12 +18,10 @@
   [n-items value]
   (vec (repeat n-items value)))

-
 (defn empty-playfield
   "Crea un campo da gioco vuoto; matrice w*h di elementi nil"
   [w h]
-  (buildrow h (buildrow w nil))
-)
+  (buildrow h (buildrow w nil)))

 (def TIPI-PESCI [:PESCE1 :PESCE2 :PESCE3])
 (def TIPI-SQUALI [:SQUALO1 :SQUALO2 :SQUALO3])
@@ -59,6 +58,8 @@
    :GDX  [ 1  1]
 })

+(def DIREZIONI (keys MOSSE))
+
 (defn somma-circolare [pos offset massimo]
   (let [p (+ pos offset)
         m (dec massimo)]
@@ -78,9 +79,7 @@

 (defn mossa-casuale []
-  (rand-nth [:SU :GIU :SX :DX :SUSX :GSX :SUDX :GDX])
-  ;:DX
-  )
+  (rand-nth DIREZIONI))

 ; defn animali
 (defn crea-nuovo-pesce []
@@ -178,14 +177,12 @@
 ; - se energia < 0 muore

 (defn pesce-adiacente? [rc celle]
-  (let [celle-da-guardare (map #(nuovopunto rc %) [:SU :GIU :SX :DX :SUSX :GSX :SUDX :GDX])
-        celle-con-pesci (filter #(cella-con-pesce? celle %) celle-da-guardare)
-        ]
-      (cond
-        (pos? (count celle-con-pesci))  (rand-nth celle-con-pesci)
-        :else                           nil
-
-      )))
+  (let [celle-da-guardare (map #(nuovopunto rc %) DIREZIONI)
+        celle-con-pesci (filter #(cella-con-pesce? celle %) celle-da-guardare)]
+
+    (cond
+      (pos? (count celle-con-pesci))  (rand-nth celle-con-pesci)
+      :else                           nil)))

 (defmethod avanza-animale :SQUALO
@@ -197,23 +194,16 @@
       ; mangio un pesce
       (let [squalo-grasso (incrementa-energia animale)]
         (muovi-animale celle
-            rc-pesce squalo-grasso
-            [r c]    nil)
-
-        )
-
+                       rc-pesce squalo-grasso
+                       [r c]    nil))

       ; nulla da mangiare
       (let [nuovacella (nuovopunto [r c] (mossa-casuale))]
         (if (cella-vuota? celle nuovacella)
           (muovi-animale celle
-              nuovacella squalo
-              [r c]      nil)
-
+                         nuovacella squalo
+                         [r c]      nil)
           celle)))))
-
-
-

@@ -246,18 +236,14 @@

 (defn join-val [dict chiave valore]
   (let [v0 (conj (get-in dict [chiave]) valore)]
-    (assoc-in dict [chiave] v0)
-  ))
+    (assoc-in dict [chiave] v0)))

 (defn conta-celle
   "Restituisce un hash con tutte le celle per tipo"
   [celle]
   (reduce #(update-in %1 [%2] inc) {:PESCE 0 :SQUALO 0}
-    (for [rc (coordinate-gioco)]
-      (:tipo (get-in celle rc)))))
-
-
-
+          (for [rc (coordinate-gioco)]
+            (:tipo (get-in celle rc)))))

 (defn run-turno-gioco
   "Questo metodo è chiamato dal bottone"
@@ -273,12 +259,7 @@
       (swap! app-state update-in [:turn] inc)
       (swap! app-state join-val :n_pesci (:PESCE tipi-celle))
       (swap! app-state join-val :n_squali (:SQUALO tipi-celle))
-      (swap! app-state join-val :loop_ms dur)
-
-
-     )
-
-  ))
+      (swap! app-state join-val :loop_ms dur))))

@@ -320,62 +301,62 @@

 (defn plot-playfield []
+
   [:div

   [:table.table.table-striped.table-bordered
-   {:cell-spacing "0" }
+   {:cell-spacing "0"}

    [:thead>tr
-     [:td {:width "20px"} "-" ]
-     (map #(vec [:th {:width "20px"} (str %)]) (range PLAYFIELD-WIDTH))
-    ]
+    [:td {:width "20px"} "-"]
+    (map #(vec [:th {:width "20px"} (str %)]) (range PLAYFIELD-WIDTH))]

    [:tbody

     (let [table (:pf @app-state)]
       (for [row (range PLAYFIELD-HEIGHT)]
-        (plot-row row (get table row))))
-
-    ]]
-
-    [:input {:type "button"
+        (plot-row row (get table row)))) ]]
+
+  ;; BOTTONI
+
+  (str "Pesci: " (first (:n_pesci @app-state))
+          " - Squali: " (first (:n_squali @app-state))
+          " - Loop: " (first (:loop_ms @app-state)) "ms")
+
+  [:br]
+
+  [:input {:type "button"
              :value (str "Avanza #" (:turn @app-state))
-             :on-click run-turno-gioco }]
-
-    [:input {:type "button" :value "Reset!"
-            :on-click
-             #(doall
-                (imposta-campo-di-gioco (empty-playfield PLAYFIELD-WIDTH PLAYFIELD-HEIGHT))
-                (swap! app-state assoc-in [:turn] 0))     }]
-
+             :on-click run-turno-gioco}]
+
+  [:input {:type "button" :value "Reset!"
+     :on-click
+     #(doall
+       (imposta-campo-di-gioco (empty-playfield PLAYFIELD-WIDTH PLAYFIELD-HEIGHT))
+       (swap! app-state assoc-in [:turn] 0))}]

     [:input {:type "button" :value "Pesce 1,1"
-            :on-click
-             #(imposta-campo-di-gioco
-                (imposta-animale (:pf @app-state) [1 1] (crea-nuovo-pesce))) }]
+     :on-click
+     #(imposta-campo-di-gioco
+       (imposta-animale (:pf @app-state) [1 1] (crea-nuovo-pesce)))}]

      [:input {:type "button" :value "Squalo 8,8"
-            :on-click
-             #(imposta-campo-di-gioco
-                (imposta-animale (:pf @app-state) [8 8] (crea-nuovo-squalo))) }]
-
-
-     [:br ]
-
-     (str "Pesci: " (first (:n_pesci @app-state))
-          " - Squali: " (first (:n_squali @app-state))
-          " - Loop: " (first (:loop_ms @app-state)) "ms"
-
-     )
+      :on-click
+      #(imposta-campo-di-gioco
+        (imposta-animale (:pf @app-state) [8 8] (crea-nuovo-squalo)))}]
+
+
+  ]
+
+
+
+
+
+  )

      ;[:pre (str @app-state)]

-
-     ]
-
-
-  )

 (reagent/render-component [plot-playfield]


Flatten n-ary operators (work in progress)

--- src/logic/transform.clj
+++ src/logic/transform.clj
@@ -22,6 +22,25 @@
   [ast]
   (insta/transform transform-map ast))

+(defn- bar
+  [o l]
+  (if (list? l)
+    (= o (first l))
+    false))
+
+(defn- foo
+  [ast]
+  (let [o (first ast) a (rest ast)] ; operator and arguments
+    (let [flat (map #(rest %) (filter (partial bar o) a))
+          not-flat (filter (partial (complement bar) o) a)]
+      (println :ast ast)
+      (println :flat flat)
+      (println :not-flat not-flat)
+      (println (apply concat  `((~o) ~@flat ~not-flat))))
+      ast))
+
+
+
 (defn- flat
   [ast]
   (if (and
@@ -29,7 +48,7 @@
         (n-ary? (first ast)))
     (do
       (println :can-maybe-flat (rest ast))
-      ast) ; TODO
+      (foo ast)) ; TODO
     ast))

 (defn flatten-ast


trash existing asset/agenda in remote server when installing a new one

--- src/node/game/core.cljs
+++ src/node/game/core.cljs
@@ -608,9 +608,15 @@
            (trigger-event state side :server-created card))
          (let [c (assoc card :advanceable (:advanceable (card-def card)))
                slot (conj dest (if (= (:type c) "ICE") :ices :content))
+               dest-zone (get-in @state (cons :corp slot))
                install-cost (if (and (= (:type c) "ICE") (not no-install-cost))
-                              (count (get-in @state (cons :corp slot))) 0)]
+                              (count dest-zone) 0)]
            (when (pay state side card extra-cost :credit install-cost)
+             (when (#{"Asset" "Agenda"} (:type c))
+               (when-let [prev-card (some #(when (#{"Asset" "Agenda"} (:type %)) %) dest-zone)]
+                 (system-msg state side (str "trashes " (if (:rezzed prev-card)
+                                                          (:title prev-card) "a card") " in " server))
+                 (trash state side prev-card)))
              (let [card-name (if rezzed (:title card) "a card")]
                (if (> install-cost 0)
                  (system-msg state side (str "pays " install-cost " [Credits] to install "


fix issue with runner card trashing message

--- src/node/game/core.cljs
+++ src/node/game/core.cljs
@@ -546,7 +546,9 @@
   (case server
     ("Heap" "Archives")
     (do (trash state side card)
-        (system-msg state side (str "trashes " (if (:rezzed card) (:title card) "a card"))))
+        (system-msg state side (str "trashes " (if (or (= (:side card) "Runner") (:rezzed card))
+                                                 (:title card)
+                                                 "a card"))))
     ("HQ" "Grip")
     (do (move state side (dissoc card :seen :rezzed) :hand)
         (system-msg state side (str "moves " (:title card) " to " server)))


Remove Carrot from the subject.

Remove Carrot from the subject.

--- src/oc/email/mailer.clj
+++ src/oc/email/mailer.clj
@@ -88,7 +88,7 @@
                   (assoc :source default-source)
                   (assoc :from default-from)
                   (assoc :reply-to default-reply-to)
-                  (assoc :subject (str "Carrot, 🔔 " (content/reminder-notification-headline reminder-data))))]
+                  (assoc :subject (str "🔔 " (content/reminder-notification-headline reminder-data))))]
     (try
       (spit html-file (content/reminder-notification-html reminder)) ; create the email in a tmp file
       (inline-css html-file inline-file) ; inline the CSS


Remove task helpers that don't mesh well with tempdirs

--- boot/core/src/boot/task_helpers.clj
+++ boot/core/src/boot/task_helpers.clj
@@ -72,22 +72,3 @@
          ~pass
          :keyring ~keyring
          :user-id ~user-id))))
-
-;; Task helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defn once
-  "Evaluate the given `task` only once, then pass through."
-  [task]
-  (let [ran? (atom false)
-        run? (partial compare-and-set! ran? @ran?)]
-    (fn [continue]
-      (let [task (task continue)]
-        #(continue ((if (run? true) task identity) %))))))
-
-(defn bg-task
-  "Run the given task once, in a separate, background thread."
-  [task]
-  @add-shutdown!
-  (once
-    (core/with-pre-wrap
-      (swap! bgs conj (future ((task identity) core/*event*))))))


Changing expired collections test to avoid failing due to timing issues.

--- int_test/cmr/metadata_db/int_test/concepts/search_test.clj
+++ int_test/cmr/metadata_db/int_test/concepts/search_test.clj
@@ -157,9 +157,9 @@
                                   (util/create-and-save-collection
                                     prov uniq-num num-revisions
                                     {:delete-time (str expire-time)})))
-        ;; Expired 60 seconds ago
-        coll1 (make-coll-expiring-in "PROV1" 1 1 -60)
-        coll2 (make-coll-expiring-in "PROV1" 2 2 -60)
+        ;; Expired 6000 seconds ago.
+        coll1 (make-coll-expiring-in "PROV1" 1 1 -6000)
+        coll2 (make-coll-expiring-in "PROV1" 2 2 -6000)
         ;; Expires in the far future
         coll3 (make-coll-expiring-in "PROV1" 3 1 5000)
         ;; Doesn't have an expiration date


formatting

formatting

--- pp-cljs-client/project.clj
+++ pp-cljs-client/project.clj
@@ -20,19 +20,13 @@

   :jvm-opts ["-Xmx384m"]

-  :cljsbuild {
-              :builds {
-                       :main {
-                              :source-paths ["src-cljs"]
-                              :compiler {
-                                         :output-to "public/js/pretty-print.js"
-                                         :output-dir "public/out"
-                                         :optimizations :whitespace}}
+  :cljsbuild {:builds {:main {:source-paths ["src-cljs"]}}
+                 :compiler {:output-to "public/js/pretty-print.js"
+                            :output-dir "public/out"
+                            :optimizations :whitespace}

-                       :main-min {
-                                  :source-paths ["src-cljs"]
-                                  :compiler {
-                                             :output-to "public/js/pretty-print.min.js"
-                                             :output-dir "public/out-min"
-                                             :optimizations :advanced
-                                             :pretty-print false}}}})
+              :main-min {:source-paths ["src-cljs"]
+                         :compiler {:output-to "public/js/pretty-print.min.js"
+                                    :output-dir "public/out-min"
+                                    :optimizations :advanced
+                                    :pretty-print false}}})


Doh... more old send-email...

Doh... more old send-email...

--- src/polismath/email.clj
+++ src/polismath/email.clj
@@ -12,6 +12,6 @@
                   {:basic-auth ["api" *mailgun-key*]
                    :query-params params})
      (catch Exception e (.printStackTrace e))))
-  ([from to subject text html] (send-email {:from from :to to :subject subject :text text :html html}))
-  ([from to subject text] (send-email {:from from :to to :subject subject :text text})))
+  ([from to subject text html] (send-email! {:from from :to to :subject subject :text text :html html}))
+  ([from to subject text] (send-email! {:from from :to to :subject subject :text text})))


ex pan changes

ex pan changes

--- src/prais2/content.cljc
+++ src/prais2/content.cljc
@@ -503,7 +503,8 @@
                               [:p [:a (core/href "http://www.ucl.ac.uk/nicor/patients" :target "_blank")
                                    [:img.thumbnail.pull-left.w100 (core/isrc "assets/nicor.png")]]
                                "Since 2007, the national audit body (" [:a (core/href "http://www.ucl.ac.uk/nicor/audits/congenital") "NCHDA"] ") has published survival rates for certain
-                               types of procedure (now over 70 different procedures) at each hospital. The "
+                               " [:a (core/href "https://nicor4.nicor.org.uk/CHD/an_paeds.nsf/WBenchmarksYears?openview&RestrictToCategory=2014&start=1&count=500"
+                                                :target "_blank") "types of procedure"] " (now over 70 different procedures) at each hospital. The "
                                [:a (core/href "http://www.ucl.ac.uk/nicor/audits/congenital") "NCHDA"] " did not
                                publish overall survival rates for each hospital, because there was no clear way to put
                                overall survival rates for each hospital into context


add a watch-futures function and implement reap-futures in terms of that

we use watch-futures from our main function and let the program die if
any of the main futures crashed or exited.

--- src/fscrawler_tika_convert/core.clj
+++ src/fscrawler_tika_convert/core.clj
@@ -50,22 +50,38 @@
     (catch Throwable err
       err)))

-(let [call-counter (atom 0)]
+
+(defn watch-futures
+  "watch a sequence of futures, call on-error if a future exited with an exception,
+   call on-exit if it exited normally"
+  [get-futures on-error on-exit]
+  (try
+    ;; (println 'watch-futures get-futures on-error on-exit)
+    (doseq [a-future (get-futures)]
+      (when (realized? a-future)
+        (if-let [error (deref-exception a-future)]
+          (on-error a-future error)
+          (on-exit a-future nil))))
+    (catch Throwable err
+      (trace/print-stack-trace err)
+      (logging/error "an error occured in watch-futures" err))))
+
+
+(let [call-counter (atom 0)
+      on-error (fn [a-future error]
+                 (logging/error "************* error in future" (str a-future) error)
+                 ((:cleanup-on-error (@future-map a-future)))
+                 (swap! future-map dissoc a-future))
+      on-exit (fn [a-future _]
+                (swap! future-map dissoc a-future))
+      get-futures #(do (swap! call-counter inc)
+                       (when (zero? (rem @call-counter 240))
+                         (logging/info "reaping futures" @call-counter))
+                       (keys @future-map))]
   (defn reap-futures
     []
-    (swap! call-counter inc)
-    (when (zero? (rem @call-counter 240))
-      (logging/info "reaping futures" @call-counter))
-    (try
-      (doseq [[a-future val] @future-map]
-        (when (realized? a-future)
-          (if-let [error (deref-exception a-future)]
-            (do
-              (logging/error "************* error in future" (str a-future) error val)
-              ((:cleanup-on-error val))))
-          (swap! future-map dissoc a-future)))
-      (catch Throwable err
-        (logging/error "error occured in reap-futures" err)))))
+    (watch-futures get-futures on-error on-exit)))
+

 (defn map-from-routing-key-string
@@ -230,6 +246,13 @@
             (map string/trim (string/split-lines s)))))

+(defn die-on-exit-or-error
+  [a-future error]
+  (when error
+    (trace/print-stack-trace error))
+  (die "thread died unexpectedly"))
+
+
 (defn -main [& args]
   ;; work around dangerous default behaviour in Clojure
   ;; (alter-var-root #'*read-eval* (constantly false))
@@ -249,14 +272,11 @@
     (when (zero? (count filesystems))
       (die (str "no filesystems defined in section " inisection " in " iniconfig)))

-    (println "max-size is" max-size)
     (periodically 250 reap-futures)

     (let [futures (doall (for [filesystem filesystems]
-                           (future (handle-command-for-filesystem filesystem))))]
-      (doseq [f futures]
-        (try
-          @f
-          (catch Throwable err
-            (trace/print-stack-trace err)
-            (die (str "thread unexpectedly died with error " err))))))))
+                           (future (handle-command-for-filesystem filesystem))))
+          wait-for-ever (promise)]
+      (periodically 1000 #(watch-futures (constantly futures)
+                                         die-on-exit-or-error die-on-exit-or-error))
+      @wait-for-ever)))


streams/where*: only evaluate predicate expr once.

Closes #381

--- src/riemann/streams.clj
+++ src/riemann/streams.clj
@@ -1646,9 +1646,10 @@
   [f & children]
   (let [[true-kids else-kids] (where-partition-clauses children)]
     `(let [true-kids# ~true-kids
-           else-kids# ~else-kids]
+           else-kids# ~else-kids
+           predicate# ~f]
       (fn stream# [event#]
-         (let [value# (~f event#)]
+         (let [value# (predicate# event#)]
            (if value#
              (call-rescue event# true-kids#)
              (call-rescue event# else-kids#))


Increase darkeness for regions outside fov

--- src/robinson/render.clj
+++ src/robinson/render.clj
@@ -63,7 +63,7 @@

 (defn darken-rgb
   ([rgb]
-  (vec (map #(/ % 3) rgb)))
+  (vec (map #(/ % 10) rgb)))
   ([rgb d]
   (vec (map #(limit-color (* % d)) rgb))))


wip: update argument type/value validation

--- src/graphql_clj/query_validator.clj
+++ src/graphql_clj/query_validator.clj
@@ -61,7 +61,7 @@
       :int-value     (or (= 'Int (:name t)) (= 'Float (:name t)))
       :float-value   (= 'Float (:name t))
       :string-value  (or (= 'String (:name t))
-                         true ; FIXME: work around for enum values
+                         (not (#{'Boolean 'Int 'Float 'String} (:name t))) ; FIXME: work around for enum values
                          )
       :null-value    (not (:required t))
       :enum-value    true ;; TODO


a nullpointer bug fixed in connection.server ns

--- src/hellhound/connection/server.clj
+++ src/hellhound/connection/server.clj
@@ -71,7 +71,7 @@
     (reset! recv-ch         ch-recv)
     (reset! send-fn!        send-fn)
     (reset! connected-uids  connected-uids)
-    (reset! event-router    (sente/start-server-chsk-router! ch-recv -router))
+    (def    event-router    (sente/start-server-chsk-router! ch-recv -router))

     ;; Returning a hashmap to be used in components.
     {:ring-ajax-post  ring-ajax-post


reformat profiles.clj

reformat profiles.clj

--- profiles.clj
+++ profiles.clj
@@ -1,10 +1,11 @@
-{:user
- {:repl-options
-   {:init (do
-     (use '[table.core :only (table)])
-     (use '[clojure.repl :only (dir-fn)])
-     (load-file (str (System/getProperty "user.home") "/.lein/user.clj")))}
-    :plugins  [[lein-clojars "0.9.0"] [lein-light "0.0.4"]]
-  }
-  :dependencies  {table "0.2.0" com.datomic/datomic "0.1.3164" }
+{
+ :user {
+   :plugins [[lein-clojars "0.9.0"] [lein-light "0.0.4"]]
+   :repl-options {
+     :init (do
+       (use '[table.core :only (table)])
+       (use '[clojure.repl :only (dir-fn)])
+       (load-file (str (System/getProperty "user.home") "/.lein/user.clj"))) }
+ }
+ :dependencies {table "0.3.2" com.datomic/datomic "0.1.3164"}
 }


Update profiles for release

Update profiles for release

--- profiles.clj
+++ profiles.clj
@@ -1,8 +1,10 @@
 {:dev {:dependencies [[org.clojure/clojure "1.6.0-beta2"]]
        :plugins [[codox/codox.leiningen "0.6.4"]
                  [lein-marginalia "0.7.1"]
-                 [lein-set-version "0.4.1"]]}
- :no-checkouts {:checkout-shares ^:replace []} ; disable checkouts
+                 [lein-pallet-release "0.1.6"]]
+       :pallet-release
+       {:url "https://pbors:${GH_TOKEN}@github.com/palletops/multi-test.git",
+        :branch "master"}}
  :clojure-1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]}
  :doc {:dependencies [[com.palletops/pallet-codox "0.1.0"]]
        :codox {:writer codox-md.writer/write-docs
@@ -11,6 +13,4 @@
                :src-linenum-anchor-prefix "L"}
        :aliases {"marg" ["marg" "-d" "doc/source/0.1"]
                  "codox" ["doc"]
-                 "doc" ["do" "codox," "marg"]}}
- :release
- {:set-version {:updates [{:path "README.md" :no-snapshot true}]}}}
+                 "doc" ["do" "codox," "marg"]}}}


Get MutliJobSpec abstraction working, develop make-job multimethod

--- src/main/clojure/clj_print/core.clj
+++ src/main/clojure/clj_print/core.clj
@@ -2,7 +2,7 @@
       :author "Roberto Acevedo"}
   clj-print.core
   (:require [clj-print [doc-flavors :as flavors]
-                       [listeners :as listeners]]
+             [listeners :as listeners]]
             [clojure.java [io :as io]]
             [clojure.pprint :refer [pprint]]
             [taoensso.timbre :as timbre])
@@ -172,55 +172,53 @@
           :attrs #{MediaTray/MAIN}
           :listener (listeners/basic-listener)})

-(defprotocol ISpoolable
-  (submit [this]) ;; Submit the job
-  (add-listener [this listener])) ;; Attach an event listener that
-                                  ;; returns a value when the process is complete
+(defprotocol IJobSpec
+  (submit [this])
+  (add-listener [this listener-fn]))
+
+;; TODO: Handle exception scenarios
 (defrecord JobSpec [doc printer job attrs]
-  ISpoolable
+  IJobSpec
   (submit [this]
+    (if-let [{listener-fn :listener-fn} this]
+      (add-listener this listener-fn))
     (let [doc-obj (make-doc doc)
           {:keys [^DocPrintJob job attrs]} this
           attr-set (make-set attrs :request)]
       (.. job (print doc-obj attr-set))))
-  (add-listener [this listener]
-    (if-let [{^DocPrintJob job :job} this]
-      (do (doto job (.addPrintJobListener listener))
-          (assoc this :listener listener))
-      (throw IllegalStateException "No DocPrintJob keyed at :job."))))
+  (add-listener [this listener-fn]
+    (let [{:keys [^DocPrintJob job listener-fn]} this
+          listener (listener-fn)]
+      (doto job (.addPrintJobListener listener)))))

 (defrecord MultiJobSpec [docs printer jobs attrs]
-  ISpoolable
+  IJobSpec
   (submit [this]
+    (if-let [{listener-fn :listener-fn} this]
+      (add-listener this listener-fn))
     (let [{:keys [docs jobs]} this
           doc-objs (map :obj docs)]
-      (map (fn [d j] (.. j (print @d (make-set attrs :request)))) doc-objs jobs))) ;; TODO: reflection
-  ;; (add-listener [this listener]
-  ;;   (if-let [{^DocPrintJob job :job} this]
-  ;;     (do (doto job (.addPrintJobListener listener))
-  ;;         (assoc this :listener listener))
-  ;;     (throw IllegalStateException "No DocPrintJob keyed at :job.")))
-  )
+      (doall (map (fn [j d] (.. j (print @d (make-set attrs :request)))) jobs doc-objs)))) ;; TODO: reflection
+  (add-listener [this listener-fn]
+    (let [{:keys [^DocPrintJob jobs listener-fn]} this]
+      (doseq [j jobs]
+        (.. j (addPrintJobListener (listener-fn)))))))

 ;; TODO: SEE http://oobaloo.co.uk/clojure-from-callbacks-to-sequences!!!
-
 (defmulti make-job
   "Dispatch on which key is present in the spec map."
   (fn [spec] (apply (some-fn #{:doc} #{:docs}) (keys spec))))

 (defmethod make-job :doc [spec]
-  (let [{{doc-attrs :attrs} :doc} spec
-        {:keys [doc ^PrintService printer attrs ^PrintJobtListener listener]
-         :or {printer (printer :default)
-              attrs #{MediaTray/MAIN}}} spec
-              maybe-listen #(if listener (add-listener % listener) %)]
-    (if  (and (valid-attrs? doc-attrs :doc)
+  (let [{:keys [^PrintService printer ^PrintJobListener listener doc attrs]} spec
+        {doc-attrs :attrs} doc]
+    (if (and (valid-attrs? doc-attrs :doc)
              (valid-attrs? attrs :job))
-      (-> (map->JobSpec {:doc doc
-                         :printer printer
-                         :attrs attrs
-                         :job (.. printer createPrintJob)})
-          maybe-listen))))
+      (letfn [(add-doc [doc-map]
+                (assoc-in doc-map [:doc :obj] (delay (make-doc doc-map))))
+              (add-job [spec]
+                (assoc-in spec [:job] (.. printer createPrintJob)))]
+        (-> spec add-doc add-job map->JobSpec)))))

 (defmethod make-job :docs [spec]
   (let [{:keys [^PrintService printer
@@ -230,11 +228,11 @@
              (valid-attrs? attrs :job))
       (letfn [(add-doc [doc-map]
                 (assoc-in doc-map [:obj] (delay (make-doc doc-map))))
-              (add-docs [m]
-                (update-in m [:docs] (fn [doc-list] (map add-doc  doc-list))))
-              (add-jobs [m]
-                (assoc-in m [:jobs] (for [d docs] (.. printer createPrintJob))))]
-        (-> spec add-docs add-jobs)))))
+              (add-docs [spec]
+                (update-in spec [:docs] (fn [doc-list] (map add-doc  doc-list))))
+              (add-jobs [spec]
+                (assoc-in spec [:jobs] (for [doc docs] (.. printer createPrintJob))))]
+        (-> spec add-docs add-jobs map->MultiJobSpec)))))

 ;; (defn make-job
 ;;   "Returns a JobSpec map that is the result of


CLJS-1392: cljs.repl/source regression

CLJS-1392: cljs.repl/source regression

--- src/main/clojure/cljs/analyzer.cljc
+++ src/main/clojure/cljs/analyzer.cljc
@@ -2378,9 +2378,13 @@
    (if ^boolean (:quoted? env)
      (analyze-list env form)
      (let [line (-> form meta :line)
-           line (when (nil? line) (:line env))
+           line (if (nil? line)
+                  (:line env)
+                  line)
            col  (-> form meta :column)
-           col  (when (nil? col) (:column env))
+           col  (if (nil? col)
+                  (:column env)
+                  col)
            env  (assoc env :line line :column col)]
        (let [op (first form)]
          (when (nil? op)


Minor stylistic change.

Minor stylistic change.

--- src/bru_3/frame.clj
+++ src/bru_3/frame.clj
@@ -20,8 +20,8 @@
   [r b1 b2]
   (let [rand-range (fn [min max] (+ min (rand (- max min))))
         rfn #(rand-range (- r) r)
-        rb1 (update-in b1 [:length] * (+ 1 (rfn)))
-        rb2 (update-in b2 [:length] * (+ 1 (rfn)))
+        rb1 (update-in b1 [:length] * (inc (rfn)))
+        rb2 (update-in b2 [:length] * (inc (rfn)))
         [b1u b1d] (d/vertices rb1)
         [b2u b2d] (d/vertices rb2)]
     (Frame. b1u b2u b1d b2d)))


Added indexer key.

Added indexer key.

--- test/elephantdb/cascading/integration_test.clj
+++ test/elephantdb/cascading/integration_test.clj
@@ -142,7 +142,7 @@
 (fact "test-incremental"
   (test/with-fs-tmp [fs tmp]
     (let [spec (DomainSpec. (JavaBerkDB.) (HashModScheme.) 2)
-          sink (ElephantDBTap. tmp spec (mk-options (IdentityIndexer.)))
+          sink (ElephantDBTap. tmp spec (mk-options :indexer (IdentityIndexer.)))
           data [[(barr 0) (barr 0 0)]
                 [(barr 1) (barr 1 1)]
                 [(barr 2) (barr 2 2)]]


Convert position

Convert position

--- raw_data/convert_players.clj
+++ raw_data/convert_players.clj
@@ -15,6 +15,8 @@
   (let [[day month year] (split s #"/")]
     (format "%s-%s-%s" year month day)))

+(def position { "GK" "Goalkeeper", "DF" "Defender", "MF" "Midfielder", "FW" "Forward" })
+
 (defn convert-player [country data]
   (let [shirt (data 0)]
     {
@@ -23,7 +25,7 @@
       :name (nameify (data 1))
       :shirt_number shirt
       :date_of_birth (iso-date (data 2))
-      :position (data 3)
+      :position (position (data 3))
       :club (data 4)
       :height (data 5)
     }))


Only some channels are based on ago.

Only some channels are based on ago.

--- src/cbfg/fence.cljs
+++ src/cbfg/fence.cljs
@@ -2,7 +2,7 @@
   (:require-macros [cljs.core.async.macros :refer [go]]
                    [cbfg.ago :refer [ago ago-loop aput atake]])
   (:require [cljs.core.async
-             :refer [chan close! <!! timeout
+             :refer [chan close! <! timeout
                      onto-chan]]))

 ;; Explaining out-of-order replies and fencing with a diagram.  Client
@@ -82,7 +82,7 @@
   (let [c (chan)]
     (ago nil
          (doseq [n (range s e)]
-           (atake (timeout delay))
+           (<! (timeout delay))
            (aput c n))
          (close! c))
     c))
@@ -104,10 +104,10 @@
                                  "FAIL")
                                test))
               [["test with 2 max-inflights"
-                (<! (test-helper 100 1 2 reqs))
+                (atake (test-helper 100 1 2 reqs))
                 '(6 3 12 40 41 42 43 44 11 11 6 7 0 8 1 2 3 4 9 32)]
                ["test with 200 max-inflights"
-                (<! (test-helper 100 1 200 reqs))
+                (atake (test-helper 100 1 200 reqs))
                 '(6 3 12 40 41 42 43 44 6 7 0 8 11 11 1 2 3 4 9 32)]]))))

 (defn test-helper [in-ch-size
@@ -118,7 +118,7 @@
         out (chan out-ch-size)
         fdp (make-fenced-pump nil in out max-inflight)
         gch (ago-loop nil [acc nil]
-              (let [result (<! out)]
+              (let [result (atake out)]
                 (if result
                   (do (println "Output result: " result)
                       (recur (conj acc result)))


hide sidebar before stream is ready

hide sidebar before stream is ready

--- src/cellf/core.cljs
+++ src/cellf/core.cljs
@@ -245,7 +245,8 @@
   (let [winner?    (and cells (= cells win-state))
         no-stream? (not stream)]
     (dom/div #js {
-      :className (str "modal" (when (or no-stream? media-error show-about? result-gif winner?) " active"))}
+      :className (str "modal"
+        (when (or no-stream? media-error show-about? result-gif winner?) " active"))}
       (cond
         media-error
           (dom/div nil
@@ -320,9 +321,13 @@
       (render [_]
         (dom/div nil
           (modal app)
-          (dom/div #js {:id "sidebar" :style #js {:width capture-size}}
-            (dom/h1 nil "cellf")
-            (dom/p nil "find yourself.")
+          (dom/div #js {
+            :id        "sidebar"
+            :className (when-not stream "hidden")
+            :style     #js {:width capture-size}}
+
+            (dom/h1 nil "Cellf")
+            (dom/h2 nil "find yourself.")
             (dom/canvas #js {
               :ref    "playback"
               :width  capture-size


added an inline function test

added an inline function test

--- test/clj_beautify/core_test.clj
+++ test/clj_beautify/core_test.clj
@@ -14,6 +14,8 @@
 (defn a-test [] ;; comments 2
   (testing "FIXME, I fail." (is (= 0 1))))

+(defn add [x y] (+ x y))
+
 ;; this is a edn data structure
 (def foo
  {:foo "bar",


move method details higher on method config page

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/method_configs/method_config_editor.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/method_configs/method_config_editor.cljs
@@ -187,6 +187,16 @@
          (style/create-text-field {:ref "confname" :style {:width 500}
                                    :defaultValue (config "name")})
          [:div {:style {:padding "0.5em 0 1em 0"}} (config "name")]))
+     (create-section-header "Referenced Method")
+     (create-section [MethodDetailsViewer
+                      {:ref "methodDetailsViewer"
+                       :name (get-in config ["methodRepoMethod" "methodName"])
+                       :namespace (get-in config ["methodRepoMethod" "methodNamespace"])
+                       :snapshotId (get-in config ["methodRepoMethod" "methodVersion"])
+                       :config config
+                       :methods methods
+                       :editing? editing?
+                       :onSnapshotIdChange #(react/call :load-new-method-template this %)}])
      (create-section-header "Root Entity Type")
      (create-section
        (if editing?
@@ -198,17 +208,7 @@
      (create-section-header "Inputs")
      (input-output-list config "inputs" invalid-inputs editing? (inputs-outputs "inputs"))
      (create-section-header "Outputs")
-     (input-output-list config "outputs" invalid-outputs editing? (inputs-outputs "outputs"))
-     (create-section-header "Referenced Method")
-     (create-section [MethodDetailsViewer
-                      {:ref "methodDetailsViewer"
-                       :name (get-in config ["methodRepoMethod" "methodName"])
-                       :namespace (get-in config ["methodRepoMethod" "methodNamespace"])
-                       :snapshotId (get-in config ["methodRepoMethod" "methodVersion"])
-                       :config config
-                       :methods methods
-                       :editing? editing?
-                       :onSnapshotIdChange #(react/call :load-new-method-template this %)}])]))
+     (input-output-list config "outputs" invalid-outputs editing? (inputs-outputs "outputs"))]))

 (defn- render-display [this state refs props]
   (let [wrapped-config (:loaded-config @state)


fix up unit test for settings.

fix up unit test for settings.

--- test/metabase/api/session_test.clj
+++ test/metabase/api/session_test.clj
@@ -151,7 +151,11 @@
 ;; GET /session/properties
 ;; Check that a non-superuser can't read settings
 (expect
-  [{:value "Metabase Test"
+  [{:value nil
+    :key "anon-tracking-enabled"
+    :description "Enable the collection of anonymous usage data in order to help Metabase improve."
+    :default "true"}
+   {:value "Metabase Test"
     :key "site-name"
     :description "The name used for this instance of Metabase."
     :default "Metabase"}]


repo-config-panel dash

repo-config-panel dash

--- cloc-webapp/src-cljs/dash/dash.cljs
+++ cloc-webapp/src-cljs/dash/dash.cljs
@@ -24,8 +24,45 @@
     om/IRender
     (render [this]
       (apply dom/div nil
-        (map-indexed repo-button state)))))
+        (map-indexed repo-button state)))))

+;; {:auth - :repo -}
+(defn repo-config-panel [state onwer]
+  (reify
+    om/IInitState
+    (init-state [_]
+      (let [mutable (atom {:state (if
+                                    (:registered current-repo)
+                                    [:registered]
+                                    [:unregistered])})]
+        (merge {:mutable mutable
+                :state-cursor (:state (om/root-cursor mutable))} state)))
+
+    om/IRenderState
+    (render-state [this state]
+      (let [cursor (:state-cursor state)
+            current-state (nth (om/observe owner (:state-cursor state)) 0)
+            auth-token (:auth state)
+            register-repo-url (format "/api/user/%s/register" (get-in state [:repo :name]))
+            register-fn (fn []
+                          (when (= current-state :unregistered)
+                            (go (let [resp (<! (http/post register-repo-url {:oauth-token auth-token
+                                                                             :json-params {}}))]
+                                   (if (= 200 (:status resp))
+                                     ;; refresh repo state
+                                     ;; TODO
+                                     (om/update! cursor [0] :registered))))))]
+
+        (case current-state
+          :registered (dom/h2 nil (get (:repo state) "full_name"))
+          :registering (dom/h2
+                          nil
+                          "registering...")
+          :unregistered (dom/button
+                          #js {:onClick register-fn}
+                          "register this repo"))))))
+
+;; {:repos - :auth -}
 (defn repo-detail-view [state owner]
   (reify
     om/IInitState
@@ -34,11 +71,11 @@

     om/IRenderState
     (render-state [this state]
-      (let [current-index (nth (om/observe owner (current-index-cur)) 0)]
-        (if (< current-index (count state))
-          (let [current-repo (nth state current-index)]
-            ;; check registered or not
-            (dom/h2 nil (get current-repo "full_name")))
+      (let [current-index (nth (om/observe owner (current-index-cur)) 0)
+            repos (:repos state)]
+        (if (< current-index (count repos))
+          (om/build repo-config-panel {:repo (nth repos current-index)
+                                       :auth (:auth state)})
           (dom/h2 nil "Add your repos"))))))

 (defn widget [state owner]
@@ -53,6 +90,7 @@
       (let [repos (vec (get-in state [:me "repos"]))]
         (dom/div nil
           (om/build repo-list-view repos)
-          (om/build repo-detail-view repos))))))
+          (om/build repo-detail-view {:repos (:me state)
+                                      :auth (:auth state)}))))))

 (om/root widget app-state {:target (.getElementById js/document "content")})


Add kill-job backpressure test

Add kill-job backpressure test

--- test/onyx/log/backpressure_generative_test.clj
+++ test/onyx/log/backpressure_generative_test.clj
@@ -118,7 +118,7 @@
     (is (= :active (get (:peer-state replica) :p1)))
     (is (= :backpressure (get (:peer-state replica) :p2)))))

-#_(deftest balanced-allocations
+(deftest backpressure-kill-job
   (checking
     "Checking balanced allocation causes peers to be evenly split"
     (times 50)
@@ -141,7 +141,6 @@
                                                                    peer-config
                                                                    job-3
                                                                    (planning/discover-tasks (:catalog job-3) (:workflow job-3)))
-                                      ;; check backpressure is off if peer may have moved
                                       {:fn :backpressure-on :args {:peer :p3}}
                                       {:fn :kill-job :args {:job job-3-id}}])
                        (assoc :bp1 [{:fn :backpressure-on :args {:peer :p1}}
@@ -150,38 +149,5 @@
           :log []
           :peer-choices []}))]
     (is (= :active (get (:peer-state replica) :p1)))
-    (is (= :backpressure (get (:peer-state replica) :p2)))
+    (is (#{:backpressure :active} (get (:peer-state replica) :p2)))
     (is (not= :idle (get (:peer-state replica) :p3)))))
-
-#_(deftest simple-backpressure
-  (checking
-    "Checking backpressure handled correctly"
-    (times 50)
-    [{:keys [entries replica log peer-choices]}
-     (log-gen/apply-entries-gen
-       (gen/return
-         {:replica {:job-scheduler :onyx.job-scheduler/balanced
-                    :messaging {:onyx.messaging/impl :dummy-messenger}}
-          :message-id 0
-          :entries (-> (log-gen/generate-join-queues (log-gen/generate-peer-ids 12))
-                       (assoc :job-1 [(api/create-submit-job-entry job-1-id
-                                                                   peer-config
-                                                                   job-1
-                                                                   (planning/discover-tasks (:catalog job-1) (:workflow job-1)))]
-                              :job-2 [(api/create-submit-job-entry job-2-id
-                                                                   peer-config
-                                                                   job-2
-                                                                   (planning/discover-tasks (:catalog job-2) (:workflow job-2)))]
-                              :job-3 [(api/create-submit-job-entry job-3-id
-                                                                   peer-config
-                                                                   job-3
-                                                                   (planning/discover-tasks (:catalog job-3) (:workflow job-3)))])
-                       (assoc :bp1 [{:fn :backpressure-on :args {:peer :p1}}
-                                    {:fn :backpressure-off :args {:peer :p1}}])
-                       (assoc :bp2 [{:fn :backpressure-on :args {:peer :p2}}]))
-          :log []
-          :peer-choices []}))]
-    ;(spit "log.edn" (pr-str log))
-    (is (empty? (apply concat (vals entries))))
-    (is (= :active (get (:peer-state replica) :p1)))
-    (is (= :backpressure (get (:peer-state replica) :p2)))))


[#2860] Refactor

[#2860] Refactor

--- backend/src/akvo/lumen/lib/visualisation/map_config.clj
+++ backend/src/akvo/lumen/lib/visualisation/map_config.clj
@@ -122,7 +122,7 @@
       (str (int (* 360 hue))))
     (catch Exception e "0")))

-(defn shape-aggregagation-extra-cols-sql [popup table-name prefix postfix]
+(defn shape-aggregation-extra-cols-sql [popup table-name prefix postfix]
   (if (= (count popup) 0)
     ""
     (str prefix
@@ -169,18 +169,11 @@
               %s
               round(_aggregation, 5) as _aggregation,
               shapefill,
-              %s.%s
+              %s
             FROM
               (
                 with temp_table as
-                  (select
-                      %s
-                      %s.rnum AS shapeRowNum,
-                      %s(pointTable.%s::decimal) AS aggregation
-                    from %s
-                    left join (select * from %s)pointTable on
-                    st_contains(%s.%s, pointTable.%s)
-                    GROUP BY %s.rnum %s)
+                  (%s)
                 select
                   %s
                   shapeRowNum,
@@ -212,22 +205,27 @@
               row_query.shapeRowNum = %s.rnum
             ;
             "
-
-            (shape-aggregagation-extra-cols-sql extra-cols "row_query" "" ",")
-            shape-table-name
-            (:geom current-layer )
-            (shape-aggregagation-extra-cols-sql extra-cols shape-table-name "" ",")
-            shape-table-name
-            aggregation-method
-            (:aggregationColumn current-layer)
-            shape-table-name
-            point-table-name
-            shape-table-name
-            (:geom current-layer)
-            (:aggregationGeomColumn current-layer)
-            shape-table-name
-            (shape-aggregagation-extra-cols-sql extra-cols shape-table-name "," "")
-            (shape-aggregagation-extra-cols-sql extra-cols "temp_table" "" ",")
+            (shape-aggregation-extra-cols-sql extra-cols "row_query" "" ",")
+            (format "%s.%s" shape-table-name (:geom current-layer ))
+            (let [cols (shape-aggregation-extra-cols-sql extra-cols shape-table-name "" ",")]
+              (format "select
+                      %s
+                      %s.rnum AS shapeRowNum,
+                      %s(pointTable.%s::decimal) AS aggregation
+                    from %s
+                    left join (select * from %s)pointTable on st_contains(%s.%s, pointTable.%s)
+                    GROUP BY %s"
+                      cols
+                      shape-table-name
+                      aggregation-method
+                      (:aggregationColumn current-layer)
+                      shape-table-name
+                      point-table-name
+                      shape-table-name
+                      (:geom current-layer)
+                      (:aggregationGeomColumn current-layer)
+                      (format "%s.rnum %s" shape-table-name cols)))
+            (shape-aggregation-extra-cols-sql extra-cols "temp_table" "" ",")
             hue
             shape-table-name
             shape-table-name)))


CMR-4095: preview gem pushed a new fix; Update CMR to refer to the new commit 2f3acec.

--- collection-renderer-lib/project.clj
+++ collection-renderer-lib/project.clj
@@ -14,7 +14,7 @@
    the hardcoded commit id during dev integration with cmr_metadata_preview project.
    The hardcoded commit id should be updated when MMT releases a new version of the gem."
   (or (System/getenv "CMR_METADATA_PREVIEW_COMMIT")
-      "de738b9"))
+      "2f3acec"))

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


memo-fn now uses an atom for its values

memo-fn now uses an atom for its values

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

--- src/conexp/util.clj
+++ src/conexp/util.clj
@@ -155,13 +155,12 @@
 (defmacro memo-fn
   "Defines memoized, anonymous function."
   [name args & body]
-  `(let [cache# (ref {})]
+  `(let [cache# (atom {})]
      (fn ~name ~args
        (if (contains? @cache# ~args)
 	 (@cache# ~args)
 	 (let [rslt# (do ~@body)]
-	   (dosync
-	    (alter cache# assoc ~args rslt#))
+	   (swap! cache# assoc ~args rslt#)
 	   rslt#)))))

 (defn inits


Added 'why' comment.

Added 'why' comment.

--- src/midje/emission/plugins/util.clj
+++ src/midje/emission/plugins/util.clj
@@ -2,4 +2,14 @@
   midje.emission.plugins.util
   (:require [midje.clojure-test-facade :as ctf]))

+
+;; The theory here was that using clojure.test output would allow text
+;; from failing *facts* to appear within the clojure.test segment of
+;; summary output. That doesn't work (though it works fine for
+;; clojure.test output). The whole rigamarole is boring and I don't
+;; care to jump through any more hoops. I say it's spinach, and I say
+;; to hell with it.
+
+;; (Don't change this to println, though. That doesn't work either.
+;; Newlines are lost.)
 (def output ctf/output)


GG & CM - Tidy up routes in core

GG & CM - Tidy up routes in core

--- src/d_cent/core.clj
+++ src/d_cent/core.clj
@@ -43,13 +43,13 @@
         "sign-out"          :sign-out
         "email"             {:get :email-capture-get}
         "users"             {:post :user-profile-post}
-        "api/v1/users"      {:post :api-user-profile-post}
         "static/"           (->Resources {:prefix "public/"})
         "objectives"        {["/create"] :objective-create
                              :post :objective-create-post
                              ["/" :id] :objective-view }
-        "api/v1/objectives"  {:post :api-objective-post
-                              ["/" :id] :objective-view}}])
+        "api/v1"            {"/users" {:post :api-user-profile-post}
+                            "/objectives" {:post :api-objective-post
+                                          ["/" :id] :objective-view}}}])

 (defn app [app-config]
   (-> (make-handler routes (some-fn handlers #(when (fn? %) %)))


thigns

thigns

--- src/tabby/local_net.clj
+++ src/tabby/local_net.clj
@@ -9,10 +9,10 @@
             [tabby.utils :as utils]))

 (defn- connect-to-peers [server]
-  (let [peers (->> (map (fn [p] (net/connect-to-peer3 @server p)) (:peers @server))
-                    (apply d/zip) ; multiple deferred's into one
-                    (deref)
-                    (into {}))]
+  (let [peers (->> (map #(net/connect-to-peer3 @server %) (:peers @server))
+                   (apply d/zip) ; multiple deferred's into one
+                   (deref)
+                   (into {}))]
     (swap! server assoc :peers peers)))

 (defn- start-server [server & rest]
@@ -65,15 +65,15 @@
     (start this))

   (kill-server [this id]
-    (-> (update-in this [:servers id] (fn [x]
-                                        (if (instance? clojure.lang.Atom x)
-                                          (swap! x stop-server)
-                                          x)))))
+    (update-in this [:servers id] (fn [x]
+                                    (if (instance? clojure.lang.Atom x)
+                                      (swap! x stop-server)
+                                      x))))
   (rez-server [this id]
-    (-> (update-in this [:servers id] (fn [x]
-                                        (if (instance? clojure.lang.Atom x)
-                                          x
-                                          (connect  (start-server x)))))))
+    (update-in this [:servers id] (fn [x]
+                                    (if (instance? clojure.lang.Atom x)
+                                      x
+                                      (connect  (start-server x))))))

   (stop-cluster [this]
     (stop this))


Testing setting DMX values.

Testing setting DMX values.

--- src/afterglow/core.clj
+++ src/afterglow/core.clj
@@ -2,7 +2,9 @@
   (:require [flatland.protobuf.core :refer :all]
             [afterglow.ola-client :as ola]
             [taoensso.timbre :as timbre])
-  (:import [ola.proto Ola$PluginListRequest Ola$PluginListReply Ola$OptionalUniverseRequest Ola$UniverseInfoReply])
+  (:import [ola.proto Ola$PluginListRequest Ola$PluginListReply Ola$OptionalUniverseRequest Ola$UniverseInfoReply
+            Ola$DmxData Ola$Ack]
+           [com.google.protobuf ByteString])
   (:gen-class))

 (timbre/refer-timbre)
@@ -11,11 +13,16 @@
 (def PluginListReply (protodef Ola$PluginListReply))
 (def OptionalUniverseRequest (protodef Ola$OptionalUniverseRequest))
 (def UniverseInfoReply (protodef Ola$UniverseInfoReply))
+(def DmxData (protodef Ola$DmxData))
+(def Ack (protodef Ola$Ack))

 (defn -main
   "Test connectivity to the OLA server by sending a few messages and pretty-printing the responses."
   [& args]
-  (let [p (protobuf PluginListRequest)]
+  #_(let [p (protobuf PluginListRequest)]
     (ola/send-request "GetPlugins" p PluginListReply #(info "Plugins" (with-out-str (clojure.pprint/pprint %)))))
-  (let [p (protobuf OptionalUniverseRequest)]
-    (ola/send-request "GetUniverseInfo" p UniverseInfoReply #(info "Universes" (with-out-str (clojure.pprint/pprint %))))))
+  #_(let [p (protobuf OptionalUniverseRequest)]
+    (ola/send-request "GetUniverseInfo" p UniverseInfoReply #(info "Universes" (with-out-str (clojure.pprint/pprint %)))))
+  ;; TODO Build DMX values in a ByteBuffer, keeping track of max one set, then copy to ByteString and send to OLA. Profit!
+  (let [p (protobuf DmxData :universe 2 :data (ByteString/copyFrom (byte-array [3 2 1 52])))]
+    (ola/send-request "UpdateDmxData" p Ack #(info "Updated DMX Data" (with-out-str (clojure.pprint/pprint %))))))


Add chunked-pmap again, via delays.

Add chunked-pmap again, via delays.

--- src/cavm/h2.clj
+++ src/cavm/h2.clj
@@ -550,6 +550,9 @@

 (def batch-size 1000)

+(defn run-delays [m]
+  (into {} (for [[k v] m] [k (if (delay? v) @v v)])))
+
 (defn- table-writer-default [dir dataset-id matrix-fn]
   (with-open [code-stmt (insert-stmt :code [:value :id :ordering :feature_id])
               position-stmt (insert-stmt :field_position
@@ -565,9 +568,13 @@
               field-seq-stmt (sequence-stmt "FIELD_IDS")
               scores-seq-stmt (sequence-stmt "SCORES_IDS")
               feature-seq-stmt (sequence-stmt "FEATURE_IDS")]
-    (let [feature-seq #(-> (feature-seq-stmt []) first :i)
-          field-seq #(-> (field-seq-stmt []) first :i)
-          scores-seq #(-> (scores-seq-stmt []) first :i)
+    ; XXX change these -seq functions to do queries returning vectors &
+    ; simplify the destructuring. Or better, stop asking the db for ids and
+    ; generate them ourselves. Getting ids is the slowest bit, even with a large
+    ; cache.
+    (let [feature-seq #(delay (-> (feature-seq-stmt []) first :i))
+          field-seq #(delay (-> (field-seq-stmt []) first :i))
+          scores-seq #(delay (-> (scores-seq-stmt []) first :i))
           ; XXX try memoization again?
           ;        score-id-fn (memoize-key (comp ahashable first) scores-seq)

@@ -579,18 +586,18 @@
                   :insert-code code-stmt
                   :insert-gene gene-stmt}
           inserts (apply concat
-                         (map #(load-field-feature
-                                 feature-seq
-                                 field-seq ; XXX pmap loses our db connection
-                                 scores-seq
-                                 dataset-id
-                                 %)
-                              (:fields (matrix-fn))))]
+                         (chunked-pmap #(load-field-feature
+                                          feature-seq
+                                          field-seq
+                                          scores-seq
+                                          dataset-id
+                                          %)
+                                       (:fields (matrix-fn))))]

       (doseq [insert-batch (partition-all batch-size inserts)]
         (jdbc/transaction
           (doseq [[insert-type values] insert-batch]
-            ((writer insert-type) values)))))))
+            ((writer insert-type) (run-delays values))))))))
 ;
 ;
 ; Table writer that updates one table at a time by writing to temporary files.


Block main thread after starting system

Block main thread after starting system

--- src/asciinema/main.clj
+++ src/asciinema/main.clj
@@ -12,4 +12,5 @@
         system   (->> (load-system [(io/resource "asciinema/system.edn")] bindings)
                       (component/start))]
     (add-shutdown-hook ::stop-system #(component/stop system))
-    (println "Started HTTP server on port" (-> system :http :port))))
+    (println "Started HTTP server on port" (-> system :http :port)))
+  @(promise))


Added a test case for ITD. Needs to have the Soot nature working though.

--- EkekoAspectJ/test/test/damp/ekeko/aspectj.clj
+++ EkekoAspectJ/test/test/damp/ekeko/aspectj.clj
@@ -69,7 +69,12 @@
   tuples-to-stringsetstring
   "For a sequence of sequences (e.g., query results), converts each inner sequence
    element to a string and returns the string representation of the resulting set of
-   converted inner sequences."
+   converted inner sequences.
+
+   Run this on the results of a working query to transform them to a string that is
+   used for the tests. For example:
+   (tuples-to-stringsetstring (damp.ekeko/ekeko [?itmethod]
+           (assumptions/intertypemethod-unused ?itmethod)))"
   [seqofseqs]
   (str (tuples-to-stringset seqofseqs)))

@@ -104,8 +109,15 @@
   (tuples-are
     (ekeko [?abpointcut ?concpointcut1 ?concpointcut2]
            (assumptions/abstractpointcut-concretized-reconcretized ?abpointcut ?concpointcut1 ?concpointcut2))
-
     "#{(\"pointcut cl.pleiad.ajlmp.testPointcuts.AbstractAspect.abstractpc1()\" \"pointcut cl.pleiad.ajlmp.testPointcuts.FirstAspect.abstractpc1()\" \"pointcut cl.pleiad.ajlmp.testPointcuts.SecondAspect.abstractpc1()\")}"))
+
+(deftest
+  intertypemethod-unused-test
+  (tuples-are
+    (ekeko [?itmethod]
+           (assumptions/intertypemethod-unused ?itmethod))
+    "#{(\"(BcelTypeMunger ResolvedTypeMunger(Method, void cl.pleiad.ajlmp.testITD.BaseClass.itdB()))\")}"))
+

 ;; Test Suite
 ;; ----------


Renamed to update-cred.

Renamed to update-cred.

--- src/cbfg/world/t2.cljs
+++ src/cbfg/world/t2.cljs
@@ -55,7 +55,7 @@
              (when (= (:status res) :ok)
                (let [res-ch (achan rq-authenticate)]
                  (aput rq-authenticate lane-state-ch
-                       (assoc m :op :lane-authenticated :res-ch res-ch
+                       (assoc m :op :update-cred :res-ch res-ch
                               :cred {:realm realm :user user}))
                  (atake rq-authenticate res-ch)))
              res)
@@ -66,7 +66,7 @@

 (defn lane-handler [actx lane-state m]
   (case (:op m)
-    :lane-authenticated
+    :update-cred
     [(assoc lane-state :cred (:cred m)) (assoc m :status :ok)]
     "realms-list"
     (let [server-state-ch (:server-state-ch m)]


indenting

indenting

--- src/celestial/jobs.clj
+++ src/celestial/jobs.clj
@@ -64,8 +64,10 @@
                     (save-status spec' :success))
                 (do (apply f args)
                     (save-status spec' :success)))
-              (catch Throwable e (error e)
-                (save-status spec' :error)))))))))
+              (catch Throwable e
+                (error e)
+                (save-status spec' :error)
+                ))))))))

 (defn jobs []
   {:reload [wf/reload 2] :destroy [wf/destroy 2] :provision [wf/puppetize 2]


mount gsutil config into agent

mount gsutil config into agent

--- src/ci3/controller.clj
+++ src/ci3/controller.clj
@@ -23,7 +23,10 @@
                             :spec {:restartPolicy "Never"
                                    :volumes
                                    [{:name "docker-sock"
-                                     :hostPath {:path "/var/run/docker.sock"}}]
+                                     :hostPath {:path "/var/run/docker.sock"}}
+                                    {:name "gsutil"
+                                     :secret {:secretName "storage"
+                                              :items {:key "boto" :path ".boto"}}}]
                                    :containers
                                    [{:name "agent"
                                      :image "eu.gcr.io/aidbox-next/ci3:latest"
@@ -31,12 +34,15 @@
                                      :args ["agent"]
                                      :volumeMounts
                                      [{:name "docker-sock"
-                                       :mountPath "/var/run/docker.sock"}]
+                                       :mountPath "/var/run/docker.sock"}
+                                      {:name "gsutil"
+                                       :mountPath "/gsutil"
+                                       :readOnly true}]
                                      :env [{:name "BUILD_ID" :value id}
+                                           {:name "BOTO_CONFIG" :value "/gsutil/.boto"}
                                            {:name "REPOSITORY" :value (get-in i [:payload :repository :full_name])}
                                            {:name "DOCKER_KEY" :valueFrom {:secretKeyRef {:name "docker-registry" :key "key"}}}
-                                           {:name "SERVICE_ACCOUNT" :valueFrom {:secretKeyRef {:name "docker-registry" :key "key"}}}]}
-                                    ]}})]
+                                           {:name "SERVICE_ACCOUNT" :valueFrom {:secretKeyRef {:name "docker-registry" :key "key"}}}]}]}})]
             (println "Create pod" pod)
             (when-not (= "Failure" (get pod "status"))
               (println "Update build:"


new card implementation and fixes

new card implementation and fixes

--- src/clj/game/cards.clj
+++ src/clj/game/cards.clj
@@ -310,6 +310,15 @@
    "Collective Consciousness"
    {:events {:rez {:req (req (= (:type target) "ICE")) :msg "draw 1 card"
                    :effect (effect (draw :runner))}}}
+
+   "Comet"
+   {:events {:play-event
+             {:optional {:prompt "Play another event?" :once :per-turn
+                         :effect (effect (resolve-ability
+                                          {:prompt "Choose an Event to play"
+                                           :choices (req (filter #(has? % :type "Event") (:hand runner)))
+                                           :msg (msg "install " (:title target))
+                                           :effect (effect (play-instant target))} card nil))}}}}

    "Compromised Employee"
    {:recurring 1
@@ -712,7 +721,9 @@

    "GRNDL Refinery"
    {:advanceable :always
-    :abilities [{:cost [:click 1] :effect (effect (gain :credit (* 4 (:advance-counter card))) (trash card))}]}
+    :abilities [{:label "Gain 4 [Credits] for each advancement token on GRNDL Refinery"
+                 :cost [:click 1] :msg (msg "gain " (* 4 (:advance-counter card)) " [Credits]")
+                 :effect (effect (trash card) (gain :credit (* 4 (:advance-counter card))))}]}

    "Haas Arcology AI"
    {:advanceable :while-unrezzed
@@ -743,6 +754,17 @@

    "Harmony Medtech: Biomedical Pioneer"
    {:effect (effect (lose :agenda-point-req 1) (lose :runner :agenda-point-req 1))}
+
+   "Hayley Kaplan: Universal Scholar"
+   {:events {:runner-install
+             {:optional {:prompt (msg "Install another " (:type target) " from Grip?") :once :per-turn
+                         :effect (req (let [type (:type target)]
+                                        (resolve-ability
+                                         state side
+                                         {:prompt (msg "Choose a " type "to install")
+                                          :choices (req (filter #(has? % :type type) (:hand runner)))
+                                          :msg (msg "install " (:title target))
+                                          :effect (effect (runner-install target))} card nil)))}}}}

    "Hedge Fund"
    {:effect (effect (gain :credit 9))}


dynamic list of tickers

dynamic list of tickers

--- src/clj/ibclj/core.clj
+++ src/clj/ibclj/core.clj
@@ -93,33 +93,34 @@
                 (reset! row {:type column }))
               (swap! row assoc column value)))

-
+(def tickers ["VXX" "SPY" "AAPL" "GOOG"])

 (defn start []
   (let [api (api-ctrl)
         c (chan)
-        vxx-ctx (contract-ctx c "VXX" com.ib.controller.Types$SecType/STK)
-        spy-ctx (contract-ctx c "SPY" com.ib.controller.Types$SecType/STK)
+        ctxs (map #(contract-ctx c % com.ib.controller.Types$SecType/STK) tickers)
+;        vxx-ctx (contract-ctx c "VXX" com.ib.controller.Types$SecType/STK)
+ ;       spy-ctx (contract-ctx c "SPY" com.ib.controller.Types$SecType/STK)
 ]
     (.connect api "localhost" 7497 5)

-    (subscribe! api vxx-ctx c)
-    (subscribe! api spy-ctx c)
+    (doseq [ctx ctxs]
+      (subscribe! api ctx c))

-    (let [tickers {"VXX" (atom {})
-                 "SPY" (atom {})} ]
+    (let [tick-data (->> tickers
+                         (map (fn [sym] [sym (atom {})]))
+                         (into {})) ]
       (go-loop []
         (let [{:keys [sym type value]} (<! c)]
           (println sym type value)
-          (update-ticker sym (tickers sym) type value)
+          (update-ticker sym (tick-data sym) type value)
           (recur))))

     (Thread/sleep (* 16 60 60 1000))

-    (unsubscribe! api vxx-ctx)
-    (unsubscribe! api spy-ctx)
-
+    (doseq [ctx ctxs]
+      (unsubscribe! api ctx))

     (.disconnect api)))


get cam-chan properly

get cam-chan properly

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@8767 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -333,7 +333,9 @@
         bursts-per-camera-channel (vec (repeat camera-channel-count burst-events))]
     (doall (loop [burst-seqs bursts-per-camera-channel i 0]
              (let [image (pop-burst-image)
-                   cam-chan (or (Long/parseLong (get-in image [:tags camera-index])) 0)
+                   cam-chan (if-let [cam-chan-str (get-in image [:tags camera-index])]
+                              (Long/parseLong cam-chan-str)
+                              0)
                    event (first (burst-seqs cam-chan))]
                (println i ": " cam-chan ": " event)
                (when (zero? i)


one recursive call to path-to down, one to go

--- src/tile_game/board.clj
+++ src/tile_game/board.clj
@@ -119,7 +119,7 @@
     '()
     (if (= tile 0)
       (path-to board 0 goal avoid)
-      (let [path (path-to board 0 goal (conj (set avoid) tile))]
+      (let [path (move-to board 0 goal (conj (set avoid) tile))]
         (if (and (empty? path) (not (tile-at-coord? board 0 goal)))
           '()
           (concat path (list tile)))))))


4Clojure (~53)

4Clojure (~53)


Go blocks

Go blocks

--- src-cljs/qcon/main.cljs
+++ src-cljs/qcon/main.cljs
@@ -114,41 +114,49 @@
     (reify
       om/IInitState
       (init-state [_]
-        (println "initializing circle state yay!!")
+        {:label (rand-int 10)}
         )
       om/IWillMount
       (will-mount [_]
         (go-loop []
-          (<! (timeout 1000))
-          (println "I'am looping")
+          (<! (timeout (+ 1000 (rand-int 200))))
+          (om/set-state! owner :label (str (rand-int 10)))
           (recur)
           )
         )
       om/IRender
       (render [_]
         (html
-         [:circle {:cx (+ 300 (* offset (Math/cos angle))) :cy (- 300 (* offset (Math/sin angle))) :r 30 :fill "#5F8"}])))
-    ))
+         (let [x (+ 300 (* offset (Math/cos angle)))
+               y (- 300 (* offset (Math/sin angle)))
+               x2 (+ 300 (* (inc offset) (Math/cos angle)))
+               y2 (- 300 (* (inc offset) (Math/sin angle)))
+               ]
+           [:g {:transform (str "translate(" x "," y ")")}
+            [:circle {:cx 0 :cy 0 :r 30 :fill "#5F8"}]
+            [:text {:x -10 :y 10 :style {:font-size "32pt"}} (str (om/get-state owner :label))]]
+))))))

 (defrecord GoBlockSlide [opts]
   Slide
   (init-slide-state [_]
-    {:default-font (:font-size opts)
-     :circles (for [n (range 5)]
-                (let [angle (* n (/ (* 2 Math/PI) 5))
-                      offset 250]
-                  (create-circle offset angle)))})
+    (let [circles (:circles opts)]
+      {:default-font (:font-size opts)
+       :circles (for [n (range circles)]
+                  (let [angle (* n (/ (* 2 Math/PI) circles))
+                        offset 250]
+                    (create-circle offset angle)))}))

   (render-slide [_ data owner]
     (let [default-font (om/get-state owner :default-font)]
       [:div
        [:svg {:version "1.1" :width 600 :height 600}
-
         [:g
-         [:rect {:x 0 :y 0 :width 600 :height 600 :fill "#222"}]
+         [:rect {:x 0 :y 0 :width 600 :height 600 :fill "#292"}]
          (for [c (om/get-state owner :circles)]
            (om/build c data))
-         [:text {:x 20 :y 20 :fill "#fdf"} (str "sin:" (Math/sin (/ Math/PI 6)))]
+
+         #_[:text {:x 20 :y 120 :fill "#f00" :style {:font-size "80pt"}} "Hello Ruben, buon compleano!!!"]
          ]
         ]])))

@@ -188,12 +196,16 @@
            :custom (AltsSlide. {:font-size "30pt"})}

           {:subtitle "go blocks"
-           :custom (GoBlockSlide. {:font-size "30pt"})}
+           :custom (GoBlockSlide. {:font-size "80pt" :circles 5})}
           ;; Show result of race in alts! between a channel and a timeout

           ;; Go blocks

-          {:title "When?"}]}))
+          {:title "When?"}
+
+          {:title "Hello Ruben"}
+
+          {:title "END?"}]}))

 (defn source-snippet [data owner fname]
   (reify
@@ -234,7 +246,6 @@
                 :style {:width "100%"
                         :height "100%"}}]

-
          [:section {:class (str "slide " (:class data))}
           [:div {:class "deck-slide-scaler"}
            (when-let [bg (:background data)]
@@ -308,7 +319,14 @@
       (goog.events.listen
        js/document "keydown"
        (fn [e]
+         (println (.-keyCode e))
+
          (cond
+          (= (.-keyCode e) 49)
+          (do
+            (println "I am going to the beginning of the presentation!")
+            (om/update! app :current-slide 0))
+
           (or (= (.-keyCode e) 37)
               (= (.-keyCode e) kc/PAGE_UP))
           (when (pos? (:current-slide @app))


refactor setting SQL params into two functions for vector and map

--- src/asphalt/internal.clj
+++ src/asphalt/internal.clj
@@ -26,6 +26,17 @@

 ;; ----- error reporting -----
+
+
+(defn expected
+  "Throw illegal input exception citing `expectation` and what was `found` did not match. Optionally accept a predicate
+  fn to test `found` before throwing the exception."
+  ([expectation found]
+    (throw (IllegalArgumentException.
+             (format "Expected %s, but found (%s) %s" expectation (class found) (pr-str found)))))
+  ([pred expectation found]
+    (when-not (pred found)
+      (expected expectation found))))

 (defn illegal-arg
@@ -302,95 +313,54 @@
       (unexpected supported-sql-types param-type))))

-(defn set-params!
-  ([^PreparedStatement prepared-statement params]
-    (cond
-      (vector? params) (let [param-count (count params)]
-                         (loop [i (int 0)]
-                           (when (< i param-count)
-                             (let [j (unchecked-inc i)]
-                               (set-param-value! prepared-statement j (get params i))
-                               (recur j)))))
-      (nil? params)    nil
-      :otherwise       (unexpected "params vector" params)))
-  ([^PreparedStatement prepared-statement ^objects param-keys ^bytes param-types params]
-    (cond
-      (map? params)    (let [param-count (alength param-keys)]
-                         (loop [i (int 0)]
-                           (when (< i param-count)
-                             (let [param-key  (aget param-keys i)
-                                   param-type (aget param-types i)
-                                   j (unchecked-inc i)]
-                               (if (contains? params param-key)
-                                 (try
-                                   (set-param-value! prepared-statement j param-type (get params param-key))
-                                   (catch RuntimeException e
-                                     (throw (ex-info (str "Error setting parameter #" j " (" param-key "): "
-                                                       (.getMessage e))
-                                              {:param-index j :param-key param-key} e))))
-                                 (illegal-arg "No value found for key:" param-key "in" (pr-str params)))
-                               (recur j)))))
-      (vector? params) (let [types-count (alength param-keys)
-                             param-count (count params)]
-                         (loop [i (int 0)]
-                           (when (< i param-count)
-                             (let [j (unchecked-inc i)]
-                               (if (< i types-count)
-                                 (let [param-key  (aget param-keys i)
-                                       param-type (aget param-types i)]
-                                   (try
-                                     (set-param-value! prepared-statement j param-type (get params i))
-                                     (catch RuntimeException e
-                                       (throw (ex-info (str "Error setting parameter #" j " (" param-key "): "
-                                                         (.getMessage e))
-                                                {:param-index j :param-key param-key} e)))))
-                                 (try
-                                   (set-param-value! prepared-statement j t/sql-nil (get params i))
-                                   (catch RuntimeException e
-                                     (throw (ex-info (str "Error setting parameter #" j ": " (.getMessage e))
-                                              {:param-index j} e)))))
-                               (recur j)))))
-      (nil? params)    nil
-      :otherwise       (unexpected "map or vector" params)))
-  ([^PreparedStatement prepared-statement #_vector param-keys #_vector param-types _ params]
-    (cond
-      (map? params)    (let [param-count (count param-keys)]
-                         (loop [i (int 0)]
-                           (when (< i param-count)
-                             (let [param-key  (get param-keys i)
-                                   param-type (get param-types i)
-                                   j (unchecked-inc i)]
-                               (if (contains? params param-key)
-                                 (try
-                                   (set-param-value! prepared-statement j param-type (get params param-key))
-                                   (catch RuntimeException e
-                                     (throw (ex-info (str "Error setting parameter #" j " (" param-key "): "
-                                                       (.getMessage e))
-                                              {:param-index j :param-key param-key} e))))
-                                 (illegal-arg "No value found for key:" param-key "in" (pr-str params)))
-                               (recur j)))))
-      (vector? params) (let [types-count (count param-keys)
-                             param-count (count params)]
-                         (loop [i (int 0)]
-                           (when (< i param-count)
-                             (let [j (unchecked-inc i)]
-                               (if (< i types-count)
-                                 (let [param-key  (get param-keys i)
-                                       param-type (get param-types i)]
-                                   (try
-                                     (set-param-value! prepared-statement j param-type (get params i))
-                                     (catch RuntimeException e
-                                       (throw (ex-info (str "Error setting parameter #" j " (" param-key "): "
-                                                         (.getMessage e))
-                                                {:param-index j :param-key param-key} e))))
-                                   (try
-                                     (set-param-value! prepared-statement j t/sql-nil (get params i))
-                                     (catch RuntimeException e
-                                       (throw (ex-info (str "Error setting parameter #" j ": " (.getMessage e))
-                                                {:param-index j} e))))))
-                               (recur j)))))
-      (nil? params)    nil
-      :otherwise       (unexpected "map or vector" params))))
+(defn set-params-vec!
+  "Given a prepared statement and params vector, set the params in a positional order."
+  ([^PreparedStatement prepared-statement params-vec]
+    (let [param-count (count params-vec)]
+      (loop [i (int 0)]
+        (when (< i param-count)
+          (let [j (unchecked-inc i)]
+            (set-param-value! prepared-statement j (get params-vec i))
+            (recur j))))))
+  ([^PreparedStatement prepared-statement param-types params-vec]
+    (let [types-count (count param-types)
+          param-count (count params-vec)]
+      (loop [i (int 0)]
+        (when (< i param-count)
+          (let [j (unchecked-inc i)]
+            (if (< i types-count)
+              (let [param-type (get param-types i)]
+                (try
+                  (set-param-value! prepared-statement j param-type (get params-vec i))
+                  (catch RuntimeException e
+                    (throw (ex-info (str "Error setting parameter #" j ": "
+                                      (.getMessage e))
+                             {:param-index j} e)))))
+              (try
+                (set-param-value! prepared-statement j t/sql-nil (get params-vec i))
+                (catch RuntimeException e
+                  (throw (ex-info (str "Error setting parameter #" j ": " (.getMessage e))
+                           {:param-index j} e)))))
+            (recur j)))))))
+
+
+(defn set-params-map!
+  [^PreparedStatement prepared-statement param-keys param-types params]
+  (let [param-count (count param-keys)]
+    (loop [i (int 0)]
+      (when (< i param-count)
+        (let [param-key  (get param-keys i)
+              param-type (get param-types i)
+              j (unchecked-inc i)]
+          (if (contains? params param-key)
+            (try
+              (set-param-value! prepared-statement j param-type (get params param-key))
+              (catch RuntimeException e
+                (throw (ex-info (str "Error setting parameter #" j " (" param-key "): "
+                                  (.getMessage e))
+                         {:param-index j :param-key param-key} e))))
+            (illegal-arg "No value found for key:" param-key "in" (pr-str params)))
+          (recur j))))))

 ;; ----- result-set stuff -----
@@ -606,7 +576,11 @@
   ;;=========
   (get-sql    [template] (.-sql template))
   (set-params [template ^PreparedStatement prepared-statement params]
-    (set-params! prepared-statement ^objects (.-param-keys template) ^bytes (.-param-types template) params))
+    (cond
+      (map? params)    (set-params-map! prepared-statement (.-param-keys template) (.-param-types template) params)
+      (vector? params) (set-params-vec! prepared-statement (.-param-types template) params)
+      (nil? params)    nil
+      :otherwise       (expected "map, vector or nil" params)))
   (read-col   [template ^ResultSet result-set ^long column-index]
     (let [^bytes types (.-result-types template)]
       (if (pos? (alength types))
@@ -623,10 +597,17 @@
   ;;===========
   (get-sql    [m] (:sql m))
   (set-params [m ^PreparedStatement prepared-statement params]
-    (if-let [param-keys (:param-keys m)]
-      (let [param-types (or (:param-types m) (no-param-type-vec (count param-keys)))]
-        (set-params! prepared-statement param-keys param-types :vector params))
-      (set-params! prepared-statement params)))
+    (cond
+      (map? params)    (if-let [param-keys (:param-keys m)]
+                         (let [param-types (or (:param-types m) (no-param-type-vec (count param-keys)))]
+                           (set-params-map! prepared-statement param-keys param-types params))
+                         (expected "key :param-keys to be present" m))
+      (vector? params) (if-let [param-types (or (:param-types m) (when-let [param-keys (:param-keys m)]
+                                                                   (no-param-type-vec (count param-keys))))]
+                         (set-params-vec! prepared-statement param-types params)
+                         (set-params-vec! prepared-statement params))
+      (nil? params)    nil
+      :otherwise       (expected "map, vector or nil" params)))
   (read-col   [m ^ResultSet result-set ^long column-index]
     (if-let [types (:result-types m)]
       (let [column-type (get types (unchecked-dec column-index))]
@@ -640,7 +621,10 @@
   String
   ;;====
   (get-sql    [sql] sql)
-  (set-params [sql ^PreparedStatement prepared-statement params] (set-params! prepared-statement params))
+  (set-params [sql ^PreparedStatement prepared-statement params] (if (vector? params)
+                                                                   (set-params-vec! prepared-statement params)
+                                                                   (when-not (nil? params)
+                                                                     (expected "a params vector" params))))
   (read-col   [sql ^ResultSet result-set ^long column-index]     (read-column-value result-set column-index))
   (read-row   [sql ^ResultSet result-set ^long column-count]     (read-columns result-set column-count)))


Added support for multi-arguments including collections to pip-install

--- src/arl_docker/util.clj
+++ src/arl_docker/util.clj
@@ -86,6 +86,6 @@

 (defn pip-install
   "Install a collection of python packages using pip"
-  [items]
+  [& items]
   (dsl/run
-    (str "pip install " (str/join " " items)))
+    (str "pip install " (str/join " " (flatten items)))))


making ebs not required

making ebs not required

--- src/aws/validations.clj
+++ src/aws/validations.clj
@@ -36,7 +36,7 @@
      :instance-type #{:required :String} :key-name #{:required :String}
      :endpoint #{:required :String} :volumes #{:volume*}
      :security-groups #{:Vector :group*} :availability-zone #{:String}
-     :ebs-optimized #{:required :Boolean}
+     :ebs-optimized #{:Boolean}
     }})

@@ -50,7 +50,7 @@
   {:instance-type #{:required :String} :key-name #{:required :String}
    :placement {:availability-zone #{:String}} :security-groups #{:Vector :group*}
    :min-count #{:required :Integer} :max-count #{:required :Integer}
-   :ebs-optimized #{:required :Boolean}
+   :ebs-optimized #{:Boolean}
    })

 (defn provider-validation [{:keys [aws] :as spec}]


Extracted subject-count Function

Extracted subject-count Function

--- src/lens/routes.clj
+++ src/lens/routes.clj
@@ -11,7 +11,8 @@
             [lens.util :as util]
             [lens.api :as api]
             [clojure.core.async :refer [timeout]]
-            [clojure.core.reducers :as r])
+            [clojure.core.reducers :as r]
+            [clojure.set :as set])
   (:import [java.util UUID]))

 (def page-size 50)
@@ -532,6 +533,11 @@
        (map-vals #(->> (group-by sex %)
                        (map-vals count)))))

+(defn subject-count [visits]
+  (->> (r/map :visit/subject visits)
+       (into #{})
+       (count)))
+
 (defn query [db expr]
   (let [visits (api/query db (edn/read-string expr))]
     (ring-resp/response
@@ -540,9 +546,7 @@
        :visit-count-by-study-event (visit-count-by-study-event visits)
        :visit-count-by-age-decade-and-sex
        (visit-count-by-age-decade-and-sex visits)
-       :subject-count (->> (r/map :visit/subject visits)
-                           (into #{})
-                           (count))})))
+       :subject-count (subject-count visits)})))

 ;; ---- Snapshots -------------------------------------------------------------