Cleanup cljs unify! docstring; don't call enter/update/exit fns unless they're provided as kwargs.

--- src/cljs/c2/core.cljs
+++ src/cljs/c2/core.cljs
@@ -44,8 +44,16 @@
 (defmulti unify!
   "Given container, data, and mapping-fn, calls (mapping datum idx) for each datum and appends resulting elements to container.
 Automatically updates elements mapped to data according to key-fn (defaults to index) and removes elements that don't match.
-Scoped to selector kwarg, if given, otherwise applies to all container's children.
-Optional enter, update, and exit functions called before DOM is changed; return false to prevent default behavior.
+Scoped to :selector kwarg if given, otherwise applies to all container's children.
+
+Optional kwargs fns (args prefixed with $ are live DOM nodes):
+
+  (enter d idx $node)
+  (update d idx $old new)
+  (exit d idx $node)
+
+called before DOM changed; return false to prevent default behavior.
+
 If data implements IWatchable, DOM will update when data changes."
   (fn [container data mapping & kwargs]
     (cond (satisfies? cljs.core.IWatchable data) :atom
@@ -68,28 +76,15 @@
   [container data mapping & {:keys [selector key-fn pre-fn post-fn update exit enter
                                     defer-attr force-update]
                              :or {key-fn (fn [d idx] idx)
-                                  enter  (fn [d idx new-node]
-                                           #_(p "no-op enter called")
-                                           true)
-                                  update (fn [d idx old-node new-node]
-                                           #_(p "no-op update called")
-                                           true)
-                                  exit   (fn [d idx old-node]
-                                           #_(p "default remove called")
-                                           true)
                                   defer-attr false}}]

   (let [container (select container)
-        data (if pre-fn
-               (pre-fn data)
-               data)
-
-
-        existing-nodes-by-key (into {} (map-indexed (fn [i node]
+        data (if pre-fn (pre-fn data) data)
+        existing-nodes-by-key (into {} (map-indexed (fn [idx node]
                                                       (let [datum (read-data node)]
-                                                        [(key-fn datum i)  {:node node
-                                                                            :idx i
-                                                                            :datum datum}]))
+                                                        [(key-fn datum idx) {:node node
+                                                                             :idx idx
+                                                                             :datum datum}]))
                                                     (if selector
                                                       (select-all selector container)
                                                       (children container))))]
@@ -98,7 +93,8 @@
     (doseq [k (set/difference (set (keys existing-nodes-by-key))
                               (set (map key-fn data (range))))]
       (let [{:keys [node idx datum]} (existing-nodes-by-key k)]
-        (if (exit datum idx node)
+        (when (or (nil? exit)
+                  (exit datum idx node))
           (remove! node))))

@@ -110,19 +106,20 @@
           (do
             ;;append it (effectively moving it to the correct index in the container)
             (append! container (:node old))
-            ;;If its data is not equal to the new data, update it
-            (if (or (not= d (:datum old)) force-update)
-              (if (update d idx (:node old) new-node)
-                (attach-data (merge-dom! (:node old) new-node
-                                         :defer-attr defer-attr)
-                             d))))
+            (when (and (or (not= d (:datum old))
+                           force-update)
+                       (or (nil? update)
+                           (update d idx (:node old) new-node)))
+              (attach-data (merge-dom! (:node old) new-node
+                                       :defer-attr defer-attr)
+                           d)))

-          ;;instantiate new node on the DOM so it can be manipulated in the user-specified `enter` fn.
-          (let [new-dom-node (append! "body" new-node)]
-            (attach-data new-dom-node d)
-            (if (enter d idx new-dom-node)
-              (append! container new-dom-node) ;;move new node to container
-              (remove! new-dom-node))))))
+          (let [$new-node (-> new-node
+                              (build-dom-elem)
+                              (attach-data d))]
+            (when (or (nil? enter)
+                      (enter d idx $new-node))
+              (append! container $new-node))))))

     ;;Run post-fn, if it was given
     (if post-fn


simpler player-input

simpler player-input

--- src/tic_tac_toe/tic_tac_toe.clj
+++ src/tic_tac_toe/tic_tac_toe.clj
@@ -60,7 +60,7 @@

 (defn player-input []
   (print "Where to put your sign? ")
-  (-> *in* java.io.BufferedReader. line-seq first chars-seq map-to-ints))
+  (-> (read-line) chars-seq map-to-ints))

 ;; (map-to-ints (split "00" #""))


Remove wrong docstring.

Remove wrong docstring.

--- src/uxbox/main/data/shapes.cljs
+++ src/uxbox/main/data/shapes.cljs
@@ -146,7 +146,6 @@
       (update-in state [:shapes-by-id sid] geom/absolute-move opts))))

 (defn update-text
-  "Update the start position coordenate of the shape."
   [sid {:keys [content]}]
   {:pre [(string? content)]}
   (reify


Adding a todo comment

Adding a todo comment

--- src/vignette/util/thumbnail.clj
+++ src/vignette/util/thumbnail.clj
@@ -78,7 +78,7 @@
   (if (and (= "webp" (get-in thumb-map [:options :format]))
           (not (webp-supported? (thumbnail-path thumb-map))))
     (do
-      (log/info "webp-override-remove" (select-keys thumb-map [:original :options]))
+      (log/info "webp-override-remove" (select-keys thumb-map [:original :options])) ; todo: do we need it?
       (update-in thumb-map [:options] dissoc :format))
       thumb-map)
 )


Fix for react v15

Fix for react v15

--- src/discuss/find.cljs
+++ src/discuss/find.cljs
@@ -91,4 +91,4 @@
         (dom/div nil
                  (dom/h6 nil (str "Received " (count results) " entries."))
                  (apply dom/div nil
-                        (om/build-all item-view results)))))))+                        (map #(om/build item-view (lib/merge-react-key %)) results)))))))


organize specs

organize specs

--- src/cljs/daveconservatorie/audio/core.cljs
+++ src/cljs/daveconservatorie/audio/core.cljs
@@ -24,9 +24,16 @@

 (s/def ::context #(instance? AudioContext %))
 (s/def ::node #(instance? js/AudioNode %))
-(s/def ::node-gen (s/fspec :args #{[]} :ret ::node))
+(s/def ::node-gen (s/fspec :args (s/cat) :ret ::node))
 (s/def ::buffer #(instance? js/AudioBuffer %))
 (s/def ::time (s/and number? pos?))
+(s/def ::sound-point
+  (s/and (s/keys :req [::time] :opt [::node ::node-gen])
+         #(some #{::node ::node-gen} (keys %))))
+(s/def ::sound-point-chan (ss/chan-of ::sound-point))
+(s/def ::items-list
+  (s/+ (s/cat :node-gens (s/+ ::node-gen)
+              :interval ::time)))

 (defn decode-audio-data [buffer]
   {:pre [(s/valid? ::ss/array-buffer buffer)]}
@@ -105,10 +112,6 @@
 (s/fdef play
   :args (s/cat :sound ::sound-point))

-(s/def ::sound-point
-  (s/and (s/keys :req [::time] :opt [::node ::node-gen])
-         #(some #{::node ::node-gen} (keys %))))
-
 ;; node-spec

 ;(defmulti node-spec-type first)
@@ -136,14 +139,10 @@
 ;
 ;(s/def ::node-spec (s/multi-spec node-spec-type first))

-(s/def ::items-list
-  (s/+ (s/cat :node-gens (s/+ ::node-gen)
-              :interval ::time)))
-
 (defn loop-chan [items start chan]
   {:pre [(s/valid? ::items-list items)
          (s/valid? ::time start)
-         (s/valid? (ss/chan-of ::sound-point) chan)]}
+         (s/valid? ::sound-point-chan chan)]}
   (go
     (loop [i 0
            t start]
@@ -161,8 +160,8 @@
 (s/fdef loop-chan
   :args (s/cat :items ::items-list
                :start ::time
-               :chan (ss/chan-of ::sound-point))
-  :ret (ss/chan-of ::sound-point))
+               :chan ::sound-point-chan)
+  :ret ::sound-point-chan)

 (defn consume-loop [interval chan]
   (go
@@ -172,4 +171,10 @@
         (let [cur-time (current-time)]
           (if-not (< (- time cur-time) (* interval 2))
             (<! (async/timeout (* interval 1000)))))
-        (recur)))))
+        (recur))))
+  chan)
+
+(s/fdef consume-loop
+  :args (s/cat :interval ::time
+               :chan ::sound-point-chan)
+  :ret ::sound-point-chan)


Really fix previous bug.

Really fix previous bug.

--- src/cljs/hatnik/web/client/components.cljs
+++ src/cljs/hatnik/web/client/components.cljs
@@ -102,7 +102,7 @@
              (dom/button
               #js {:className "btn btn-default"
                    :type "button"
-                   :onClick nil #(pmenu/show {:project-id id
+                   :onClick #(pmenu/show {:project-id id
                                           :name name})}
               (dom/span #js {:className "glyphicon glyphicon-pencil pull-right"})))))


fixed node list statistics if agent not running or statistics cache empty

--- src/cljs/swarmpit/component/node/list.cljs
+++ src/cljs/swarmpit/component/node/list.cljs
@@ -70,12 +70,15 @@
        [:td "MEMORY"]]
       [:tr
        [:td (str cpu " " (clojure.contrib.inflect/pluralize-noun cpu "core"))]
-       [:td (humanize/filesize disk-bytes :binary false)]
+       [:td (if (some? disk-bytes)
+              (humanize/filesize disk-bytes :binary false)
+              "-")]
        [:td (humanize/filesize memory-bytes :binary false)]]
-      [:tr.node-progress-table-usage
-       (node-item-usage (get-in item [:stats :cpu :usedPercentage]))
-       (node-item-usage (get-in item [:stats :disk :usedPercentage]))
-       (node-item-usage (get-in item [:stats :memory :usedPercentage]))]]]))
+      (when (some? (:stats item))
+        [:tr.node-progress-table-usage
+         (node-item-usage (get-in item [:stats :cpu :usedPercentage]))
+         (node-item-usage (get-in item [:stats :disk :usedPercentage]))
+         (node-item-usage (get-in item [:stats :memory :usedPercentage]))])]]))

 (defn- node-item
   [item]


Added support for cloud cover aql search.

--- src/cmr/search/services/aql/conversion.clj
+++ src/cmr/search/services/aql/conversion.clj
@@ -204,6 +204,12 @@
   [concept-type element]
   (qm/map->EquatorCrossingLongitudeCondition (element->num-range concept-type element)))

+(defmethod element->condition :num-range
+  [concept-type element]
+  (let [condition-key (elem-name->condition-key concept-type (:tag element))
+        numeric-range-map (assoc (element->num-range concept-type element) :field condition-key)]
+    (qm/map->NumericRangeCondition numeric-range-map)))
+
 (def aql-query-type->concept-type
   "Mapping of AQL query type to search concept type"
   {"collections" :collection


Add Java type hints

Add Java type hints

--- src-clj/acha/git_parser.clj
+++ src-clj/acha/git_parser.clj
@@ -40,7 +40,7 @@
       (.setNoCheckout true))
     (.call)))

