Add JS wrapper for the main API

Add JS wrapper for the main API

--- src/cljs/catsocket_client/core.cljs
+++ src/cljs/catsocket_client/core.cljs
@@ -124,7 +124,7 @@
       (swap! cat update-in [:sent-messages] assoc (:id params) params)
       (.send (:socket @cat) (stringify params)))
     (do
-      (log "enqueing")
+      ;; (log "enqueing")
       (swap! cat update-in [:queue] conj params))))

 (defn send [cat action data]
@@ -179,14 +179,21 @@
   (log "Closing the socket.. Bye!")
   (.close (:socket @cat)))

+(defn build [api-key host port]
+  (let [cat (init api-key)]
+    (reify
+      Object
+      (join [this room fn] (join cat room fn))
+      (leave [this room] (leave cat room))
+      (broadcast [this room msg] (broadcast cat room msg))
+      (close [this] (close cat)))))

 (defn main []
-  (let [cat (init "foo-key")]
+  (set! (.-catsocket js/window) (.-core js/catsocket_client))
+  (let [cat (init "foo")]
     (set! (.-nuf js/window) cat)
     (set! (.-su js/window) (:socket @cat))
-    (log cat)
     (join cat "test" #(log %))
-    (log "handlers:" (get-in @cat [:handlers]))
     (broadcast cat "test" "hello!"))


Remove paredit delete

Remove paredit delete

--- src/clojure/paredit_widget/core.clj
+++ src/clojure/paredit_widget/core.clj
@@ -62,7 +62,6 @@
    [nil "{"] :paredit-open-curly
    [nil "}"] :paredit-close-curly
    [nil "Backspace"] :paredit-backward-delete
-   [nil "Delete"] :paredit-forward-delete
    [nil "\""] :paredit-doublequote ;; \"
    ["C" "9"] :paredit-backward-slurp-sexp
    ["C" "0"] :paredit-forward-slurp-sexp
@@ -78,7 +77,6 @@

 (def ^:const advanced-alternative-keymap
   {[nil "⌫"] :paredit-backward-delete
-   [nil "⌦"] :paredit-forward-delete
    ["C" "Open Bracket"] :paredit-backward-barf-sexp
    ["C" "Close Bracket"] :paredit-forward-barf-sexp
    ["M" "←"] :paredit-expand-left


Support more configuration options for client creation.

--- src/http/async/client.clj
+++ src/http/async/client.clj
@@ -25,30 +25,47 @@
 (defn create-client
   "Creates new Async Http Client.
   Arguments:
-  - :user-agent - User-Agent branding string
-  - :request-timeout - global request timeout in ms
-  - :connection-timeout - global connections timeout in ms
-  - :idle-timeout - global idle connection timeout in ms"
-  [& {user-agent :user-agent
-      request-timeout :request-timeout
-      connection-timeout :connection-timeout
-      idle-timeout :idle-timeout
-      max-conns-per-host :max-conns-per-host
-      max-conns-total :max-conns-total}]
+  - :compression-enabled :: enable HTTP compression
+  - :connection-timeout :: connections timeout in ms
+  - :follow-redirects :: enable following HTTP redirects
+  - :idle-timeout :: idle connection timeout in ms
+  - :keep-alive :: enable HTTP keep alive, enabled by default
+  - :max-conns-per-host :: max number of polled connections per host
+  - :max-conns-total :: max number of total connections held open by client
+  - :max-redirects :: max nuber of redirects to follow
+  - :request-timeout :: request timeout in ms
+  - :user-agent :: User-Agent branding string"
+  [& {:keys [compression-enabled
+             connection-timeout
+             follow-redirects
+             idle-timeout
+             keep-alive
+             max-conns-per-host
+             max-conns-total
+             max-redirects
+             ;; proxy-server
+             ;; realm
+             request-timeout
+             user-agent]}]
   (AsyncHttpClient.
    (.build
     (let [b (AsyncHttpClientConfig$Builder.)]
-      (.setUserAgent b (if user-agent user-agent *user-agent*))
-      (when request-timeout (.setRequestTimeoutInMs b request-timeout))
+      (when compression-enabled (.setCompressionEnabled b compression-enabled))
       (when connection-timeout (.setConnectionTimeoutInMs b connection-timeout))
+      (when follow-redirects (.setFollowRedirects b follow-redirects))
       (when idle-timeout (.setIdleConnectionTimeoutInMs b idle-timeout))
+      (when keep-alive (.setKeepAlive b keep-alive))
       (when max-conns-per-host (.setMaximumConnectionsPerHost b max-conns-per-host))
       (when max-conns-total (.setMaximumConnectionsTotal b max-conns-total))
+      (when max-redirects (.setMaximumNumberOfRedirects b max-redirects))
+      (when request-timeout (.setRequestTimeoutInMs b request-timeout))
+      (.setUserAgent b (if user-agent user-agent *user-agent*))
       b))))

 (defmacro with-client
   "Creates new Async Http Client with given configuration
-  than executes body and closes the client."
+  than executes body and closes the client.
+  Config accepts same configuration options as create-client."
   [config & body]
   `(with-open [c# (create-client ~@(apply concat config))]
      (binding [*client* c#]


comopile exception to single warning message to support React Native

--- support/src/figwheel/client.cljs
+++ support/src/figwheel/client.cljs
@@ -352,12 +352,11 @@
     line (str " at line " line)
     (and line column) (str ", column " column)))

-(defn default-on-compile-fail [{:keys [formatted-exception exception-data cause] :as ed}]
-  (utils/log :debug "Figwheel: Compile Exception")
-  (doseq [msg (format-messages exception-data)]
-    (utils/log :info msg))
-  (if cause
-    (utils/log :info (str "Error on " (file-line-column ed))))
+(defn default-on-compile-fail [{:keys [exception-data cause] :as ed}]
+  (let [message (cond-> (apply str "Figwheel: Compile Exception " (format-messages exception-data))
+                  (:file exception-data)
+                  (str " Error on " (file-line-column exception-data)))]
+    (utils/log :warn message))
   ed)

 (defn default-on-compile-warning [{:keys [message] :as w}]


Unset styles on before/after

Unset styles on before/after

--- src/day8/re_frame/trace/styles.cljs
+++ src/day8/re_frame/trace/styles.cljs
@@ -28,7 +28,7 @@
 (def css-reset
   [:#--re-frame-trace--
    {:all "initial"}
-   [:*
+   [:* "*:before" "*:after"
     {:all "unset"}]


Use Google Closure to find dom element

Use Google Closure to find dom element

--- src/discuss/components/sidebar.cljs
+++ src/discuss/components/sidebar.cljs
@@ -2,6 +2,7 @@
   "Controlling the sidebar."
   (:require [om.core :as om]
             [om.dom :as dom]
+            [goog.dom :as gdom]
             [discuss.utils.common :as lib]
             [discuss.utils.views :as vlib]))

@@ -10,13 +11,13 @@
 (defn toggle
   "Toggle visibility of sidebar."
   ([]
-   (let [sidebar-dom (.getElementById js/document id)
-         main-wrapper (.getElementById js/document "main-wrapper")]
+   (let [sidebar-dom (gdom/getElement id)
+         main-wrapper (gdom/getElement "main-wrapper")]
      (lib/toggle-class sidebar-dom "active")
      (lib/toggle-class main-wrapper "active")))
   ([bool]
-   (let [sidebar-dom (.getElementById js/document id)
-         main-wrapper (.getElementById js/document "main-wrapper")]
+   (let [sidebar-dom (gdom/getElement id)
+         main-wrapper (gdom/getElement "main-wrapper")]
      (lib/toggle-class sidebar-dom "active" bool)
      (lib/toggle-class main-wrapper "active" bool))))


Refactoring from loop/recur to reduce as a step validating variables

--- src/graphql_clj/query_validator.clj
+++ src/graphql_clj/query_validator.clj
@@ -23,46 +23,6 @@
 (defn- get-root [schema def]
   (get (:roots schema) (if (= :mutation-definition (:tag def)) :mutation :query)))

-(defn- check-selection-set
-  [schema errors fragmap tname sset]
-  (let [tdef (get-in schema [:type-map tname])
-        fieldmap (:field-map tdef)]
-    (if (nil? (:selection-set sset))
-      [errors sset]
-      (loop [errors errors vfields [] [f & fields] (:selection-set sset)]
-        (if f
-          (case (:tag f)
-            :selection-field
-            (if-let [fdecl (get fieldmap (:name f))]
-              (let [[errors f] (check-selection-set schema errors fragmap (base-type (:type fdecl)) f)]
-                (recur errors (conj vfields (assoc f :resolved-type (:type fdecl))) fields))
-              (recur (if (:alias f)
-                       (err errors (:name f) "field '%s' (aliased as '%s') is not defined on type '%s'" (:name f) (:alias f) tname)
-                       (err errors (:name f) "field '%s' is not defined on type '%s'" (:name f) tname))
-                     vfields
-                     fields))
-
-            :inline-fragment
-            (let [on (get-in f [:on :name])]
-              (if-let [ontype (get-in schema [:type-map on])]
-                (case (:tag ontype)
-                  (:type-definition :interface-definition :union-definition)
-                  (recur errors vfields fields) ;; TODO: check-selection-set recurse
-                  (recur (err errors on "inline fragment on non-composite type '%s'" on) vfields fields))
-                (recur (err errors on "inline fragment on undefined type '%s'" on) vfields fields)))
-
-            :fragment-spread
-            (if-let [frag (fragmap (:name f))]
-              (recur errors vfields fields)
-              (recur (err errors (:name f) "fragment '%s' is not defined" (:name f)) vfields fields)))
-          [errors (assoc sset :selection-set vfields)])))))
-
-(defn- build-fragment-map [errors schema query]
-  (loop [errors errors fmap {} [def & defs] (filter #(= :fragment-definition (:tag %)) query)]
-    (cond
-      (nil? def) [errors fmap]
-      (contains? fmap (:name def)) (recur (err errors (:name def) "fragment '%s' is already declared" (:name def)) fmap defs)
-      :else (recur errors (assoc fmap (:name def) def) defs))))

 ;; Compute the referenced fragment set from a given selection-set.
 ;; The result is a hash set of symbols of fragments referenced by the
@@ -110,44 +70,122 @@
                                    (into #{}) ;; put it back into a set, then assoc it to the updated graph
                                    (assoc g' k))) {}))))))

-(defn- check-operations [errors schema fmap query]
-  (loop [errors errors vdefs [] anon nil dmap {} fmap' fmap [def & defs] query]
-    (if def
-      (case (:tag def)
-        :selection-set
-        (if anon
-          ;; 5.1.2.1 lone anonymous operation
-          (recur (err errors def "anonymous selection set is already declared") vdefs anon dmap fmap' defs)
-          (let [[errors def] (check-selection-set schema errors fmap (get-in schema [:roots :query]) def)]
-            (recur errors (conj vdefs def) def dmap fmap' defs)))
+(defn- check-fragment-cycles [a]
+  (loop [errors (:errors a) g (build-fragment-ref-graph (:fragment-map a))]
+    (if (empty? g)
+      (assoc a :errors errors)
+      ;; recurrance:
+      ;; (1) cyclic reference is detected when a fragment references
+      ;; itself after transitive dependencies are added.
+      ;; (2) the graph is updated to remove all nodes with no
+      ;; references remaining (thus cannot participate in a cyclic
+      ;; reference), or when the error for the cyclic reference has
+      ;; been recorded.  The map is then updated to add dependencies
+      (recur (->> (filter #(contains? (% 1) (% 0)) g)
+                  (reduce #(err %1 (%2 0) "fragment '%s' contains a cyclic reference" (%2 0)) errors))
+             (->> (remove (fn [[k v]] (or (contains? v k) (empty? v))) g)
+                  (reduce (fn [g' [k v]]
+                              (->> (map g v) ;; map a dependency to its frag reference sets
+                                   (reduce set/union v) ;; union them together
+                                   (filter g) ;; remove dependencies no longer in graph
+                                   (into #{}) ;; put it back into a set, then assoc it to the updated graph
+                                   (assoc g' k))) {}))))))

-        (:mutation :query-definition)
-        (if (contains? dmap (:name def))
-          ;; 5.1.1.1 operation name uniqueness
-          (recur (err errors (:name def) "operation with name '%s' is already declared" (:name def)) vdefs anon dmap fmap' defs)
-          (let [[errors def] (check-selection-set schema errors fmap (get-root schema def) def)]
-            (recur errors (conj vdefs def) anon (assoc dmap (:name def) def) fmap' defs)))
+(declare check-selection-set)

-        :fragment-definition
-        (let [on (get-in def [:on :name])]
-          (if-let [t (get-in schema [:type-map on])]
-            (if (#{:type-definition :interface-definition :union-definition} (:tag t))
-              (let [[errors def] (check-selection-set schema errors fmap on def)]
-                (recur errors vdefs anon dmap (assoc fmap' (:name def) def) defs))
-              ;; 5.4.1.3 Fragments on composite types
-              (recur (err errors on "fragment on non-composite type '%s'" on) vdefs anon dmap fmap' defs))
-            (recur (err errors on "fragment on undefined type '%s'" on) vdefs anon dmap fmap' defs))))
+(defn- check-field [tdef field-map a f]
+  (case (:tag f)
+    :selection-field
+    (if-let [fdecl (field-map (:name f))]
+      (let [[errors f] (check-selection-set (base-type (:type fdecl)) a (assoc f :resolved-type (:type fdecl)))]
+        (-> (assoc a :errors errors)
+            (update :vfields conj f)))
+      (if (:alias f)
+        (update a :errors err (:name f) "field '%s' (aliased as '%s') is not defined on type '%s'" (:name f) (:alias f) (:name tdef))
+        (update a :errors err (:name f) "field '%s' is not defined on type '%s'" (:name f) (:name tdef))))

-      ;; else, end of defs:
-      ;; 5.1.2.1 lone anonymous operation
-      [(if (and anon (not (empty? dmap)))
-         (err errors anon "anonymous selection set must be lone operation")
-         errors)
-       vdefs])))
-
+    :inline-fragment
+    (let [on (get-in f [:on :name])]
+      (if-let [ontype (get-in a [:schema :type-map on])]
+        (if (contains? #{:type-definition :interface-definition :union-definition} (:tag ontype))
+          a
+          (update a :errors err on "inline fragment on non-composite type '%s'" on))
+        (update a :errors err on "inline fragment on undefined type '%s'" on)))
+
+    :fragment-spread
+    (if-let [frag (get-in a [:fragment-map (:name f)])]
+      a
+      (update a :errors err (:name f) "fragment '%s' is not defined" (:name f)))))
+
+(defn- check-selection-set [tname a def]
+  (if-let [sset (:selection-set def)]
+    (let [tdef (get-in a [:schema :type-map tname])
+          field-map (:field-map tdef)
+          a (reduce (partial check-field tdef field-map) (assoc a :vfields []) sset)]
+      [(:errors a) (assoc def :selection-set (:vfields a))])
+    [(:errors a) def]))
+
+(defn- check-definition [a def]
+  (case (:tag def)
+    :selection-set
+    (if (:anon a)
+      (update a :errors err def "anonymous selection set is already declared")
+      (let [[errors def] (check-selection-set (get-in a [:schema :roots :query]) a def)]
+        (-> (assoc a :errors errors :anon def)
+            (update :query conj def))))
+
+    (:mutation :query-definition)
+    (if (contains? (:def-map a) (:name def))
+      ;; 5.1.1.1 operation name uniqueness
+      (update a :errors err (:name def) "operation with name '%s' is already declared" (:name def))
+      (let [[errors def] (check-selection-set (get-root (:schema a) def) a def)]
+        (-> (assoc a :errors errors)
+            (update :def-map assoc (:name def) def)
+            (update :query conj def))))
+
+    :fragment-definition
+    (let [on (get-in def [:on :name])]
+      (if-let [t (get-in a [:schema :type-map on])]
+        (if (#{:type-definition :interface-definition :union-definition} (:tag t))
+          (let [[errors def] (check-selection-set on a def)]
+            (-> (assoc a :errors errors)
+                (assoc-in [:fragment-map (:name def)] def)))
+          ;; 5.4.1.3 Fragments on composite types
+          (update a :errors err on "fragment on non-composite type '%s'" on))
+        (update a :errors err on "fragment on undefined type '%s'" on)))))
+
+(defn- check-definitions [a]
+  (reduce check-definition (assoc a :query []) (:query a)))
+
+;; 5.1.2.1 lone anonymous operation
+;; must be called after check-definition
+(defn- check-lone-anonymous [a]
+  (if (and (:anon a) (not (empty? (:def-map a))))
+    (update a :errors err (:anon a) "anonymous selection set must be lone operation")
+    a))
+
+(defn- check-fragment [a def]
+  (if (contains? (:fragment-map a) (:name def))
+    (update a :errors err (:name def) "fragment '%s' is already declared" (:name def))
+    (assoc-in a [:fragment-map (:name def)] def)))
+
+(defn- build-fragment-map [a]
+  (->> (:query a)
+       (filter #(= :fragment-definition (:tag %)))
+       (reduce check-fragment a)))
+
+(defn- restructure [a]  [(:errors a) (:query a)])
+
 (defn validate-query
   [schema query]
-  (let [[errors fmap] (build-fragment-map [] schema query)
-        fragment-errors (check-fragment-cycles errors fmap)
-        [errors vquery] (check-operations fragment-errors schema fmap query)]
-    [(vec errors) vquery]))
+  (-> {:errors []
+       :query query
+       :schema schema
+       :anon nil
+       :fragment-map {}
+       :def-map {}}
+      (build-fragment-map)
+      (check-fragment-cycles)
+      (check-definitions)
+      (check-lone-anonymous)
+      (restructure)))


Extract laserplayer function

Extract laserplayer function

--- src/overtone_workspace/grunbles.clj
+++ src/overtone_workspace/grunbles.clj
@@ -46,21 +46,31 @@
         rel (* dur (* 4 15))]  ; 15bars
     (at (metro beat)
         (do
-          (laserbeam :pan (- (rand 2) 1.0) :freq (+ (rand-int 5000) 1000))
           (if (zero? (mod beat 8)) (grumble :freq freq :freq-mul 0.5 :attack attack :release rel))
           (if (zero? (mod beat 16)) (grumble :freq freq :freq-mul 1 :attack attack :release rel))
           (if (zero? (mod beat 48)) (grumble :freq freq :freq-mul (choose rates) :attack attack :release rel))
           ))
-    (at (metro (+ beat 0.25))
-          (laserbeam :pan (- (rand 2) 1.0) :freq (+ (rand-int 5000) 1000)))
-    (at (metro (+ beat 0.5))
-          (laserbeam :pan (- (rand 2) 1.0) :freq (+ (rand-int 5000) 1000)))
-    (at (metro (+ beat 0.75))
-          (laserbeam :pan (- (rand 2) 1.0) :freq (+ (rand-int 5000) 1000)))
     (apply-by (metro (inc beat)) #'player (inc beat) rates [])
     ))

 (player (metro) [])
+
+(defn laserplayer [beat]
+  (let [dur (/ 60.0 (metro :bpm))]  ; 15bars
+    (at (metro beat)
+      (laserbeam :pan (- (rand 2) 1.0) :freq (+ (rand-int 5000) 1000)))
+    (at (metro (+ beat 0.25))
+      (laserbeam :pan (- (rand 2) 1.0) :freq (+ (rand-int 5000) 1000)))
+    (at (metro (+ beat 0.5))
+      (laserbeam :pan (- (rand 2) 1.0) :freq (+ (rand-int 5000) 1000)))
+    (at (metro (+ beat 0.75))
+      (laserbeam :pan (- (rand 2) 1.0) :freq (+ (rand-int 5000) 1000)))
+    (apply-by (metro (inc beat)) #'laserplayer (inc beat) [])
+    ))
+
+
+;(laserplayer (metro))
+
 ;;(stop)

 ;; (def dirty-kick (freesound 777))


Conditionally complete.

Conditionally complete.

--- src/onyx/peer/task_lifecycle.clj
+++ src/onyx/peer/task_lifecycle.clj
@@ -83,8 +83,8 @@
             response (<!! seal-response-ch)]
         (swap! pipeline-state assoc :tried-to-seal? true)
         (if response
-          (merge event (p-ext/seal-resource event) {:onyx.core/sealed? true})
-          (merge event {:onyx.core/sealed? true}))))))
+          (merge event (p-ext/seal-resource event) {:onyx.core/sealed? response})
+          (merge event {:onyx.core/sealed? response}))))))

 (defn munge-complete-task
   [{:keys [onyx.core/pipeline-state onyx.core/sealed? onyx.core/outbox-ch] :as event}]


Speed up read - tails reads on vec are slow.

--- src/onyx/queue/hornetq_utils.clj
+++ src/onyx/queue/hornetq_utils.clj
@@ -119,14 +119,17 @@
     (let [consumer (.createConsumer session queue-name)
           results (atom [])]
       (.start session)
-      (while (not= (last @results) :done)
-        (when (zero? (mod (count @results) echo))
-          (info (format "Read %s segments" (count @results)))
-          (.commit session))
-        (let [message (.receive consumer)]
-          (when message
-            (.acknowledge message)
-            (swap! results conj (fressian/read (.toByteBuffer (.getBodyBuffer message)))))))
+      (loop [last-message nil]
+        (when (not= last-message :done)
+          (when (zero? (mod (count @results) echo))
+            (info (format "Read %s segments" (count @results)))
+            (.commit session))
+          (let [message (.receive consumer)]
+            (when message
+              (let [decompressed (fressian/read (.toByteBuffer (.getBodyBuffer message)))]
+                (.acknowledge message)
+                (swap! results conj decompressed)
+                (recur decompressed))))))

       (info "Done reading")
       (.commit session)


Fix typo in convertion function name

Fix typo in convertion function name

--- src/strava_activity_graphs/core.clj
+++ src/strava_activity_graphs/core.clj
@@ -11,7 +11,7 @@
                      "https://www.strava.com/api/v3/activities"
                      {:query-params {:access_token token :per_page 200}}))))

-(def meters-per-hour->kilometers-per-hour (partial * 3.6))
+(def meters-per-second->kilometers-per-hour (partial * 3.6))
 (defn- seconds->minutes [s] (/ s 60))
 (defn- string-date->millis [str-date]
   (.getTime
@@ -19,7 +19,7 @@

 (defn- get-activities [token]
   (->> (strava-json-activities token)
-       (map #(update-in % ["average_speed"] meters-per-hour->kilometers-per-hour))
+       (map #(update-in % ["average_speed"] meters-per-second->kilometers-per-hour))
        (map #(update-in % ["start_date_local"] string-date->millis))
        (map #(update-in % ["elapsed_time"] seconds->minutes))
        (map #(update-in % ["moving_time"] seconds->minutes))))


Add prob-* settings

Add prob-* settings

--- src/overtone_workspace/beats.clj
+++ src/overtone_workspace/beats.clj
@@ -221,8 +221,17 @@
   (swap! *fn-beats assoc rand-latchbell (vec (repeat 8 1)))
   (swap! *fn-beats assoc rand-latchbell (vec (repeat 16 1)))
   (swap! *fn-beats assoc rand-latchbell [_])
+
+  (let
+    [fnrep 128]
+    (swap! *fn-beats assoc ambi-rand (vec (repeat fnrep 1)))
+    (swap! *fn-beats assoc prob-kick (vec (repeat fnrep 0.6)))
+    (swap! *fn-beats assoc prob-sd (vec (repeat fnrep 0.6)))
+    (swap! *fn-beats assoc prob-hat (vec (repeat fnrep 0.4)))
+    (swap! *fn-beats assoc prob-openhh (vec (repeat fnrep 0.4))))
   (do
     ;; prob-beats
+    (swap! *fn-beats assoc ambi-rand (vec (repeat 32 1)))
     (swap! *fn-beats assoc prob-kick (take 32 (cycle [10 0 2 0 6 0 2 0 3 0 6 0 1.1 0 2 4])))
     (swap! *fn-beats assoc prob-sd (take 32 (cycle [0 0 1.1 0 1.1 0 6 0 6 0 1.1 0 1.1 0 6 0])))
     (swap! *fn-beats assoc prob-hat (take 32 (cycle [10 2 8 2 1 2])))


Stupid arity bug

Stupid arity bug

--- src/oxcart/passes/tree_shake.clj
+++ src/oxcart/passes/tree_shake.clj
@@ -129,7 +129,7 @@
   {:pre [(every? symbol? modules)
          (symbol? entry)
          (every? (partial contains? ast) modules)]}
-  (let [ast      (require-pass analyze-var-dependencies options)
+  (let [ast      (require-pass ast analyze-var-dependencies options)
         emit-set (get (:reach-map ast) (resolve entry))]
     (-> ast
         (trim-with-emit-set emit-set)


core: keep

core: keep

--- core/data/core.clj
+++ core/data/core.clj
@@ -2485,6 +2485,19 @@
           g
           (last steps)))))

+(defn keep
+  "Returns a lazy sequence of the non-nil results of (f item). Note,
+  this means false return values will be included.  f must be free of
+  side-effects."
+  {:added "1.0"}
+  [f coll]
+  (lazy-seq
+   (when-let [s (seq coll)]
+     (let [x (f (first s))]
+       (if (nil? x)
+         (keep f (rest s))
+         (cons x (keep f (rest s))))))))
+
 (defn slurp
   "Opens a file f and reads all its contents, returning a string."
   {:added "1.0"}


Layout Shape resize controls

Layout Shape resize controls

--- src/uxbox/ui/workspace/selrect.cljs
+++ src/uxbox/ui/workspace/selrect.cljs
@@ -42,9 +42,9 @@
    :vectorEffect "non-scaling-stroke"})

 (def ^:private default-selection-props
-  {:r 4 :style selection-circle-style
-   :fill "lavender"
-   :stroke "gray"})
+  {:r 5 :style selection-circle-style
+   :fill "#333"
+   :stroke "#333"})

 (defn shapes-selrect-render
   [own shapes]
@@ -53,9 +53,9 @@
           {:keys [width height x y]} (sh/group-size-and-position shapes)]
       (html
        [:g.controls
-        [:rect {:x x :y y :width width :height height
-                :style {:stroke "black" :fill "transparent"
-                        :stroke-opacity "0.5"}}]
+        [:rect {:x x :y y :width width :height height :stroke-dasharray "5,5"
+                :style {:stroke "#333" :fill "transparent"
+                        :stroke-opacity "1"}}]
         [:circle.top-left (merge default-selection-props
                                  {:cx x :cy y})]
         [:circle.top-right (merge default-selection-props


20Sep13b minor surpiouse char

20Sep13b minor surpiouse char

--- src/main/clojure/redbridge/blog1.clj
+++ src/main/clojure/redbridge/blog1.clj
@@ -31,7 +31,7 @@
 ;; => Logging on the REPL console

 ;; common map function
-s
+
 (keys c2j-m1)
 ;; =>
 '("class" "method")


[Fix #38] Make artifact-versions work on its own

in cljr we always call `artifact-list` followed by `artifact-versions`
on one of the results.  This puts in place a guard which fetches info
about the artifacts in the even `artifact-list` was called first so we
don't return the wrong thing.

--- src/refactor_nrepl/artifacts.clj
+++ src/refactor_nrepl/artifacts.clj
@@ -95,6 +95,8 @@
     (transport/send transport (response-for msg :value names :status :done))))

 (defn- artifact-versions [{:keys [transport artifact] :as msg}]
+  (when (stale-cache?)
+    (update-artifact-cache!))
   (let [versions (->> artifact (@artifacts) (interpose " ") (apply str))]
     (transport/send transport (response-for msg :value versions  :status :done))))


Update lesson 1 to work for linear regression with multiple variables

--- src/Lucas/lesson1.clj
+++ src/Lucas/lesson1.clj
@@ -1,22 +1,30 @@
 ;; All about higher order functions =)
+;; Linear Regression with multiple variables
+
 (ns mlpractice.lesson1)

+;innefficient because iterate holds onto old maps, should use a different function?
 (defn generate-data-set
-  "Generates a map of :x y values for linear regression"
-  [constant slope num]
+  "Generates a map of a vector x of feature values
+   to its y value for linear regression"
+  [data-point-num & coefficients]
   (nth (iterate
-        #(let [x (Math/random)]
-           (assoc %1 x (+ constant (* slope x)))) {}) num))
+        #(let [n (count coefficients)
+               x-vec (repeatedly n (fn [] (Math/random)))]
+           (assoc %1 x-vec (apply + (map * x-vec coefficients))))
+        {})
+       data-point-num))

 (defn hypothesis-fn
-  "Builds the hypothesis function h(x) using th0 and th1"
-  [theta0 theta1]
+  "Builds the hypothesis function h(x) using a vector theta of coefficients"
+  [param-vec]
   (fn h
-    [x]
-    (+ theta0 (* theta1 x))))
+    [feature-vec]
+    (apply + (map * param-vec feature-vec))))

 (defn cost-summation
-  "The function that gets applied to every entry in every data set"
+  "The function that finds the error between our hypothesis function
+   and our actual y value, and adds it to an aggregate"
   [hypothesis agg data]
   (let [x (first data)
         y (second data)]
@@ -28,7 +36,9 @@
   [data]
   (let [coefficient (->> data (count) (* 2) (/ 1))]
     (fn cost
-      [th0 th1]
-      (let [hypothesis (hypothesis-fn th0 th1)]
-        (* coefficient
-           (reduce (partial cost-summation hypothesis) 0 data))))))
+      [param-vec]
+      (let [hypothesis (hypothesis-fn param-vec)]
+        (-> (partial cost-summation hypothesis)
+            (reduce 0 data)
+            (Math/pow 2)
+            (* coefficient))))))


Return status view

Return status view

Former-commit-id: b4c9c724813493b5a9fce8c57510bd5a5825d627

--- src/syng_im/components/chat.cljs
+++ src/syng_im/components/chat.cljs
@@ -148,19 +148,19 @@
       (let [msgs                @messages
                                         ;_                 (log/debug "messages=" msgs)
             ;; temp to show first status
-            ;; msgs-clj (assoc (js->clj msgs) "-1"
-            ;;                 {:msg-id "-1"
-            ;;                  :content (str "The brash businessman’s braggadocio "
-            ;;                                "and public exchange with candidates "
-            ;;                                "in the US presidential election")
-            ;;                  :delivery-status "seen"
-            ;;                  :from "Status"
-            ;;                  :chat-id "-"
-            ;;                  :content-type content-type-status
-            ;;                  :timestamp 1
-            ;;                  :outgoing false
-            ;;                  :to nil})
-            ;; msgs (clj->js msgs-clj)
+            msgs-clj (assoc (js->clj msgs) "-1"
+                            {:msg-id "-1"
+                             :content (str "The brash businessman’s braggadocio "
+                                           "and public exchange with candidates "
+                                           "in the US presidential election")
+                             :delivery-status "seen"
+                             :from "Status"
+                             :chat-id "-"
+                             :content-type content-type-status
+                             :timestamp 1
+                             :outgoing false
+                             :to nil})
+            msgs (clj->js msgs-clj)
             ;; end temp
             datasource          (to-realm-datasource msgs)
             contacts            (:contacts @chat)


added table with dropdown for client adjudicator selection

--- src/tango/cljs/runtime/core.cljs
+++ src/tango/cljs/runtime/core.cljs
@@ -295,22 +295,73 @@
   Object
   (render
     [this]
-    (let [client (:client (om/props this))]
-      (dom/div nil
-        (dom/h3 nil (str "Client Name : " (:client/name client)))))))
+    (let [client (:client (om/props this))
+          panels (sort-by :adjudicator-panel/name (:adjudicator-panels (om/props this)))]
+      (dom/tr nil
+        (dom/td nil (:client/name client))
+        (dom/td nil
+                (dom/div #js {:className "dropdown"}
+                  (dom/button #js {:className "btn btn-default dropdown-toggle"
+                                   :data-toggle "dropdown"} ""
+                              (dom/span #js {:className "selection"} "AA ")
+                              (dom/span #js {:className "caret"}))
+                  ;(dom/ul #js {:className "dropdown-menu"
+                  ;             :role "menu"}
+                  ;  (dom/li #js {:className "dropdown-header"} (str "Panel - "
+                  ;                                                  (:adjudicator-panel/name (first panels))))
+                  ;  (dom/li #js {:role "presentation"}
+                  ;    (dom/a #js {:role "menuitem"} "AA"))
+                  ;  (dom/li #js {:role "presentation"}
+                  ;    (dom/a #js {:role "menuitem"} "BB")))
+
+                  (apply dom/ul #js {:className "dropdown-menu" :role "menu"}
+                    (map (fn [panel]
+                           [(dom/li #js {:className "dropdown-header"}
+                              (str "Panel - " (:adjudicator-panel/name panel)))
+                            (map (fn [adjudicator]
+                                   (dom/li #js {:role    "presentation"
+                                                :onClick #(log (str "Change ajd to " (:adjudicator/name adjudicator)))}
+                                     (dom/a #js {:role "menuitem"} (:adjudicator/name adjudicator))))
+                                 (:adjudicator-panel/adjudicators panel))])
+                         panels))
+                  ))
+        ))))
+
+;

+;<button class="btn btn-default dropdown-toggle" type="button" id="menu1" data-toggle="dropdown">Tutorials
+;</button>
+;

+;
HTML

+;
CSS

+;
JavaScript

+;

+;
About Us

+;

+;

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Clients View
 (defui ClientsView
   static om/IQuery
   (query [_]
-    [:client/id :client/name])
-  Object
-  (render
-    [this]
-    (let [clients (:clients (om/props this))]
-      (dom/div nil
-        (map #((om/factory ClientRow) {:client %}) clients)))))
+    (into [] (om/get-query ClientRow)))
+  Object
+  (render
+    [this]
+    (let [clients (:clients (om/props this))
+          panels (:adjudicator-panels (om/props this))]
+      (log "Ajd")
+      (log panels)
+      (dom/div nil
+        (dom/h2 nil "Clients")
+        (dom/table
+          #js {:className "table table-hover table-condensed"}
+          (dom/thead nil
+            (dom/tr nil
+              (dom/th #js {:width "100"} "Name")
+              (dom/th #js {:width "50"} "Assigned to Adjudicator")))
+          (apply dom/tbody nil (map #((om/factory ClientRow) {:client       %
+                                                              :adjudicator-panels panels}) clients)))))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; MainComponent
@@ -318,7 +369,11 @@
 (defui MainComponent
   static om/IQuery
   (query [_]
-    [{:app/selected-competition (into [:competition/name :competition/location]
+    [{:app/selected-competition (into [:competition/name :competition/location
+                                       {:competition/panels [:adjudicator-panel/name
+                                                             {:adjudicator-panel/adjudicators
+                                                              [:adjudicator/id
+                                                               :adjudicator/name]}]}]
                                       (concat (om/get-query ScheduleView)))}
      :app/status
      :app/selected-page
@@ -346,7 +401,8 @@
                                                      (:app/selected-activities p)
                                                      :speaker-activities
                                                      (:app/speaker-activities p)})
-          :clients ((om/factory ClientsView) {:clients (:app/clients p)}))
+          :clients ((om/factory ClientsView) {:clients      (:app/clients p)
+                                              :adjudicator-panels (:competition/panels selected-competition)}))
         ))))

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


Add prepare-word function to trim/line-split each word

--- src/text_justification/core.cljs
+++ src/text_justification/core.cljs
@@ -31,23 +31,24 @@

 (defn text_justification[words page_width]
   (if (empty? words) [0.0 []]
-  (reduce (fn[acc word_id]
-    (let [ prev_ugliness (first acc) line (subvec words 0 word_id) rest_words (subvec words word_id)
-      sub_problem_solution (text_justification rest_words page_width)
-      ugliness (+ (badness line page_width) (first sub_problem_solution)) ; combined ugliness (line now + all lines under)
-      solution_proposal (cons line (second sub_problem_solution))]
-      (if (< ugliness prev_ugliness) [ugliness solution_proposal] acc))
-    ) [js/Infinity []] (map inc (range (count words))) )))
-
-;; TODO paragraphs
+    (reduce ( fn
+      [acc word_id]
+      (let [line (subvec words 0 word_id) rest_words (subvec words word_id)
+            sub_problem_solution (text_justification rest_words page_width)
+            ugliness (+ (badness line page_width) (first sub_problem_solution))
+            solution_proposal (cons line (second sub_problem_solution))]
+        ; (print "sub" line "|words in line" (count words))
+        (if (< ugliness (first acc)) [ugliness solution_proposal] acc)))
+    [js/Infinity []]
+    (map inc (range (count words))) )))

 (defn stretch_string [line max_width]
-  (let [ str_len (count line)
-    char_count (count_chars line) ;; total characters in provided string
-    chars_left (- max_width char_count) ;; chars left in line
-    spaces_per_break_f (float (/ chars_left (dec str_len)))
-    spaces_per_break_i (int spaces_per_break_f)
-    extra_space_every_X_words (/ 1 (- spaces_per_break_f spaces_per_break_i))]
+  (let [str_len (count line)
+        char_count (count_chars line) ;; total characters in provided string
+        chars_left (- max_width char_count) ;; chars left in line
+        spaces_per_break_f (float (/ chars_left (dec str_len)))
+        spaces_per_break_i (int spaces_per_break_f)
+        extra_space_every_X_words (/ 1 (- spaces_per_break_f spaces_per_break_i))]
     ; (if (> char_count max_width) ;; TODO restore this
       ; (throw (Exception. "Could not stretch string, it is already too long")))
     (second (reduce (fn [acc e] ;; run reduce and take second component
@@ -60,37 +61,59 @@
       [1 ""] line))
 ))

+(defn prepare-word "remove whitespaces, split word if it is too long" [max-len word-raw]
+  (let [word (gstring/trim word-raw) len (count word)]
+    (cond
+      (<= max-len 0) word
+      (= len 0) space-char
+      (<= len max-len) word
+      ;;:else (str (.substring word 0 max-len) " _" (prepare-word max-len (.substring word max-len)))) ;; TODO return list and then flatten
+      :else [(.substring word 0 max-len) (str " -" (prepare-word max-len (.substring word max-len)))] ;; TODO return list and then flatten
+    )))
+; (println "norm:" (prepare-word 3 "abc"))
+; (println "trim:" (prepare-word 3 "  abc  "))
+; (println "long:" (prepare-word 2 "abc"))
+; (println "test:" (prepare-word 11 "aaabbbccc111"))

-(defn execute []
-  (.log js/console "Execute !!!")
+(defn execute [target-el lazy-text page-width]
+  ;; clear target text
   (dom/removeChildren target-el)

-  (let [strs (seq (.split (get-text) #" "))
-    justified_lines (second (text_justification strs page-width))]
-    ;;(print ">>" justified_lines)
-    ;;(print "<<" strs)
-    (doseq [line_strs justified_lines]
-      (let [line (stretch_string line_strs page-width)
-        el (.createElement js/document "div")]
-        (println "line:" line)
-        (.appendChild target-el el)
-        (set! (.-innerText el) line)
-        )))
+  ;; paragraphs
+  (doseq [paragraph (seq (.split (lazy-text) "\n"))] ;; TODO if paragraph is empty ? should leave it empty
+    (println "PARAGRAPH:" paragraph)
+    (let [words-raw  (.split paragraph #" ")
+          words (vec (flatten (map #(prepare-word page-width %) words-raw)))
+          ; justified_lines words] ;; debug
+          [_ justified_lines] (text_justification words page-width)]
+      ; (print ">>" words)
+      ; (print "<<" justified_lines)
+      ; (print (type words))
+      (doseq [line_strs justified_lines]
+        (let [line (stretch_string line_strs page-width)
+          el (.createElement js/document "div")]
+          ; (println "line:" line)
+          (.appendChild target-el el)
+          (set! (.-innerText el) line)
+          )))
+    )
   )

 ;; remove listeners from text area
 (let [ old-node (get-text-el) new-node (.cloneNode old-node true)]
   (.replaceChild (.-parentNode old-node) new-node old-node)
+  (set! (.-value new-node) "Bleh Bleh Bleh Bleh aaabbbccc\n\naaa bbb")
+  ; (set! (.-value new-node) "aaabbbccc111 a")
+  ; (set! (.-value new-node) "aaabbbccc11 -1 a")
   )

 ;; add keyup listner to text-el
  (.addEventListener (get-text-el) "keyup" (fn [] ;; TODO only characters, not f.e. arrows
-  (execute)
+  (execute target-el get-text page-width)
   ))

-(execute)
-
+(execute target-el get-text page-width)

 (comment


one possibility...

one possibility...

--- src/unspun/screens/rum_bars.cljs
+++ src/unspun/screens/rum_bars.cljs
@@ -1,7 +1,8 @@
 (ns unspun.screens.rum-bars
   (:require-macros [rum.core :refer [defc defcs]])
   (:require [rum.core :as rum]
-            [shared.ui :refer [font-scale pixel-ratio get-dimensions text-field-font-size ios? button]]
+            [unspun.navigation.bottom-nav :refer [bottom-button-bar next-story previous-icon]]
+            [shared.ui :refer [font-scale pixel-ratio get-dimensions text-field-font-size ios? button txt]]
             [cljs-exponent.components :refer [element text view image status-bar animated-view scroll-view] :as rn]
             [themes.palettes :refer [get-palette]]
             [unspun.db :refer [app-state palette-index stories story-index compare-text-vector to-pc clamp]]
@@ -159,7 +160,7 @@
                             :justifyContent "center"
                             :alignItems     "stretch"
                             }}
-                   (scroll-view {:style {:flex            1
+                   (scroll-view {:style {:flex            0.7
                                          :backgroundColor (:dark-primary palette)}}
                                 (view {:style {:flex 0.7}}
                                       (text {:style {:padding  20
@@ -169,12 +170,21 @@
                                             (text-field :light-primary "normal" cmp-brpc-to-change)
                                             (text-field :light-primary "bold" cmp-change)
                                             (text-field :light-primary "normal" cmp-change-to-erpc)
-                                            (text-field :text-icons "bold" cmp-erpc))
-                                      (if (ios?)
-                                        (button (clj->js {:onPress #(prn "Hi")
-                                                          :title   "Hello - this long"
-                                                          :color   "white"
-                                                          }))))))
+                                            (text-field :text-icons "bold" cmp-erpc)))
+                                )
+                   (if (ios?)
+                     (button {:key       "prev-but"
+                              :bordered  true
+                              :small     (not (ios?))
+                              :textStyle {:color (:accent palette)}
+                              :style     {:margin      10
+                                          :borderWidth 2
+                                          :borderColor (:text-icons palette)}
+                              :onPress   next-story}
+                             (previous-icon palette)
+                             (txt {:key   "prev-txt"
+                                   :style {:color (:accent palette)}} "Previous"))
+                     ))
              (view {:key   2
                     :style {:flex 0.7}}
                    ;;;


PLATFORM-1891 fix broken thumbnails when filename is nil

--- src/vignette/util/filesystem.clj
+++ src/vignette/util/filesystem.clj
@@ -53,5 +53,5 @@

 (defn file-extension
   [filename]
-  (let [[_ extension] (re-find #"\.(\w+)$" filename)]
+  (let [[_ extension] (if filename (re-find #"\.(\w+)$" filename))]
     extension))


Added update-wishlist-json controller

Added update-wishlist-json controller

--- src/wishlistd/views/wishlist.clj
+++ src/wishlistd/views/wishlist.clj
@@ -15,4 +15,7 @@

 (defn get-wishlist-json [code]
   (let [wishlist (read-wishlist code)]
-    (response/json wishlist)))+    (response/json wishlist)))
+
+(defn update-wishlist-json [wishlist]
+  (response/json (update-wishlist wishlist)))


replacing reference to the by macro with explicit use of when

--- libs/cloudlog/src/cloudlog/core.clj
+++ libs/cloudlog/src/cloudlog/core.clj
@@ -9,6 +9,13 @@

 (permacode.core/pure
  (declare generate-rule-func)
+
+ (defmacro by [set body]
+   `(when (contains? (-> ~'$input$ meta :writers) ~set)
+      ~body))
+
+ (defmacro by-anyone [body]
+   body)

  (defmulti propagate-symbols (fn [cond symbols] (first cond)) :default :no-bindings)
  (defmethod propagate-symbols :no-bindings [cond symbols]
@@ -78,7 +85,8 @@
          travmap (unify/traverse (vec (rest source-fact)) (constantly true))
          [conds bindings] (unify/conds-and-bindings (map identity travmap) term-has-vars)
          body (if (symbol? source-fact-name)
-                `(by (-> ~source-fact-name meta :ns str) ~body)
+                `(when (contains? (-> ~'$input$ meta :writers) (-> ~source-fact-name meta :ns str))
+                   ~body)
                 ;; else
                 body)
          func `(fn [~'$input$]
@@ -164,13 +172,6 @@
      (str ns "/" name)))
  (prefer-method fact-table clojure.lang.Named clojure.lang.IFn)

- (defmacro by [set body]
-   `(when (contains? (-> ~'$input$ meta :writers) ~set)
-      ~body))
-
- (defmacro by-anyone [body]
-   body)
-
  (defn rule-cont [rule]
    (loop [func rule
           res nil]


added comos function - will need to spit out appropriate data, though

--- src/analysis/core.clj
+++ src/analysis/core.clj
@@ -21,14 +21,16 @@
        (reduce #(assoc %1 (%2 0) (%2 1)) (sorted-map))))

 (defn- make-reports [reports-chunk]
-  (let [pred #(.contains % ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;")]
-    (for [chunk (remove pred (partition-by pred reports-chunk))]
-      (->> chunk
-           (map #(s/split % #":"))
-           (remove #(not= 2 (count %)))
-           (flatten)
-           (map s/trim)
-           (apply sorted-map)))))
+  (let [pred #(.contains % ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;")]
+    (let [reports (for [chunk (remove pred (partition-by pred reports-chunk))]
+                    (->> chunk
+                         (map #(s/split % #":"))
+                         (remove #(not= 2 (count %)))
+                         (flatten)
+                         (map s/trim)
+                         (apply sorted-map)))
+          max-attributes (apply max (map count reports))]
+      (filter #(= max-attributes (count %)) reports))))

 (defn- make-summary [summary-chunk]
   (let [outcome (re-find #"SUCCESS|FAILURE" (first summary-chunk))
@@ -116,4 +118,17 @@
                             (remove nil?)
                             (map read-string)
                             flatten)]
-    (/ (apply + best-fitnesses) (count best-fitnesses))))+    (/ (apply + best-fitnesses) (count best-fitnesses))))
+
+(defn cosmos
+  "Returns a summary of the recommended runs for this data set"
+  [logs cosmos-extraction-fn]
+  (cosmos/recommended-runs (-> (for [log logs]
+                                 (for [[report gen] (map #(vector %1 %2) (:reports log) (iterate inc 0))]
+                                   (for [[ord val] (cosmos-extraction-fn report)]
+                                     (struct-map cosmos/cosmos-data
+                                       :ord ord
+                                       :gen gen
+                                       :val val))))
+                               flatten)))
+


Fix another merge conflict artifact.

Fix another merge conflict artifact.

--- src/clj/game/core.clj
+++ src/clj/game/core.clj
@@ -851,11 +851,7 @@
                 (let [cost (steal-cost state side c)]
                   (if (pos? (count cost))
                     (optional-ability state :runner c (str "Pay " (costs-to-symbol cost) " to steal " name "?")
-<<<<<<< HEAD
                                       {:yes-ability {:cost cost
-=======
-                                      {:yes-ability {:cost
->>>>>>> 8db3e973dc5876dbdad2587afb20b1bdc239a6e5
                                                      :effect (effect (system-msg (str "pays " (costs-to-symbol cost)
                                                                                " to steal " (:title c)))
                                                                      (resolve-steal c))}


Improved trash handling to indicate the cause of the trashing. Used for I've Had Worse and Armand "Geist" Walker.

--- src/clj/game/core.clj
+++ src/clj/game/core.clj
@@ -481,7 +481,7 @@
              (swap! state update-in [:runner :brain-damage] #(+ % n))
              (swap! state update-in [:runner :max-hand-size] #(- % n)))
        (doseq [c (take n (shuffle hand))]
-              (trash state side c {:unpreventable true} type))
+              (trash state side c {:unpreventable true :cause type} type))
        (trigger-event state side :damage type card)))

 (defn damage
@@ -581,11 +581,11 @@
   (when (>= (get-in @state [side :agenda-point]) (get-in @state [side :agenda-point-req]))
     (system-msg state side "wins the game")))

-(defn resolve-trash [state side {:keys [zone type] :as card} {:keys [unpreventable] :as args} & targets]
+(defn resolve-trash [state side {:keys [zone type] :as card} {:keys [unpreventable cause] :as args} & targets]
   (let [cdef (card-def card)
         moved-card (move state (to-keyword (:side card)) card :discard false)]
     (when-let [trash-effect (:trash-effect cdef)]
-      (resolve-ability state side trash-effect moved-card targets))))
+      (resolve-ability state side trash-effect moved-card (cons cause targets)))))

 (defn trash-resource [state side args]
   (when (pay state side nil :click 1 :credit 2)
@@ -599,14 +599,14 @@

 (defn trash
   ([state side {:keys [zone type] :as card}] (trash state side card nil))
-  ([state side {:keys [zone type] :as card} {:keys [unpreventable] :as args} & targets]
+  ([state side {:keys [zone type] :as card} {:keys [unpreventable cause] :as args} & targets]
     (let [ktype (keyword (clojure.string/lower-case type))]
-      (when (not unpreventable)
+      (when (and (not unpreventable) (not= cause :ability-cost))
         (swap! state update-in [:trash :trash-prevent] dissoc ktype))
       (when (not= (last zone) :current)
-        (trigger-event state side :trash card targets))
+        (apply trigger-event state side :trash card cause targets))
       (let [prevent (get-in @state [:prevent :trash ktype])]
-        (if (and (not unpreventable) (> (count prevent) 0))
+        (if (and (not unpreventable) (not= cause :ability-cost) (> (count prevent) 0))
           (do
             (system-msg state :runner "has the option to prevent trash effects")
             (show-prompt


whoops

whoops

--- src/complico/core.clj
+++ src/complico/core.clj
@@ -16,7 +16,7 @@

     var foundin = $('a').each(function(index){
     var link = $(this).attr('href');
-    var newLink = http://" server ":" port "/convert?url=' + encodeURIComponent(link);
+    var newLink = 'http://" server ":" port "/convert?url=' + encodeURIComponent(link);
     $(this).attr('href', newLink);
   });
   });


random git fuck up and also sampling framework

--- src/crawler/crawl.clj
+++ src/crawler/crawl.clj
@@ -301,9 +301,9 @@
   ([start]
      (let [start-body   (download-with-cookie start)
            to-eliminate (template-removal/all-xpaths start-body start my-cs)]
-       (sample-sitemap [{:url start}] (set []) to-eliminate [])))
-
-  ([queue visited to-eliminate leaf-paths]
+       (sample-sitemap [{:url start}] (set []) (set []) to-eliminate [])))
+
+  ([queue visited observed to-eliminate leaf-paths]
      (if (seq queue)
        (do
         (Thread/sleep 2000)
@@ -322,6 +322,7 @@
                                body url to-eliminate (clojure.set/union
                                                       (set visited)
                                                       (set [url])
+                                                      (set observed)
                                                       (set (map :url queue))))
                               (catch Exception e nil))

@@ -343,44 +344,88 @@
               mined      (when-not leaf?
                            (rich-char-extractor/filter-content
                             content))
-              mined-links (try
-                           (reverse
-                            (filter
-                             #(and (-> % :url)
-                                   (not (some #{(-> % :url)} (clojure.set/union
-                                                              (set visited)
-                                                              (set [url])
-                                                              (set (map (fn [x] (:url x)) queue))))))
-                             (reduce
-                              concat
-                              (map
-                               (fn [{xpath :xpath score :score hrefs :hrefs text :texts}]
-                                 ;; take only a 25 % sample from here.
-                                 (take
-                                  (Math/ceil (/ (count hrefs) 4))
+
+              obs-links  (try
+                           (distinct-by-key
+                            (reverse
+                             (filter
+                              #(and (-> % :url)
+                                    (not (some #{(-> % :url)} (clojure.set/union
+                                                               (set visited)
+                                                               (set [url])
+                                                               (set (map (fn [x] (:url x)) queue))))))
+                              (reduce
+                               concat
+                               (map
+                                (fn [{xpath :xpath score :score hrefs :hrefs text :texts}]
+                                  ;; take only a 25 % sample from here.
                                   (map
                                    (fn [h]
                                      {:url h
                                       :src-xpath (cons xpath src-xp)
                                       :src-url url
                                       :src-nav-num (cons (if body score 0) src-nav-num)})
-                                   hrefs)))
-                               mined))))
-                           (catch Exception e []))]
-          (if (and (not leaf?) (seq mined-links))
-            (recur (concat (rest queue)
-                           mined-links)
-                   (clojure.set/union visited
-                                      (set [url]))
-                   to-eliminate
-                   leaf-paths)
-            (recur
-             (rest queue)
-             (clojure.set/union visited (set [url]))
-             to-eliminate
-             (cons
-              nil
-              leaf-paths)))))
+                                   hrefs))
+                                mined))))
+                             :url)
+                            (catch Exception e []))
+
+              mined-links (try
+                            (distinct-by-key
+                             (reverse
+                              (filter
+                              #(and (-> % :url)
+                                    (not (some #{(-> % :url)} (clojure.set/union
+                                                               (set visited)
+                                                               (set [url])
+                                                               (set (map (fn [x] (:url x)) queue))))))
+                              (reduce
+                               concat
+                               (map
+                                (fn [{xpath :xpath score :score hrefs :hrefs text :texts}]
+                                  ;; take only a 25 % sample from here.
+                                  (take
+                                   (Math/ceil (/ (count hrefs) 4))
+                                   (map
+                                    (fn [h]
+                                      {:url h
+                                       :src-xpath (cons xpath src-xp)
+                                       :src-url url
+                                       :src-nav-num (cons (if body score 0) src-nav-num)})
+                                    hrefs)))
+                                mined))))
+                             :url)
+                            (catch Exception e []))]
+          (cond
+           (and (not leaf?) (seq mined-links))
+           (recur (concat (rest queue)
+                          mined-links)
+                  (clojure.set/union visited
+                                     (set [url]))
+                  (clojure.set/union observed (set obs-links))
+                  to-eliminate
+                  leaf-paths)
+
+           (and
+            (not leaf?)
+            (not
+             (seq mined-links)))
+           (recur
+            (rest queue)
+            (clojure.set/union visited (set [url]))
+            observed
+            to-eliminate
+            leaf-paths)
+
+           :else
+           (recur
+            (rest queue)
+            (clojure.set/union visited (set [url]))
+            observed
+            to-eliminate
+            (cons
+             (cons nil src-xp)
+             leaf-paths)))))
       (frequencies leaf-paths))))

 (defn crawl


added tighter clustering of leaves

added tighter clustering of leaves

--- src/crawler/crawl.clj
+++ src/crawler/crawl.clj
@@ -884,7 +884,7 @@
                                                (let [to-assign (.indexOf
                                                                 (map
                                                                  (fn [a-cluster]
-                                                                   (some
+                                                                   (every?
                                                                     (fn [c]
                                                                       (similarity/similar?
                                                                        (-> c new-corpus :body)


Fix indentation

Fix indentation

--- src/expenses/core.clj
+++ src/expenses/core.clj
@@ -22,11 +22,11 @@

 (defn income [expenses]
   (let [income? (fn [expense]
-                        (and
-                          (not (contains?
-                                 #{"S A L D O" "Saldo Anterior"}
-                                 (:description expense)))
-                          (pos? (read-string (:value expense)))))
+                  (and
+                    (not (contains?
+                           #{"S A L D O" "Saldo Anterior"}
+                           (:description expense)))
+                    (pos? (read-string (:value expense)))))
         without-balance (filter income? expenses)
         values (map #(read-string (:value %)) without-balance)]
     (reduce + values)))


Delete comment

Delete comment

--- src/layzee/paging.clj
+++ src/layzee/paging.clj
@@ -1,28 +1,14 @@
 (ns layzee.paging)

-;(defn page
-;  ":fn-producer -- the source
-;   :fn-stop     -- how we tell we're finished
-;   :result      -- collects the results"
-;  ([fn-producer fn-stop result]
-;     (if (apply fn-stop [result])
-;       result
-;       (recur fn-producer fn-stop (concat (apply fn-producer []) result)))))
-
 (defn- default-fn-args[result args] args)
-
-(defn- produce[fn args]
-  (apply fn
-         (if (nil? args)
-           []
-           [args])))
+(defn- produce[fn args] (apply fn (if (nil? args) [] [args])))

 (defn page
   ":fn-producer -- function that produces the results
    :fn-args     -- function that produces arguments for the producer
    :fn-stop     -- how we tell we're finished
    :result      -- collects the results
-   :args        -- [optional] arguments for :fn-producer. Defaults to nil(, and :fn-producer is invoked with zero arity)."
+   :args        -- [optional] arguments for :fn-producer. Defaults to nil (, and :fn-producer is invoked with zero arity)."
   ([fn-producer fn-stop result]
      (page fn-producer default-fn-args fn-stop result nil))
   ([fn-producer fn-args fn-stop result args]


remove lancet require from pom, it wasn't being used

--- src/leiningen/pom.clj
+++ src/leiningen/pom.clj
@@ -1,6 +1,5 @@
 (ns leiningen.pom
   "Write a pom.xml file to disk for Maven interop."
-  (:require [lancet])
   (:use [clojure.contrib.duck-streams :only [reader copy]]
         [clojure.contrib.java-utils :only [file as-properties]])
   (:import [java.io StringWriter]


tseitin performance enhanced

tseitin performance enhanced

--- src/logic/tseitin.clj
+++ src/logic/tseitin.clj
@@ -77,7 +77,9 @@
   "Recursive helper function for generate-tseitin-symbols."
   [f z t]
   (if (literal? f)
-    t
+    (swap! t #(conj %
+                {(symbol (str tseitin-prefix (swap! z inc)))
+                 f}))
     (let [rec-syms (doall (for [f' (rest f)]
                             (gen-tseit-rec f' z t)))]
       (swap! t #(conj %
@@ -88,9 +90,7 @@
   "Generate tseitin symbols for all subformulas and literals."
   [formula z]
   (let [lits (find-variables formula)
-        tmap (atom (apply merge (map
-                                  #(hash-map (symbol (str tseitin-prefix (swap! z inc))) %)
-                                  lits)))
+        tmap (atom (hash-map))
         _ (gen-tseit-rec formula z tmap)
         rev-tmap (zipmap (vals @tmap) (keys @tmap))
         ]


clarify purpose of `fn` in `assoc*`

clarify purpose of `fn` in `assoc*`


Make note continue to play while pressed down

--- src/musicbox/one.cljs
+++ src/musicbox/one.cljs
@@ -31,61 +31,85 @@
                (nth colors (mod n (count colors))))))
       (.fillRect draw-ctx (* n note-width) 0 note-width h))))

-(defn create-synth
-  []
-  (.play (timbre "OscGen" (js-obj "wave" "fami" "mul" 0.3 "poly" 8))))
-  ;; (timbre "*"
-  ;;         (timbre "+"
-  ;;                 (timbre "sin" freq)
-  ;;                 (timbre "sin" (* freq 2) 0.5)
-  ;;                 (timbre "sin" (* freq 4) 0.25)
-  ;;                 (timbre "sin" (* freq 5) 0.125))
-  ;;         (timbre "adsr" "24db" 5 1000 0.0 2500)))
+(defn create-note-synth
+  [freq]
+  (timbre "adsr"
+          (js-obj "a" 5 "d" 10000 "s" 0 "r" 500)
+          (timbre "fami" (js-obj "freq" freq "mul" 0.5))))

-(defn play-note [synth note]
-  (.noteOnWithFreq synth (:freq note) 64))
-
-
-;; (defn synth-play
-;;   [synth note]
-;;   (util/dirr synth)
-;;   (.bang synth))
-
-;; (defn synth-stop
-;;   [synth note]
-;;   (.keyoff synth (get (.-args synth) 1)))
+(defn create-instrument
+  [scale]
+  {:notes (apply sorted-map
+                 (flatten (map vector
+                               scale
+                               (map (fn [x] {:synth (create-note-synth x) :touch-id nil})
+                                    scale))))
+   :w 0
+   :h 0})

 (defn audio-time []
   (.-currentTime js/audioCtx))

-(defn touch-to-notes [touch interface]
-  (let [touches (js->clj (.-touches (.-event_ touch)))]
-    (map (fn [x]
-           {:time (audio-time)
-            :freq (scales/quantize (get x "clientX")
-                                   0 (:w interface)
-                                   (:scale interface))})
+(defn touch-data->touches [touch-data]
+  (let [event (.-event_ touch-data)
+        touches (js->clj (.-changedTouches event))]
+    (map (fn [x] {:type (.-type event)
+                  :touch-id (get x "identifier")
+                  :clientX (get x "clientX")})
          (for [x (range (get touches "length"))] (get touches (str x))))))

-(defn update-size [interface canvas-id]
+
+(defn touch->freq
+  [instrument touch]
+  (scales/quantize (get touch :clientX)
+                   0
+                   (:w instrument)
+                   (keys (:notes instrument))))
+
+(def instrument-fns
+  {"touchstart" (fn
+                  [instrument {touch-id :touch-id :as event}]
+                  (let [freq (touch->freq instrument event)
+                        note (get (:notes instrument) freq)]
+                    (if (not (:touch-id note))
+                      (do
+                        (.play (.bang (:synth note)))
+                        (assoc-in instrument [:notes freq :touch-id] touch-id)))))
+   "touchend" (fn
+                [{notes :notes :as instrument} {touch-id :touch-id :as event}]
+                (if-let [freq (first (filter (fn [x] (= touch-id (:touch-id (get notes x))))
+                                             (keys notes)))]
+                    (do
+                      (.release (:synth (get notes freq)))
+                      (assoc-in instrument [:notes freq :touch-id] nil))))})
+
+(defn fire-event-on-instrument
+  [instrument event]
+  (let [f-instrument (get instrument-fns (:type event))]
+    (or (and f-instrument (f-instrument instrument event))
+        instrument)))
+
+(defn update-size [instrument canvas-id]
   (let [{w :w h :h :as dimensions} (util/get-window-size)]
-    (if (or (not= w (:w interface) (not= h (:h interface))))
+    (if (or (not= w (:w instrument) (not= h (:h instrument))))
       (do (util/set-canvas-size! canvas-id w h)
-          (assoc (assoc interface :h h) :w w))
-      interface)))
+          (assoc (assoc instrument :h h) :w w))
+      instrument)))

 (let [canvas-id "canvas"
       draw-ctx (util/get-ctx canvas-id)
-      interface (update-size {:scale (scales/c-minor)} canvas-id)
-      c-touch (merge [(util/listen (dom/getElement canvas-id) :touchstart)])]
+      instrument (update-size (create-instrument (scales/c-minor)) canvas-id)
+      c-touch-start (util/listen (dom/getElement canvas-id) :touchstart)
+      c-touch-end (util/listen (dom/getElement canvas-id) :touchend)]
+  (util/dirr (get (:notes instrument) (nth (keys (:notes instrument)) 0)))
+  (go
+   (<! c-touch-start) (<! c-touch-end) ;; do not start until get first touch, otherwise will break sound

-  (go
-   (<! c-touch) ;; do not start until get first touch, otherwise will break sound
-   (let [synth (create-synth)]
-     (loop [notes []
-            interface interface]
-       (draw draw-ctx interface notes)
-       (let [new-notes (touch-to-notes (<! c-touch) interface)]
-         (dorun (map (partial play-note synth) new-notes))
-         (recur (concat notes new-notes) (update-size interface canvas-id))))))
+   (loop [instrument instrument]
+     (draw draw-ctx instrument)
+     (let [[touch-data c] (alts! [c-touch-start c-touch-end])
+           touches (touch-data->touches touch-data)]
+
+       (recur (update-size (reduce fire-event-on-instrument instrument touches)
+                           canvas-id)))))
   )


fix broken sign in button on join team page


fixing config setter

fixing config setter

--- src/plasma/config.clj
+++ src/plasma/config.clj
@@ -17,6 +17,6 @@
 (defn config
   "Lookup a config value."
   ([] @config*)
-  ([key] (get @config* key))
-  ([k v] (dosync (alter config* k v))))
+  ([k] (get @config* k))
+  ([k v] (dosync (alter config* assoc k v))))


docstring fixes

docstring fixes

--- src/promesa/core.cljc
+++ src/promesa/core.cljc
@@ -373,8 +373,8 @@
 ;; --- Utils

 (defn promisify
-  "Given a function that accepts a callback as the last argument return other
-  function that returns a promise. Callback is expected to take single
+  "Given a function that accepts a callback as the last argument, return a
+  function that returns a promise. Callback is expected to take one
   parameter (result of a computation)."
   [callable]
   (fn [& args]
@@ -398,7 +398,7 @@
   "Returns a cancellable promise that will be fulfilled with this
   promise's fulfillment value or rejection reason.  However, if this
   promise is not fulfilled or rejected within `ms` milliseconds, the
-  returned promise is cancelled with a TimeoutError"
+  returned promise is cancelled with a TimeoutError."
   ([p t] (timeout p t ::default exec/default-scheduler))
   ([p t v] (timeout p t v exec/default-scheduler))
   ([p t v scheduler]
@@ -410,7 +410,7 @@

 (defn delay
   "Given a timeout in miliseconds and optional value, returns a promise
-  that will fulfilled with provided value (or nil) after the time is
+  that will be fulfilled with provided value (or nil) after the time is
   reached."
   ([t] (delay t nil exec/default-scheduler))
   ([t v] (delay t v exec/default-scheduler))
@@ -421,7 +421,7 @@

 (defmacro do!
   "Execute potentially side effectful code and return a promise resolved
-  to the last expression. Always awaiting the result of each
+  to the last expression after awaiting the result of each
   expression."
   [& exprs]
   `(pt/-bind
@@ -467,7 +467,7 @@

 (defmacro future
   "Analogous to `clojure.core/future` that returns a promise instance
-  instead of the `Future`. Useful for execute synchronous code in a
+  instead of the `Future`. Useful for executing synchronous code in a
   separate thread (also works in cljs)."
   [& body]
   `(c/-> (exec/submit! (fn []
@@ -515,9 +515,9 @@
 (defmacro ->
   "Like the clojure.core/->, but it will handle promises in values
   and make sure the next form gets the value realized instead of
-  the promise. Example using to fetch data in the browser with CLJS:
-
-  Example:
+  the promise.
+
+  Example fetching data in the browser with CLJS:

   (p/-> (js/fetch #js {...}) ; returns a promise
         .-body)
@@ -535,9 +535,9 @@
 (defmacro ->>
   "Like the clojure.core/->>, but it will handle promises in values
   and make sure the next form gets the value realized instead of
-  the promise. Example using to fetch data in the browser with CLJS:
-
-  Example:
+  the promise.
+
+  Example fetching data in the browser with CLJS:

   (p/->> (js/fetch #js {...}) ; returns a promise
          .-body


Add proper implementation for `do*` macro.

--- src/promesa/core.cljc
+++ src/promesa/core.cljc
@@ -374,9 +374,15 @@

 #?(:clj
    (defmacro do*
-     "A sugar syntax on top of `attempt`."
-     [& body]
-     `(attempt #(do ~@body))))
+     [& exprs]
+     `(p/bind nil (fn [_#]
+                    ~(condp = (count exprs)
+                       0 `(pt/-promise nil)
+                       1 `(pt/-promise ~(first exprs))
+                       (reduce (fn [acc e]
+                                 `(bind ~e (fn [_#] ~acc)))
+                               `(pt/-promise ~(last exprs))
+                               (reverse (butlast exprs))))))))

 (defn await
   [v]


Add substring-after.

Add substring-after.

Right now it returns a function instead of doing the work immediately.
It seems like this is more efficient (don't have to pass the delim over
and over), but (a) it might be confusing for no reason, and (b) I don't
know that it's actually more efficient. Some follow-up needed here.

--- src/useful/string.clj
+++ src/useful/string.clj
@@ -31,3 +31,12 @@
      (plural 9 \"radius\" \"radii\") => \"9 radii\""
   [num singular & [plural]]
   (str num " " (if (= 1 num) singular (or plural (str singular "s")))))
+
+(defn substring-after
+  "Find the part of the string s which comes after the last instance of delim."
+  [^String delim]
+  (fn [^String s]
+    (let [idx (.lastIndexOf s delim)]
+      (if (neg? idx)
+        s ;; no match
+        (subs s (inc idx))))))


Remove unused requirements.

Remove unused requirements.

--- test/cljam/algo/convert_test.clj
+++ test/cljam/algo/convert_test.clj
@@ -3,8 +3,6 @@
             [clojure.string :as cstr]
             [cljam.test-common :refer :all]
             [cljam.algo.convert :as convert]
-            [cljam.io.sam :as sam]
-            [cljam.io.sam.util.sequence :as sam-seq]
             [cljam.io.sequence :as cseq]
             [cljam.io.fastq :as fq]
             [clojure.java.io :as cio]))


star detector merge

star detector merge

--- src/plugins/Scripts/Funimage/Experimental/star_detector.clj
+++ src/plugins/Scripts/Funimage/Experimental/star_detector.clj
@@ -5,11 +5,11 @@
          '[funimage.segmentation.imp :as ij1seg]
          '[funimage.imp.statistics :as ij1stats])

-;(def filename "/Users/kharrington/Data/Sanchez_Alicia/30_no amp.tif")

 (when-not (ij.IJ/getInstance)
   (def filename "/Users/kharrington/Data/Harrington_Kyle/SanchezLab/ShapesOnPetriDish.tif")
   (def imp (ij1/open-imp filename)))
+

 (ij.IJ/run imp "8-bit" "")


fixing jobs

fixing jobs

--- test/celestial/integration/jobs.clj
+++ test/celestial/integration/jobs.clj
@@ -2,7 +2,7 @@
   (:require
     [celestial.model :refer (operations)]
     [celestial.fixtures.core :refer (with-conf)]
-    [celestial.jobs :refer (jobs initialize-workers workers)])
+    [celestial.jobs :refer (jobs apply-config initialize-workers workers)])
   (:use midje.sweet))

 (with-conf
@@ -10,5 +10,6 @@
     (fact "workers creation" :integration :redis
       (initialize-workers) => nil
       (provided
-        (jobs) => {:machine [identity 2]})
-      (keys @workers) => (just :machine))))
+        (jobs) => {:stage [identity 2]}
+        (apply-config {:stage [identity 2]}) => {:stage [identity 2]}))
+      (keys @workers) => (just :stage)))


Enable attack actions

Enable attack actions

--- src/obb_rules/action.cljc
+++ src/obb_rules/action.cljc
@@ -1,6 +1,6 @@
 (ns obb-rules.action
   (:require [obb-rules.actions.rotate :as rotate]
-            #?(:clj [obb-rules.actions.attack :as attack])
+            [obb-rules.actions.attack :as attack]
             [obb-rules.actions.deploy :as deploy]
             #?(:clj [obb-rules.actions.auto-deploy :as auto-deploy])
             #?(:clj [obb-rules.actions.goto :as goto])
@@ -10,6 +10,7 @@
   #?(:cljs
   {:rotate rotate/build-rotate
    :move move/build-move
+   :attack attack/build-attack
    :deploy deploy/build-deploy})
   #?(:clj
   {:rotate rotate/build-rotate


Help.

Help.

--- src/onyx_starter/core.clj
+++ src/onyx_starter/core.clj
@@ -4,6 +4,7 @@
             [onyx.plugin.core-async]
             [onyx.api]))

+;;;;; Implementation functions ;;;;;
 (defn split-by-spaces-impl [s]
   (clojure.string/split s #"\s+"))

@@ -18,9 +19,9 @@
 (defn question-impl [s]
   (str s "?"))

+;;;;; Destructuring functions ;;;;;
 (defn split-by-spaces [segment]
-  (map (fn [word] {:word word})
-       (split-by-spaces-impl (:sentence segment))))
+  (map (fn [word] {:word word}) (split-by-spaces-impl (:sentence segment))))

 (defn mixed-case [segment]
   {:word (mixed-case-impl (:word segment))})
@@ -30,6 +31,18 @@

 (defn question [segment]
   {:word (question-impl (:word segment))})
+
+;;;;; Configuration ;;;;;
+
+;;;            input
+;;;              |
+;;;       split-by-spaces
+;;;              |
+;;;          mixed-case
+;;;            /    \
+;;;         loud     question
+;;;           |         |
+;;;    loud-output    question-output

 (def workflow
   {:input
@@ -46,6 +59,8 @@

 (def question-output-chan (chan capacity))

+;;; Inject the channels needed by the core.async plugin for each
+;;; input and output.
 (defmethod l-ext/inject-lifecycle-resources :input
   [_ _] {:core-async/in-chan input-chan})

@@ -106,12 +121,15 @@
     :onyx/batch-size batch-size
     :onyx/doc "Writes segments to a core.async channel"}])

+;;; Input data to pipe into the input channel, plus the
+;;; sentinel to signal the end of input.
 (def input-segments
   [{:sentence "Hey there user"}
    {:sentence "It's really nice outside"}
    {:sentence "I live in Redmond"}
    :done])

+;;; Put the data onto the input chan
 (doseq [segment input-segments]
   (>!! input-chan segment))

@@ -120,11 +138,11 @@
 (def id (java.util.UUID/randomUUID))

 (def coord-opts
-  {:hornetq/mode :vm
+  {:hornetq/mode :vm ;; Run HornetQ inside the VM for convenience
    :hornetq/server? true
    :hornetq.server/type :vm
    :zookeeper/address "127.0.0.1:2185"
-   :zookeeper/server? true
+   :zookeeper/server? true ;; Run ZK inside the VM for convenience
    :zookeeper.server/port 2185
    :onyx/id id
    :onyx.coordinator/revoke-delay 5000})
@@ -134,8 +152,10 @@
    :zookeeper/address "127.0.0.1:2185"
    :onyx/id id})

+;; Connect to the coordinator. Also boots up in the in-memory services.
 (def conn (onyx.api/connect :memory coord-opts))

+;; Start the worker peers.
 (def v-peers (onyx.api/start-peers conn 1 peer-opts))

 (onyx.api/submit-job conn {:catalog catalog :workflow workflow})


Better example

Better example

--- test/cljc/spec_tools/core_test.cljc
+++ test/cljc/spec_tools/core_test.cljc
@@ -56,15 +56,17 @@
           (is (thrown?
                 #?(:clj Exception, :cljs js/Error)
                 (st/create-spec
-                  {:spec (fn [x] (inc x))}))))
+                  {:name "positive?"
+                   :spec (fn [x] (pos? x))}))))
         (testing ":form and :type can be provided"
           (is (not
                 (nil?
                   (st/spec?
                     (st/create-spec
-                      {:spec (fn [x] (inc x))
+                      {:name "positive?"
+                       :spec (fn [x] (pos? x))
                        :type :long
-                       :form `(fn [x] (inc x))}))))))))
+                       :form `(fn [x] (pos? x))}))))))))

     (testing "wrapped predicate work as a predicate"
       (is (true? (my-integer? 1)))


[refs #3055] increase number of retries before mark-trusted-peer call

--- src/status_im/protocol/handlers.cljs
+++ src/status_im/protocol/handlers.cljs
@@ -227,8 +227,12 @@
  ::fetch-peers
  (fn [{:keys [wnode web3 retries]}]
    ;; Run immediately on first run, add delay before retry
-   (let [delay (if (zero? retries) 0 300)]
-     (if (> retries 3)
+   (let [delay (cond
+                 (zero? retries) 0
+                 (< retries 3) 300
+                 (< retries 10) 1000
+                 :else 5000)]
+     (if (> retries 100)
        (log/error "Number of retries for fetching peers exceed" wnode)
        (js/setTimeout
         (fn [] (inbox/fetch-peers #(re-frame/dispatch [::fetch-peers-success web3 % retries])


fix issue where #'namespace throws NPE

fix issue where #'namespace throws NPE

--- src/tailrecursion/boot/core/task.clj
+++ src/tailrecursion/boot/core/task.clj
@@ -10,7 +10,7 @@
 (defn first-line [s] (when s (first (split s #"\n"))))

 (defn get-doc [sym]
-  (when sym
+  (when (symbol? sym)
     (when-let [ns (namespace sym)] (require (symbol ns)))
     (join "\n" (-> sym find-var meta :doc str (split #" *\n *")))))


Declare-kokeilu

Declare-kokeilu

--- clj-elasticsearch/src/clj_elasticsearch/elastic_connect.clj
+++ clj-elasticsearch/src/clj_elasticsearch/elastic_connect.clj
@@ -2,6 +2,8 @@
     (:require [clj-elasticsearch.elastic-utils :refer :all]
               [clj-http.client :as http]
               [cheshire.core :as json]))
+
+(declare elastic-host)

 (defn get-cluster-health [host]
       (elastic-get-as-json (str host "/_cluster/health")))
@@ -34,9 +36,9 @@

 (defn parse-search-result [res] (map :_source (get-in res [:hits :hits])))

-(defn get-document [host index mapping-type id] ;TODO URL encoding
+(defn get-document [index mapping-type id] ;TODO URL encoding
       (try
-        (elastic-get (elastic-url host index mapping-type id))
+        (elastic-get (elastic-url elastic-host index mapping-type id))
         (catch Exception e
           (if (= 404 ((ex-data e) :status)) {:found false} (throw e)))))


Review-korjaus

Review-korjaus

--- clj-elasticsearch/src/clj_elasticsearch/elastic_connect.clj
+++ clj-elasticsearch/src/clj_elasticsearch/elastic_connect.clj
@@ -52,7 +52,7 @@

 (defn bulk
   [index mapping-type data]
-  (if (not (empty? data))
+  (when (seq data)
     (let [bulk-url   (elastic-url index mapping-type "_bulk")
           partitions (bulk-partitions data)]
       (for [partition partitions]


Adds test for explain-str

Adds test for explain-str

--- test/expound/alpha_test.cljc
+++ test/expound/alpha_test.cljc
@@ -824,3 +824,23 @@
 -------------------------
 Detected 1 error"
                   (:cause (Throwable->map e)))))))))
+
+(s/def :test-explain-str/name string?)
+(deftest test-explain-str
+  (is (= (pf "-- Spec failed --------------------
+
+  :hello
+
+should satisfy
+
+  string?
+
+-- Relevant specs -------
+
+:test-assert/name:
+  pf.core/string?
+
+-------------------------
+Detected 1 error")
+         (binding [s/*explain-out* expound/printer]
+           (s/explain-str :test-assert/name :hello)))))


Update version.

Update version.

--- lein/profiles.clj
+++ lein/profiles.clj
@@ -1,2 +1,2 @@
-{:user {:plugins [[cider/cider-nrepl "0.9.0-SNAPSHOT"]]
+{:user {:plugins [[cider/cider-nrepl "0.9.0"]]
         :dependencies [[org.clojure/tools.nrepl "0.2.10"]]}}


Bump lein-ancient version

Bump lein-ancient version

Along with more of its outdated dependencies

--- lein/profiles.clj
+++ lein/profiles.clj
@@ -68,7 +68,7 @@
         :plugins [[cider/cider-nrepl "0.10.0" :exclusions [org.clojure/java.classpath]]
                   [com.jakemccrary/lein-test-refresh "0.9.0"]
                   [jonase/eastwood "0.2.2" :exclusions [org.clojure/clojure]]
-                  [lein-ancient "0.6.7" :exclusions [cheshire common-codec commons-codec slingshot]]
+                  [lein-ancient "0.6.8" :exclusions [cheshire common-codec commons-codec org.clojure/clojure org.clojure/tools.reader slingshot]]
                   ;; This next one's super useful, but its dependencies are out of date
                   ;; TODO: Update!
                   #_[lein-kibit "0.0.8"]


fix bug not accounting for explicit comparison files!

--- services/gen-feature-counts.clj
+++ services/gen-feature-counts.clj
@@ -4,12 +4,12 @@

  :graph {:dir  {:type "func"
                 :name "get-comparison-files"
-                :args ["#1", "#2"]} ; eid rep?
+                :args ["#1", "#2", "#3" ]} ; eid, comparison-file, rep?
          :fcnt {:type "func"
                 :name "featureCounts"
-                :args ["#3", "#4"]} ; feature-type gtf
+                :args ["#3", "#4"]} ; feature-type, gtf

          :edges {:dir [:fcnt]}}

- :description "Produce 'feature' counts for each pair in the comparison set determined by eid (#1 arg) and whether replicates are used (#2 arg). Requires a gtf (#4 arg) matching the bam reference gbk and feature-type in gtf (#3 arg 'gene', 'CDS', et.al.)."
+ :description "Produce 'feature' counts for each pair in the comparison set determined by eid (#1 arg), the given comparison file for eid (#2 arg) and whether replicates are used (#3 arg). Requires a gtf (#5 arg) matching the bam reference gbk and feature-type in gtf (#4 arg 'gene', 'CDS', et.al.)."
  }


assert hostname and target

assert hostname and target

--- src/remote/capistrano.clj
+++ src/remote/capistrano.clj
@@ -44,7 +44,8 @@

 (defmethod rconstruct :capistrano [{:keys [capistrano name timeout] :as action}
                                    {:keys [env] :as run-info}]
-  (let [{:keys [args src]} (capistrano env) interuplated (mapv #(interpulate % run-info) args)]
-    (->Capistrano src interuplated (<< "~(tmpdir)/~(gen-uuid)/~{name}") timeout)))
+  (let [{:keys [args src]} (capistrano env)]
+    (assert (and (:target run-info) (:hostname run-info)))
+    (->Capistrano src (mapv #(interpulate % run-info) args) (<< "~(tmpdir)/~(gen-uuid)/~{name}") timeout)))


add defspec macro for defining clojure.test test vars for a property (fixes gh-4)

--- src/simple_check/core.clj
+++ src/simple_check/core.clj
@@ -71,6 +71,20 @@
               (if (empty? children)
                 (recur tail head (inc total-nodes-visited) depth false)
                 (recur children head (inc total-nodes-visited) (inc depth) true)))))))))
+
+(defmacro defspec
+  "Defines a new clojure.test test var that uses `quick-check` to verify
+  [property] with the given [args] (should be a sequence of generators),
+  [default-times] times by default.  You can call the function defined as [name]
+  with no arguments to trigger this test directly (i.e.  without starting a
+  wider clojure.test run), or with a single argument that will override
+  [default-times]."
+  [name default-times property & args]
+  `(defn ~(vary-meta name assoc :test
+                     `(fn [] (println (assoc (~name ~default-times) :test-var (str '~name)))))
+     ([] (~name ~default-times))
+     ([times#]
+      (qc/quick-check times# (vary-meta ~property assoc :name (str '~property)) ~@args))))

 (defn- report-trial
   [property-fun so-far num-tests]


Added preds from paper

Added preds from paper

--- damp.ekeko.aspectj.plugin/src/damp/ekeko/aspectj/annotations.clj
+++ damp.ekeko.aspectj.plugin/src/damp/ekeko/aspectj/annotations.clj
@@ -153,4 +153,67 @@
         (fails
           (l/project [?pattern]
             (l/!= ?pattern (clojure.string/replace ?pattern #"\+" ""))
-            (type-type|pattern ?type (clojure.string/replace ?pattern #"\+" ""))))))+            (type-type|pattern ?type (clojure.string/replace ?pattern #"\+" ""))))))
+
+
+
+;------------------------  ASPECT PRESENCE (GASREE Section 6.1) ------------------------------
+
+(defn- get-all-matches
+  [pattern]
+  (ekeko [?t] (type-type|pattern2 ?t pattern)))
+
+(defn- typepatterns-matches
+  [?pattern ?matches]
+  (l/all
+    (v+ ?pattern)
+    (equals ?matches (get-all-matches ?pattern))))
+
+(defn missing|required-requires [?name ?requirer]
+  (l/fresh [?reqds ?required]
+         (requiring|type-key-val ?requirer "type" ?reqds)
+         (contains ?reqds ?name)
+         (fails (type-type|pattern ?required ?name))))
+(defn present|excluded-excluder [?exd ?excluder]
+  (l/fresh [?exds ?excluded]
+         (excluding|type-key-val ?excluder "type" ?exds)
+         (contains ?exds ?exd)
+         (type-type|pattern ?excluded ?exd )))
+(defn oneOfViolation [?targettype]
+  (l/fresh [?patterns ?matches ?count ?pattern]
+         (oneOfing|type-key-val ?targettype "type" ?patterns)
+         (contains ?patterns ?pattern)
+         (typepatterns-matches ?pattern ?matches) ;don;t exists
+         (differs ?count 1)
+         (equals ?count (count ?matches))))
+
+
+(defn oneOf|definer-offenders [?def ?offs]
+  (l/fresh  [?patterns ?count ?pattern]
+             (oneOfing|type-key-val ?def "type" ?patterns)
+             (contains ?patterns ?pattern)
+             (typepatterns-matches ?pattern ?offs)
+             (differs ?count 1)
+             (equals ?count (count ?offs))))
+
+
+;------------------------  Control Flow (GASREE Section 6.2) ------------------------------
+
+(defn present|excludedPrevious-excluder [?excluded ?excluder]
+  (l/fresh [?label]
+         (exclPrev|behavior-val ?excluder ?label)
+         (labeled|behavior-label|val ?excluded ?label)
+         (ajsoot/behavior-reachable|behavior ?excluded ?excluder)))
+
+(defn missing|requiredPrevious-requirer [?required ?requirer]
+  (l/fresh [?label]
+         (reqPrev|behavior-val ?requirer ?label)
+         (labeled|behavior-label|val ?required ?label)
+         (fails (ajsoot/behavior-reachable|behavior ?required ?requirer))))
+
+(defn missing|requiredPrevious-requirer-label [?required ?requirer ?label]
+  (l/all
+         (reqPrev|behavior-val ?requirer ?label)
+         (labeled|behavior-label|val ?required ?label)
+         (fails (ajsoot/behavior-reachable|behavior ?required ?requirer))))
+


CMR-2112 Script changes to print out better, more concise error messages

--- system-int-test/test/cmr/system_int_test/ingest/ops_collections_translation_test.clj
+++ system-int-test/test/cmr/system_int_test/ingest/ops_collections_translation_test.clj
@@ -166,6 +166,35 @@
         (umm/validate-xml :collection metadata-format metadata)
         (json-schema/validate-umm-json (umm-json/umm->json (:collection record)) :collection)))))

+(defn- extract-errors-from-collection
+  "During collection translation from native XML to UMM, errors are put directly on the fields that
+  cannot be translated with the :_errors key. Walk through the collection and pull out the errors
+  so they can be reported."
+  [collection]
+  (remove empty?
+          (flatten
+           (concat
+            [(:_errors collection)]
+            (for [key (keys collection)
+                  :let [coll (get collection key)]]
+              (cond
+                (map? coll) (extract-errors-from-collection coll)
+                (coll? coll) (for [entry coll]
+                               (when (map? entry)
+                                 (extract-errors-from-collection entry)))))))))
+
+(defn- reformat-error-messages
+  "For each 'string too long' error, just print out what string it is and the size so that
+  the test output does not get bloated with the full string"
+  [errors]
+  (map
+   (fn [error]
+     (if-let [result (re-find #"\w+ string .*is too long \(length: \d+, maximum allowed: \d+\)" (str/replace error "\n" ""))]
+       (let [string-index (str/index-of result "string")
+             length-index (str/index-of result "is too long (length:")]
+         (str (subs result 0 (+ 6 string-index)) " " (subs result length-index)))
+       error))
+   errors))

 (defn- get-collection-validation-errors
   "Collect the following collection validations:
@@ -177,8 +206,8 @@
   [record]
   (remove empty?
    (concat
-     [(str (get-in record [:collection :_errors]))] ; Errors from translating to UMM
-     (validate-record-schemas record)
+     (extract-errors-from-collection (:collection record)) ; Errors from translating to UMM
+     (reformat-error-messages (validate-record-schemas record))
      (umm-validation/validate-collection record))))

 (defn- translate-and-validation-collection
@@ -255,7 +284,7 @@
     (let [collections (get-collections validation-search-page-size page-num)
           error-results (remove nil? (map translate-and-validation-collection collections))
           all-results (conj results error-results)]
-      (info "Processed Page " page-num " " (count error-results) " errors")
+      (println "Processed Page " page-num " " (count error-results) " errors")
       (if (>= (count collections) validation-search-page-size)
         (recur (+ page-num 1) all-results)
         all-results))))
@@ -281,7 +310,7 @@

 (comment
   ;; Translate and validate a specific collection by concept-id
-  (def record (get-collection "C1214311756-AU_AADC"))
+  (def record (get-collection "C1214604828-SCIOPS"))
   (translate-and-validation-collection record)
   (translate-record-to-umm record)
   (:metadata-format record)


Parse int from env string

Parse int from env string

--- src/time_tracker/core.clj
+++ src/time_tracker/core.clj
@@ -9,4 +9,4 @@
   [& args]
   (web-service/init!)
   (log/info {:event ::server-start})
-  (run-server web-service/app {:port (from-config :port)}))
+  (run-server web-service/app {:port (Integer/parseInt (from-config :port))}))


Extra perfomance test code

Extra perfomance test code

--- test/clj/cortex/performance_test.clj
+++ test/clj/cortex/performance_test.clj
@@ -1,5 +1,6 @@
 (ns cortex.performance-test
   (:require [clojure.core.matrix :as m]
+            [cortex.layers :as layers]
             [cortex.impl.layers :as impl]
             [cortex.core :as core]
             [cortex.description :as desc]
@@ -42,3 +43,14 @@
                 (cp/forward network input)
                 (cp/backward network input output-gradient))
               (core/optimise optimizer network 1))))))
+
+;; miscellaneous performance tests
+(comment
+  ;; testing for linear layer computation
+  (let [a (layers/linear-layer 1000 1000)
+        input (vec (range 1000))
+        ograd (vec (range 1000))
+        a (time (core/forward a input))
+        a (time (core/backward a input ograd))]
+    :OK)
+  )


New tests: test-get-stage-test-job-suffix1/2

--- test/emender_jenkins/config_test.clj
+++ test/emender_jenkins/config_test.clj
@@ -409,6 +409,23 @@
             (get-preview-test-jobs-suffix {:configuration nil}) nil
             (get-preview-test-jobs-suffix nil) nil)))

+(deftest test-get-stage-test-jobs-suffix-1
+    "Check the behaviour of function emender-jenkins.config/get-stage-test-jobs-suffix."
+    (testing "the behaviour of function emender-jenkins.config/get-stage-test-jobs-suffix."
+        (are [x y] (= x y)
+            (get-stage-test-jobs-suffix {:configuration {:jobs {:stage-test-jobs-suffix nil}}})   nil
+            (get-stage-test-jobs-suffix {:configuration {:jobs {:stage-test-jobs-suffix false}}}) false
+            (get-stage-test-jobs-suffix {:configuration {:jobs {:stage-test-jobs-suffix true}}})  true
+            (get-stage-test-jobs-suffix {:configuration {:jobs {:stage-test-jobs-suffix "xyzzy"}}}) "xyzzy")))
+
+(deftest test-get-stage-test-jobs-suffix-2
+    "Check the behaviour of function emender-jenkins.config/get-stage-test-jobs-suffix."
+    (testing "the behaviour of function emender-jenkins.config/get-stage-test-jobs-suffix."
+        (are [x y] (= x y)
+            (get-stage-test-jobs-suffix {:configuration {:jobs nil}}) nil
+            (get-stage-test-jobs-suffix {:configuration nil}) nil
+            (get-stage-test-jobs-suffix nil) nil)))
+
 (deftest test-override-options-by-cli-1
     "Check the behaviour of function emender-jenkins.config/override-options-by-cli."
     (testing "the behaviour of function emender-jenkins.config/override-options-by-cli."


[#3073] Refactor the way to access the merge data using data groups

Co-authored-by: Juan A. Ruz <fd32a78311daf157576625b0c2bbe145183ae007@gmail.com>

--- backend/src/akvo/lumen/lib/transformation/merge_datasets.clj
+++ backend/src/akvo/lumen/lib/transformation/merge_datasets.clj
@@ -96,6 +96,13 @@
             {}
             rows)))

+(defn fetch-data-2
+  [conn {:keys [source-data-group source target]}]
+  (let [simple-query? (= (:source-table-name source-data-group)
+                         (:table-name source))]
+    )
+)
+
 (defn add-columns
   "Add the new columns to the target dataset"
   [conn table-name columns]
@@ -135,19 +142,31 @@
         columns-by-group (->> (set (get source "mergeColumns"))
                               (map-indexed (fn [i column-name]
                                              (let [dg (engine/datagroup-by-column data-groups column-name)
-                                                   column (first (filter (fn [c]
-                                                                           (= (get c "columnName") column-name))
-                                                                         (:columns dg)))]
+                                                   column (first (filter #(= (get % "columnName") column-name) (:columns dg)))]
                                                (-> column
-                                                (assoc "columnName" (engine/derivation-column-name
+                                                   (assoc "sourceColumnName" (get column "columnName")
+                                                          "columnName" (engine/derivation-column-name
                                                                      (+ (engine/next-column-index target-dataset-columns) i)))
                                                 reset-column-values))))
-                              (group-by #(get % "groupId")))]
+                              (group-by #(get % "groupId")))
+        instance-id-column (->> (db.data-group/get-data-group-by-column-name ;; TODO: define column as a var? (def instance-id-col {})
+                                 conn
+                                 {:column-name "instance_id"})
+                                :columns
+                                (first (filter #(= "instance_id" (get % "columnName")))))]
     (map (fn [[group-id columns]]
-           (let [dg (first (filter #(= (:group-id %) group-id) data-groups))]
+           (let [dg (first (filter #(= (:group-id %) group-id) data-groups))
+                 instance-id (merge instance-id-column {:groupId group-id
+                                                        :groupName (:groupName dg)
+                                                        :key false
+                                                        :hidden true})
+                 instance-id-exists? (boolean (first (filter #(= "instance_id" (get % "columnName")) columns)))]
              (assoc dg
-                    :columns columns
+                    :columns (if instance-id-exists?
+                               columns
+                               (conj columns instance-id))
                     :table-name (util/gen-table-name "ds")
+                    :source-table-name (:table-name dg)
                     :imported-table-name nil))) columns-by-group)))

 (defn get-source-dataset [conn source]
@@ -182,20 +201,22 @@
   (let [source (get-in op-spec ["args" "source"])
         target (get-in op-spec ["args" "target"])
         data-groups-to-be-created (get-data-groups-to-be-created conn source columns)
-        dataset-version (db.dataset-version/latest-dataset-version-2-by-dataset-id conn {:dataset-id (get target "datasetId")})
-        instance-id-column     (->> (db.data-group/get-data-group-by-column-name
-                                     conn
-                                     {:column-name "instance_id"})
-                                    :columns
-                                    (first (filter #(= "instance_id" (get % "columnName")))))]
-    (doseq [[{:keys [group-id group-name columns table-name]}] data-groups-to-be-created]
-      (let [adapted-instance-id-column (merge instance-id-column {:groupId group-id
-                                                                  :groupName group-name
-                                                                  :key false
-                                                                  :hidden true})]
-        (postgres/create-dataset-table conn table-name (conj columns adapted-instance-id-column))))
-
-    (prn data-groups-to-be-created)
+        target-dataset-version (db.dataset-version/latest-dataset-version-2-by-dataset-id conn {:dataset-id (get target "datasetId")})
+        target-merge-data-group (db.data-group/get-data-group-by-column-name conn {:column-name (get target "mergeColumn")
+                                                                                :dataset-version-id (:id target-dataset-version)})
+        source-dataset-version (db.dataset-version/latest-dataset-version-2-by-dataset-id conn {:dataset-id (get source "datasetId")})
+        source-merge-column-data-group (db.data-group/get-data-group-by-column-name {:column-name (get source "mergeColumn")
+                                                                                :dataset-version-id (:id source-dataset-version)})]
+    (doseq [[{:keys [columns table-name] :as source-data-group} ] data-groups-to-be-created]
+      (let [data (fetch-data-2 conn {:source-data-group source-data-group
+                                     :source {:merge-column (get source "mergeColumn")
+                                              :table-name (:table-name source-merge-column-data-group)}
+                                     :target {:merge-column (get target "mergeColumn")
+                                              :table-name (:table-name target-merge-data-group)}})] ;; [{:instance_id 123 :c1234 0} {:instance_id 566 :c1234 10}]
+        (postgres/create-dataset-table conn table-name columns)
+        (jdbc/insert-multi! conn table-name data)))
+
+    (map #(dissoc % :original-table-name) data-groups-to-be-created)
     {:success? true
      :execution-log [(format "Merged columns from %s into %s"
                              "(:table-name source-dataset)"