Simplify partition logic by separating families and tablet ids.

--- src/merkle_db/partition.clj
+++ src/merkle_db/partition.clj
@@ -15,27 +15,34 @@

 (s/def :merkle-db.data/count nat-int?)

+(s/def :merkle-db.data/families
+  (s/map-of keyword? (s/coll-of any? :kind set?)))
+
 ; TODO: bloom filter for key membership

 (s/def ::first-key key/bytes?)
 (s/def ::last-key key/bytes?)
-
-(s/def :merkle-db.data.partition.tablet/data merkle-link?)
-(s/def :merkle-db.data.partition.tablet/fields (s/coll-of any? :kind set?))
-
-(s/def ::tablets
-  (s/map-of keyword? (s/keys :req-un [:merkle-db.data.partition.tablet/id]
-                             :opt-un [:merkle-db.data.partition.tablet/fields])))
+(s/def ::tablets (s/map-of keyword? merkle-link?))

 (s/def :merkle-db/partition
   (s/keys :req [:merkle-db.data/count
                 ::start-key
                 ::end-key
-                ::tablets]))
+                ::tablets]
+          :opt [:merkle-db.data/families]))

 ;; ## Constructors
+
+(defn- partition-families
+  "Builds a field family map from a map of tablet keys to link values."
+  [store tablet-ids]
+  (-> {}
+      (into (map (juxt key #(tablet/fields-present (node/get-data store %))))
+            tablet-ids)
+      (dissoc :base)))
+

 (defn from-tablets
   "Constructs a new partition from the given map of tablets. The argument should
@@ -45,19 +52,13 @@
     (throw (ex-info "Cannot construct a partition without a base tablet"
                     {:tablets tablet-ids})))
   (let [base (node/get-data store (:base tablet-ids))
-        records (vec (tablet/read base))]
+        base-records (vec (tablet/read base))]
     {:data/type :merkle-db/partition
-     :merkle-db.data/count (count records)
-     ::first-key (first (first (tablet/read base)))
-     ::last-key (first (last (tablet/read base)))
-     ::tablets (-> tablet-ids
-                   (->>
-                     (map (fn [[k id]]
-                            [k {:id id
-                                :fields (tablet/fields-present
-                                          (node/get-data store id))}]))
-                     (into {}))
-                   (update :base dissoc :fields))}))
+     :merkle-db.data/count (count base-records)
+     :merkle-db.data/families (partition-families store tablet-ids)
+     ::first-key (first (first base-records))
+     ::last-key (first (last base-records))
+     ::tablets tablet-ids}))

@@ -98,23 +99,16 @@
         (cons [next-key next-data] (record-seq next-seqs))))))

-(defn- tablet-families
-  "Returns a map of tablet keys to sets of fields contained in those tablets."
-  [part]
-  (into {}
-        (map (juxt key (comp :fields val)))
-        (dissoc (::tablets part) :base)))
-
-
 (defn read-tablets
   "Performs a read across the tablets in the partition by selecting based on
   the desired fields. The reader function is called on each selected tablet
   along with any extra args, producing a collection of lazy record sequences
   which are combined into a single sequence of key/record pairs."
   [store part fields read-fn & args]
+  ; OPTIMIZE: use transducer instead of intermediate sequences.
   (->> (set fields)
-       (choose-tablets (tablet-families part))
-       (map (comp :id (::tablets part)))
+       (choose-tablets (:merkle-db.data/families part))
+       (map (::tablets part))
        (map (partial node/get-data store))
        (map #(apply read-fn % args))
        (record-seq)
@@ -143,7 +137,7 @@
         updates))))

-(defn- update-tablets
+(defn- update-tablets!
   [store f tablets [family-key tablet-updates]]
   (let [tablet (or (node/get-data store (get-in tablets [family-key :id]))
                    (throw (ex-info (format "Couldn't find tablet %s in backing store"
@@ -161,7 +155,7 @@
          (assoc-in tablets [family-key :id]))))

-(defn add-records
+(defn add-records!
   "Performs an update across the tablets in the partition to merge in the given
   record data."
   [store part f records]
@@ -172,7 +166,7 @@
         ; Update partition tablet map.
         tablets (->> records
                      (reduce (partial append-record-updates field->family) {})
-                     (reduce (partial update-tablets store f) (::tablets part)))
+                     (reduce (partial update-tablets! store f) (::tablets part)))
         part' (assoc part
                      :merkle-db.data/count (count (tablet/read (node/get-data store (get-in tablets [:base :id]))))
                      ::tablets tablets


Make filter-offensive-jobs lazy

Make filter-offensive-jobs lazy

Signed-off-by: Wil <41c73e1c187a64e501bf473cfef5419e8eb5a640@twosigma.com>

--- scheduler/src/cook/mesos/scheduler.clj
+++ scheduler/src/cook/mesos/scheduler.clj
@@ -228,7 +228,7 @@
                                      :task-lost
                                      :task-error} :instance.status/failed)
                  prior-job-state (:job/state (d/entity db job))
-                 progress (try
+                 progress (try
                               (when (:data status)
                                   (:percent (read-string (String. (:data status)))))
                           (catch Exception e
@@ -932,8 +932,14 @@
                             (:job/_instance task)))))]
     jobs))

-(timers/deftimer [cook-mesos scheduler rank-jobs-duration])
-(meters/defmeter [cook-mesos scheduler rank-jobs-failures])
+(timers/deftimer [cook-mesos scheduler filter-offensive-jobs-duration])
+
+(defn is-offensive?
+  [max-memory-mb max-cpus job]
+  (let [{memory-mb :mem
+         cpus :cpus} (util/job-ent->resources job)]
+    (or (> memory-mb max-memory-mb)
+        (> cpus max-cpus))))

 (defn filter-offensive-jobs
   "Base on the constraints on memory and cpus, given a list of job entities it
@@ -945,22 +951,19 @@
   ;; TODO these limits should come from the largest observed host from Fenzo
   ;; .getResourceStatus on TaskScheduler will give a map of hosts to resources; we can compute the max over those
   [{max-memory-gb :memory-gb max-cpus :cpus} offensive-jobs-ch jobs]
-  (let [max-memory-mb (* 1024.0 max-memory-gb)
-        categorized-jobs (group-by (fn [job]
-                                     (let [{memory-mb :mem
-                                            cpus :cpus} (util/job-ent->resources job)]
-                                       (if (or (> memory-mb max-memory-mb)
-                                               (> cpus max-cpus))
-                                         :offensive
-                                         :inoffensive)))
-                                   jobs)]
-    ;; Put offensive jobs asynchronically such that it could return the
-    ;; inoffensive jobs immediately.
-    (async/go
-      (when (seq (:offensive categorized-jobs))
-        (log/info "Found" (count (:offensive categorized-jobs)) "offensive jobs")
-        (async/>! offensive-jobs-ch (:offensive categorized-jobs))))
-    (:inoffensive categorized-jobs)))
+  (timers/time!
+    filter-offensive-jobs-duration
+    (let [max-memory-mb (* 1024.0 max-memory-gb)
+          is-offensive? (partial is-offensive? max-memory-mb max-cpus)
+          inoffensive (remove is-offensive? jobs)
+          offensive (filter is-offensive? jobs)]
+      ;; Put offensive jobs asynchronically such that it could return the
+      ;; inoffensive jobs immediately.
+      (async/go
+        (when (seq offensive)
+          (log/info "Found" (count offensive) "offensive jobs")
+          (async/>! offensive-jobs-ch offensive)))
+      inoffensive)))

 (defn make-offensive-job-stifler
   "It returns an async channel which will be used to receive offensive jobs expected
@@ -989,6 +992,9 @@
               (log/error e "Failed to kill the offensive job!")))
           (recur))))
     offensive-jobs-ch))
+
+(timers/deftimer [cook-mesos scheduler rank-jobs-duration])
+(meters/defmeter [cook-mesos scheduler rank-jobs-failures])

 (defn rank-jobs
   "Return a list of job entities ordered by dru.


Remove warning til we find a suitable synonym

--- scheduling/src/immutant/scheduling.clj
+++ scheduling/src/immutant/scheduling.clj
@@ -14,6 +14,7 @@

 (ns immutant.scheduling
   "Schedule jobs for execution"
+  (:refer-clojure :exclude [repeat])
   (:require [immutant.util :as u]
             [immutant.scheduling.options :refer [resolve-options defoption]])
   (:import org.projectodd.wunderboss.WunderBoss


Added a few differentiation methods.

Added a few differentiation methods.

--- src/main/cljc/clojure_club/x121_universal_computation_engine/mbastian.cljc
+++ src/main/cljc/clojure_club/x121_universal_computation_engine/mbastian.cljc
@@ -9,6 +9,25 @@
                        (symbol? t) (m t)
                        (number? t) t
                        :default ((compute t) m))) r)))))