-(defn load-repo [url]
+(defn load-repo ^Git [url]
   (let [path (data-dir url)]
     (if (.exists (io/as-file path))
       (doto (jgit.p/load-repo path)
@@ -71,8 +71,8 @@

 (def commit-list jgit.q/rev-list)

-(defn- complete-id [ent side reader]
-  (let [id (.getId ent side)]
+(defn- complete-id [^DiffEntry entry side ^ObjectReader reader]
+  (let [id (.getId entry side)]
     (if (.isComplete id)
       id
       (when-first [obj-id (.resolve reader id)]
@@ -119,15 +119,15 @@
       (finally
         (.close stream)))))

-(defn- open-diff [ent side reader]
-  (let [mode (.getMode ent side)]
+(defn- open-diff [^DiffEntry entry side ^ObjectReader reader]
+  (let [mode (.getMode entry side)]
     (when (and (not= FileMode/MISSING mode)
                (= Constants/OBJ_BLOB (.getObjectType mode)))
-      (let [id (complete-id ent side reader)
-            path (.getPath ent side)]
+      (let [id (complete-id entry side reader)
+            path (.getPath entry side)]
         (load-obj id path reader)))))

-(defn- parse-diff-changes [entry alg reader]
+(defn- parse-diff-changes [^DiffEntry entry ^DiffAlgorithm alg ^ObjectReader reader]
   (when-not (or (= FileMode/GITLINK (.getOldMode entry))
                 (= FileMode/GITLINK (.getNewMode entry))
                 (nil? (.getOldId entry))
@@ -151,7 +151,7 @@
      :new-file (merge new-file (:new-file diff-changes))
      :diff (:diff diff-changes)}))

-(defn- tree-iterator [^RevCommit commit ^ObjectReader reader]
+(defn- tree-iterator ^AbstractTreeIterator [^RevCommit commit ^ObjectReader reader]
   (if commit
     (doto (CanonicalTreeParser.) (.reset reader (.getTree commit)))
     (EmptyTreeIterator.)))


update with multimethod

update with multimethod

--- src/elm_cljs/app.cljs
+++ src/elm_cljs/app.cljs
@@ -13,36 +13,37 @@

 ;; --- Actions ------------------------------------------------

-(defprotocol Action
-  (run [this model]))
+(defrecord Increment [])

-(defrecord Increment []
-  Action
-  (run [this model]
-    [(update model :counter inc) nil]))
+(defrecord Decrement [])

-(defrecord Decrement []
-  Action
-  (run [this model]
-    [(update model :counter dec) nil]))
+(defrecord SetCounter [value])

-(defrecord SetCounter [value]
-  Action
-  (run [this model]
-    [(assoc model :counter value) nil]))
+(defrecord GenerateRandom [])

-(defrecord GenerateRandom []
-  Action
-  (run [this model]
-    [model (->Random 50 ->SetCounter)]))
+(defrecord Type [text])

-(defrecord Type [text]
-  Action
-  (run [this model]
-    [(assoc model :text (:text this)) nil]))
+;; --- Update ------------------------------------------------

-(defn update [model message]
-  (run message model))
+(defmulti update-state (fn [model message] (type message)))
+
+(defmethod update-state Increment [model message]
+  [(update model :counter inc) nil])
+
+(defmethod update-state Decrement [model message]
+  [(update model :counter dec) nil])
+
+(defmethod update-state SetCounter [model message]
+  [(assoc model :counter (:value message)) nil])
+
+(defmethod update-state GenerateRandom [model message]
+  [model (->Random 50 ->SetCounter)])
+
+(defmethod update-state Type [model message]
+  [(assoc model :text (:text message)) nil])
+
+(defmethod update-state :default [model message]
+  [model nil])

 ;; --- View ------------------------------------------------

@@ -62,4 +63,4 @@

 (def root (.getElementById js/document "app"))

-(main model view update root)
+(main model view update-state root)


Removed unused functions related to finding and expanding recurring events since I discovered the singleEvents property of the calendar api.

--- src/gcal2org/core.clj
+++ src/gcal2org/core.clj
@@ -78,37 +78,6 @@
   [events]
   (let [items (.getItems events)]
     (map event-to-map items)))
-
-(defn parse-calendar-items
-  "Turns a list of calendar events into clojure maps."
-  [items]
-  (map event-to-map items))
-
-(defn range-predicate [event min-time max-time]
-  (let [interval (t/interval min-time max-time)]
-    (or (t/within? interval (:start event))
-        (t/within? interval (:end event)))))
-
-(defn remove-events-out-of-range [events min-time max-time]
-  (filter #(range-predicate % min-time max-time) events))
-
-(defn get-recurring-events [client calendar-id recurring-id min-time max-time]
-  (.. client
-      events
-      (instances calendar-id recurring-id)
-      (setTimeMax (joda-to-date-time max-time))
-      (setTimeMin (joda-to-date-time min-time))
-      execute))
-
-(defn expand-recurring-events [events client calendar-id min-time max-time]
-  (map #(if (:recurring-id %)
-          (-> (get-recurring-events client calendar-id (:recurring-id %) min-time max-time)
-              parse-calendar-events)
-          %)
-       events))
-
-(defn get-calendar-ids [#^CalendarList calendar-list]
-  (map #(.getId %) (.getItems calendar-list)))

 (defn create-file-header [category]
   (format "#+TITLE: Google Calendar Entries


fix copy to not refer to a master password

--- src/metabase/driver/redshift.clj
+++ src/metabase/driver/redshift.clj
@@ -74,11 +74,11 @@
                                              :placeholder  "toucan_sightings"
                                              :required     true}
                                             {:name         "user"
-                                             :display-name "Master username"
+                                             :display-name "Database username"
                                              :placeholder  "cam"
                                              :required     true}
                                             {:name         "password"
-                                             :display-name "Master user password"
+                                             :display-name "Database user password"
                                              :type         :password
                                              :placeholder  "*******"
                                              :required     true}])})


Mes 'o changes

Mes 'o changes

I managed to complect whitespace changes with significant code changes
so this commit is a bunch of garbage.

--- src/oxcart.clj
+++ src/oxcart.clj
@@ -13,8 +13,8 @@
    :author "Reid McKenzie"}
   (:refer-clojure :exclude [eval macroexpand-1 macroexpand load compile])
   (:require [clojure.tools.analyzer.jvm :as ana.jvm]
-            [clojure.tools.analyzer
-             :refer [macroexpand-1
+            [clojure.tools.analyzer
+             :refer [macroexpand-1
                      macroexpand]
              :as ana]
             [clojure.tools.emitter.jvm.emit :as e]
@@ -26,7 +26,7 @@
   (:import clojure.lang.IFn))

-(def root-directory
+(def root-directory
   @#'clojure.core/root-directory)

 (def ^:dynamic *load-configuration*
@@ -58,12 +58,15 @@
   appropriate bytecode and returns a computed result side effecting
   the invoking Clojure runtime."

-  ([form]
-     (eval form
+  ([form]
+     (eval form
            (or *load-configuration*
                {:debug? false})))

-  ([form {:keys [debug? ast env classloader] :as options}]
+  ([form {:keys [debug? exec? ast env classloader]
+          :or   {exec? true
+                 debug? false}
+          :as options}]
      (let [defs-ast  (:defs ast)
            forms-ast (:forms ast)
            mform     (binding [macroexpand-1 ana.jvm/macroexpand-1]
@@ -84,43 +87,61 @@

            (doseq [expr statements]
              (eval expr options))
-
+
            (eval ret options))

          ;; bare expression handling
          ;;-----------------------------
-         ;; FIXME:
+         ;; FIXME: Repeated analysis
          ;;   Is there some way that I can merge this so that only one
          ;;   ana.jvm/analyze invocation is required? I think the
          ;;   answer is no, but it'd be nice.
+
+         ;; FIXME: Closed over defs
+         ;;  This is gonna be invalid for a whole lot of code. Lambda
+         ;;  lifting is gonna come into play here methinks. I have to
+         ;;  get this working so that closed over defs are supported,
+         ;;  eg:
+         ;;
+         ;;  (let [x 3]
+         ;;    (def foo [y]
+         ;;         (+ x y)))
+         ;;
+         ;; This issue also impacts multimethods which are implemented
+         ;; with closed over defs.
+
          (let [ast   (binding [ana/macroexpand-1 ana.jvm/macroexpand-1
                                ana/create-var    ana.jvm/create-var
                                ana/parse         ana.jvm/parse
                                ana/var?          var?]
-                       (ana.jvm/analyze mform
-                                        (or env (ana.jvm/empty-env))))
-               r     (-> `(^:once fn* [] ~mform)
-                         (ana.jvm/analyze (or env (ana.jvm/empty-env)))
-                         (e/emit {:debug?       debug?
-                                  :class-loader (or classloader
-                                                    (clojure.lang.RT/makeClassLoader))}))
-               class (-> r meta :class)]
-
+                       (ana.jvm/analyze mform
+                                        (or env (ana.jvm/empty-env))))]
+
            ;; the accumulator for the whole read program
            (when (and forms-ast
                       (atom? forms-ast))
              (swap! forms-ast conj ast))
-
+
            ;; the accumulator for defs to structure
            (when (and defs-ast
                       (atom? defs-ast)
                       (patern/def? ast))
-             (swap! defs-ast assoc
+             (swap! defs-ast assoc
                     (patern/def->symbol ast)
                     ast))

-           ;; and run the code for side-effects
-           (.invoke ^IFn (.newInstance ^Class class)))))))
+           ;; FIXME: Eval for side effects
+           ;;  Running code for side-effects may be something that I
+           ;;  need to conditionalize, see "Closed over defs"
+
+           ;; and run the code for side-effects.
+           (let [r     (-> `(^:once fn* [] ~mform)
+                           (ana.jvm/analyze (or env (ana.jvm/empty-env)))
+                           (e/emit {:debug?       debug?
+                                    :class-loader (or classloader
+                                                      (clojure.lang.RT/makeClassLoader))}))
+                 class (-> r meta :class)]
+             (.invoke ^IFn (.newInstance ^Class class))))))))

 (defn load
@@ -148,7 +169,8 @@
   ([res]
      (load res
            (or *load-configuration*
-               {:debug? false})))
+               {:debug? false
+                :exec?  true})))

   ([res {:keys [debug?] :as options}]
      (let [p      (str (apply str (replace {\. \/ \- \_} res)) ".clj")
@@ -166,8 +188,6 @@
          (loop []
            (let [form (r/read reader false eof)]
              (when (not= eof form)
-               (when debug?
-                 (println *ns* "|" form))
                (eval form options)
                (recur))))))
      nil))
@@ -184,14 +204,14 @@
   config-map:
    `:passes` is a sequence of functions constituting an optimization
     configuration. These functions must be
-    (λ form-seq → def-map → settings → whole-ast)
-    and pure. It is expected but not enforced that passes may not
+    (λ form-seq → def-map → settings → form-seq)
+    and pure. It is expected but not enforced that passes may not
     emit nodes which an emitter does not support. If passes is empty
     no program transformations will be done and the emitter will be
     invoked directly.

     `:emitter` is a single function which is λ form-seq → nil which
-    is expected to emit the appropriate classfiles.
+    is expected to emit the appropriate classfiles as side effects.

     `:settings` may be a map containing `:passes` and `:emitter`,
     these being option maps which will be applied respectively at the
@@ -209,26 +229,33 @@
             (fn? emitter)]}
      (let [forms (atom [])
            defs  (atom {})
-           config {:debug false
+           config {:debug? false
+                   :exec?  true
                    :ast {:forms forms
                          :defs defs}}]
        ;; Loads and macroexpands all the code using the built config
        ;; to generate the forms and defs structures.
        (load res config)
-
+
        ;; The atoms now contain the whole analyzed program, apply
        ;; program passes as updates over the entire AST. Updated ASTs
        ;; are re-evaluated and the symbol to AST mapping rebuilt
        ;; between each pass.
-       ;;
-       ;; FIXME:
+       ;;
+       ;; FIXME: Implementation of method updates
        ;;   It's worth discussing the correctness of this approach on
-       ;;   the maining list.
+       ;;   the mailing list.
        (let [settings (:passes settings)]
          (doseq [pass passes]
            (swap! forms pass @defs settings)
-           (doseq [form @forms]
-             (eval form config))))
+
+           (let [eval-forms @forms]
+             (reset! forms [])
+             (reset! defs  {})
+
+             (doseq [form eval-forms]
+               (eval (:form form)
+                     config)))))

        ;; Having taken an O(Nᵏ) compile operation to the face we now
        ;; run the emitter and call it quits.


Tweak return values

Tweak return values

--- src/oxcart.clj
+++ src/oxcart.clj
@@ -162,8 +162,8 @@
                (when debug?
                  (println *ns* "|" form))
                (eval form options)
-               (recur)))))
-       nil)))
+               (recur))))))
+     nil))

 (defn compile
@@ -197,7 +197,8 @@
      (compile res nil))

   ([res {:keys [passes emitter settings] :as config}]
-     {:pre [(every? fn? passes)
+     {:pre [(seq? passes)
+            (every? fn? passes)
             (fn? emitter)]}
      (let [forms (atom [])
            defs  (atom {})
@@ -225,7 +226,5 @@
        ;; Having taken an O(Nᵏ) compile operation to the face we now
        ;; run the emitter and call it quits.
        (let [settings (:emitter settings)]
-         (emitter @forms))
-
-       ;; Enforce nil result
-       nil)))
+         (emitter @forms)))
+     nil))


[#2185] Fix null values on extract multiple vals

--- backend/src/akvo/lumen/lib/transformation/multiple_column/caddisfly.clj
+++ backend/src/akvo/lumen/lib/transformation/multiple_column/caddisfly.clj
@@ -72,7 +72,7 @@
                                                             cad-results)
                                                            (reduce #(apply assoc % %2) {}))]
                                       (log/debug :update-vals update-vals)
-                                      (multiple-column/update-row conn table-name (:rnum m) update-vals ""))))
+                                      (multiple-column/update-row conn table-name (:rnum m) update-vals "NULL"))))
                                  doall)]
       (log/debug :db-txs selected-column add-db-columns update-db-columns)
       {:success?      true


Report metrics to org.onyxplatform ns.

Report metrics to org.onyxplatform ns.

--- src/onyx/monitoring/metrics_monitoring.clj
+++ src/onyx/monitoring/metrics_monitoring.clj
@@ -28,7 +28,6 @@
 (defn update-timer-ns! [^com.codahale.metrics.Timer timer ns]
   (.update timer ns TimeUnit/NANOSECONDS))

-;; TODO, define all of the keys we need
 (defrecord Monitoring []
   extensions/IEmitEvent
   (extensions/registered? [this event-type]
@@ -77,7 +76,9 @@
           group-prepare-join-cnt (c/counter reg ["group" "prepare-join" "event"])
           group-accept-join-cnt (c/counter reg ["group" "accept-join" "event"])
           group-notify-join-cnt (c/counter reg ["group" "notify-join" "event"])
-          reporter (.build (JmxReporter/forRegistry reg))
+          reporter (-> (JmxReporter/forRegistry reg)
+                       (.inDomain "org.onyxplatform")
+                       (.build))
           _ (.start ^JmxReporter reporter)]
       (info "Started Metrics Reporting to JMX.")
       (assoc component
@@ -236,7 +237,9 @@
           read-offset (AtomicLong.)
           read-offset-gg (g/gauge-fn task-registry (conj tag "offset") (fn [] (.get ^AtomicLong read-offset)))
           recover-latency ^com.codahale.metrics.Timer (t/timer task-registry (into tag ["recover-latency"]))
-          reporter (.build (JmxReporter/forRegistry task-registry))
+          reporter (-> (JmxReporter/forRegistry task-registry)
+                       (.inDomain "org.onyxplatform")
+                       (.build))
           _ (.start ^JmxReporter reporter)]
       (info "Starting Task Metrics Reporter. Starting reporting to JMX.")
       (reduce


Fix type hint

Fix type hint

--- src/jungerer/algo.clj
+++ src/jungerer/algo.clj
@@ -1,5 +1,5 @@
 (ns jungerer.algo
-  (:import edu.uci.ics.jung.graph.Graph
+  (:import [edu.uci.ics.jung.graph Graph Hypergraph]
            [edu.uci.ics.jung.algorithms.scoring
             BarycenterScorer BetweennessCentrality ClosenessCentrality
             DegreeScorer EigenvectorCentrality HITS PageRank VertexScorer]
@@ -45,7 +45,7 @@
 (defn closeness-centrality
   ([graph]
    (ClosenessCentrality. graph))
-  ([^Graph graph ^Distance distance]
+  ([^Hypergraph graph ^Distance distance]
    (ClosenessCentrality. graph distance)))

 (defn eigenvector-centrality


start peers with peer group instead of config map

--- src/lib_onyx/peer.clj
+++ src/lib_onyx/peer.clj
@@ -8,7 +8,7 @@
         _ (println "Starting env")
         env (onyx.api/start-env env-config)
         _ (println "Starting peers")
-        peers (onyx.api/start-peers n-peers peer-config)]
+        peers (onyx.api/start-peers n-peers peer-group)]
     (println "Attempting to connect to Zookeeper @" (:zookeeper/address peer-config))
     (.addShutdownHook (Runtime/getRuntime)
                       (Thread.


Added a comment on use of the returned trained-model.

--- src/sk_dl4j/core.clj
+++ src/sk_dl4j/core.clj
@@ -3,5 +3,7 @@
   (:import (org.nd4j.linalg.activations Activation)))

 (comment
+  ;; Run me! REPL-up, and evaluate the following form. Nothing else to be configured.
+  ;; It returns the trained model too. You can capture that in a var to play with in the REPL.
   (xor-nn/run :hl-activation-fn Activation/HARDTANH
               :ol-activation-fn Activation/SOFTMAX))


cleanup

cleanup

--- src/splash/core.cljs
+++ src/splash/core.cljs
@@ -12,19 +12,12 @@

 (enable-console-print!)

-(println "Edits to this text should show up in your developer console.")
-
-;; define your app data so that it doesn't get over-written on reload
-
-(defonce app-state (atom {:text "Hello world!"}))
-
 (defonce canvas
   (canv/init
    {:expand true
     :engine :auto
-    :layers [:stars]
+    :layers [:stars :ui]
     :background 0x505050}))
-

 (defonce render-go-block (go (while true
                (<! (events/next-frame))


removed unecessary code

removed unecessary code

--- src/server/client-interface.cljs
+++ src/server/client-interface.cljs
@@ -43,32 +43,6 @@
                    "track-change"
                     reply
                     sound-id)))))))
-  (comment
-  (rooms/add-to-change-track-list room track-num
-    (fn []
-      (rooms/start-changing-track room
-        (fn [reply]
-          (if-not (nil? reply)
-            (rooms/track-complete room
-              (fn []
-                (rooms/clear-ready-to-start room
-                  (fn []
-                    (rooms/get-num-of-tracks room
-                      (fn [num-of-tracks]
-                        (if (and (>= track-num 0) (< track-num num-of-tracks))
-                          (rooms/clear-track-complete room
-                            (fn []
-                              (rooms/change-track room track-num sound-id
-                                (fn [track-id]
-                                  (rooms/set-current-track-position room 0
-                                    (fn []
-                                      (rooms/track-complete room
-                                        (fn []
-                                          (.emit (.to io room)
-                                                 "track-change"
-                                                 track-id
-                                                 sound-id))))))))))))))))))))))
-

 (defn connection [socket]
   (println (str "User " (.-id socket) " has connected!"))


implement conditional notification

implement conditional notification

--- src/traffic/app.cljs
+++ src/traffic/app.cljs
@@ -1,9 +1,15 @@
 (ns traffic.app)

-(defn  ^:export onDeviceReady []
-  (-> (js* "navigator") (.-notification)
-      (.alert "PhoneGap is working" (fn [] nil) "" "")))
+(defn ^:export prompt
+  [msg]
+  (try (-> (js* "navigator") (.-notification) (.alert msg (fn [] nil) "" ""))
+       (catch :default e (js/alert msg))))
+
+
+(defn ^:export onDeviceReady []
+  (prompt "PhoneGap is working"))
+

 (defn  ^:export initialize []
   (.addEventListener js/document "deviceready" onDeviceReady true))


some CLJS syntax updates for the google maps service

--- src/shoreleave/services/geo.cljs
+++ src/shoreleave/services/geo.cljs
@@ -20,17 +20,18 @@
       (include-js))
     (catch js/Error err
       (include-js))
-    (finally (js/google.maps.Geocoder.))))
+    (finally (js/google.maps.Geocoder.)))
+  (js/google.maps.Geocoder.))

 ;; TODO: if we want the zip, it's the last element in (.-address_components geo-obj)
 (defn mapify-location [geocode-results]
   (let [[geo-obj] geocode-results
-        lat (.geometry.location.lat geo-obj)
-        lng (.geometry.location.lng geo-obj)]
+        lat (.-geometry.location.lat geo-obj)
+        lng (.-geometry.location.lng geo-obj)]
     {:lat         lat
      :lng         lng
      :latlng-str  (str lat "," lng)
-     :formatted   geo-obj.formatted_address}))
+     :formatted   (.-formatted_address geo-obj)}))

 (defn normalize-location
   ([loc-str callback]


Add parse record to parsers core.

Add parse record to parsers core.

--- src/incise/parsers/core.clj
+++ src/incise/parsers/core.clj
@@ -1,5 +1,11 @@
 (ns incise.parsers.core
   (:require [clojure.string :as s]))
+
+(defrecord Parse [^String title
+                  ^String content
+                  ^String date
+                  ^clojure.lang.Seqable tags
+                  ^String category])

 (def parsers
   "An atom containing a mapping of extensions (strings) to parse functions. A


list-item on-click

list-item on-click

--- src/mojo_ui/list.cljs
+++ src/mojo_ui/list.cljs
@@ -17,8 +17,8 @@

 (defn list-item
   "a single list view item"
-  ([{:keys [icon right-icon]} text]
-   [:div.ui-list-item
+  ([{:keys [icon right-icon on-click]} text]
+   [:div.ui-list-item {:on-click on-click}
     (if icon [font-icon icon] nil)
     text
     [ripple]])


Re-enable sound

Re-enable sound

--- src/musicbox/one.cljs
+++ src/musicbox/one.cljs
@@ -87,7 +87,7 @@
                     (if (empty? (:notes piano-key))
                       (do
                         (println "play" piano-key)
-                        ;; (.play (.bang (:synth piano-key)))
+                        (.play (.bang (:synth piano-key)))
                         (assoc-in instrument
                                   [:piano-keys freq :notes]
                                   [{:on time :off nil :touch-id touch-id}])))))


add try for creating elastic search document

--- src/ophion/search.clj
+++ src/ophion/search.clj
@@ -17,7 +17,10 @@

 (defn create
   [{:keys [connection index]} mapping data]
-  (document/create connection index mapping data))
+  (try
+    (document/create connection index mapping data)
+    (catch Exception e
+      (log/info e))))

 (defn index-message
   [connection {:keys [id data graph]}]


starting multi search

starting multi search

--- src/ophion/search.clj
+++ src/ophion/search.clj
@@ -2,6 +2,7 @@
   (:require
    [clojurewerkz.elastisch.rest :as elastic]
    [clojurewerkz.elastisch.rest.index :as index]
+   [clojurewerkz.elastisch.rest.multi :as multi]
    [clojurewerkz.elastisch.rest.document :as document]))

 (defn connect
@@ -62,8 +63,45 @@
       :size 1000)
      [:hits :hits]))))