+
+(defn differentiate [f]
+  (fn [m]
+    (cond
+      (number? f) 0
+      (m f) 1
+      (list f) (case (first f)
+                 + (reduce + (map (fn [x] ((differentiate x) m)) (rest f)))
+                 - (reduce - (map (fn [x] ((differentiate x) m)) (rest f)))
+                 * (reduce + (map
+                               (fn [i] (let [[u [x & r]] (split-at i (rest f))]
+                                         (* ((differentiate x) m) ((compute (cons '* (into u r))) m))))
+                               (range (count (rest f)))))
+                 / :not-yet))))
+
+
+;(differentiate '(+ (* x x x) (* 2 x x) (* -4 x) -3))
+;((differentiate '(+ (* x x x 3) (* x x) (* x -87) -84)) {'x 2})
+;((compute '(+ (* x x x 3) (* x x) (* x -87) -84)) {'x 2})

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


cjl - add to get-games test

cjl - add to get-games test


Fix inst

Fix inst

--- src/overtone/inst/synth.clj
+++ src/overtone/inst/synth.clj
@@ -82,7 +82,7 @@
         src (clip2 (* 1.3 src) 0.8)
         sub (sin-osc (/ freq 2))
         filt (resonz (rlpf src (* 4.4 freq) 0.09) (* 2.0 freq) 2.9)]
-    (* env amp (fold (distort (* 1.3 (+ filt sub))) 0.08))))
+    (* env amp (fold:ar (distort (* 1.3 (+ filt sub))) 0.08))))

 (definst grunge-bass [note 48 amp 0.5 dur 0.1 a 0.01 d 0.01 s 0.4 r 0.01]
   (let [freq (midicps note)


Avoid an iteration

Avoid an iteration

populate the queue directly

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

--- src/conexp/contrib/algorithms/downing_gallier.clj
+++ src/conexp/contrib/algorithms/downing_gallier.clj
@@ -30,12 +30,13 @@
   (let [numargs                    (reduce (fn [numargs i]
                                              (assoc numargs i (dec (get numargs i))))
                                            numargs
-                                           (mapcat in-premise input-set))
-        empty-premise-implications (map first
-                                        (filter (fn [[i c]] (zero? c))
-                                                numargs))]
-    (loop [queue   (into (clojure.lang.PersistentQueue/EMPTY)
-                         empty-premise-implications),
+                                           (mapcat in-premise input-set))]
+    (loop [queue   (reduce (fn [queue [i c]]
+                             (if (zero? c)
+                               (conj queue i)
+                               queue))
+                           (clojure.lang.PersistentQueue/EMPTY)
+                           numargs),
            numargs (transient numargs)
            result  input-set]
       (if (empty? queue)


elasitcsearch; connect to clusters with native client

--- joplin.elasticsearch/src/joplin/elasticsearch/database.clj
+++ joplin.elasticsearch/src/joplin/elasticsearch/database.clj
@@ -113,8 +113,19 @@
 (defn client [{:keys [host port]}]
   (es/connect (str "http://" host ":" port)))

-(defn native-client [{:keys [host port]}]
-  (esn/connect [[host port]]))
+(defn native-client [{:keys [host port cluster]}]
+  (esn/connect [[host port]] {"cluster.name" cluster}))
+
+(defn wait-for-ready [es-native-client shards]
+  (-> es-native-client
+      .admin
+      .cluster
+      (.prepareHealth (into-array String []))
+      ;; Don't wait for green -- it may never come for the cluster.
+      .setWaitForYellowStatus
+      (.setWaitForActiveShards shards)
+      .execute
+      .actionGet))

 (defn find-index-names [es-client alias-name]
   (->> (esi/get-settings es-client)


Delete unused REST specs.

Delete unused REST specs.

--- spec/freefrog/rest_spec.clj
+++ spec/freefrog/rest_spec.clj
@@ -234,278 +234,4 @@
             (should= 400 (:status @response))
             (should-contain "Agenda is closed" (:body @response))))))))

-;      (context "putting to the agenda endpoint"
-;        (with response (http-put-request "/circles/1234/governance/5678/agenda"
-;                                         "New agenda"))
-;
-;        (it "should return a 201"
-;          (should= 201 (:status @response)))))))
-;          (should-invoke p/put-governance-log {:times 1}
-;                         @response)
-;          (should-contain "Governance meeting does not exist" (:body @response)))))))
-
-;    (context "with nothing having been created"
-;      (context "requesting the root resource"
-;        (with response (http-get-request "/"))
-;        (it "should return an empty object"
-;          (should= 200 (:status @response))
-;          (should= "{}" (:body @response))))
-;
-;      (should-return-4xx "with creating a role"
-;                         (fn [] "/")
-;                         (json/generate-string {:command "addRole"
-;                                                :params {:name "Test Role"}})
-;                         400
-;                         "IllegalArgumentException"))
-;
-;    (context "with creating the anchor circle"
-;      (should-return-4xx "with no paramaters"
-;                         (fn [] "/")
-;                         (json/generate-string
-;                           {:command "anchorCircle"})
-;                         400
-;                         "IllegalArgumentException")
-;
-;      (should-return-4xx "with missing paramaters"
-;                         (fn [] "/")
-;                         (json/generate-string
-;                           {:command "anchorCircle"
-;                            :params {:foo "Test Circle!"}})
-;                         400
-;                         "IllegalArgumentException")
-;
-;      (context "with valid parameters"
-;        (with create-anchor-circle-response (http-post-request
-;                                              "/"
-;                                              (json/generate-string
-;                                                {:command "anchorCircle",
-;                                                 :params {:name "Test Circle!"}})))
-;        (before @create-anchor-circle-response)
-;
-;        (it "should return the location of the newly created resource"
-;          (should= 201 (:status @create-anchor-circle-response))
-;          (should= "/" (get-location @create-anchor-circle-response)))
-;
-;        (context "with retrieving the circle"
-;          (with get-response (http-get-request (get-location @create-anchor-circle-response)))
-;          (it "should return the content that was created"
-;            (should= 200 (:status @get-response))
-;            (should-contain "Test Circle!" (:body @get-response))))
-;
-;        (context "with deleting the anchor circle"
-;          (with delete-response (http-client/delete "http://localhost:3000/"
-;                                                    {:throw-exceptions false}))
-;          (it "should return method-not-allowed."
-;            (should= 405 (:status @delete-response))))
-;
-;        (context "with updating the anchor circle"
-;          (context "with invalid parameters"
-;            (with response (http-put-request
-;                             "/"
-;                             (json/generate-string
-;                               {:command "anchorCircle",
-;                                :params {:foo "Test Circle!"}})))
-;            (xit "should return an error response"))
-;
-;          (context "with valid parameters"
-;            (with response (http-put-request
-;                             "/"
-;                             (json/generate-string
-;                               {:command "anchorCircle",
-;                                :params {:name "Test Circle!"}})))
-;            (xit "should return the location of the updated resource")))
-;
-;        (context "with getting a non-existent role"
-;          (with get-role-response (http-get-request "/DummyRole"))
-;          (it "should return 404"
-;            (should= 404 (:status @get-role-response))))
-;
-;        (context "with creating a role"
-;          (with create-role-response (http-post-request
-;                                       "/"
-;                                       (json/generate-string
-;                                         {:command "addRole",
-;                                          :params {:foo "Test Circle!"}})))
-;          (context "with invalid parameters"
-;            (it "should return a failure"
-;              (should= 400 (:status @create-role-response))))
-;
-;          (context "with valid parameters"
-;            (with create-role-response (http-post-request
-;                                         "/"
-;                                         (json/generate-string
-;                                           {:command "addRole",
-;                                            :params {:name "Test Circle!"}})))
-;            (before @create-role-response)
-;            (it "should return the location of the newly created resource"
-;              (should= 201 (:status @create-role-response))
-;              (should= (str "/" (url-encode "Test Circle!"))
-;                (get-location @create-role-response)))
-;
-;            (context "with retrieving the role"
-;              (with get-role-response (http-get-request
-;                                        (str "/" (url-encode "Test Circle!"))))
-;              (xit "should return contents of the newly created resource"
-;                (should= 200 (:status @get-role-response))))
-;
-;            (context "with deleting the role"
-;              (with delete-response
-;                    (http-client/delete (str "http://localhost:3000/"
-;                                             (url-encode "Test Circle!"))
-;                                        {:throw-exceptions false}))
-;              (before @delete-response)
-;              (xit "should return a valid response code of 204"
-;                (should= 204 (:status @delete-response)))
-;
-;              (context "with requesting the deleted role"
-;                (with deleted-get-response
-;                      (http-get-request (str "/" (url-encode "Test Circle!"))))
-;                (xit "should return a 404.")))
-;
-;            (context "with updating a role"
-;              (with put-response
-;                (http-put-request (str "/" (url-encode "Test Circle!"))))
-;              (xit "should update the role accordingly"))
-;
-;            (context "with converting a role to a circle"
-;              (with convert-response
-;                    (http-post-request
-;                      (str "/" (url-encode "Test Circle!"))
-;                      (json/generate-string
-;                        {:command "convertRoleToCircle"})))
-;              (xit "should convert the role to a circle"))))))))
-;
-;
-;;(should-return-4xx "with invalid paramaters"
-;;                   (fn [] "circles")
-;;                   (json/generate-string {:foo "Test Circle!"})
-;;                   400
-;;                   "IllegalArgumentException")
-;;(should-return-4xx "with missing paramaters"
-;;                   (fn [] "circles")
-;;                   (json/generate-string {:foo "Test Circle!"})
-;;                   400
-;;                   "IllegalArgumentException")
-;;(should-return-4xx "with malformed JSON"
-;;                   (fn [] "circles")
-;;                   "{\"name\" :: \"Bill\""
-;;                   400
-;;                   "IOException"))
-;;
-;;(context "with a created circle"
-;;  (with location (get-location (http-post-request
-;;                                 "circles"
-;;                                 (json/generate-string
-;;                                   {:name "Test Circle!"}))))
-;;  (context "and its specified location"
-;;    (with get-response (http-get-request @location))
-;;    (it "should return the content that was created"
-;;      (should= 200 (:status @get-response))
-;;      (should-contain "Test Circle!" (:body @get-response))))
-;;
-;;  (context "and its implicit location"
-;;    (with get-response (http-get-request (url-encode "Test Circle!")))
-;;    (it "should return the content that was created"
-;;      (should-not= nil @location)
-;;      (should= 200 (:status @get-response))
-;;      (should-contain "Test Circle!" (:body @get-response)))))
-;;
-;;(context "when creating multiple circles"
-;;  (before (http-post-request "circles"
-;;                             (json/generate-string
-;;                               {:name "Test Circle!"})
-;;                             {:throw-exceptions true}))
-;;
-;;  (before (http-post-request "circles"
-;;                             (json/generate-string
-;;                               {:name "Test Circle 2"})
-;;                             {:throw-exceptions true}))
-;;
-;;  (with get-response (http-get-request "circles"))
-;;
-;;  (it "should return an array of created circles"
-;;    (should= 200 (:status @get-response))
-;;    (should-contain "application/json" (get-in @get-response
-;;                                               [:headers "Content-Type"]))
-;;    (should= 2 (count (json/parse-string (:body @get-response)))))))
-;;
-;;(context "roles"
-;;  (context "when requesting the list of roles for a non-existent circle"
-;;    (with roles-response (http-get-request "circles/New%20Circle/roles"))
-;;    (it "should 404"
-;;      (should= 404 (:status @roles-response))))
-;;
-;;  (context "when posting a new role to a non-existent circle"
-;;    (with roles-response (http-post-request
-;;                           "circles/New%20Circle/roles"
-;;                           (json/generate-string {:name "My Role!"})))
-;;    (it "should 422 with a helpful error message"
-;;      (should= 404 (:status @roles-response))
-;;      (should-contain "Circle 'New Circle' does not exist." (:body @roles-response))))
-;;
-;;  (context "with a circle"
-;;    (with circle-location (get-location (http-post-request
-;;                                          "circles"
-;;                                          (json/generate-string
-;;                                            {:name "Test Circle!"}))))
-;;
-;;    (context "when requesting the list of roles"
-;;      (with roles-response (http-get-request (str @circle-location "/roles")))
-;;
-;;      (it "should return an empty array"
-;;        (should= 200 (:status @roles-response))
-;;        (should= "[]" (:body @roles-response))))
-;;
-;;    (context "when creating a role"
-;;      (context "with valid parameters"
-;;        (with roles-response (http-post-request
-;;                               (str @circle-location "/roles")
-;;                               (json/generate-string {:name "My Role!"})))
-;;
-;;        (it "should return the location of the newly created resource"
-;;          (should= 201 (:status @roles-response))
-;;          (should= (str "/circles/" (url-encode "Test Circle!") "/roles/"
-;;                        (url-encode "My Role!"))
-;;                   (get-location @roles-response))))
-;;
-;;      (should-return-4xx "with invalid paramaters"
-;;                         #(str @circle-location "/roles")
-;;                         (json/generate-string {:foo "Test Role"})
-;;                         400
-;;                         "IllegalArgumentException")
-;;      (should-return-4xx "with missing paramaters"
-;;                         #(str @circle-location "/roles")
-;;                         (json/generate-string {})
-;;                         400
-;;                         "IllegalArgumentException")
-;;      (should-return-4xx "with malformed JSON"
-;;                         #(str @circle-location "/roles")
-;;                         "{\"name\" :: \"Bill\""
-;;                         400
-;;                         "IOException"))
-;;
-;;    (context "with a created role and its location"
-;;      (with role-location (get-location (http-post-request
-;;                                          (str @circle-location "/roles")
-;;                                          (json/generate-string
-;;                                            {:name "Test Role"})
-;;                                          {:throw-exceptions true} )))
-;;      (with get-response (http-get-request @role-location))
-;;      (it "should return the content that was created"
-;;        (should= 200 (:status @get-response))
-;;        (should-contain "Test Role" (:body @get-response))))
-;;
-;;    (context "with a created role with accountabilities and its location"
-;;      (with role-location (get-location (http-post-request
-;;                                          (str @circle-location "/roles")
-;;                                          (json/generate-string
-;;                                            {:name "Test Role"
-;;                                             :purpose "End world hunger"})
-;;                                          {:throw-exceptions true} )))
-;;      (with get-response (http-get-request @role-location))
-;;      (it "should return the content that was created"
-;;        (should= 200 (:status @get-response))
-;;        (should-contain "Test Role" (:body @get-response))
-;;        (should-contain "End world hunger" (:body @get-response)))))))
-
 (run-specs)


TCHECK-155 don't generate :/ keyword

TCHECK-155 don't generate :/ keyword

--- src/main/clojure/clojure/test/check/generators.cljc
+++ src/main/clojure/clojure/test/check/generators.cljc
@@ -1473,11 +1473,9 @@

 (def keyword
   "Generates keywords without namespaces."
-  (frequency [[100
-               (->> symbol-name-or-namespace
-                    (fmap core/keyword)
-                    (resize-symbolish-generator))]
-              [1 (return :/)]]))
+  (->> symbol-name-or-namespace
+       (fmap core/keyword)
+       (resize-symbolish-generator)))

 (def
   ^{:added "0.5.9"}


Add durable database

Add durable database

--- modules/datomic/src/modular/datomic.clj
+++ modules/datomic/src/modular/datomic.clj
@@ -30,6 +30,13 @@
     (d/shutdown false)
     this))

+(defrecord DurableDatabase [uri]
+  component/Lifecycle
+  (start [this] this)
+  (stop [this]
+    (d/shutdown false)
+    this))
+
 (def new-datomic-database-schema
   {:uri s/Str
    :ephemeral? s/Bool})