+(defn multi-index
+  [index]
+  {:index index
+   :ignore_unavailable true
+   :preference 1})
+
+(defn multi-query
+  [query]
+  {:size 0
+   :query
+   {:query_string
+    {:analyze_wildcard true
+     :query query}}})
+
+(defn multi-term
+  [term]
+  {:aggs
+   {(keyword term)
+    {:terms
+     {:field (str term ".keyword")
+      :order {:_term "asc"}}}}})
+
+(defn multi-from
+  [query size from]
+  (let [out (multi-query query)]
+    (assoc out :size size :from from)))
+
+(defn multi-aggregation
+  [query term]
+  (merge
+   (multi-query query)
+   (multi-term term)))
+
 (defn aggregate
-  [])
+  [{:keys [connection index]} terms query size from]
+  (let [in (multi-index index)
+        agg (mapv (partial multi-aggregation query) terms)
+        queries (conj agg (multi-from size from))
+        out (mapcat list (repeat in) queries)]))

 (def default-config
   {:host "127.0.0.1"


using util to get immigrate.

using util to get immigrate.

--- src/overtone/live.clj
+++ src/overtone/live.clj
@@ -1,9 +1,9 @@
 (ns overtone.live
+  (:use overtone.util)
   (:require clojure.stacktrace
-            midi
-            osc
+            midi
+            osc
             byte-spec
-            overtone.util
             (overtone.core config time-utils log sc ugen synth synthdef envelope sample)
             (overtone.music rhythm pitch tuning)
             overtone.studio


Remove search button

Remove search button

--- src-cljs/frontend/components/documentation.cljs
+++ src-cljs/frontend/components/documentation.cljs
@@ -13,7 +13,8 @@
             [goog.string :as gstring]
             [goog.string.format])
   (:require-macros [frontend.utils :refer [defrender html]]
-                   [cljs.core.async.macros :as am :refer [go go-loop alt!]]))
+                   [cljs.core.async.macros :as am :refer [go go-loop alt!]])
+  (:import [goog.events KeyCodes]))

 (defn docs-search [app owner]
   (reify
@@ -44,12 +45,11 @@
            {:type "text",
             :value query
             :on-change #(utils/edit-input owner state/docs-search-path %)
-            :placeholder "What can we help you find?",
-            :name "query"}]
-          [:button {:on-click #(do (raise! owner [:doc-search-submitted {:query query}])
-                                   false)
-                    :type "submit"}
-           [:i.fa.fa-search]]])))))
+            :on-key-down #(when (= (.-keyCode %) (.-ENTER KeyCodes))
+                            (raise! owner [:doc-search-submitted {:query query}])
+                            (.preventDefault %))
+            :placeholder "What can we help you find?"
+            :name "query"}]])))))

 (defrender article-list [articles]
   (html


project list spinner (#1702)

project list spinner (#1702)

--- src-cljs/frontend/components/nux_bootstrap.cljs
+++ src-cljs/frontend/components/nux_bootstrap.cljs
@@ -89,9 +89,11 @@
                (gstring/format "%s out of %s projects selected" selected-projects-count projects-count)
                "Counting projects...")]]
            (when expanded?
-             [:div.projects-container.maybe-border-bottom
-              (check-all-activity-repos)
-              (project-items projects)])])))))
+             (if projects-loaded?
+               [:div.projects-container.maybe-border-bottom
+                (check-all-activity-repos)
+                (project-items projects)]
+               (spinner)))])))))

 (defn nux-bootstrap-content [data owner]
   (let [projects (->> (:projects data)


Update docstring for widths

Update docstring for widths

--- src-cljs/frontend/components/pieces/button.cljs
+++ src-cljs/frontend/components/pieces/button.cljs
@@ -173,8 +173,9 @@

     ## Widths
-    Button widths vary based on button text length and can have a **Fixed**
-    attribute which if set to **true** will make the button fixed width for
+
+    Button widths vary based on button text length and can have a `fixed?`
+    attribute which if set to `true` will make the button fixed width for
     cases where we want buttons to be consistent."

     (button-display


undid dancer counts

undid dancer counts

--- src/tango/cljs/speaker/core.cljs
+++ src/tango/cljs/speaker/core.cljs
@@ -106,7 +106,7 @@
     [this]
     (let [{:keys [heat-number starting]} (om/props this)]
       (dom/div #js {:className "Row"}
-        (dom/h4 #js {:className "col-xs-2"} (str "Heat " heat-number " (" (count starting) "):"))
+        (dom/h4 #js {:className "col-xs-2"} (str "Heat " heat-number ":"))
         (dom/div #js {:className "col-xs-10"}
                  (map #(dom/h4 #js {:className "col-xs-1"} (:participant/number %)) starting))))))


(fix) error handler name

(fix) error handler name

--- src/papaline/core.clj
+++ src/papaline/core.clj
@@ -245,7 +245,7 @@
     (error-handler ctx (:args ctx) ex)
     (assoc ctx :args next-args)))

-(defrecord+ AsyncDedicatedThreadPoolPipeline [executor stages user-error-handler]
+(defrecord+ AsyncDedicatedThreadPoolPipeline [executor stages error-handler]
   clojure.lang.IFn
   (invoke [this ctx]
           (let [pre-hook  *pre-execution-hook*
@@ -257,7 +257,7 @@
             (letfn [(clos [stgs ctx]
                       (if-let [^RealizedStage current-stage (first stgs)]
                         (let [current-stage-name (:name current-stage)
-                              error-handler (stage-name-aware-error-handler current-stage-name user-error-handler)
+                              error-handler (stage-name-aware-error-handler current-stage-name error-handler)
                               processor (Thread/currentThread)]
                           (.handle (run-stage current-stage ctx)
                                    (reify BiFunction
@@ -280,9 +280,9 @@
                         (if (or (:abort ctx) use-fork-or-join?)
                           (do
                             (when post-hook (post-hook ctx))
-                            (when (and user-error-handler use-fork-or-join?)
+                            (when (and error-handler use-fork-or-join?)
                               (try
-                                (user-error-handler (UnsupportedOperationException. "Fork or Join is not supported in AsyncDedicatedThreadPoolPipeline"))
+                                (error-handler (UnsupportedOperationException. "Fork or Join is not supported in AsyncDedicatedThreadPoolPipeline"))
                                 (catch Exception _)))
                             (.complete result ctx))
                           (clos (rest stgs) ctx))))]


more loops for sente

more loops for sente

--- src/pc/http/sente.clj
+++ src/pc/http/sente.clj
@@ -1140,10 +1140,11 @@
   (let [tap (async/chan (async/sliding-buffer 100))
         mult (async/mult (:ch-recv sente-state))]
     (async/tap mult tap)
-    (async/go-loop []
-                   (when-let [req (async/<! tap)]
-                     (utils/straight-jacket (handle-req req))
-                     (recur)))))
+    (dotimes [x 10]
+      (async/go-loop []
+        (when-let [req (async/<! tap)]
+          (utils/straight-jacket (handle-req req))
+          (recur))))))

 (defn close-ws
   "Closes the websocket, client should reconnect."


Doubled max points

Doubled max points

--- src/clojush/problems/regression/korns_regression_p12.clj
+++ src/clojush/problems/regression/korns_regression_p12.clj
@@ -276,7 +276,7 @@
                       'float_cos
                       ;'float_tan
                       )
-   :max-points 60
+   :max-points 120
    :max-genome-size-in-initial-program 30
    :evalpush-limit 50
    :population-size 500


Deprecate run! infavor of screen! to avoid conflict with clojure 1.7

--- src/play_clj/core.clj
+++ src/play_clj/core.clj
@@ -551,14 +551,19 @@
   [screen & args]
   ((:update-fn! screen) assoc args))

-(defn run!
+(defn screen!
   "Runs a function defined in another screen. You may optionally pass a series
 of key-value pairs, which will be given to the function via its screen map.

-    (run! my-other-screen :on-show)
-    (run! my-other-screen :on-change-color :color :blue)"
+    (screen! my-other-screen :on-show)
+    (screen! my-other-screen :on-change-color :color :blue)"
   [screen-object fn-name & options]
   (let [execute-fn! (:execute-fn! screen-object)
         screen-fn (-> screen-object :options (get fn-name))]
     (apply execute-fn! screen-fn options)
     nil))
+
+(defn run!
+  "Deprecated. Please use `screen!` instead."
+  [& args]
+  (apply screen! args))


Be consistent in use of show argument.

Be consistent in use of show argument.

--- src/afterglow/show.clj
+++ src/afterglow/show.clj
@@ -237,8 +237,8 @@
         (let [dmx-future (cp/future @(:pool show) (send-dmx-buffers show buffers))
               extensions-future (cp/future @(:pool show) (send-extension-buffers show))]
           @dmx-future @extensions-future))
-  (swap! (:movement *show*) #(dissoc (assoc % :previous (:current %)) :current))
-  (swap! (:statistics *show*) update-stats (:instant snapshot) (:refresh-interval show)))
+  (swap! (:movement show) #(dissoc (assoc % :previous (:current %)) :current))
+  (swap! (:statistics show) update-stats (:instant snapshot) (:refresh-interval show)))

 (defn add-frame-fn!
   "Arranges for the supplied function to be called when the Afterglow


Fix fetch_helper indentation

Fix fetch_helper indentation

--- src/trustroots/fetch_helper.cljs
+++ src/trustroots/fetch_helper.cljs
@@ -1,8 +1,5 @@
 (ns trustroots.fetch-helper
-  (:require
-    [trustroots.helpers :refer [log info debug]]))
-
-
+  (:require [trustroots.helpers :refer [log info debug]]))

 (def baseurl "https://www.trustroots.org/api")
 (def url_map
@@ -18,10 +15,10 @@
 (defn- handle-fetch-promise
   [promise & {:keys [on-success on-error parse-json]}]
   (-> promise
-      ; network error
+      ;; network error
       (.catch (fn [err] (on-error {:data err :type :network-error})))

-      ; fecth resolves also 400 and 500 errors
+      ;; fecth resolves also 400 and 500 errors
       (.then (fn [res]
                (if (not (nil? res))
                  (let [ok (.-ok res)
@@ -29,20 +26,21 @@
                        error-type (cond
                                     ok nil
                                     (= status 403) :unauthorized
-                                   :else :http-error)
+                                    :else :http-error)
                        handle-data (fn [data]
                                      (if ok
                                        (on-success {:data data :status status :ok ok})
                                        (on-error   {:data data :status status :type error-type})))
                        has-json (if (nil? parse-json) false
-                                      parse-json)]
+                                    parse-json)]

                    (-> (if has-json
                          (-> (.json res)
                              (.then #(js->clj %1 :keywordize-keys true))
-                             (.then #(if (vector? %1)
-                                        (vec (map clojure.walk/keywordize-keys %1))
-                                        %1)))
+                             (.then
+                              #(if (vector? %1)
+                                 (vec (map clojure.walk/keywordize-keys %1))
+                                 %1)))
                          (.text res))
                        (.then #(do (log %) %))
                        (.then handle-data))))))))
@@ -55,16 +53,15 @@
         path           (apply str (map (partial str "/") endpoint-path))
         req-url        (if (nil? endpoint)
                          url
-                         ;(get-url endpoint)
-                          (str (get-url endpoint) path))
+                         ;;(get-url endpoint)
+                         (str (get-url endpoint) path))

         default-header {"Content-Type" "application/json" "Accept" "application/json"}
         optional-body  (if body
                          {"body" (js/JSON.stringify (clj->js body))}
                          {})

-        args (merge {
-                     "method"   method
+        args (merge {"method"   method
                      "credentials" "include"
                      "headers" (merge default-header headers)}
                     optional-body)
@@ -82,19 +79,17 @@
         path           (apply str (map (partial str "/") endpoint-path))
         req-url        (if (nil? endpoint)
                          url
-                         ;(get-url endpoint)
-                          (str (get-url endpoint) path))
+                         ;;(get-url endpoint)
+                         (str (get-url endpoint) path))
         optional-body  (if body
                          {"body" (js/JSON.stringify (clj->js body))}
                          {})

-        args (merge {
-                     "method"   method
+        args (merge {"method"   method
                      "credentials" "include"
                      "headers" headers}
                     optional-body)
         query (react-fetch req-url (clj->js args))]

-
     (log "fetch-no-response:" method req-url headers)
     (handle-fetch-promise query :on-error on-error :on-success on-success :parse-json false)))


bars text layout adjustments

bars text layout adjustments

--- src/unspun/screens/rum_bars.cljs
+++ src/unspun/screens/rum_bars.cljs
@@ -237,17 +237,17 @@
                                                  ;:left 0
                                                  ;:right 0
                                                  ;:width 30
-                                                 :marginLeft     (* 10 font-scale)
-                                                 :marginRight     (* 10 font-scale)
+                                                 :marginLeft     (* 14 font-scale)
+                                                 :marginRight    (* 14 font-scale)
                                                  :flexDirection  "column"
                                                  :alignItems     "center"
-                                                 :borderTopColor (:light-primary palette)
+                                                 :borderTopColor "red" ; (:light-primary palette)
                                                  :borderTopWidth 1
                                                  }}
                                         (text {:key   1
                                                :style {:position        "absolute"
-                                                       :left            (* -9 font-scale)
-                                                       :top             (* -2 font-scale)
+                                                       :left            (* -12 font-scale)
+                                                       :top             (* -4 font-scale)
                                                        :color           (:light-primary palette)
                                                        :backgroundColor "rgba(0,0,0,0)"
                                                        :fontSize        10
@@ -258,8 +258,8 @@
                                                               ) "%"))
                                         (text {:key   2
                                                :style {:position        "absolute"
-                                                       :right            (* -9 font-scale)
-                                                       :top             (* -2 font-scale)
+                                                       :right           (* -12 font-scale)
+                                                       :top             (* -4 font-scale)
                                                        :color           (:light-primary palette)
                                                        :backgroundColor "rgba(0,0,0,0)"
                                                        :fontSize        10


Update intro.cljs

Update intro.cljs

lots of wording changes suggested by Martin and amended by me

--- src/prais2/intro.cljs
+++ src/prais2/intro.cljs
@@ -83,13 +83,13 @@

      [:h1 "What, why, how?"]

-     [:p "This site is to help people make sense of the " [:a {:href "https://www.ucl.ac.uk/nicor/audits/congenital/documents/datasets/NCHDA2011-14Report"} "published survival statistics"] " about children’s heart surgery. "]
-     #_[:p.col-lg-12 "This site is to help people make sense of the published survival statistics about children’s heart surgery."]
+     [:p "This site is to help people make sense of the " [:a {:href "https://www.ucl.ac.uk/nicor/audits/congenital/documents/datasets/NCHDA2011-14Report"} "published survival data"] " about children’s heart surgery. "]
+     #_[:p.col-lg-12 "This site is to help people make sense of the published survival data about children’s heart surgery."]

      (key-points)
-     (section 1 "WHAT do we mean by survival statistics?" section-1-content)
-     (section 2 "WHY can survival rate data be difficult to interpret?" section-2-content)
-     (section 3 "HOW does the NHS monitor survival rates?" section-3-content)
+     (section 1 "WHAT do we mean by survival rate?" section-1-content)
+     (section 2 "WHY can data about survival be difficult to interpret?" section-2-content)
+     (section 3 "HOW does the NHS monitor hospitals that do children’s heart surgery?" section-3-content)
      (section 4 "What this site cannot do" section-4-content)
      (section 5 "What this site can do" section-5-content)
      ]]])
@@ -98,16 +98,16 @@
   [:section.well.danger.col-sm-8
    [:h2 "Key points"]
    [:ul
-    [:li "If one hospital has a higher survival rate than another hospital it does not mean that it is better than the other"]
-    [:li "The predicted range is calculated by a formula and depends " [:b "only"] " on the children treated at that hospital. A " [:b "lower"] " predicted range means a hospital treated children with " [:b "more complex"] " medical problems." ]
+    [:li "If a higher percentage of patients survive at one hospital than another, it does not mean that it is a better hospital."]
+    [:li "The NHS compares the survival at each hospital to a predicted range of survival that is calculated by a formula and depends " [:b "only"] " on the children treated at that hospital. A " [:b "lower"] " predicted range means a hospital treated children with " [:b "more complex"] " medical problems." ]
     [:li "A hospital's survival rate should only be compared to its predicted range. It is not valid to compare survival rates between hospitals."]
-    [:li "The 30-day survival rate for all UK hospitals is very high."]]])
+    [:li "The percentage of children that survive at least 30 days after heart surgery is very high at all UK hospitals."]]])

 (rum/defc section-1-content []
   [:section.row
-   [:p.col-sm-12 "The NHS monitors children’s heart surgery in the UK by reviewing each hospital’s 30-day survival rate. This is the percentage of operations where the child survived at least 30 days after their heart surgery."]
+   [:p.col-sm-12 "The 30-day survival rate is the percentage of operations where the child survived to at least 30 days after their heart surgery. The NHS monitors children’s heart surgery in the UK by reviewing each hospital’s 30-day survival rate."]
    [:p.col-sm-12 "Approximately 3500 children under the age of 16 have heart surgery each year in the United Kingdom and Republic of Ireland."]]
   )

@@ -123,19 +123,19 @@
 (rum/defc section-3-content []
   [:section.row
    [:.col-lg-12
-    [:p "The NHS monitors survival rates by taking into account how ill the children were that the hospital treated. This is a fairer way of looking at survival rate data."]
+    [:p "The NHS monitors hospitals that perform children’s heart surgery by reviewing the 30-day survival rate for each hospital, taking into account how ill the children were that each hospital treated. This is a fairer way of looking at survival rate data."]
     [:p "Risk factors that affect a child’s chance of survival include:"]
     [:ul
      [:li
       "the age and weight of the child (other things being equal, the bigger and stronger a child is, the safer the surgery is); "]

-     [:li "what problem in the heart the surgery is trying to fix (some hearts have more complex defects than others); "]
+     [:li "what problem in the heart the surgery is trying to fix (some hearts have more complex problems than others); "]

      [:li "other health problems a child might have (e.g. a genetic syndrome); "]
      [:li "the complexity of the surgical procedure.  "]
      ]

-    [:p "Knowing these factors for each patient allows us to identify types of patient who are at greater or lesser risk, even though we cannot predict exactly how a particular individual will respond."]
+    [:p "Knowing these factors for each child allows us to predict the percentage of children within a group that will survive, even though we cannot predict exactly whether individual children will survive."]

     [:p "The national audit body (NICOR) uses a statistical formula to combine data on these risk factors for all the children a hospital has treated over the previous three years giving a " [:b "predicted range"] " for the overall proportion of survivors for that specific hospital and time period. The audit body then compares the survival rate achieved by a hospital with its predicted range."]


Remove unused examples.

Remove unused examples.

--- src/african_polyphony_and_polyrhythm/talk.clj
+++ src/african_polyphony_and_polyrhythm/talk.clj
@@ -226,9 +226,6 @@
 (def descending -)

 (comment
-  (map (comp A pentatonic) (range 0 6))
-  (map (comp A descending pentatonic) (range 0 6))
-
   (->> (phrase (repeat 1/4) (range 0 6))
        (where :pitch (comp midi->hz A pentatonic))
        live/play)
@@ -236,6 +233,9 @@
   (->> (phrase (repeat 1/4) (range 0 6))
        (where :pitch (comp midi->hz A descending pentatonic))
        live/play))
+
+
+


Add model balendorc on the xylophone.

Add model balendorc on the xylophone.

--- src/african_polyphony_and_polyrhythm/talk.clj
+++ src/african_polyphony_and_polyrhythm/talk.clj
@@ -2,7 +2,8 @@
   (:require [overtone.live :refer :all :exclude [stop]]
             [leipzig.melody :refer :all]
             [leipzig.canon :refer [canon]]
-            [leipzig.scale :refer [A B major minor]]
+            [leipzig.scale :refer [A B major minor pentatonic]]
+            [leipzig.temperament :as temperament]
             [leipzig.live :as live]
             [leipzig.live :refer [stop]]))

@@ -41,3 +42,40 @@
     (split 1 1/2)
     )
   )
+
+(definst akadinda [freq 440 vol 0.5]
+  (-> (sin-osc freq)
+      (+ (* 1/3 (sin-osc (* 2.01 freq))))
+      (+ (* 1/2 (sin-osc (* 3.001 freq))))
+      (+ (* 1/8 (sin-osc (* 5.001 freq))))
+      (clip2 0.8)
+      (lpf (* 5 440))
+      (* (env-gen (adsr 0.01 0.05 0.15 0.2) (line:kr 1 0 0.1) :action FREE))
+      (+ (* (env-gen (perc 0.02 0.03)) (* 1/3 (sin-osc (* 0.5 freq)))))
+      (* vol)))
+
+(defmethod live/play-note :default [{:keys [pitch]}]
+  (when pitch (akadinda pitch)))
+
+(def balendorc
+  (let [a (phrase [2 1/2 3/2] (repeat 0))
+        b (phrase [1 5/4 3/4 1] (cons nil (repeat 1)))
+        c (phrase [1/2 3 1/2] (cons nil (repeat 2)))
+        d (phrase [2 2] (repeat 2))
+        e (phrase [3/2 3/4 7/4] (cons nil (repeat 2)))
+        ]
+    (with a b c d e)
+    )
+  )
+
+(def inverse-pentatonic (comp (partial + 24) pentatonic -))
+
+(comment
+  (->>
+    balendorc
+    (where :pitch (comp temperament/equal A inverse-pentatonic))
+    (times 8)
+    (tempo (bpm 120))
+    (live/play)
+    )
+  )


Pan and fix up variations.

Pan and fix up variations.

--- src/african_polyphony_and_polyrhythm/talk.clj
+++ src/african_polyphony_and_polyrhythm/talk.clj
@@ -36,7 +36,7 @@
                           (update-in [:time] + fraction))]
       (concat before [first-note second-note] after))))

-(definst akadinda [freq 440 vol 0.5]
+(definst akadinda [freq 440 vol 0.5 pan 0]
   (-> (sin-osc freq)
       (+ (* 1/3 (sin-osc (* 2.01 freq))))
       (+ (* 1/2 (sin-osc (* 3.001 freq))))
@@ -45,10 +45,11 @@
       (lpf (* 5 440))
       (* (env-gen (adsr 0.01 0.05 0.15 0.2) (line:kr 1 0 0.1) :action FREE))
       (+ (* (env-gen (perc 0.02 0.03)) (* 1/3 (sin-osc (* 0.5 freq)))))
+      (pan2 pan)
       (* vol)))

-(defmethod live/play-note :default [{:keys [pitch]}]
-  (when pitch (akadinda pitch)))
+(defmethod live/play-note :default [{:keys [pitch pan]}]
+  (when pitch (akadinda :freq pitch :pan pan)))

 (defn rand-variations [variations]
   (concat
@@ -60,37 +61,49 @@

 (def tete
   (part
-    (phrase [2 1/2 3/2] (repeat 0))
+    (phrase [8/4 3/4 5/4] (repeat 0))
     (split 0 1/4)
     (comp (split 1/4 1/4) (split 0 1/4))
     (comp (split 2/4 1/4) (split 1/4 1/4) (split 0 1/4))))

 (def ta
   (part
-    (phrase [1 5/4 3/4 1] (cons nil (repeat 1)))
+    (phrase [4/4 5/4 3/4 4/4] (cons nil (repeat 1)))
     (split 9/4 1/4)
-    (split 3 1/2)))
+    (comp (split 10/4 1/4) (split 9/4 1/4))
+    (comp (split 11/4 1/8) (split 10/4 1/4) (split 9/4 1/4))
+    (split 4/4 1/4)))

 (def ha
   (part
-    (phrase [1/2 3 1/2] (cons nil (repeat 2)))
-    (comp (split 3/2 1/4) (split 1/2 1/4) (split 0 1/4))))
+    (phrase [2/4 12/4 2/4] (cons nil (repeat 2)))
+    (comp (split 2/4 1/4) (split 0 1/4))
+    (comp (split 6/4 1/4) (split 0 1/4))
+    (comp (split 6/4 1/4))
+    (comp (split 6/4 1/4) (split 2/4 1/4) (split 0 1/4))))

 (def tulule
   (part
-    (phrase [2 2] (repeat 3))
-    (comp (split 2 1/2) (split 0 1/2))))
+    (phrase [8/4 8/4] (repeat 3))
+    (comp (split 8/4 2/4) (split 0 2/4)) ; 28
+    (comp (split 1/4 0) (split 2/4 1/4) (split 8/4 2/4) (split 0 2/4)) ; 6
+    (comp (split 3/4 1/8) (split 1/4 0) (split 2/4 1/4) (split 8/4 2/4) (split 0 2/4)))) ; 5

 (def bongo
   (part
-    (phrase [3/2 3/4 7/4] (cons nil (repeat 4)))
-    (split 9/4 5/4)
-    (comp (split 3/2 1/4) (split 9/4 5/4))
-    (comp (split 14/4 1/4) (split 3/2 1/4) (split 9/4 5/4))))
+    (phrase [6/4 3/4 7/4] (cons nil (repeat 4))) ; 5
+    (split 9/4 5/4) ; 6
+    (comp (split 6/4 1/4) (split 9/4 5/4)) ; 9
+    (comp (split 14/4 1/4) (split 3/2 1/4) (split 9/4 5/4)))) ; 8

 (defn big [notes]
   (->> notes
        (map (partial where :pitch #(+ % 5)))))
+
+(defn pan [{:keys [pitch] :as note}]
+  (if pitch
+    (-> note (assoc :pan (-> pitch (/ 9) dec)))
+    note))

 (def balendoro
   (->> [tete ta ha tulule bongo
@@ -98,8 +111,10 @@
         (big (big tete)) (big (big ta)) (big (big ha)) (big (big tulule)) (big (big bongo))
         (big (big (big tete))) (big (big (big ta))) (big (big (big ha)))]
        (map rand-variations)
+       (map after (range 0 (* 8 18) 8))
        ;(map first)
-       (reduce with)))
+       (reduce with)
+       (map pan)))

 (def inverse-pentatonic (comp (partial + 12) pentatonic -))


Add prime-factors and phi functions to toolset.clj

--- euler_clojure/src/euler/toolset.clj
+++ euler_clojure/src/euler/toolset.clj
@@ -25,3 +25,20 @@
        (take-while pos?)      ; (1234, 123, 12, 1)
        (mapv #(mod % 10))     ; [4, 3, 2, 1]
        rseq))                 ; (1 2 3 4)
+
+(defn prime-factors
+  ([n]
+   (prime-factors n 2))
+  ([n start]
+   (let [candidates (range start (inc (int (math/sqrt n))))
+         factor (first (filter #(= 0 (mod n %)) candidates))]
+     (if (nil? factor)
+       (list n)
+       (cons factor (prime-factors (/ n factor) factor))))))
+
+(defn phi [n]
+  (cond
+    (= n 0) 0
+    (= n 1) 1
+    :else (let [ps (distinct (prime-factors n))]
+            (int (* n (reduce * (map #(- 1 (/ 1 %)) ps)))))))


This was easy

This was easy

--- src/cljs/early_vote_site/elections/views.cljs
+++ src/cljs/early_vote_site/elections/views.cljs
@@ -59,7 +59,7 @@
 (defn election-list-row
   [election]
   (let [roles @(re-frame/subscribe [:roles])
-        admin? (seq (set/intersection roles #{"super-admin" "state-admin"}))
+        admin? (seq (set/intersection roles #{"super-admin"}))
         editing @(re-frame/subscribe [:elections/editing])]
     (if (contains? editing (:id election))
       [form (:id election)]


Ditto

Ditto

--- src/clojure/clojurewerkz/cassaforte/bytes.clj
+++ src/clojure/clojurewerkz/cassaforte/bytes.clj
@@ -1,3 +1,12 @@
+;; Copyright (c) 2012-2014 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
+;;
+;; The use and distribution terms for this software are covered by the
+;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
+;; which can be found in the file epl-v10.html at the root of this distribution.
+;; By using this software in any fashion, you are agreeing to be bound by
+;; the terms of this license.
+;; You must not remove this notice, or any other, from this software.
+
 (ns clojurewerkz.cassaforte.bytes
   "Facility functions to use with serialization, handle deserialization of all the data types
    supported by Cassandra."


Clean up and fix off-by-one error in knock-off-chip-off-the-old-block

--- src/clojush/pushgp/selection/preselection.clj
+++ src/clojush/pushgp/selection/preselection.clj
@@ -83,15 +83,14 @@
        (Exception.
         ":print-history must be true for :knock-off-chip-off-the-old-block"))
       (if (= true  (:knock-off-chip-off-the-old-block argmap))
-        (let [changed (vec (filter #(or (empty? (:history %))
-                                        (not= (:errors %) (second (:history %))))
+        (let [changed (vec (filter #(not= (first (:history %)) (second (:history %)))
                                    pop))]
           (if (empty? changed)
             pop
             changed))
         (let [diffs (first (:knock-off-chip-off-the-old-block argmap))
               outof (second (:knock-off-chip-off-the-old-block argmap))
-              changed (vec (filter #(or (< (count (:history %)) (inc outof))
+              changed (vec (filter #(or (< (count (:history %)) outof)
                                         (>= (count (distinct (take outof (:history %))))
                                             diffs))
                                    pop))]


Stub out database call in settings handler test.

--- test/lunchlotto/settings/handlers_test.clj
+++ test/lunchlotto/settings/handlers_test.clj
@@ -15,21 +15,22 @@
         (is (= {:user {:id 1}} (.params response)))))))

 (deftest update-settings
-  (testing "successfully update settings"
-    (with-redefs [models/update-settings (fn [_ _] true)
-                  val/validate-settings (fn [_ _] [true {}])]
-      (let [{:keys [:status :headers :flash]} (handlers/update-settings {})]
-        (is (= 302 status))
-        (is (= "/settings" (get headers "Location")))
-        (is (= "Your settings have been updated." flash)))))
+  (with-redefs [models/find-user-by-id (fn [_ _] true)]
+    (testing "successfully update settings"
+      (with-redefs [models/update-settings (fn [_ _] true)
+                    val/validate-settings (fn [_ _] [true {}])]
+        (let [{:keys [:status :headers :flash]} (handlers/update-settings {})]
+          (is (= 302 status))
+          (is (= "/settings" (get headers "Location")))
+          (is (= "Your settings have been updated." flash)))))

-  (testing "cannot update because of validation error"
-    (with-redefs [models/update-settings (fn [_ _] true)
-                  val/validate-settings (fn [_ _] [false {}])]
-      (let [response (handlers/update-settings {})]
-        (is (= 400 (.status response)))
-        (is (= "settings/show.html" (.template response)))
-        (is (= {:user {:email nil}} (.params response)))))))
+    (testing "cannot update because of validation error"
+      (with-redefs [models/update-settings (fn [_ _] true)
+                    val/validate-settings (fn [_ _] [false {}])]
+        (let [response (handlers/update-settings {})]
+          (is (= 400 (.status response)))
+          (is (= "settings/show.html" (.template response)))
+          (is (= {:user {:email nil}} (.params response))))))))

 (deftest delete-user
   (testing "successfully delete account"


Extending the migration demo with a function that populates one of our tables

--- src/blaagh/db/core.clj
+++ src/blaagh/db/core.clj
@@ -20,3 +20,20 @@
             "CREATE TABLE baz (name text); ")
         (catch Exception e
             (println e))))
+
+(defn populate-tables []
+    (try
+        (sql/db-do-commands db-conn
+            "INSERT INTO foo (name) VALUES
+                ('Rick'),
+                ('Carol'),
+                ('Daryl'),
+                ('Michonne'),
+                ('Glenn'),
+                ('Maggie'),
+                ('Carl'),
+                ('Sasha'),
+                ('Abraham'),
+                ('Morgan');")
+        (catch Exception e
+            (println e))))


Update to use iterate / nth

Update to use iterate / nth

--- src/advent_2018/day_08.cljc
+++ src/advent_2018/day_08.cljc
@@ -7,11 +7,11 @@

 (defn parse-license [input]
   (let [node+more (fn node+more [[child-count metadata-count & more]]
-                    (let [[children more] (reduce (fn [[children more] _]
-                                                    (let [[child more] (node+more more)]
-                                                      [(conj children child) more]))
-                                            [[] more]
-                                            (range child-count))
+                    (let [[children more] (-> (iterate (fn [[children more]]
+                                                          (let [[child more] (node+more more)]
+                                                            [(conj children child) more]))
+                                                 [[] more])
+                                            (nth child-count))
                           [metadata more] (split-at metadata-count more)]
                       [{:children children, :metadata metadata} more]))
         nums      (map read-string (re-seq #"\d+" input))]


api added

api added

--- src/webdriver/new.clj
+++ src/webdriver/new.clj
@@ -73,6 +73,17 @@
                   ~data)]
      ~@body))

+;;
+;; session and status
+;;
+
+(defn get-status [driver]
+  (with-resp driver :get
+    [:status]
+    nil
+    resp
+    (:value resp)))
+
 (defn create-session [driver]
   (with-resp driver
     :post
@@ -87,6 +98,94 @@
     [:session (:session @driver)]
     nil
     _))
+
+;;
+;; windows
+;;
+
+(defmulti get-window-handle dispatch-driver)
+
+(defmethod get-window-handle :default
+  [driver]
+  (with-resp driver :get
+    [:session (:session @driver) :window_handle]
+    nil
+    resp
+    (:value resp)))
+
+(defmethod get-window-handle :firefox
+  [driver]
+  (with-resp driver :get
+    [:session (:session @driver) :window]
+    nil
+    resp
+    (-> resp :value)))
+
+(defmulti get-window-handles dispatch-driver)
+
+(defmethod get-window-handles :firefox
+  [driver]
+  (with-resp driver :get
+    [:session (:session @driver) :window :handles]
+    nil resp
+    (:value resp)))
+
+(defmethods get-window-handles [:chrome :phantom]
+  [driver]
+  (with-resp driver :get
+    [:session (:session @driver) :window :window_handles]
+    nil resp
+    (:value resp)))
+
+(defn switch-window [driver handle]
+  (with-resp driver :post
+    [:session (:session @driver) :window]
+    {:handle handle} _))
+
+(defmulti maximize dispatch-driver)
+
+(defmethod maximize :firefox
+  [driver]
+  (with-resp driver :post
+    [:session (:session @driver) :window :maximize]
+    nil _))
+
+(defmethods maximize [:chrome :safari]
+  [driver]
+  (let [h (get-window-handle driver)]
+    (with-resp driver :post
+      [:session (:session @driver) :window h :maximize]
+      nil _)))
+
+;; size and pos
+
+;;
+;; mouse
+;;
+
+;;
+;; touch
+;;
+
+;;
+;; skip/only driver
+;;
+
+;;
+;; input and submit
+;;
+
+;;
+;; forms
+;;
+
+;;
+;; screenshot
+;;
+
+;;
+;; human actions
+;;

 ;;
 ;; navigation


add future tests

add future tests

--- test/cljam/t_core.clj
+++ test/cljam/t_core.clj
@@ -37,14 +37,22 @@

 (with-state-changes [(before :facts (prepare-cache!))
                      (after  :facts (clean-cache!))]
-  (fact "about sort"
-        ;; TODO: add test to sort by qname
-        (with-out-file temp-out (core/sort [test-sam-file temp-sam])) => nil
+  (fact "about sort (by pos)"
+        (with-out-file temp-out (core/sort ["-o" "coordinate" test-sam-file temp-sam])) => anything
         (slurp-sam-for-test temp-sam) => test-sam-sorted-by-pos
         (check-sort-order (slurp-sam-for-test temp-sam) test-sam-sorted-by-pos) => anything
-        (with-out-file temp-out (core/sort [test-bam-file temp-bam])) => nil
+        (with-out-file temp-out (core/sort ["-o" "coordinate" test-bam-file temp-bam])) => anything
         (slurp-bam-for-test temp-bam) => test-sam-sorted-by-pos
         (check-sort-order (slurp-bam-for-test temp-bam) test-sam-sorted-by-pos) => anything
+        ))
+
+(with-state-changes [(before :facts (prepare-cache!))
+                     (after  :facts (clean-cache!))]
+  (fact "about sort (by qname)"
+        (with-out-file temp-out (core/sort ["-o" "queryname" test-sam-file temp-sam])) =future=> anything
+        (slurp-sam-for-test temp-sam) =future=> test-sam-sorted-by-qname
+        (with-out-file temp-out (core/sort ["-o" "queryname" test-bam-file temp-bam])) =future=> anything
+        (slurp-bam-for-test temp-bam) =future=> test-sam-sorted-by-qname
         ))

 (with-state-changes [(before :facts (prepare-cache!))


Update play-cljs template

Update play-cljs template

--- build.boot
+++ build.boot
@@ -14,7 +14,7 @@
                   [leiningen "2.8.1" :exclusions [leiningen.search]]
                   [ring "1.6.1"]
                   [hawk "0.2.11"]
-                  [play-cljs/lein-template "0.10.1-5"]
+                  [play-cljs/lein-template "0.10.2"]
                   [eval-soup "1.2.3" :exclusions [org.clojure/core.async]]
                   [org.eclipse.jgit/org.eclipse.jgit "4.6.0.201612231935-r"]]
   :repositories (conj (get-env :repositories)


Upgrade to latest yada to get 304 improvements

--- build.boot
+++ build.boot
@@ -37,7 +37,7 @@
    [org.clojure/tools.namespace "0.2.11"]
    [prismatic/schema "1.0.4"]
    [selmer "1.0.4"]
-   [yada "1.1.21"]
+   [yada "1.1.22"]

    ;; Logging
    [org.clojure/tools.logging "0.3.1"]


0.0-2411-1 -- boot 2.0.0-rc1 compat.

0.0-2411-1 -- boot 2.0.0-rc1 compat.

- change task-options format
- use adzerk/bootlaces instead of tailrecursion/boot-useful for build/deployo

--- build.boot
+++ build.boot
@@ -1,20 +1,20 @@
 (set-env!
   :dependencies '[[org.clojure/clojure       "1.6.0"     :scope "provided"]
-                  ;[boot/core                 "2.0.0-rc1" :scope "provided"]
-                  [tailrecursion/boot-useful "0.1.4"     :scope "test"]
+                  [boot/core                 "2.0.0-rc1" :scope "provided"]
+                  [adzerk/bootlaces          "0.1.5"     :scope "test"]
                   [org.clojure/clojurescript "0.0-2411"  :scope "test"]])

-(require '[tailrecursion.boot-useful :refer :all])
+(require '[adzerk.bootlaces :refer :all])

-(def +version+ "0.0-2411-0")
+(def +version+ "0.0-2411-1")

-(useful! +version+)
+(bootlaces! +version+)

 (task-options!
-  pom  [:project     'adzerk/boot-cljs
-        :version     +version+
-        :description "Boot task to compile ClojureScript applications."
-        :url         "https://github.com/adzerk/boot-cljs"
-        :scm         {:url "https://github.com/adzerk/boot-cljs"}
-        :license     {:name "Eclipse Public License"
-                      :url  "http://www.eclipse.org/legal/epl-v10.html"}])
+ pom  {:project     'adzerk/boot-cljs
+       :version     +version+
+       :description "Boot task to compile ClojureScript applications."
+       :url         "https://github.com/adzerk/boot-cljs"
+       :scm         {:url "https://github.com/adzerk/boot-cljs"}
+       :license     {:name "Eclipse Public License"
+                     :url  "http://www.eclipse.org/legal/epl-v10.html"}})


Add comment

Add comment

--- build.boot
+++ build.boot
@@ -1,4 +1,12 @@
 ;; Copyright © 2016, JUXT LTD.
+
+;; A complete development environment for websites in Clojure and
+;; ClojureScript.
+
+;; Most users will use 'boot dev' from the command-line or via an IDE
+;; (e.g. CIDER).
+
+;; See README.md for more details.

 (set-env!
  :source-paths #{"sass" "src"}


Bump devtools

Bump devtools

--- build.boot
+++ build.boot
@@ -33,7 +33,8 @@
                  [org.clojure/tools.reader    "1.0.0-alpha3"]
                  [cljsjs/enquire              "2.1.2-0"]
                  [com.cemerick/piggieback     "0.2.1"]
-                 [binaryage/devtools          "0.4.1"]
+                 [org.clojars.stumitchell/clairvoyant "0.2.0"]
+                 [binaryage/devtools          "0.5.2"]
                  [day8/re-frame-tracer        "0.1.0-SNAPSHOT"]
                  [cljsjs/codemirror           "5.10.0-0"]])


Add read/write bytes method to IBuffer interface and corresponding implementations.

--- src/bytebuf/buffer.clj
+++ src/bytebuf/buffer.clj
@@ -9,7 +9,10 @@
   (read-int [_ pos] "Read an integer (32 bits) from buffer.")
   (write-int [_ pos value] "Write an integer to the buffer.")
   (read-long [_ pos] "Read an long (64 bits) from buffer.")
-  (write-long [_ pos value] "Write an long to the buffer."))
+  (write-long [_ pos value] "Write an long to the buffer.")
+  (read-bytes [_ pos size] "Read a byte array.")
+  (write-bytes [_ pos size data] "Write byte array."))
+

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; NIO & Netty Buffer implementations
@@ -25,6 +28,16 @@
     (.putInt buff pos value))
   (write-long [buff pos value]
     (.putLong buff pos value))
+  (read-bytes [buff pos size]
+    (let [tmpbuf (byte-array size)
+          oldpos (.position buff)]
+      (.get buff tmpbuf)
+      (.position buff oldpos)
+      tmpbuf))
+  (write-bytes [buff pos size data]
+    (let [oldpos (.position buff)]
+      (.put buff data, 0, size)
+      (.position buff oldpos)))

   ByteBuf
   (read-int [buff pos]
@@ -34,7 +47,13 @@
   (write-int [buff pos value]
     (.setInt buff pos value))
   (write-long [buff pos value]
-    (.setLong buff pos value)))
+    (.setLong buff pos value))
+  (read-bytes [buff pos size]
+    (let [tmpbuf (byte-array size)]
+      (.getBytes buff tmpbuf)
+      tmpbuf))
+  (write-bytes [buff pos size data]
+    (.setBytes buff pos 0 size)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Public Api


more encyclopedic implications

more encyclopedic implications

--- src/babel/encyclopedia.cljc
+++ src/babel/encyclopedia.cljc
@@ -52,14 +52,18 @@
                        :part-of-human-body false
                        :pet false
                        :physical-object true
+                       :place false
                        :speakable false}

    {:consumable false} {:drinkable false
                         :edible false}

-   {:drinkable true}   {:mass true}
+   {:drinkable true}   {:consumable true
+                        :edible false
+                        :mass true}

-   {:edible true}      {:consumable true}
+   {:edible true}      {:consumable true
+                        :drinkable false}

    {:event true}       {:physical-object false}

@@ -85,7 +89,9 @@
    {:living false} {:animate false
                     :human false}

-   {:living true} {:artifact false}
+   {:living true} {:artifact false
+                   :place false}
+

    {:part-of-human-body true} {:consumable false
                                :human false
@@ -97,7 +103,8 @@
                 :human false
                 :spec {:of {:human true}}}

-   {:physical-object false} {:animate false}
+   {:physical-object false} {:animate false
+                             :consumable false}

    {:place true} {:activity false
                   :consumable false


Renamed event handler.

Renamed event handler.

--- src/cbfg/world/t1.cljs
+++ src/cbfg/world/t1.cljs
@@ -146,6 +146,8 @@
 (def run-world-hover
   (atom nil))

+; -------------------------------------------------------------------
+
 (defn render-world [app owner]
   (apply dom/ul nil
          (map (fn [[k v]] (dom/li nil (str k ":" v))) app)))
@@ -153,11 +155,11 @@
 (defn render-snapshot [app owner ss-ts]
   (render-world (get-in app [:snapshots ss-ts] nil) owner))

-(defn event-focus [snapshot-ts event-ts]
+(defn on-event-focus [snapshot-ts event-ts]
   (when-let [ss (get-in @run-history [:snapshots snapshot-ts])]
     (reset! run-world-hover ss)))

-(defn event-blur [snapshot-ts event-ts]
+(defn on-event-blur [snapshot-ts event-ts]
   (reset! run-world-hover nil))

 (defn render-events [app owner]
@@ -168,16 +170,16 @@
              (if (= kind :snapshot)
                [ts
                 (conj res
-                      (dom/li #js {:onMouseEnter #(event-focus ts nil)
-                                   :onMouseLeave #(event-blur ts nil)}
+                      (dom/li #js {:onMouseEnter #(on-event-focus ts nil)
+                                   :onMouseLeave #(on-event-blur ts nil)}
                               (str ts)
                               (render-snapshot app owner ts)))]
                [(or last-snapshot-ts ts)
                 (conj res
                       (dom/li #js {:onMouseEnter
-                                   #(event-focus last-snapshot-ts ts)
+                                   #(on-event-focus last-snapshot-ts ts)
                                    :onMouseLeave
-                                   #(event-blur last-snapshot-ts ts)}
+                                   #(on-event-blur last-snapshot-ts ts)}
                               (str ts (pr-str args))))]))
            [nil []]
            (:events app)))))


return nil if no such invite

return nil if no such invite

--- src/chat/server/db.clj
+++ src/chat/server/db.clj
@@ -314,7 +314,7 @@

 (defn get-invite
   [invite-id]
-  (-> (d/pull (d/db *conn*)
+  (some-> (d/pull (d/db *conn*)
               [:invite/id
                {:invite/from [:user/id]}
                :invite/to


Docstrings for all forms

Docstrings for all forms

--- src/branch_handler/core.clj
+++ src/branch_handler/core.clj
@@ -26,14 +26,29 @@
 (require '[clj-fileutils.fileutils :as file-utils])
 (require '[clj-jenkins-api.jenkins-api :as jenkins-api])

-(def verbose false)
-(def port    3000)
-(def workdir "/tmp/bare-repositories")
-(def job-list-command "/api/json?tree=jobs[name]")
-(def branch-job-prefix "branch-")
-
-
-(def jenkins-url (System/getenv "JENKINS_URL"))
+(def verbose
+  "Flag to enable or disable verbosity level."
+  false)
+
+(def port
+  "Default port for the service."
+  3000)
+
+(def workdir
+  "Working directory."
+  "/tmp/bare-repositories")
+
+(def job-list-command
+  "Command used to retrieve job list from Jenkins."
+  "/api/json?tree=jobs[name]")
+
+(def branch-job-prefix
+  "Prefix used for all 'branch' build jobs."
+  "branch-")
+
+(def jenkins-url
+  "URL to Jenkins server."
+  (System/getenv "JENKINS_URL"))

 (defn read-request-body
   "Read all informations from the request body."
@@ -41,38 +56,45 @@
   (file-utils/slurp- (:body request)))

 (defn log-request
+  "Record an event about request into log."
   [request]
   (log/info "Handling request: " (:uri request) (:remote-addr request))
   (if verbose
     (clojure.pprint/pprint request)))

 (defn send-response
+  "Send response in HTML format to client."
   [response-text]
   (-> (http-response/response response-text)
       (http-response/content-type "text/html")))

 (defn parse-gitlab-info
+  "Parse payload sent from GitLab in response body."
   [request]
   (let [body (read-request-body request)]
     (if body
       (json/read-str body :key-fn clojure.core/keyword))))

 (defn repo-workdir
+  "Construct name of work directory for given group and repository name."
   [workdir group reponame]
   (string/join "/" [workdir group reponame]))

 (defn repodir-exists?
+  "Check if directory exist for given group and repository name."
   [workdir group reponame]
   (let [f (new java.io.File (repo-workdir workdir group reponame))]
     (.isDirectory f)))

 (defn fetch-mirror-repo
+  "Fetch the content of selected repository."
   [workdir group reponame repository-url]
   (log/info "Fetching mirror repository" repository-url)
   ; TODO test --prune
   (shell/sh "git" "--git-dir" (repo-workdir workdir group reponame) "fetch"))

 (defn clone-mirror-repo
+  "Clone content of selected repository."
   [workdir group reponame repository-url]
   (log/info "Cloning mirror repository" repository-url)
   (shell/sh "git"
@@ -82,6 +104,7 @@
             (repo-workdir workdir group reponame)))

 (defn read-branch-list-from-repo
+  "Read list of all branches from selected repository."
   [workdir group reponame]
   (let [repodir (repo-workdir workdir group reponame)]
     (log/info "Reading branches from repository" repodir)
@@ -94,6 +117,7 @@
          (map #(subs % 2)))))

 (defn clone-or-fetch-mirror-repo
+  "Clone the repository or fetch data if directory with clone already exist."
   [action]
   (log/info "Cloning or fetching repository")
   (let [reponame       (:name action)
@@ -105,22 +129,26 @@
       (clone-mirror-repo workdir group reponame repository-url))))

 (defn start-jenkins-jobs
+  "Call Jenkins to start selected job."
   [jenkins-url action]
   (let [original-data (:original-data action)]
     (clojure.pprint/pprint original-data)))

 (defn filter-branch-jobs
+  "Filter jobs according to given prefix in job name."
   [all-jobs prefix]
   (for [job all-jobs
         :when (.startsWith (get job "name") prefix)]
     (get job "name")))

 (defn read-jobs-for-branches
+  "Read list of all jobs having specified prefix in job name."
   [jenkins-url job-list-command branch-job-prefix]
   (-> (jenkins-api/read-list-of-all-jobs jenkins-url job-list-command)
       (filter-branch-jobs branch-job-prefix)))

 (defn parse-job-name
+  "Parse the job name, try to get group, repository, and branch from it."
   [branch-job-prefix job-name]
   (let [parsed (clojure.string/split job-name #"\+")]
     (if (= (count parsed) 3)
@@ -131,11 +159,13 @@
        :branch     (clojure.string/trim (nth parsed 2))})))

 (defn parse-job-names
+  "Parse all job names, try to get group, repository, and branch from them."
   [branch-job-prefix job-names]
   (for [job-name job-names]
        (parse-job-name branch-job-prefix job-name)))

 (defn create-or-delete-jenkins-job
+  "Create or delete Jenkins job according to selected action."
   [jenkins-url job-list-command branch-job-prefix action]
   (log/info "Create-or-delete-jenkins-job")
   (let [reponame       (:name action)
@@ -148,10 +178,12 @@
     jobs-info))

 (defn create-action-queue
+  "Construct queue to store all actions that needs to be performed."
   []
   (java.util.concurrent.LinkedBlockingQueue.))

 (defn action-consumer
+  "Consumer that process messages dequed from action queue."
   [actions-queue]
   (while true
          (when-let [action (.take actions-queue)] ; blocking operation
@@ -165,18 +197,23 @@
            (log/info "Finished action for repository" action))))

 (defn start-action-consumer
+  "Start consumer of action queue in its own thread."
   [actions-queue]
   (log/info "Starting actions consumer")
   (future                                    ; start consumer in its own thread
     (action-consumer actions-queue)))

 (defn new-action
+  "Plan for a new action via action queue."
   [actions-queue action]
   (.put actions-queue action))

-(def empty-SHA "0000000000000000000000000000000000000000")
+(def empty-SHA
+  "Default SHA used to detect operation that needs to be performed."
+  "0000000000000000000000000000000000000000")

 (defn get-operation
+  "Get the next operation that needs to be planned."
   [before after]
   (if (= before empty-SHA)
     (if (= after empty-SHA)
@@ -187,14 +224,18 @@
         :branch-updated)))

 (defn get-branch
+  "Retrieve branch name for given Git reference."
   [git-ref]
   (try (subs git-ref (inc (.lastIndexOf git-ref "/")))
        (catch Exception e
               nil)))

-(def actions-queue (create-action-queue))
+(def actions-queue
+  "Queue to plan actions that will need to be performed."
+  (create-action-queue))

 (defn api-call-handler
+  "Handler for all API calls."
   [request]
   (let [gitlab-info      (parse-gitlab-info request)
         repository-url   (-> gitlab-info :repository :url)
@@ -244,6 +285,7 @@
   (jetty/run-jetty ring-app {:port port}))

 (defn create-workdir
+  "Create new working directory."
   [workdir]
   (let [directory (new java.io.File workdir)]
     (when-not (.isDirectory directory))


First attempt at simple storage-set.

First attempt at simple storage-set.

--- src/cbfg/world-storage.cljs
+++ src/cbfg/world-storage.cljs
@@ -2,30 +2,42 @@
   (:require-macros [cbfg.ago :refer [ago ago-loop achan-buf aput atake atimeout]])
   (:require [cljs.core.async :refer [<! merge map<]]
             [goog.dom :as gdom]
-            [cbfg.vis :refer [vis-init listen-el get-el-value
-                              get-el-innerHTML set-el-innerHTML]]
+            [cbfg.vis :refer [dissoc-in listen-el get-el-value
+                              get-el-innerHTML set-el-innerHTML
+                              vis-init ]]
             [cbfg.fence :refer [make-fenced-pump]]))

 (defn storage-get [storage opaque-id key]
   (let [s @storage
-        sq (get (:kvs s) key)
-        change (when sq (get (:changes s) sq))]
+        sq (get (:keys s) key)
+        change (get (:changes s) sq)]
     (if (and change (not (:deletion change)))
-      [:ok (:val change)]
-      [:not-found nil])))
+      [:ok {:val (:val change) :sq sq}]
+      [:not-found {}])))
+
+(defn storage-set [storage opaque-id key val]
+  (let [storage2 (swap! storage
+                        #(-> %
+                             (dissoc-in [:changes (get-in % [:keys key :sq])])
+                             (assoc-in [:keys key] (:next-sq %))
+                             (assoc-in [:changes (:next-sq %)]
+                                       {:key key :val val :sq (:next-sq %)})
+                             (update-in [:next-sq] inc)))]
+    [:ok {:sq (dec (:next-sq storage2))}]))

 (defn make-storage-cmd-handlers [storage]
   {"get" [["key"]
           (fn [c] {:rq (fn [actx]
                          (ago storage-cmd-get actx
-                              (let [[status val] (storage-get storage (:opaque-id c) (:key c))]
+                              (let [[status ext] (storage-get storage (:opaque-id c) (:key c))]
                                 {:opaque-id (:opaque-id c) :status status
-                                 :key (:key c) :val val})))})]
+                                 :key (:key c) :val (:val ext) :sq (:sq ext)})))})]
    "set" [["key" "val"]
           (fn [c] {:rq (fn [actx]
                          (ago storage-cmd-set actx
-                              {:opaque-id (:opaque-id c) :status :ok
-                               :key (:key c)}))})]
+                              (let [[status ext] (storage-set storage (:opaque-id c) (:key c) (:val c))]
+                                {:opaque-id (:opaque-id c) :status :ok
+                                 :key (:key c) :sq (:sq ext)})))})]
    "del" [["key"]
           (fn [c] {:rq (fn [actx]
                          (ago storage-cmd-del actx
@@ -56,7 +68,7 @@
                          (get-el-innerHTML (str el-prefix "-" log-kind "-log")))))

 (defn world-vis-init [el-prefix]
-  (let [storage (atom {:kvs {} :changes {} :last-sq 0 :max-deleted-sq 0})
+  (let [storage (atom {:keys {} :changes {} :next-sq 1 :max-deleted-sq 1})
         storage-cmd-handlers (make-storage-cmd-handlers storage)
         cmd-ch (map< (fn [ev] {:op (.-id (.-target ev))})
                      (merge (map #(listen-el (gdom/getElement %) "click")


Proto for pay.

Proto for pay.

--- src/ombs/handler/handle.clj
+++ src/ombs/handler/handle.clj
@@ -3,6 +3,7 @@
     [ombs.view.pages :as pages]
     [ombs.db :as db]
     [ombs.core :as core]
+    [ombs.validate :as isvalid]
     [noir.session :as sess]
     [noir.response :refer [redirect] ]
     [noir.validation :as vld]
@@ -24,3 +25,10 @@
     (redirect "/"))
   )

+(defn pay [{ename :event-name date :date price :price }]
+  "Add participation of current user and selected event(given as param from post)"
+  (let [uname (sess/get :username)
+        uid (db/get-uid uname)
+        eid (db/get-eid ename date)]
+    (isvalid/stake? eid uid)
+    ))