@@ -40,7 +47,7 @@
                            (s/validate new-datomic-database-schema))]
     (if ephemeral?
       (->EphemeralDatabase uri)
-      (throw (ex-info "Persistent databases not yet implemented" {})))))
+      (->DurableDatabase uri))))

 (defrecord DatomicConnection []
   component/Lifecycle
@@ -48,7 +55,9 @@
   (stop [this] this))

 (defn new-datomic-connection []
-  (->DatomicConnection))
+  (component/using
+   (->DatomicConnection)
+   [:database]))

 (defrecord DatomicSchema [res]
   component/Lifecycle
@@ -65,4 +74,6 @@
   (stop [this] this))

 (defn new-datomic-schema [res]
-  (->DatomicSchema res))
+  (component/using
+   (->DatomicSchema res)
+   [:connection]))


Set up simulated vote stream _inside_ poller (realize actors need to have larger mailboxes)

--- src/polismath/stormspec.clj
+++ src/polismath/stormspec.clj
@@ -4,6 +4,7 @@
             [polismath.conv-man :as cm]
             [polismath.db :as db]
             [clojure.core.matrix :as ccm]
+            [plumbing.core :as pc]
             [polismath.env :as env]
             [clojure.string :as string]
             [clojure.newtools.cli :refer [parse-opts]]
@@ -20,22 +21,45 @@
 (ccm/set-current-implementation :vectorz)
 (ccm/matrix [[1 2 3] [4 5 6]])

+(let [at-a-time 100
+      interval  1000
+      reaction-gen
+        (atom
+          (sim/make-vote-gen
+            {:n-convs 3
+             :vote-rate interval
+             :person-count-start 4
+             :person-count-growth 5
+             :comment-count-start 3
+             :comment-count-growth 3}))]
+  (defn sim-poll! [& {:keys [last-timestamp] :as opts}]
+    (let [results (take at-a-time @reaction-gen)]
+      (swap! reaction-gen (partial drop at-a-time))
+      (map (pc/fn-> (assoc :created (- last-timestamp (rand 500)))) results)))
+
+  (defn poll [last-timestamp]
+    (let [db-results (db/poll last-timestamp)
+          last-timestamp (reduce max last-timestamp (map :created db-results))
+          sim-results (sim-poll! :last-timestamp last-timestamp)]
+      (concat db-results sim-results))))
+

 (defspout sim-reaction-spout ["zid" "last-timestamp" "reactions"] {:prepare true}
   [conf context collector]
-  (let [at-a-time 10
-        interval 1000
+  (let [at-a-time 100
+        interval  1000
         reaction-gen
           (atom
             (sim/make-vote-gen
               {:n-convs 3
                :vote-rate interval
                :person-count-start 4
-               :person-count-growth 3
+               :person-count-growth 5
                :comment-count-start 3
-               :comment-count-growth 1}))]
+               :comment-count-growth 3}))]
     (spout
       (nextTuple []
+        (log/info "Polling simutated reaction spout")
         (let [rxn-batch (take at-a-time @reaction-gen)
               split-rxns (group-by :zid rxn-batch)
               last-timestamp (System/currentTimeMillis)]
@@ -53,7 +77,7 @@
     (spout
       (nextTuple []
         (log/info "Polling :created >" @last-timestamp)
-        (let [new-votes (db/poll @last-timestamp)
+        (let [new-votes (poll @last-timestamp)
               grouped-votes (group-by :zid new-votes)]
           ; For each chunk of votes, for each conversation, send to the appropriate spout
           (doseq [[zid rxns] grouped-votes]
@@ -73,10 +97,16 @@
         (let [[zid last-timestamp rxns] (.getValues tuple)
               ; First construct a new conversation builder. Then either find a conversation, or call that
               ; builder in conv-agency
-              conv-actor (cm/get-or-set!
-                           conv-agency zid (fn []
-                                             (cm/new-conv-actor
-                                               (partial cm/load-or-init zid))))]
+              conv-actor (cm/get-or-set! conv-agency zid
+                           (fn []
+                             (let [ca (cm/new-conv-actor (partial cm/load-or-init zid))]
+                               (add-watch
+                                 (:conv ca)
+                                 :size-watcher
+                                 (fn [k r o n]
+                                   (when ((set (range 4)) (:zid n))
+                                     (log/info "Size of conversation" (:zid n) "is" (:n n) (:n-cmts n)))))
+                               ca)))]
           (cm/send-votes conv-actor {:last-timestamp last-timestamp :reactions rxns}))
         (ack! collector tuple)))))


Make rest of tests use the defexamples macro

Guess I missed a few when refactoring.

--- test/superstring/core_test.clj
+++ test/superstring/core_test.clj
@@ -120,13 +120,12 @@
           cases2 (map case-to-int (str/swap-case s))]
       (apply = 0 (map + cases1 cases2)))))

-(deftest swap-case
-  (are [expected actual] (= expected actual)
-    "Foo" (str/swap-case "fOO" )
-    "foo" (str/swap-case "FOO")
-    "åÅBERG" (str/swap-case "Ååberg")
-    "æÆå." (str/swap-case "ÆæÅ.")
-    "SS" (str/swap-case "ß")))
+(defexamples swap-case
+  (str/swap-case "fOO" ) "Foo"
+  (str/swap-case "FOO") "foo"
+  (str/swap-case "Ååberg") "åÅBERG"
+  (str/swap-case "ÆæÅ.") "æÆå."
+  (str/swap-case "ß") "SS")

 (defspec slice-without-end-has-length-1 100
   (prop/for-all [[s i] (gen/bind (gen/not-empty gen/string)
@@ -182,23 +181,21 @@
           width (second vals)]
       (= (.length (str/pad-right s width)) width))))

-(deftest right-pad
-  (are [expected actual] (= expected actual)
-    "" (str/pad-right "" 0)
-    " " (str/pad-right "" 1)
-    "foo "(str/pad-right "foo" 4)
-    "foo  " (str/pad-right "foo" 5)
-    "foo.!" (str/pad-right "foo" 5 ".!")
-    "foo.!." (str/pad-right "foo" 6 ".!")))
-
-(deftest left-pad
-  (are [expected actual] (= expected actual)
-    "" (str/pad-left "" 0)
-    " " (str/pad-left "" 1)
-    " foo"(str/pad-left "foo" 4)
-    "  foo" (str/pad-left "foo" 5)
-    ".!foo" (str/pad-left "foo" 5 ".!")
-    ".!.foo" (str/pad-left "foo" 6 ".!")))
+(defexamples right-pad
+  (str/pad-right "" 0) ""
+  (str/pad-right "" 1) " "
+  (str/pad-right "foo" 4) "foo "
+  (str/pad-right "foo" 5) "foo  "
+  (str/pad-right "foo" 5 ".!") "foo.!"
+  (str/pad-right "foo" 6 ".!") "foo.!.")
+
+(defexamples left-pad
+  (str/pad-left "" 0) ""
+  (str/pad-left "" 1) " "
+  (str/pad-left "foo" 4) " foo"
+  (str/pad-left "foo" 5) "  foo"
+  (str/pad-left "foo" 5 ".!") ".!foo"
+  (str/pad-left "foo" 6 ".!") ".!.foo")

 (defspec left-pad-results-in-strings-with-new-width 100
   (prop/for-all
@@ -393,9 +390,8 @@
     (is (not (str/upper-case? (str/lower-case s))))))

 (deftest upper-case-test
-  (are [expected actual] (= expected actual)
-    "UPPER" (str/upper-case? "UPPER")
-    "123UPPER!" (str/upper-case? "123UPPER!")))
+  (str/upper-case? "UPPER") "UPPER"
+  (str/upper-case? "123UPPER!") "123UPPER!")

 (defspec lower-case?-returns-true-on-all-lower 100
   (prop/for-all [s (gen/not-empty gen/string)]


Fix monstergen

Fix monstergen

--- src/robinson/monstergen.clj
+++ src/robinson/monstergen.clj
@@ -26,7 +26,7 @@
                :turtle :crocodile
                :crab :hermit-crab} race))

-(defrecord Monster [race name name-plural hp energy speed size strength toughness body-parts attacks movement-policy range-threshold status]
+(defrecord Monster [race name name-plural hp energy speed size strength toughness body-parts attacks temperment movement-policy range-threshold status]
   Object
   (toString [this] (str "#Monster" (into {} this))))

@@ -72,10 +72,10 @@
   (Monster. :komodo-dragon  "komodo dragon"  "komodo dragons" 12 0 0.8  60    10   14 #{:head :body :leg :tail}                   #{:bite :claw}                :hostile-after-attacked               :random                               2 #{:hostile})
   (Monster. :cobra          "cobra"          "cobras"          5 0 0.8   6     3    7 #{:head :body :tail}                        #{:bite :bite-venom}          :hostile-after-attacked               :random                               2 #{:hostile})
   (Monster. :puffer-fish    "puffer fish"    "puffer fish"     3 0 1.1   1     0.6  7 #{:head :body :tail}                        #{:sting-venom}               :hostile-during-day                   :random                               2 #{:hostile})
-  (Monster. :crab           "crab"           "crabs"           4 0 0.8   2     1.5  9 #{:head :body}                              #{:claw}                      :hostile-after-sound                  2 #{:hostile})
-  (Monster. :hermit-crab    "hermit crab"    "hermit crabs"    3 0 0.6   1     1   15 #{:head :shell :leg}                        #{:claw}                      :hostile-during-day                   1 #{:hostile})
-  (Monster. :electric-eel   "electric eel"   "electric eels"   5 0 0.6  10     5    8 #{:head :body}                              #{:bite}                      :follow-player-in-range-or-random     2 #{:hostile})
-  (Monster. :jellyfish      "jellyfish"      "jellyfish"       3 0 0.6   1     0.1  4 #{:body}                                    #{:sting-venom}               :retreat-after-attacked               1 #{:hostile})])
+  (Monster. :crab           "crab"           "crabs"           4 0 0.8   2     1.5  9 #{:head :body}                              #{:claw}                      :hostile-after-sound                  :random                               2 #{:hostile})
+  (Monster. :hermit-crab    "hermit crab"    "hermit crabs"    3 0 0.6   1     1   15 #{:head :shell :leg}                        #{:claw}                      :hostile-during-day                   :random                               1 #{:hostile})
+  (Monster. :electric-eel   "electric eel"   "electric eels"   5 0 0.6  10     5    8 #{:head :body}                              #{:bite}                      :hostile                              :follow-player-in-range-or-random     2 #{:hostile})
+  (Monster. :jellyfish      "jellyfish"      "jellyfish"       3 0 0.6   1     0.1  4 #{:body}                                    #{:sting-venom}               :retreat-after-attacked               :random                               1 #{:hostile})])

 (def ^:private race->monster-map
   (apply hash-map (mapcat (fn [[k v]] [k (first v)])


implicitly order by breakout fields in QP

--- src/metabase/driver/generic_sql/query_processor.clj
+++ src/metabase/driver/generic_sql/query_processor.clj
@@ -94,7 +94,8 @@
     [nil] nil ; empty clause
     _     (let [field-names (map field-id->kw field-ids)]
             `[(group  ~@field-names)
-              (fields ~@field-names)])))
+              (fields ~@field-names)
+              (order  ~@field-names :ASC)])))

 ;; ### `:fields`
 ;; ex.


Fix doc typo.

Fix doc typo.

--- src/afterglow/transform.clj
+++ src/afterglow/transform.clj
@@ -264,9 +264,9 @@

   If there is more than one legal solution, return the one that is
   closest to the specified target value. If no target value is
-  specified (using the keyword parameter :target-value), then use the
-  fixture's center position as the default target value to stay close
-  to."
+  specified (using the keyword parameters :target-pan
+  and :target-tilt), then use the fixture's center position as the
+  default target value to stay close to."
   [fixture x y z & {:keys [target-pan target-tilt] :or {target-pan (:pan-center fixture) target-tilt (:tilt-center fixture)}}]
   {:pre [(some? fixture) (number? x) (number? y) (number? z) (number? target-pan) (number? target-tilt)]}
   (let [direction (invert-direction fixture x y z)


Unquote NS and file in standard-metadata

--- src/main/clojure/com/stuartsierra/lazytest/arguments.clj
+++ src/main/clojure/com/stuartsierra/lazytest/arguments.clj
@@ -21,14 +21,14 @@
   "Returns a metadata map with keys :ns, :file,
   :line, :form, :doc, and :name."
   ([form docstring]
-     `{:ns *ns*
-       :file *file*
+     `{:ns ~*ns*
+       :file ~*file*
        :line ~(:line (meta form))
        :form '~form
        :doc ~docstring})
   ([form docstring name]
-     `{:ns *ns*
-       :file *file*
+     `{:ns ~*ns*
+       :file ~*file*
        :line ~(:line (meta form))
        :form '~form
        :doc ~docstring


[chat] Fix threads not showing up for new users

Fixes #214

If a thread was created before a user registered, new messages on that thread would not show up for that user.

Fixed by subscribing new users to all tagged threads.

--- src/braid/chat/db/group.clj
+++ src/braid/chat/db/group.clj
@@ -176,13 +176,30 @@
          (db/db) group-id)
     (map (fn [[tag]] [:db/add [:user/id user-id] :user/subscribed-tag tag]))))

+(defn user-subscribe-to-all-tagged-threads
+  "Subscribe the user to all tagged conversation threads (ie. public).
+   Without this, threads that were started *before* a new user registered
+   would not show up for that user even if new messages were posted on those threads."
+  [user-id group-id]
+  (->> (d/q '[:find [?thread ...]
+              :in $ ?group-id
+              :where
+              [?group :group/id ?group-id]
+              [?tag :tag/group ?group]
+              [?thread :thread/tag ?tag]
+              [?thread :thread/group ?group]]
+            (db/db) group-id)
+       (map (fn [thread]
+              [:db/add [:user/id user-id] :user/subscribed-thread thread]))))
+
 (defn user-join-group-txn
   "Add a user to the given group, subscribe them to the group tags,
   and subscribe them to the five most recent threads in the group."
   [user-id group-id]
   (concat
     (user-add-to-group-txn user-id group-id)
-    (user-subscribe-to-group-tags-txn user-id group-id)))
+    (user-subscribe-to-group-tags-txn user-id group-id)
+    (user-subscribe-to-all-tagged-threads user-id group-id)))

 (defn user-open-recent-threads
   "Opens last 10 visible threads for new user.


only show messages from users in the group in inbox

--- src/braid/common/state.cljs
+++ src/braid/common/state.cljs
@@ -1,7 +1,7 @@
 (ns braid.common.state
   (:require
     [reagent.ratom :include-macros true :refer-macros [reaction]]
-    [clojure.set :refer [union intersection]]))
+    [clojure.set :refer [union intersection subset?]]))

 (defn set-active-group-id!
   [state [_ group-id]]
@@ -114,22 +114,27 @@
   (let [group-id (reaction (get-in @state [:open-group-id]))
         open-thread-ids (reaction (get-in @state [:user :open-thread-ids]))
         tag-id->group-id (reaction
-                           (->> (@state :tags)
-                                vals
-                                (map (juxt :id :group-id))
-                                (into {})))
+                           (into {} (map (juxt :id :group-id))
+                                 (vals (@state :tags))))
         threads (reaction (@state :threads))
-        open-threads-kv (reaction
-                          (-> @threads
-                              (select-keys @open-thread-ids)))
-        open-threads (reaction (vals @open-threads-kv))]
+        open-threads (reaction (vals (select-keys @threads @open-thread-ids)))
+        group-users (reaction
+                      (into #{}
+                            (comp
+                              (filter (fn [u] (contains? (set (u :group-ids)) @group-id)))
+                              (map :id))
+                            (vals (@state :users))))]
     (reaction
-      (doall ; avoid laziness in reactions! lead to @group-id not being deref'd, so subs didn't update
+      (doall
         (filter (fn [thread]
-                  (or (empty? (thread :tag-ids))
-                      (contains?
-                        (into #{} (map @tag-id->group-id (thread :tag-ids)))
-                        @group-id)))
+                  (and
+                    (or (empty? (thread :tag-ids))
+                        (contains?
+                          (into #{} (map @tag-id->group-id) (thread :tag-ids))
+                          @group-id))
+                    (subset?
+                      (set (thread :mentioned-ids))
+                      @group-users)))
                 @open-threads)))))

 (defn get-users-in-group


Fix remaining reflection issues in pem

Fix remaining reflection issues in pem

--- src/buddy/core/keys/pem.clj
+++ src/buddy/core/keys/pem.clj
@@ -33,10 +33,10 @@
   (Security/addProvider (org.bouncycastle.jce.provider.BouncyCastleProvider.)))

 (defn- decryptor
-  [builder passphrase]
+  [^String passphrase]
   (when (nil? passphrase)
     (throw (ex-info "Passphrase is mandatory with encrypted keys." {})))
-  (.build builder (.toCharArray passphrase)))
+  (.toCharArray passphrase))

 ;; TODO: maybe make this functions work with strings instead of reader

@@ -49,14 +49,14 @@
                       (.setProvider "BC"))]
       (cond
         (instance? PEMEncryptedKeyPair obj)
-        (->> (.decryptKeyPair obj (decryptor (JcePEMDecryptorProviderBuilder.) passphrase))
+        (->> (.decryptKeyPair ^PEMEncryptedKeyPair obj (.build (JcePEMDecryptorProviderBuilder.) (decryptor passphrase)))
              (.getKeyPair converter)
              (.getPrivate))
         (instance? PEMKeyPair obj)
         (->> (.getKeyPair converter obj)
              (.getPrivate))
         (instance? PKCS8EncryptedPrivateKeyInfo obj)
-        (->> (.decryptPrivateKeyInfo obj (decryptor (JceOpenSSLPKCS8DecryptorProviderBuilder.) passphrase))
+        (->> (.decryptPrivateKeyInfo ^PKCS8EncryptedPrivateKeyInfo obj (.build (JceOpenSSLPKCS8DecryptorProviderBuilder.) (decryptor passphrase)))
              (.getPrivateKey converter))
         (instance? PrivateKeyInfo obj)
         (.getPrivateKey converter obj)
@@ -71,6 +71,6 @@
           converter (doto (JcaPEMKeyConverter.)
                       (.setProvider "BC"))]
       (if (instance? X509CertificateHolder keyinfo)
-        (.getPublicKey converter (.getSubjectPublicKeyInfo keyinfo))
+        (.getPublicKey converter (.getSubjectPublicKeyInfo ^X509CertificateHolder keyinfo))
         (.getPublicKey converter keyinfo)))))


RS & ML | 161 | added sign-in-or-register handler to disable caching exceptions

--- src/stonecutter/handler.clj
+++ src/stonecutter/handler.clj
@@ -91,19 +91,19 @@
        :authorise-client                     (partial oauth/authorise-client auth-code-store client-store user-store token-store)
        :show-authorise-failure               (partial oauth/show-authorise-failure client-store)}
       (m/wrap-handlers-except #(m/wrap-handle-403 % forbidden-err-handler) #{})
-      (m/wrap-handlers-except m/wrap-disable-caching #{:theme-css :index})
+      (m/wrap-handlers-except m/wrap-disable-caching #{:theme-css :index :sign-in-or-register})
       (m/wrap-handlers-except m/wrap-signed-in #{:index :sign-in-or-register
-                                          :sign-out
-                                          :show-profile-deleted
-                                          :authorise
-                                          :ping
-                                          :theme-css
-                                          :confirm-email-with-id
-                                          :confirmation-sign-in-form :confirmation-sign-in
-                                          :show-forgotten-password-form :send-forgotten-password-email
-                                          :show-forgotten-password-confirmation
-                                          :show-reset-password-form
-                                          :reset-password}))))
+                                                 :sign-out
+                                                 :show-profile-deleted
+                                                 :authorise
+                                                 :ping
+                                                 :theme-css
+                                                 :confirm-email-with-id
+                                                 :confirmation-sign-in-form :confirmation-sign-in
+                                                 :show-forgotten-password-form :send-forgotten-password-email
+                                                 :show-forgotten-password-confirmation
+                                                 :show-reset-password-form
+                                                 :reset-password}))))

 (defn api-handlers [config-m stores-m id-token-generator json-web-key-set]
   (let [auth-code-store (storage/get-auth-code-store stores-m)


wrap api routes in edn-params too

wrap api routes in edn-params too

--- src/chat/server/handler.clj
+++ src/chat/server/handler.clj
@@ -59,6 +59,7 @@

 (defroutes api-routes
   (POST "/auth" req
+    (println "auth" req (req :params))
     (if-let [user-id (let [{:keys [email password]} (req :params)]
                        (when (and email password)
                          (db/with-conn (db/authenticate-user email password))))]
@@ -73,27 +74,27 @@
                                     :port 6379}})

 (def app
-  (routes
-    (wrap-defaults
-      (routes sync-routes api-routes)
-      (-> api-defaults
-          (assoc-in [:session :cookie-attrs :secure] (= (env :environment) "prod"))
-          (assoc-in [:session :store] (carmine/carmine-store *redis-conf*
-                                                             {:expiration-secs (* 60 60 24 7)
-                                                              :key-prefix "lpchat"}))))
-      (->
-        (wrap-defaults
-          (routes
-            resource-routes
-            site-routes)
-          (-> site-defaults ; ssl stuff will be handled by nginx
-              (assoc-in [:session :cookie-attrs :secure] (= (env :environment) "prod"))
-              (assoc-in [:session :store] (carmine/carmine-store *redis-conf*
-                                                                 {:expiration-secs (* 60 60 24 7)
-                                                                  :key-prefix "lpchat"}))
-              (assoc-in [:security :anti-forgery]
-                {:read-token (fn [req] (-> req :params :csrf-token))})))
-        wrap-edn-params)))
+  (->
+    (routes
+      (wrap-defaults
+        (routes sync-routes api-routes)
+        (-> api-defaults
+            (assoc-in [:session :cookie-attrs :secure] (= (env :environment) "prod"))
+            (assoc-in [:session :store] (carmine/carmine-store *redis-conf*
+                                                               {:expiration-secs (* 60 60 24 7)
+                                                                :key-prefix "lpchat"}))))
+      (wrap-defaults
+        (routes
+          resource-routes
+          site-routes)
+        (-> site-defaults ; ssl stuff will be handled by nginx
+            (assoc-in [:session :cookie-attrs :secure] (= (env :environment) "prod"))
+            (assoc-in [:session :store] (carmine/carmine-store *redis-conf*
+                                                               {:expiration-secs (* 60 60 24 7)
+                                                                :key-prefix "lpchat"}))
+            (assoc-in [:security :anti-forgery]
+              {:read-token (fn [req] (-> req :params :csrf-token))}))))
+    wrap-edn-params))

 (defonce server (atom nil))


Give prevention prompts :priority 10 to supersede all other prompts.

--- src/clj/game/core-rules.clj
+++ src/clj/game/core-rules.clj
@@ -144,7 +144,8 @@
                                  (str "prevents " (if (= prevent Integer/MAX_VALUE) "all" prevent )
                                       " " (name type) " damage")
                                  "will not prevent damage"))
-                   (resolve-damage state side type (max 0 (- n (or prevent 0))) args)))))
+                   (resolve-damage state side type (max 0 (- n (or prevent 0))) args)))
+               {:priority 10}))
          (resolve-damage state side type n args))))))

@@ -190,7 +191,8 @@
                                  (str "avoids " (if (= prevent Integer/MAX_VALUE) "all" prevent)
                                       (if (< 1 prevent) " tags" " tag"))
                                  "will not avoid tags"))
-                   (resolve-tag state side (max 0 (- n (or prevent 0))) args)))))
+                   (resolve-tag state side (max 0 (- n (or prevent 0))) args)))
+               {:priority 10}))
          (resolve-tag state side n args))))))

@@ -234,7 +236,8 @@
                                   (do (system-msg state :runner (str "prevents the trashing of " (:title card)))
                                       (swap! state update-in [:trash :trash-prevent] dissoc ktype))
                                   (do (system-msg state :runner (str "will not prevent the trashing of " (:title card)))
-                                      (apply resolve-trash state side card args targets))))))
+                                      (apply resolve-trash state side card args targets))))
+                              {:priority 10}))
              ;; No prevention effects; resolve the trash.
              (apply resolve-trash state side card args targets))))))))


Normalize SELECT results to set of *sets*

--- src/clj/sparqlab/sparql.clj
+++ src/clj/sparqlab/sparql.clj
@@ -171,7 +171,7 @@
   "Normalize results of a SPARQL SELECT query."
   [query-results]
   (let [data (json/parse-string query-results keyword)]
-    (cond-> (map (partial map val) (get-in data [:results :bindings]))
+    (cond-> (map (comp set (partial map val)) (get-in data [:results :bindings]))
       (not (get-in data [:results :ordered])) set ; Unordered bindings are compared as sets
       )))


Client db: Tidy up schema and rest

Client db: Tidy up schema and rest

 - Add a full schema for documentation.

 - Make the names of the attributes more regular.

 - Make the scratch areas more rigorous. Keys are not new attributes in
   the database anymore, but have to be stored as the "key" attribute of
   an entity. This appears more clean to me.

 - Add some documentation.

These changes are breaking and the rest of the code still has to be
adapted to them.

--- src/cljs/theatralia/db.cljs
+++ src/cljs/theatralia/db.cljs
@@ -1,10 +1,38 @@
-(ns theatralia.db)
+(ns theatralia.db
+  "Definitions of the schema of the DataScript DB in the client."
+  (:require [plumbing.core :as plumbing]
+            [schema.core :as s]))

-;; TODO: Get some structure into what we're doing by defining a Prismatic schema
-;;       or something like that. See also
-;;       https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/db.cljs.
-;;       (RM 2015-08-27)
+(def full-schema
+  "Complete schema for the DB.

-(def schema {:scratch/key {:db/unique :db.unique/identity}
-             :search-result {:db/cardinality :db.cardinality/many}
-             :tag/index {:db/unique :db.unique/identity}})
+  DataScript only supports a subset of schema attributes, so we can't use this
+  verbatim. Especially, it doesn't support custom value types specified with
+  Prismatic schema. So this is mainly for documentation."
+  {:scratch/handle {:db/unique :db.unique/identity}
+   :scratch/kv-cells {:db/cardinality :db.cardinality/many
+                      :db/valueType   :db.type/ref}
+
+   :kv-cell/key {:db/valueType :db.type/string}
+   :kv-cell/val {:db/valueType s/Any}
+
+   :search/result
+   {:db/cardinality :db.cardinality/many
+    :db/valueType [(s/one s/Int "server entity ID")
+                   (s/one s/String "result title")
+                   (s/one s/Num "score")]}
+
+   :tag/s-id {:db/unique :db.unique/identity
+              :db/valueType :db.type/long}
+   :tag/text {:db/valueType :db.type/string}})
+
+(def schema
+  "Actual schema for the DataScript database, generated from the full schema.
+
+  This is all DataScript supports."
+  (plumbing/for-map [[a m] full-schema]
+    a (plumbing/for-map [[aa v] m
+                         :when (or (= aa :db/cardinality)
+                                   (= aa :db/unique)
+                                   (= v :db.type/ref))]
+        aa v)))


Fixed spawn call for Windows and OS X

Fixed spawn call for Windows and OS X

--- src/cljs/zest/settings.cljs
+++ src/cljs/zest/settings.cljs
@@ -327,13 +327,13 @@
                        (.spawn child-process
                                (zest.core/get-binary-path "sogrep")
                                (apply array @so-index-tags)
-                               "env" (js-obj
-                                       "PATH"
-                                       (.dirname path (.dirname path (.-__dirname js/window))))
-                               "cwd"
-                               (.join path
-                                      (zest.docs.registry/get-so-root)
-                                      "new_index")))
+                               (js-obj "env" (js-obj
+                                               "PATH"
+                                               (.dirname path (.dirname path (.-__dirname js/window))))
+                                       "cwd"
+                                       (.join path
+                                              (zest.docs.registry/get-so-root)
+                                              "new_index"))))
               extractor (if (= (.-platform js/process) "linux")
                           nil
                           (run-so-extractor (array)))]


indentation

indentation


Fix typo in docstring

Fix typo in docstring

--- src/com/puppetlabs/time.clj
+++ src/com/puppetlabs/time.clj
@@ -88,7 +88,7 @@

 (def hour-formatter
   "A formatter that converts Hour `Period` objects to strings formatted as,
-  e.g., '2 days'."
+  e.g., '2 hours'."
   (build-parser #(.appendHours %) " hour" " hours"))

 (def minute-formatter


Add typical fracture size and fracture angle

--- src/test_utils/sandbox.cljc
+++ src/test_utils/sandbox.cljc
@@ -316,7 +316,7 @@
 (defn delta-p-seq []
   (let [start-at (rand-stage-time-point-seconds)
         at-times (iterate (fn [t] (+ t 30)) start-at)]
-    (map #(rand-delta-p %) at-times)))
+    (map #(rand-delta-p %) at-times)))hA

 (defn rand-fhl []
   (tuc/draw-normal 773 106))
@@ -331,14 +331,15 @@
   "Generate a normally-distributed, random value with the range typical-min to typical-max, inclusive."
   {:pre (< typical-min typical-max)}
   (let [mean (/ (+ typical-min typical-max) 2)
-        ;; Typical range (assumed normal) is within 3-sigma of the mean
+          ;; Typical range (assumed normal) is within 3-sigma of the mean
         sigma (/ mean 6)]
     (tuc/draw-normal mean sigma)))

 (defn convert-units-f [from to]
   (let [converter {[:psi :kPa] (partial * 6.89476)
                    [:kPa :MPa] #(/ % 1000)
-                   [:C :F] #(+ (* % 1.8) 32)}]
+                   [:C :F] #(+ (* % 1.8) 32)
+                   [:ft :m] #(/ (* % 30.48) 100)}]
     (converter [from to])))

 (defn typical-monitor-pressure [units]
@@ -392,4 +393,12 @@
         separator (if (rand-nth [true false]) "-" "")]
     (str indicator separator discriminator)))

-
+(defn typical-fracture-size [units]
+  (cond (= units :ft)
+        [(value-from-typical-range 500 1000) (value-from-typical-range 100 150)]
+        (= units :m)
+        (map #(convert-units-f :ft :m) (typical-monitor-temperature :m))))
+
+(defn typical-fracture-azimuth []
+  (value-from-typical-range 0 180))
+


refactor two-pass-scheduler to only require :processor (like single-pass & async ctx), add parallel-two-pass-processor, update default ctx configs

--- src/thi/ng/fabric/core.cljc
+++ src/thi/ng/fabric/core.cljc
@@ -325,8 +325,9 @@

 (defn parallel-signal-pass
   [thresh]
-  (fn [vertices]
+  (fn [workgroup-size vertices]
     (r/fold
+     workgroup-size
      sub-pass-combine
      (fn [acc v]
        (if (should-signal? v thresh)
@@ -337,8 +338,9 @@

 (defn parallel-collect-pass
   [thresh]
-  (fn [vertices]
+  (fn [workgroup-size vertices]
     (r/fold
+     workgroup-size
      sub-pass-combine
      (fn [acc v]
        (if (should-collect? v thresh)
@@ -347,7 +349,17 @@
          acc))
      vertices)))

-(defn probabilistic-vertex-processor
+(defn parallel-two-pass-processor
+  [s-thresh c-thresh]
+  (let [sig-fn  (parallel-signal-pass s-thresh)
+        coll-fn (parallel-collect-pass c-thresh)]
+    (fn [workgroup-size vertices]
+      (let [#?@(:cljs [vertices (seq vertices)])
+            [s-act sigs]  (sig-fn workgroup-size vertices)
+            [c-act colls] (coll-fn workgroup-size vertices)]
+        [(into s-act c-act) sigs colls]))))
+
+(defn probabilistic-single-pass-processor
   [s-thresh c-thresh]
   (fn [[active sigs colls] v]
     (let [active (conj active v)]
@@ -361,7 +373,7 @@
               [active sigs (inc colls)])
           [active sigs colls])))))

-(defn eager-probabilistic-vertex-processor
+(defn eager-probabilistic-single-pass-processor
   [s-thresh c-thresh]
   (fn [[active sigs colls] v]
     (let [active (conj active v)]
@@ -386,13 +398,7 @@

 (defn two-pass-scheduler
   [ctx]
-  (let [sig-fn  ((:signal-fn ctx) (:signal-thresh ctx))
-        coll-fn ((:collect-fn ctx) (:collect-thresh ctx))]
-    (fn [_ vertices]
-      (let [#?@(:cljs [vertices (seq vertices)])
-            [s-act sigs]  (sig-fn vertices)
-            [c-act colls] (coll-fn vertices)]
-        [(into s-act c-act) sigs colls]))))
+  ((:processor ctx) (:signal-thresh ctx) (:collect-thresh ctx)))

 (defn add-context-watches
   [g watch-id queue]
@@ -453,21 +459,20 @@
                   (->result :converged i sigs colls t0)))
               (->result :max-iter-reached i sigs colls t0))))))))

-(defn default-context-opts
+(defn default-scheduled-context-opts
   []
   {:collect-thresh 0
    :signal-thresh  0
-   ;;:signal-fn      parallel-signal-pass
-   ;;:collect-fn     parallel-collect-pass
-   ;;:scheduler      two-pass-scheduler
-   :processor      eager-probabilistic-vertex-processor
-   :scheduler      single-pass-scheduler
+   :processor      parallel-two-pass-processor
+   :scheduler      two-pass-scheduler
+   ;;:processor      eager-probabilistic-single-pass-processor
+   ;;:scheduler      single-pass-scheduler
    :max-ops        1e6
    :threads        #?(:clj (inc (.availableProcessors (Runtime/getRuntime))) :cljs 1)})

 (defn scheduled-execution-context
   [opts]
-  (let [ctx       (merge (default-context-opts) opts)
+  (let [ctx       (merge (default-scheduled-context-opts) opts)
         g         (:graph ctx)
         c-thresh  (:collect-thresh ctx)
         s-thresh  (:signal-thresh ctx)
@@ -512,8 +517,10 @@
   []
   {:collect-thresh 0
    :signal-thresh  0
-   :processor      eager-probabilistic-vertex-processor
-   :scheduler      single-pass-scheduler
+   :processor      parallel-two-pass-processor
+   :scheduler      two-pass-scheduler
+   ;;:processor      eager-probabilistic-single-pass-processor
+   ;;:scheduler      single-pass-scheduler
    :max-ops        1e6
    :threads        #?(:clj (inc (.availableProcessors (Runtime/getRuntime))) :cljs 1)})


Make buffers absurdly large.

Make buffers absurdly large.

--- src/onyx_benchmark/peer.clj
+++ src/onyx_benchmark/peer.clj
@@ -103,6 +103,10 @@
                      :onyx.messaging/bind-addr (slurp "http://169.254.169.254/latest/meta-data/local-ipv4")
                      :onyx.messaging/peer-ports (vec (range 40000 40200))
                      :onyx.messaging/peer-link-gc-interval 99999999
+                     :onyx.messaging/inbound-buffer-size 4000000
+                     :onyx.messaging/completion-buffer-size 500000
+                     :onyx.messaging/release-ch-buffer-size 500000
+                     :onyx.messaging/retry-ch-buffer-size 1000000
                      ;:onyx.messaging.aeron/embedded-driver? false
                      :onyx.peer/join-failure-back-off 500
                      :onyx.peer/job-scheduler :onyx.job-scheduler/greedy


Somewhat working windowing/trigger state check

--- src/onyx_jepsen/checker.clj
+++ src/onyx_jepsen/checker.clj
@@ -93,7 +93,10 @@
   (let [exception (job-exception log-conn final-replica)
         ledger-reads (first (history->read-ledgers history :persist))
         trigger-ledger-reads (first (history->read-ledgers history :identity-log))
-        _ (println "Trigger ledger reads " trigger-ledger-reads)
+        ;; grab only job 0's ledgers for now
+        final-window-state-write (last (last (:results (last (get (:value trigger-ledger-reads) 0)))))
+        window-state-filtered? (= (sort-by :id final-window-state-write)
+                                  (sort-by :id (set final-window-state-write)))
         ledger-read-results (ledger-reads->job+reads ledger-reads)
         ;; Add a check here that there are no overlaps in the ledgers read by the jobs
         correct-jobs? (reads-correct-jobs? ledger-read-results)
@@ -103,17 +106,25 @@
                          (mapcat :read-results)
                          (map #(dissoc % :job-num))
                          set)
-        diff-written-read (clojure.set/difference added-values read-values)
-        all-written-read? (empty? diff-written-read)
+        diff-added-read (clojure.set/difference added-values read-values)
+        all-added-read? (empty? diff-added-read)
+        all-added-triggered? (empty?
+                               (clojure.set/difference added-values
+                                                       (->> final-window-state-write
+                                                            (map #(dissoc % :job-num))
+                                                            set)))
         unacked-writes-read (clojure.set/difference read-values added-values)]
     {:information {:read-values read-values
-                   :diff-written-read diff-written-read
+                   :diff-added-read diff-added-read
                    :unacknowledged-writes-read unacked-writes-read
                    :job-exception-message (some-> exception (.getMessage))
-                   :job-exception-trace (if exception (with-out-str (clojure.stacktrace/print-stack-trace exception)))}
-     :invariants {:job-completed? (nil? exception)
+                   :job-exception-trace (if exception
+                                          (with-out-str (clojure.stacktrace/print-stack-trace exception)))}
+     :invariants {:window-state-filtered? window-state-filtered?
+                  :job-completed? (nil? exception)
                   :reads-correct-jobs? correct-jobs?
-                  :all-written-read? all-written-read?}}))
+                  :all-added-triggered? all-added-triggered?
+                  :all-added-read? all-added-read?}}))

 (defn history->job-name [history]
   (:job-type (first (filter (fn [action]


Add an append-if function to more clearly describe what's going on in the forwarding mechanism

--- src/useful/experimental.clj
+++ src/useful/experimental.clj
@@ -97,7 +97,11 @@
           (let [{:keys [ns name]} (meta v)
                 ns (ns-name ns)
                 sigs (:sigs @v)]
-            (keyed [ns name sigs])))]
+            (keyed [ns name sigs])))
+        (append-if [test item coll]
+          (if-not test
+            coll
+            (concat coll [item])))]

   (defmacro protocol-stub
     [name trace-fn proto-specs]
@@ -120,12 +124,11 @@
                   (cons `fn
                         (for [[this & args :as argvec] arglists]
                           `([~@argvec]
-                            (let [~ret ~(when forward?
-                                           `(~fn-name (~impl-kw ~this) ~@args))]
-                              (~trace '~short-name (list ~@argvec)
-                                      ~@(when forward?
-                                          [ret]))
-                              ~ret))))}))}))]
+                              (let [~ret ~(when forward?
+                                            `(~fn-name (~impl-kw ~this) ~@args))]
+                                ~(->> `(~trace '~short-name (list ~@argvec))
+                                      (append-if forward? ret))
+                                ~ret))))}))}))]
       `(do
          (defrecord ~name [~impl-field])
          (let [~trace ~trace-fn]


Remove whitespace.

Remove whitespace.

--- src/uxbox/worker/align.cljs
+++ src/uxbox/worker/align.cljs
@@ -24,7 +24,6 @@
      (vreset! state tree)
      (wrk/reply! sender nil))))

-
 (defmethod wrk/handler :grid/align
   [{:keys [sender point] :as message}]
   (let [point #js [(:x point) (:y point)]


formatting

formatting

--- src/overtone/inst/synth.clj
+++ src/overtone/inst/synth.clj
@@ -51,10 +51,10 @@
                             :action FREE)
         fil-env    (env-gen (perc))
         fil-cutoff (+ cutoff (* env-amount fil-env))
-        waves     (* vol-env
-                     [(saw freqs)
-                      (pulse freqs 0.5)
-                      (lf-tri freqs)])
+        waves      (* vol-env
+                      [(saw freqs)
+                       (pulse freqs 0.5)
+                       (lf-tri freqs)])
         selector   (select wave waves)
         filt       (rlpf selector fil-cutoff r)]
     (* amp filt)))
@@ -77,14 +77,14 @@
    fsustain {:default 0.999 :min 0.0001 :max 1 :step 0.001}
    frelease {:default 0.0001 :min 0.0001 :max 6 :step 0.001}
    gate 1]
-  (let [freq (midicps note)
+  (let [freq       (midicps note)
         osc-bank-1 [(saw freq) (sin-osc freq) (pulse freq)]
         osc-bank-2 [(saw freq) (sin-osc freq) (pulse freq)]
-        amp-env (env-gen (adsr attack decay sustain release) gate :action FREE)
-        f-env (env-gen (adsr fattack fdecay fsustain frelease) gate)
-        s1 (* osc1-level (select osc1 osc-bank-1))
-        s2 (* osc2-level (select osc2 osc-bank-2))
-        filt (moog-ff (+ s1 s2) (* cutoff f-env) 3)]
+        amp-env    (env-gen (adsr attack decay sustain release) gate :action FREE)
+        f-env      (env-gen (adsr fattack fdecay fsustain frelease) gate)
+        s1         (* osc1-level (select osc1 osc-bank-1))
+        s2         (* osc2-level (select osc2 osc-bank-2))
+        filt       (moog-ff (+ s1 s2) (* cutoff f-env) 3)]
     (* amp filt)))

 (definst rise-fall-pad
@@ -104,17 +104,17 @@

 (definst pad
   [note 60 t 10 amt 0.3 amp 0.1 a 0.4 d 0.5 s 0.8 r 2]
-  (let [freq       (midicps note)
-        lfo        (+ 2 (* 0.01 (sin-osc:kr 5 (rand 1.5))))
-        src        (apply + (saw [freq (* freq lfo)]))
-        env        (env-gen (adsr a d s r) (sin-osc:kr 0.2))
-        f-env      (x-line:kr 0.001 4 t)
-        src        (* env src)
-        signal     (rlpf src (+ (* 0.3 freq) (* f-env 2 freq)) 0.5)
-        k          (/ (* 4 amt) (- 1 amt))
-        dist       (clip2 (/ (* (+ 1 k) signal) (+ 1 (* k (abs signal))))
-                          0.03)
-        snd        (* amp dist (line:kr 1 0 t))]
+  (let [freq   (midicps note)
+        lfo    (+ 2 (* 0.01 (sin-osc:kr 5 (rand 1.5))))
+        src    (apply + (saw [freq (* freq lfo)]))
+        env    (env-gen (adsr a d s r) (sin-osc:kr 0.2))
+        f-env  (x-line:kr 0.001 4 t)
+        src    (* env src)
+        signal (rlpf src (+ (* 0.3 freq) (* f-env 2 freq)) 0.5)
+        k      (/ (* 4 amt) (- 1 amt))
+        dist   (clip2 (/ (* (+ 1 k) signal) (+ 1 (* k (abs signal))))
+                      0.03)
+        snd    (* amp dist (line:kr 1 0 t))]
     src))

 (definst overpad
@@ -132,17 +132,17 @@
 (definst buzz
   [pitch 40 cutoff 300 dur 200]
   (let [lpf-lev (* (+ 1 (lf-noise1:kr 10)) 400)
-        a (lpf (saw (midicps pitch)) lpf-lev)
-        b (sin-osc (midicps (- pitch 12)))
-        env (env-gen 1 1 0 1 2 (perc 0.01 (/ dur 1000)))]
+        a       (lpf (saw (midicps pitch)) lpf-lev)
+        b       (sin-osc (midicps (- pitch 12)))
+        env     (env-gen 1 1 0 1 2 (perc 0.01 (/ dur 1000)))]
     (* env (+ a b))))

 (definst bass
   [freq 120 t 0.6 amp 0.5]
-  (let [env (env-gen (perc 0.08 t) :action FREE)
-        src (saw [freq (* 0.98 freq) (* 2.015 freq)])
-        src (clip2 (* 1.3 src) 0.8)
-        sub (sin-osc (/ freq 2))
+  (let [env  (env-gen (perc 0.08 t) :action FREE)
+        src  (saw [freq (* 0.98 freq) (* 2.015 freq)])
+        src  (clip2 (* 1.3 src) 0.8)
+        sub  (sin-osc (/ freq 2))
         filt (resonz (rlpf src (* 4.4 freq) 0.09) (* 2.0 freq) 2.9)]
     (* env amp (fold:ar (distort (* 1.3 (+ filt sub))) 0.08))))

@@ -156,15 +156,15 @@

 (definst grunge-bass
   [note 48 amp 0.5 dur 0.1 a 0.01 d 0.01 s 0.4 r 0.01]
-  (let [freq (midicps note)
-        env (env-gen (adsr a d s r) (line:kr 1 0 (+ a d dur r 0.1))
-                     :action FREE)
-        src (saw [freq (* 0.98 freq) (* 2.015 freq)])
-        src (clip2 (* 1.3 src) 0.9)
-        sub (sin-osc (/ freq 2))
-        filt (resonz (rlpf src (* 8.4 freq) 0.29) (* 2.0 freq) 2.9)
-        meat (ring4 filt sub)
-        sliced (rlpf meat (* 2 freq) 0.1)
+  (let [freq    (midicps note)
+        env     (env-gen (adsr a d s r) (line:kr 1 0 (+ a d dur r 0.1))
+                         :action FREE)
+        src     (saw [freq (* 0.98 freq) (* 2.015 freq)])
+        src     (clip2 (* 1.3 src) 0.9)
+        sub     (sin-osc (/ freq 2))
+        filt    (resonz (rlpf src (* 8.4 freq) 0.29) (* 2.0 freq) 2.9)
+        meat    (ring4 filt sub)
+        sliced  (rlpf meat (* 2 freq) 0.1)
         bounced (free-verb sliced 0.8 0.9 0.2)]
     (* env bounced)))

@@ -194,7 +194,7 @@
 ; Work in progress...  just getting started
 (comment definst b3
   [note 60 a 0.01 d 3 s 1 r 0.01]
-  (let [freq (midicps note)
+  (let [freq  (midicps note)
         waves (sin-osc [(* 0.5 freq)
                         freq
                         (* (/ 3 2) freq)
@@ -204,8 +204,8 @@
                         (* freq 2 2 (/ 5 4))
                         (* freq 2 2 (/ 3 2))
                         (* freq 2 2 2)])
-        snd (apply + waves)
-        env (env-gen (adsr a d s r) :action FREE)]
+        snd   (apply + waves)
+        env   (env-gen (adsr a d s r) :action FREE)]
     (* env snd 0.1)))

 ; Experimenting with Karplus Strong synthesis...


Add impls of `render` for regex ops

Add impls of `render` for regex ops

--- src/pinpointer/printer.cljc
+++ src/pinpointer/printer.cljc
@@ -142,3 +142,21 @@
     (fn [i [k v]]
       (let [vprinter (cond-> printer (= k key) pop-trace)]
         [:span (visit/visit printer k) " " (visit/visit vprinter v)]))))
+
+(defmethod render `s/cat [frame _ printer x]
+  (render-coll frame printer x))
+
+(defmethod render `s/& [frame _ printer x]
+  (render-coll frame printer x))
+
+(defmethod render `s/alt [frame _ printer x]
+  (render-coll frame printer x))
+
+(defmethod render `s/? [frame _ printer x]
+  (render-coll frame printer x))
+
+(defmethod render `s/* [frame _ printer x]
+  (render-coll frame printer x))
+
+(defmethod render `s/+ [frame _ printer x]
+  (render-coll frame printer x))


Only show grandfather migration notice if you already have an osx plan.

--- src-cljs/frontend/components/org_settings.cljs
+++ src-cljs/frontend/components/org_settings.cljs
@@ -471,7 +471,7 @@
           [:div.osx-plans {:data-component `osx-plans-list-ga}
            [:fieldset
             [:legend (str "OS X Plans")]
-            (when-not (pm/osx-ga-plan? plan)
+            (when (and (pm/osx? plan) (not (pm/osx-ga-plan? plan)))
               (om/build limited-release-notice plan))
             [:p "Your selection selection below only applies to OS X service and will not affect Linux Containers."]
             (when (and (pm/osx-trial-plan? plan) (not (pm/osx-trial-active? plan)))


filter out nil lines #260

filter out nil lines
#260

--- src/clj/swarmpit/docker/engine/log.clj
+++ src/clj/swarmpit/docker/engine/log.clj
@@ -23,14 +23,13 @@

 (defn parse-log
   [service-log]
-  (if (some? service-log)
-    (->> service-log
-         (map (fn [x]
-                {:line      (parse-log-line x)
-                 :timestamp (parse-log-timestamp x)
-                 :task      (parse-log-task x)}))
-         (filter #(some? (:task %)))
-         (sort-by :timestamp))))
+  (->> service-log
+       (filter #(some? %))
+       (map (fn [x]
+              {:line      (parse-log-line x)
+               :timestamp (parse-log-timestamp x)
+               :task      (parse-log-task x)}))
+       (sort-by :timestamp)))

 (defn format-log
   [task-log task-id]


Mult on close-chan to send signal on all events

This was probably the reason why specifying the handle-event on .off
did not work.  It probably only worked on the first .off go-loop.

--- src/cljs/hacker_agent/hacker-base.cljs
+++ src/cljs/hacker_agent/hacker-base.cljs
@@ -51,9 +51,10 @@
   ([fbref]
    (fb->chan fbref (chan)))
   ([fbref close-chan]
-   (let [events [:child_added :child_changed :child_removed]
+   (let [mult-close (mult close-chan)
+         events [:child_added :child_changed :child_removed]
          event-chans (map (fn [event]
-                            (fb->chan fbref close-chan event))
+                            (fb->chan fbref (tap mult-close (chan)) event))
                           events)]
      (merge event-chans)))
   ([fbref close-chan event]
@@ -65,7 +66,7 @@
                                (js->clj (.val snapshot))]))]
      (.on fbref (clojure.core/name event) handle-event)
      (go (<! close-chan)
-         (.off fbref (clojure.core/name event)))
+         (.off fbref (clojure.core/name event) handle-event))
      event-chan)))

 (defn- id->fb-chan


use hb cache instead of fetching via zk

use hb cache instead of fetching via zk

--- storm-core/src/clj/backtype/storm/daemon/nimbus.clj
+++ storm-core/src/clj/backtype/storm/daemon/nimbus.clj
@@ -365,7 +365,8 @@
                        nimbus-time
                        (>= (time-delta nimbus-time) timeout))
        :nimbus-time nimbus-time
-       :executor-reported-time reported-time}))
+       :executor-reported-time reported-time
+       :heartbeat hb}))

 (defn update-heartbeat-cache [cache executor-beats all-executors timeout]
   (let [cache (select-keys cache all-executors)]
@@ -1265,7 +1266,7 @@
               launch-time-secs (if base (:launch-time-secs base) (throw (NotAliveException. (str storm-id))))
               task->component (storm-task-info (try-read-storm-topology conf storm-id) topology-conf)
               assignment (.assignment-info storm-cluster-state storm-id nil)
-              beats (.executor-beats storm-cluster-state storm-id (:executor->node+port assignment))
+              beats (map-val :heartbeat (get @(:heartbeats-cache nimbus) storm-id))
               all-components (-> task->component reverse-map keys)
               errors (->> all-components
                           (map (fn [c] [c (get-errors storm-cluster-state storm-id c)]))


Pass prompt in to PLANCK_READ_PASSWORD

Pass prompt in to PLANCK_READ_PASSWORD

And fix formatting of docstring

--- planck-cljs/src/planck/core.cljs
+++ planck-cljs/src/planck/core.cljs
@@ -139,10 +139,10 @@

 (defn read-password
   "Reads the next line from console with echoing disabled.
-   It will print out a prompt if supplied"
+  It will print out a prompt if supplied"
   ([] (read-password ""))
   ([prompt]
-   (js/PLANCK_READ_PASSWORD)))
+   (js/PLANCK_READ_PASSWORD prompt)))

 (defonce
   ^:dynamic


Made the port 8000 to match the other servers

--- competition/cljwsdemo/src/cljwsdemo/core.clj
+++ competition/cljwsdemo/src/cljwsdemo/core.clj
@@ -7,4 +7,4 @@
 (defn -main
   "Starts the websocket server"
   [& args]
-  (start-http-server ws-handler {:port 8080 :websocket true}))
+  (start-http-server ws-handler {:port 8000 :websocket true}))


Correct docstring

Correct docstring

--- src/clojure/clojurewerkz/cassaforte/client.clj
+++ src/clojure/clojurewerkz/cassaforte/client.clj
@@ -89,7 +89,7 @@
     (.build builder)))

 (defn ^Session connect
-  "Connects to the Cassandra cluster. Use `build` function to build cluster with all required options."
+  "Connects to the Cassandra cluster. Use `build-cluster` to build a cluster."
   ([hosts]
      (flush-prepared-statement-cache!)
      (.connect (build-cluster {:hosts hosts})))


Fix misplaced docstring

Fix misplaced docstring

--- src/refactor_nrepl/core.clj
+++ src/refactor_nrepl/core.clj
@@ -80,10 +80,11 @@
                             pred
                             (complement build-artifact?)))))

-(defn data-file? [path-or-file]
+(defn data-file?
   "True of f is named like a clj file but represents data.

-E.g. true for data_readers.clj"
+  E.g. true for data_readers.clj"
+  [path-or-file]
   (let [path (.getPath (io/file path-or-file))
         data-files #{"data_readers.clj" "project.clj" "boot.clj"}]
     (reduce (fn [acc data-file] (or acc (.endsWith path data-file)))


default cassandra-version is now 3

default cassandra-version is now 3

--- src/er_cassandra/schema.clj
+++ src/er_cassandra/schema.clj
@@ -9,7 +9,7 @@

 ;; HACK ALERT
 (def cassandra-version (or (some-> (env :cassandra-version) Integer/parseInt)
-                           2))
+                           3))

 (defn ^:private table-metadata-query
   [keyspace table]


cleaned upp app-state

cleaned upp app-state

--- src/frontend/app-state.cljs
+++ src/frontend/app-state.cljs
@@ -11,14 +11,11 @@
                           :track-order []
                           :track-id-hashes {}
                           :music-info []
-                          :is-file-downloading? false
                           :current-track-id nil
                           :current-sound-id nil
                           :ball-being-dragged? false
                           :looping? false
                           :upload-slots default-upload-slots
-                          :num-of-uploads 0
-                          :num-of-downloads 0
                           :file-hashes {}
                           :uploads {}
                           :active-uploads []


Fixed dynamic var warning in Clojure 1.3 for *default-encoding*.

--- src/hiccup/page_helpers.clj
+++ src/hiccup/page_helpers.clj
@@ -117,7 +117,8 @@
 (def
  #^{:doc "Name of the default encoding to use .
   Default is UTF-8."
-    :tag "java.lang.String"}
+    :tag "java.lang.String"
+    :dynamic true}
  *default-encoding* "UTF-8")

 (defmacro with-encoding


Add p-min function, expand new-indiv to accomidate p-min function.

p-min changes the lower value of p according to the value of thickness using a qudratic fit equation.
This prevents undefined regions and snarls in the shape of the foil

--- src/hydrofoil/evolution.clj
+++ src/hydrofoil/evolution.clj
@@ -14,21 +14,45 @@
     lower-bound
     exploratory-limit))

+(defn p-min
+  [t]
+  (cond
+    (and (> t 0) (< t 20)) (+ 0.21934298928655427 (* 0.006602765526534473 (Math/pow t 2)))
+    ( = t 0) 0.0100
+    :else 2.79 ))
+
 (defn new-indv
   [parent]
   (let [exploration-factor 30 ;;; Doesn't do anything yet. hopefully will change m, p, and t, exp-factors.
         ;;; how far you can go from the parent value
         m-exp-factor 10
-        p-exp-factor 10
+        p-exp-factor 1
         t-exp-factor 10
         ;;; the numerical values of the upper limits
         m-upper-bound (upper-bound-check (+ m-exp-factor (parent :max-camber)) 100)
-        p-upper-bound (upper-bound-check (+ p-exp-factor (parent :positon-camber)) 100)
+        p-upper-bound (upper-bound-check (+ p-exp-factor (parent :positon-camber)) 10)
         t-upper-bound (upper-bound-check (+ t-exp-factor (parent :thickness)) 100)
         ;;; the numerical value of the lower limits
         m-lower-bound (lower-bound-check (- (parent :max-camber) m-exp-factor) 0)
-        p-lower-bound (lower-bound-check (- (parent :positon-camber) p-exp-factor) 0)
-        t-lower-bound (lower-bound-check (- (parent :thickness) t-exp-factor) 0)]
+        ;p-lower-bound (lower-bound-check (- (parent :positon-camber) p-exp-factor) 0)
+        t-lower-bound (lower-bound-check (- (parent :thickness) t-exp-factor) 0)
+
+        t-value (rand-double t-lower-bound t-upper-bound)
+        p-lower-bound (lower-bound-check (- (parent :positon-camber) p-exp-factor) (p-min t-value))]
+
     (NACA-design (rand-double m-lower-bound m-upper-bound)
                  (rand-double p-lower-bound p-upper-bound)
-                 (rand-double t-lower-bound t-upper-bound))))
+                 t-value)))
+
+
+(defn rand-individual
+  []
+  (let [t-value (rand-double 0 100)]
+    (NACA-design (rand-double 0 100)
+                 (rand-double (p-min t-value) 10)
+                 t-value)))
+
+
+
+
+


use keyword mapping for wbid for now

use keyword mapping for wbid for now

--- src/wb_es/mappings/core.clj
+++ src/wb_es/mappings/core.clj
@@ -10,7 +10,7 @@
 (def default-mapping
   {:properties
    {:wbid {:type "string"
-           :analyzer "keyword_ignore_case"
+           :analyzer "keyword"
            :include_in_all false}

     :label {:type "string"


Development versions should be snapshots, take 2

--- metrics-clojure-ring/project.clj
+++ metrics-clojure-ring/project.clj
@@ -1,4 +1,4 @@
-(defproject metrics-clojure-ring "0.9.2"
+(defproject metrics-clojure-ring "0.10.0-SNAPSHOT"
   :description "Various things gluing together metrics-clojure and ring."
   :dependencies [[cheshire "2.2.2"]
                  [metrics-clojure "0.9.2"]])


Clojure Collector: bump commons-codec to 1.11 (closes #3782)

--- 2-collectors/clojure-collector/java-servlet/project.clj
+++ 2-collectors/clojure-collector/java-servlet/project.clj
@@ -27,7 +27,7 @@
                      [compojure "1.6.1"]
                      [metrics-clojure "2.10.0"]
                      [metrics-clojure-ring "2.10.0"]
-                     [commons-codec/commons-codec "1.7"]]
+                     [commons-codec/commons-codec "1.11"]]
   ;; The jetty adapter is only used during development
   :profiles         {:dev {:dependencies [[ring/ring-jetty-adapter "1.6.3"]]}}
   :war-resources-path   "war-resources"


Fixed warning in factor analysis

Fixed warning in factor analysis

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

--- src/conexp/contrib/factor_analysis.clj
+++ src/conexp/contrib/factor_analysis.clj
@@ -106,7 +106,7 @@
                        V 0]
                   (let [j-s     (difference M D),
                         max-j   (apply max-key (partial oplus-count context U D) j-s),
-                        max-val (oplus-count context U D max-j)]
+                        max-val (int (oplus-count context U D max-j))]
                     (if (< V max-val)
                       (recur (context-attribute-closure context (conj D max-j))
                              max-val)
@@ -165,18 +165,19 @@
            F #{}]
       (if (empty? U)
         F
-        (let [D (loop [D (make-fuzzy-set {}),
-                       V 0,
+        (let [D (loop [D           (make-fuzzy-set {}),
+                       V           0,
                        [j a value] (find-maximal U D)]
-                  (when (zero? value)
-                    (illegal-state "Could not find next attribute (0 value). "
-                                   "Make sure that no floating point inaccuracies occured."))
-                  (if (> value V)
-                    (recur (fuzzy-object-derivation context
-                                                    (fuzzy-attribute-derivation context (assoc D j a)))
-                           value
-                           (find-maximal U D))
-                    D)),
+                  (let [value (int value)]
+                    (when (zero? value)
+                      (illegal-state "Could not find next attribute (0 value). "
+                                     "Make sure that no floating point inaccuracies occured."))
+                    (if (> value V)
+                      (recur (fuzzy-object-derivation context
+                                                      (fuzzy-attribute-derivation context (assoc D j a)))
+                             value
+                             (find-maximal U D))
+                      D))),
               C (fuzzy-attribute-derivation context D),
               F (conj F [C,D]),
               U (set-of [i j] [[i j] U,


Make the correct example horizontal

Make the correct example horizontal

--- src/docs/om_mantras/docs/sortable.cljs
+++ src/docs/om_mantras/docs/sortable.cljs
@@ -324,7 +324,6 @@
   (fn [state _]
     (style-container4
       (sortable {:items (:items @state)
-                 :direction :horizontal
                  :element-fn #(dom/span nil %)
                  :change-fn #(swap! state assoc :items %)})))
   {:items ["First" "Second" "Third" "Fourth" "Fifth"]}
@@ -373,6 +372,7 @@
   (fn [state _]
     (style-container5
       (sortable {:items (:items @state)
+                 :direction :horizontal
                  :element-fn #(dom/span nil %)
                  :change-fn #(swap! state assoc :items %)})))
   {:items ["First" "Second" "Third" "Fourth" "Fifth"]}


Defaulting the consumer-window-size to 1 [IMMUTANT-86]

--- support/build-support/src/main/clojure/immutant/build/tools.clj
+++ support/build-support/src/main/clojure/immutant/build/tools.clj
@@ -159,6 +159,11 @@

 (defn disable-hq-security [loc]
   (zip/append-child loc {:tag :security-enabled :content ["false"]}))
+
+(defn disable-flow-control
+  "Assumes loc is :jms-connection-factories and its first child is the in-vm one"
+  [loc]
+  (zip/append-child (zip/down loc) {:tag :consumer-window-size :content ["1"]}))

 (defn looking-at? [tag loc]
   (= tag (:tag (zip/node loc))))
@@ -188,6 +193,7 @@
              (looking-at? :max-size-bytes loc) (zip/edit loc assoc :content ["20971520"])
              (looking-at? :address-full-policy loc) (zip/edit loc assoc :content ["PAGE"])
              (looking-at? :hornetq-server loc) (disable-hq-security loc)
+             (looking-at? :jms-connection-factories loc) (disable-flow-control loc)
              :else loc)))))

 (defn transform-config [file]


CMR-4502: Fix REPL loading issue

CMR-4502: Fix REPL loading issue

--- search-relevancy-test/src/search_relevancy_test/boost_test.clj
+++ search-relevancy-test/src/search_relevancy_test/boost_test.clj
@@ -83,7 +83,7 @@
           max-value (or (when max-value (Double/parseDouble max-value))
                         max-boost-value)
           ;; Hardcoded to run the provider test suite
-          filename relevancy-test/provider-anomaly-filename]
+          filename core/provider-anomaly-filename]
       (boost-tests filename boost-field min-value max-value))
     (println "No field specified for boosts tests. Must specify a field to
              test boosts with the '-field' argument")))


Fix tests (add missing require)

Fix tests (add missing require)

--- test/clj/cljdoc/reaper.clj
+++ test/clj/cljdoc/reaper.clj
@@ -1,5 +1,6 @@
 (ns cljdoc.reaper
   (:require [clojure.java.io :as io]
+            [clojure.pprint :as pprint]
             [clojure.string :as str]))

 (defn reap! []
@@ -27,7 +28,7 @@
                                                             'metosin/reitit-frontend
                                                             'metosin/reitit-middleware]
               :cljdoc.doc/tree docs}]
-    (spit "doc/cljdoc.edn" (with-out-str (clojure.pprint/pprint data)))))
+    (spit "doc/cljdoc.edn" (with-out-str (pprint/pprint data)))))

 (comment
   (reap!))


Fix source type test

Fix source type test

--- test/cljam/io/wig_test.clj
+++ test/cljam/io/wig_test.clj
@@ -8,6 +8,29 @@
   (:import [java.io BufferedReader InputStreamReader ByteArrayInputStream
             ByteArrayOutputStream OutputStreamWriter BufferedWriter]
            [cljam.io.wig WIGReader WIGWriter]))
+
+(def ^:private test-wig-fields1
+  [{:format :variable-step :chrom "chr19" :start 49304701 :end 49304850 :value 10.0}
+   {:format :variable-step :chrom "chr19" :start 49304901 :end 49305050 :value 12.5}
+   {:format :variable-step :chrom "chr19" :start 49305401 :end 49305550 :value 15.0}
+   {:format :variable-step :chrom "chr19" :start 49305601 :end 49305750 :value 17.5}
+   {:format :variable-step :chrom "chr19" :start 49305901 :end 49306050 :value 20.0}
+   {:format :variable-step :chrom "chr19" :start 49306081 :end 49306230 :value 17.5}
+   {:format :variable-step :chrom "chr19" :start 49306301 :end 49306450 :value 15.0}
+   {:format :variable-step :chrom "chr19" :start 49306691 :end 49306840 :value 12.5}
+   {:format :variable-step :chrom "chr19" :start 49307871 :end 49308020 :value 10.0}
+   {:format :fixed-step :chrom "chr19" :start 49307401 :end 49307600 :value 1000}
+   {:format :fixed-step :chrom "chr19" :start 49307701 :end 49307900 :value 900}
+   {:format :fixed-step :chrom "chr19" :start 49308001 :end 49308200 :value 800}
+   {:format :fixed-step :chrom "chr19" :start 49308301 :end 49308500 :value 700}
+   {:format :fixed-step :chrom "chr19" :start 49308601 :end 49308800 :value 600}
+   {:format :fixed-step :chrom "chr19" :start 49308901 :end 49309100 :value 500}
+   {:format :fixed-step :chrom "chr19" :start 49309201 :end 49309400 :value 400}
+   {:format :fixed-step :chrom "chr19" :start 49309501 :end 49309700 :value 300}
+   {:format :fixed-step :chrom "chr19" :start 49309801 :end 49310000 :value 200}
+   {:format :fixed-step :chrom "chr19" :start 49310101 :end 49310300 :value 100}])
+
+(def ^:private ^String temp-wig-file (str temp-dir "/test.wig"))

 (defn- str->wig
   [^String s]
@@ -78,25 +101,7 @@
   (testing "read wig file"
     (with-open [r (wig/reader test-wig-file1)]
       (is (= (wig/read-fields r)
-             [{:format :variable-step :chrom "chr19" :start 49304701 :end 49304850 :value 10.0}
-              {:format :variable-step :chrom "chr19" :start 49304901 :end 49305050 :value 12.5}
-              {:format :variable-step :chrom "chr19" :start 49305401 :end 49305550 :value 15.0}
-              {:format :variable-step :chrom "chr19" :start 49305601 :end 49305750 :value 17.5}
-              {:format :variable-step :chrom "chr19" :start 49305901 :end 49306050 :value 20.0}
-              {:format :variable-step :chrom "chr19" :start 49306081 :end 49306230 :value 17.5}
-              {:format :variable-step :chrom "chr19" :start 49306301 :end 49306450 :value 15.0}
-              {:format :variable-step :chrom "chr19" :start 49306691 :end 49306840 :value 12.5}
-              {:format :variable-step :chrom "chr19" :start 49307871 :end 49308020 :value 10.0}
-              {:format :fixed-step :chrom "chr19" :start 49307401 :end 49307600 :value 1000}
-              {:format :fixed-step :chrom "chr19" :start 49307701 :end 49307900 :value 900}
-              {:format :fixed-step :chrom "chr19" :start 49308001 :end 49308200 :value 800}
-              {:format :fixed-step :chrom "chr19" :start 49308301 :end 49308500 :value 700}
-              {:format :fixed-step :chrom "chr19" :start 49308601 :end 49308800 :value 600}
-              {:format :fixed-step :chrom "chr19" :start 49308901 :end 49309100 :value 500}
-              {:format :fixed-step :chrom "chr19" :start 49309201 :end 49309400 :value 400}
-              {:format :fixed-step :chrom "chr19" :start 49309501 :end 49309700 :value 300}
-              {:format :fixed-step :chrom "chr19" :start 49309801 :end 49310000 :value 200}
-              {:format :fixed-step :chrom "chr19" :start 49310101 :end 49310300 :value 100}])))
+             test-wig-fields1)))
     (with-open [r (wig/reader test-wig-file2)]
       (is (= (wig/read-fields r)
              [{:format :variable-step :chrom "chr19" :start 49304701 :end 49304701 :value 10.0}
@@ -140,12 +145,20 @@
       (is (= s (-> s str->wig wig->str))))))

 (deftest source-type-test
-  (let [temp-file (str temp-dir "test.wig")]
+  (testing "reader"
+    (with-open [server (http-server)]
+      (are [x] (with-open [rdr (wig/reader x)]
+                 (= (wig/read-fields rdr) test-wig-fields1))
+        test-wig-file1
+        (cio/file test-wig-file1)
+        (cio/as-url (cio/file test-wig-file1))
+        (cio/as-url (str (:uri server) "/wig/test1.wig")))))
+
+  (testing "writer"
     (are [x] (with-before-after {:before (prepare-cache!)
                                  :after (clean-cache!)}
-               (with-open [rdr (wig/reader test-wig-file1)
-                           wtr (wig/writer temp-file)]
-                 (not-throw? (wig/write-fields wtr (wig/read-fields rdr)))))
-         temp-file
-         (cio/file temp-file)
-         (cio/as-url (cio/file temp-file)))))
+               (with-open [wtr (wig/writer x)]
+                 (not-throw? (wig/write-fields wtr test-wig-fields1))))
+      temp-wig-file
+      (cio/file temp-wig-file)
+      (cio/as-url (cio/file temp-wig-file)))))


minor project.clj fix and cleanup

minor project.clj fix and cleanup

--- src/leiningen/new/reagent_liveedit/project.clj
+++ src/leiningen/new/reagent_liveedit/project.clj
@@ -41,7 +41,7 @@
             [lein-pdo "0.1.1"]
             [com.cemerick/clojurescript.test "0.3.3"]
             [lein-figwheel "0.2.2-SNAPSHOT" :exclusions [org.clojure/clojure org.clojure/core.async]]
-            [cider/cider-nrepl "0.9.0"]]
+            [cider/cider-nrepl "0.9.0-SNAPSHOT"]]

   :ring {:handler {{ns-name}}.server.handler/app}

@@ -59,13 +59,13 @@
    {"resources/public/css/site.min.css" "resources/public/css/site.css"
     "resources/public/css/dev.min.css" "resources/public/css/dev.css"}}

-  :aliases {"fig" ["exec" "-pe" "(use '{{ns-name}}.server.services) (start-figwheel)"]
-            "server" ["ring" "server"]
-            "css" ["garden" "auto"]
+  :aliases {"fig"      ["exec" "-pe" "(use '{{ns-name}}.server.services) (start-figwheel)"]
+            "server"   ["ring" "server"]
+            "css"      ["garden" "auto"]
             "autotest" ["cljsbuild" "auto" "test"]
-            "test" ["cljsbuild" "test"]
-            "web" ["with-profile" "production" "trampoline" "ring" "server"]
-            "dev" ["pdo" "css," "fig," "server"]}
+            "test"     ["cljsbuild" "test"]
+            "web"      ["with-profile" "production" "trampoline" "ring" "server"]
+            "dev"      ["pdo" "css," "fig," "server"]}

   :garden {:builds [{:id "site"
                      :source-paths ["src/styles"]


Don't error when revoking caps

Don't error when revoking caps

--- test/icecap/e2e/common.clj
+++ test/icecap/e2e/common.clj
@@ -34,5 +34,5 @@
 (defn revoke-cap
   "Revokes the capability with the given URL."
   [cap-url]
-  (spy (http/delete cap-url)))
   (info "Revoking cap" cap-url)
+  (http/delete cap-url {:throw-exceptions false}))


Fix a bug in the get-or-create node test.

--- test/shale/test/client.clj
+++ test/shale/test/client.clj
@@ -82,7 +82,7 @@
     (testing "that sessions are created on the specified node"
       (let [node-id (-> (shale.client/nodes)
                         first
-                        :id)]
+                        (get "id"))]

         (dotimes [_ 3]
           (shale.client/get-or-create-session!


Switch to APIs.guru API v2

Switch to APIs.guru API v2

--- test/ardoq/swagger_test.clj
+++ test/ardoq/swagger_test.clj
@@ -83,7 +83,7 @@
              (count (:references swag)))))))

 (deftest import-swaggers
-  (doall (take 5 (for [[name swag] (:body (http/get "https://apis-guru.github.io/api-models/api/v1/list.json" {:as :json}))]
+  (doall (take 5 (for [[name swag] (:body (http/get "https://api.apis.guru/v2/list.json" {:as :json}))]
                    (let  [spec (->> swag
                                     (:versions)
                                     ((keyword (:preferred swag)))