[examples/scrabble] Update momentum, add prediction, decoder.

--- examples/scrabble/src/scrabble/core.clj
+++ examples/scrabble/src/scrabble/core.clj
@@ -29,38 +29,49 @@
       (mapv #(new Double (str %)))))

 (defn char->bit-array [character]
-  "Takes a character and bit vector with a 1.0 in the nth position where
-  n is the offset from the character 'a'."
+  "Takes a character, returns and bit vector with a 1.0 in the nth position
+  where n is the offset from the character 'a'."
   (let [offset (- (int character) (int \a))
         begin (take offset (repeatedly #(new Double 0.0)))
         end (take (- 26 offset 1) (repeatedly #(new Double 0.0)))]
   (into [] (concat begin [1.0] end))))

-;; training
+;; decoder
+
+(defn bit-array->num [input]
+  "Inverse of encoder, takes a bit array and converts it into an int"
+  (-> (map int input)
+       clojure.string/join
+       (Integer/parseInt 2)))
+
+;; training, evaluation and prediction

 (defn train [network training-data training-labels]
-  (let [n-epochs 2000            ;; Number of iterations to train
+  (let [n-epochs 30            ;; Number of iterations to train
         learning-rate 0.3
-        momentum 0.9
+        momentum 0.1
         batch-size 1
         loss-fn (opt/quadratic-loss)
         optimizer (net/sgd-optimizer network loss-fn learning-rate momentum)]
-    (println "Training network...")
     (net/train-network optimizer n-epochs batch-size training-data training-labels)))

 (defn evaluate [network test-data test-labels]
-  (let [_ (println "Evaluating network...")
-        [results score] (net/evaluate network test-data test-labels)
+  (let [[results score] (net/evaluate network test-data test-labels)
         label-count (count test-data)
         score-percent (float (/ score label-count))]
     (println (format "Score: %f [%d of %d]" score-percent score label-count))))

+(defn predict [network character]
+  (-> (net/predict network [(char->bit-array character)])
+      first
+      bit-array->num))
+
 (defn run-experiment []
   (let [;; convert the values from the scrabble pieces (letters) into floating-point bit-arrays
-        training-data   (mapv #(into [] [(char->bit-array %)]) (keys scrabble-values))
+        training-data (for [k (keys scrabble-values)] [(char->bit-array k)])

         ;; convert the "labels" of the scrabble pieces (scores) into floating-point bit-arrays
-        training-labels (mapv #(into [] [(num->bit-array %)]) (vals scrabble-values))
+        training-labels (for [v (vals scrabble-values)] [(num->bit-array v)])

         ;; infer the width of the input and output based on the shape of the training data
         ;; - input layer has one input corresponding to each possible letter
@@ -82,5 +93,7 @@
     ;; Once the network has been trained, use the same input data to test to see
     ;; how the neural network has learned the target function. We use the same
     ;; data for testing as training for this degenerate case.
-    (evaluate network training-data training-labels)))
+    (evaluate network training-data training-labels)

+    ;; Use the network to perform a prediction
+    (println (format "Piece 'k' is worth %d points." (predict network \k)))))


added ability to disable validation

added ability to disable validation

--- src/selmer/validator.clj
+++ src/selmer/validator.clj
@@ -4,6 +4,12 @@
        selmer.util
        [clojure.set :only [difference]]
        [clojure.java.io :only [reader]]))
+
+(def validate? (atom true))
+
+(defn validate-on! [] (reset! validate? true))
+
+(defn validate-off! [] (reset! validate? false))

 (defn validate-filters [template line tag-value]
   (let [tag-filters (map
@@ -55,13 +61,14 @@
        tags))))

 (defn validate [template]
-  (let [orphan-tags (validate-tags template)]
-    (when-not (empty? orphan-tags)
-      (->> (validate-tags template)
-           (map (fn [{:keys [tag-name line]}] (str "\n" tag-name " on line " line)))
-           doall
-           (apply str "The template contains orphan tags: ")
-           exception))))
+  (when @validate?
+    (let [orphan-tags (validate-tags template)]
+      (when-not (empty? orphan-tags)
+        (->> (validate-tags template)
+             (map (fn [{:keys [tag-name line]}] (str "\n" tag-name " on line " line)))
+             doall
+             (apply str "The template contains orphan tags: ")
+             exception)))))

 (validate (.getAbsolutePath (java.io.File. "test/templates/validation-test.html")))


Fix shapes loading as single entity

Fix shapes loading as single entity

Shapes should load an entity and then load shape-points as components.

--- env/dev/clj/gtfve/datomic.clj
+++ env/dev/clj/gtfve/datomic.clj
@@ -186,16 +186,22 @@
    "shape_pt_lon" :shape.point/longitude})

 (def shapes-val-transforms
-  {:shape/id (fn [x] nil)
-   :shape.point/sequence read-string
+  {:shape.point/sequence read-string
    :shape/distance-traveled (comp double read-string)
    :shape.point/latitude (comp double read-string)
    :shape.point/longitude (comp double read-string)})

 (defn load-shapes! [path conn]
-  (csv->map shapes-header-keys
-          shapes-val-transforms
-          path))
+  (->> (csv->maps shapes-header-keys shapes-val-transforms path)
+       (group-by :shape/id)
+       (reduce (fn [acc [id attrs]]
+                 (let [new-attrs (mapv #(dissoc % :shape/id) attrs)]
+                   (->> new-attrs
+                        (assoc {:shape/id id} :shape/points)
+                        (assoc-temp-id)
+                        (conj acc))))
+               [])
+       (d/transact conn)))

 ;; Frequencies ;;
 ;;;;;;;;;;;;;;;;;


Add implementation of step* for s/spec

Add implementation of step* for s/spec

--- src/spectrace/trace.cljc
+++ src/spectrace/trace.cljc
@@ -33,6 +33,10 @@
   (if ret
     (succ ret fail)
     (fail)))
+
+(defmethod step* `s/spec [state succ fail]
+  (with-cont succ fail
+    (update state :spec second)))

 (defn- choose-spec [specs state succ fail]
   (letfn [(rec [specs]


CMR-3673: Addressed the PR comment.

CMR-3673: Addressed the PR comment.

--- umm-spec-lib/src/cmr/umm_spec/xml_to_umm_mappings/echo10.clj
+++ umm-spec-lib/src/cmr/umm_spec/xml_to_umm_mappings/echo10.clj
@@ -134,15 +134,11 @@
       (update access-constraints-record :Description #(u/with-default % sanitize?)))))

 (defn- parse-doi
-  "There could be multiple DOIs under Collection.
-   Each DOI contains ONE DOI. The doi-list below will contain something like:
-   [nil {:DOI \"doi1\" :Authority \"auth1\"} {:DOI \"doi2\" :Authority \"auth2\"}]
-   We will pick the first DOI for now."
+  "There could be multiple DOIs under Collection, just take the first one for now."
   [doc]
-  (let [doi-list (for [doi (select doc "Collection/DOI")]
-                   {:DOI (value-of doi "DOI")
-                    :Authority (value-of doi "Authority")})]
-    (first (filter :DOI doi-list))))
+  (let [doi (first (select doc "Collection/DOI"))]
+    {:DOI (value-of doi "DOI")
+     :Authority (value-of doi "Authority")}))

 (defn- parse-echo10-xml
   "Returns UMM-C collection structure from ECHO10 collection XML document."


check socket is open before transmit

check socket is open before transmit

--- src/adzerk/boot_reload/websocket.cljs
+++ src/adzerk/boot_reload/websocket.cljs
@@ -35,7 +35,8 @@
        (.open this url protocol)))

   (transmit [this message]
-    (.send this message))
+    (when (open? this)
+      (.send this message)))

   (close [this]
     (.close this ()))


group tests by file and show filename in tests tab

--- frontend/components/build_head.cljs
+++ frontend/components/build_head.cljs
@@ -264,13 +264,15 @@
                      (string/join ", " (map test-model/pretty-source sources))
                      " with " (pluralize (count failed-tests) "failure") ".")]
                (when (seq failed-tests)
-                 (for [[source tests] (group-by :source failed-tests)]
+                 (for [[source tests-by-source] (group-by :source failed-tests)]
                    [:div.build-tests-list-container
                     [:span.failure-source (str (test-model/pretty-source source) " failures:")]
                     [:ol.build-tests-list
-                     (map (fn [test]
-                            [:li (test-model/format-test-name test)])
-                          (sort-by test-model/format-test-name tests))]]))]))])))))
+                     (for [[file tests-by-file] (group-by :file tests-by-source)]
+                       (list (when file [:div.filename (str file ":")])
+                             (map (fn [test]
+                                    [:li (test-model/format-test-name test)])
+                                  (sort-by test-model/format-test-name tests-by-file))))]]))]))])))))

 (defn circle-yml-ad []
   [:div


fix nested p tags

fix nested p tags

--- frontend/components/build_head.cljs
+++ frontend/components/build_head.cljs
@@ -171,12 +171,9 @@

 (defn artifacts-ad []
   [:div
-   [:p "We didn't find any build artifacts for this build. You can upload build artifacts by moving files to the $CIRCLE_ARTIFACTS directory."
-    [:p "Use artifacts for screenshots, coverage reports, deployment tarballs, and more."]
-    [:p
-     "More information "
-     [:a {:href (routes/v1-doc-subpage {:subpage "build-artifacts"})}
-      "in our docs"] "."]]])
+   [:p "We didn't find any build artifacts for this build. You can upload build artifacts by moving files to the $CIRCLE_ARTIFACTS directory."]
+   [:p "Use artifacts for screenshots, coverage reports, deployment tarballs, and more."]
+   [:p "More information " [:a {:href (routes/v1-doc-subpage {:subpage "build-artifacts"})} "in our docs"] "."]])

 (defn build-artifacts-list [data owner {:keys [show-node-indices?] :as opts}]
   (reify


fix spelling

fix spelling

--- src/clj/org/openforis/ceo/handler.clj
+++ src/clj/org/openforis/ceo/handler.clj
@@ -191,12 +191,12 @@
         (handler (assoc request :params (merge params get-params post-params))))
       (handler request))))

-(def updateable-session-keys [:tokenKey])
+(def updatable-session-keys [:tokenKey])

 (defn wrap-persistent-session [handler]
   (fn [request]
     (let [{:keys [params session]} request
-          to-update    (select-keys params updateable-session-keys)
+          to-update    (select-keys params updatable-session-keys)
           session      (apply dissoc session (keys to-update))
           intersection (set/intersection (set (keys params)) (set (keys session)))
           response     (handler (update request :params merge session))]
@@ -205,7 +205,7 @@
       (if (and (contains? response :session)
                (nil? (:session response)))
         response
-        (update response :session #(merge session % to-update))))))
+        (update response :session #(merge session to-update %))))))

 (defn wrap-exceptions [handler]
   (fn [request]


correct sort order in subsequent-items

correct sort order in subsequent-items

--- src/clj_money/models/transactions.clj
+++ src/clj_money/models/transactions.clj
@@ -287,7 +287,7 @@
             {:account-id (:account-id reference-item)
              :index [:>= (:index reference-item)]
              :transaction-date [:between (:transaction-date reference-item) (t/today)]} ; TODO: let the system look up the latest date
-            {:sort [[:index :desc]]})
+            {:sort [[:index :asc]]})
           (remove #(= (:id reference-item) (:id %)))
           (map after-item-read)))))


Add shre and reset buttons.

Add shre and reset buttons.

--- src/cljs/editor/quil_site/editor.cljs
+++ src/cljs/editor/quil_site/editor.cljs
@@ -32,11 +32,33 @@
     (c/run code))
   (.tab (j/$ "#result-tab") "show"))

+(defn show-share-dialog [resp]
+  (let [path (str "/sketches/show/" (:id resp))
+        url (str (.-protocol js/location) "//" (.-host js/location) path)]
+    (println "Share url:" url)
+    (when-let [history (.-history js/window)]
+      (.replaceState history
+                     #js {} "" path))))
+
+(defn share []
+  (j/ajax
+   {:url "/sketches/create"
+    :method "POST"
+    :data (.stringify js/JSON #js {:cljs (.getValue @editor)})
+    :contentType "application/json"
+    :success (fn [resp]
+              (let [resp (js->clj resp :keywordize-keys true)]
+                (show-share-dialog resp)))}))
+
 (defn resize-iframe [message]
   (let [{:keys [width height]} message
         iframe (j/$ "iframe")]
     (j/attr iframe "width" width)
     (j/attr iframe "height" height)))
+
+(defn reset-iframe []
+  (let [iframe (j/$ "iframe")]
+    (j/attr iframe "src" (j/attr iframe "src"))))

 (defn init []
   (.registerHelper
@@ -71,6 +93,8 @@
     :success #(.setValue @editor (.-cljs %))})

   (j/on (j/$ "#send") "click" compile)
+  (j/on (j/$ "#reset") "click" reset-iframe)
+  (j/on (j/$ "#share") "click" share)
   (j/on (j/$ js/window) "message"
         (fn [event]
           (let [message (js->clj (.-data (.-originalEvent event))


repetitions done for import_new

repetitions done for import_new

--- src/tango/import_new.clj
+++ src/tango/import_new.clj
@@ -205,10 +205,16 @@
 (defn- time-attr-to-date [loc base-date]
   (start-time-to-date (get-time-attr loc) base-date))

+(defn- make-event-number [loc]
+  (if (event-number-attr-empty? loc)
+    -1
+    (event-number-attr-as-number loc)))
+
 (defn- round-list->map [rounds-loc id-generator-fn base-time]
   (for [round rounds-loc]
     (let [round-id (id-generator-fn)
-          start-date-time (time-attr-to-date round base-time)]
+          start-date-time (time-attr-to-date round base-time)
+          event-number (make-event-number round)]
       {:dp/temp-class-id (class-number-attr-as-number round)

        :round/id round-id
@@ -217,7 +223,7 @@
                               ;; Post processed
                               ""
                               ;; Events that represent comments do not have an EventNumber and do now get -1
-                              (if (event-number-attr-empty? round) -1 (event-number-attr-as-number round))
+                              event-number
                               (zx/attr round :Comment)
                               (id-generator-fn)
                               (increased-seq-attr round)
@@ -227,7 +233,7 @@
                               )
                         :dp/temp-class-id (class-number-attr-as-number round))

-       :round/number (if (event-number-attr-empty? round) -1 (event-number-attr-as-number round))
+       :round/number event-number

        ;; Post process, need to get this from the previous round
        :round/starting []


Add `create-table` `:block?` option TODO

--- src/taoensso/faraday.clj
+++ src/taoensso/faraday.clj
@@ -331,10 +331,12 @@
     :hash-keydef  - (required) {:name _ :type <#{:s :n :ss :ns :b :bs}>}.
     :range-keydef - (optional) {:name _ :type <#{:s :n :ss :ns :b :bs}>}.
     :indexes      - (optional) [{:name _ :range-keydef _
-                                 :projection #{:all :keys-only [<attr> ...]}}]"
+                                 :projection #{:all :keys-only [<attr> ...]}}]
+    :block?       - (optional) block until table is actually available?"
   [creds {table-name :name
-          :keys [throughput hash-keydef range-keydef indexes]
+          :keys [throughput hash-keydef range-keydef indexes block?]
           :or   {throughput {:read 1 :write 1}}}]
+  ;; TODO Implement block? feature
   (as-map
    (.createTable (db-client creds)
      (doto (CreateTableRequest.)


Housekeeping

Housekeeping

--- src/taoensso/faraday.clj
+++ src/taoensso/faraday.clj
@@ -62,9 +62,6 @@

 ;;;; Coercion - values

-;; TODO see http://goo.gl/hOzhR and http://goo.gl/NSY3Z for types supported by
-;; the Java SDK! (incl. Date, Long, BigDecimal, BigInteger, ...).
-
 ;; TODO Nippy support (will require special marker bin-wrapping), incl.
 ;; Serialized (boxed) type (should allow empty strings & ANY type of set)
 ;; Maybe require special wrapper types for writing bins/serialized
@@ -258,6 +255,8 @@
                         :write         (.getWriteCapacityUnits   throughput)
                         :last-decrease (.getLastDecreaseDateTime throughput)
                         :last-increase (.getLastIncreaseDateTime throughput)}))
+
+;;;; TODO Code walk-through below

 ;;;; API - tables

@@ -323,28 +322,15 @@
            (.setTableName name))))
        (catch ResourceNotFoundException _)))

-(defn ensure-table
-  "Creates the table if it does not already exist."
+(defn ensure-table "Creates the table if it does not already exist."
   [creds {name :name :as properties}]
-  (if-not (describe-table creds name)
-    (create-table creds properties)))
-
-(defn delete-table
-  "Delete a table in DynamoDB with the given name."
-  [creds name]
-  (.deleteTable
-   (db-client creds)
-   (DeleteTableRequest. name)))
-
-(defn list-tables
-  "Return a list of tables in DynamoDB."
-  [creds]
-  (-> (db-client creds)
-      .listTables
-      .getTableNames
-      seq))
-
-;;;; TODO Code walk-through below
+  (if-not (describe-table creds name) (create-table creds properties)))
+
+(defn delete-table "Deletes a table in DynamoDB with the given name."
+  [creds name] (.deleteTable (db-client creds) (DeleteTableRequest. name)))
+
+(defn list-tables "Returns a list of tables in DynamoDB."
+  [creds] (-> (db-client creds) (.listTables) (.getTableNames) seq))

 ;;;; API - items


Fixes Conj test, factors out maybe generator.

--- test/onyx/generative/flow_conditions_gen_test.clj
+++ test/onyx/generative/flow_conditions_gen_test.clj
@@ -87,6 +87,11 @@
                            :flow/to (gen/return nil))]
        (gen/fmap #(merge v %) g)))))

+(defn maybe-predicate [g]
+  (gen/frequency
+   [[1 (true-flow-condition-gen g)]
+    [1 (false-flow-condition-gen g)]]))
+
 (deftest nil-flow-conditions
   "No flow condition routes to all downstream tasks"
   (let [downstream [:a :b]
@@ -105,17 +110,19 @@
   (checking
    "It joins the :flow/to tasks together and limits selection"
    (times 50)
-   [flow-conditions (gen/vector (->> :a
-                         (flow-condition-gen)
-                         (flow-to-tasks-gen)
-                         (true-flow-condition-gen)))
+   [flow-conditions
+    (gen/not-empty
+     (gen/vector (->> :a
+                      (flow-condition-gen)
+                      (flow-to-tasks-gen)
+                      (true-flow-condition-gen))))
     other-downstream-tasks (gen/vector gen/keyword)]
    (let [compiled (c/compile-fc-norms flow-conditions :a)
          target-tasks (mapcat :flow/to flow-conditions)
          downstream (into other-downstream-tasks target-tasks)
          event {:onyx.core/compiled-norm-fcs compiled}
          results (t/route-data event nil nil flow-conditions downstream)]
-     (is (= (into #{} target-tasks) (:flow results)))
+     (is (= (into #{} target-tasks) (into #{} (:flow results))))
      (is (nil? (:action results))))))

 (deftest no-false-predicate-picks
@@ -166,9 +173,7 @@
     (gen/vector (->> :a
                      (flow-condition-gen)
                      (flow-to-tasks-gen)
-                     ((fn [g] (gen/frequency
-                              [[1 (true-flow-condition-gen g)]
-                               [1 (false-flow-condition-gen g)]])))))]
+                     (maybe-predicate)))]
    (let [flow-conditions (into (into (into false-1 true-1) false-1) mixed-1)
          downstream (mapcat :flow/to flow-conditions)
          compiled (c/compile-fc-norms flow-conditions :a)
@@ -176,3 +181,49 @@
          results (t/route-data event nil nil flow-conditions downstream)]
      (is (= (into #{} (:flow/to (first true-1))) (into #{} (:flow results))))
      (is (nil? (:action results))))))
+
+(deftest retry-action
+  (checking
+   "Using a retry action with a true predicate flows to nil"
+   (times 20)
+   [retry-false
+    (gen/vector (->> :a
+                     (flow-condition-gen)
+                     (false-flow-condition-gen)
+                     (retry-flow-condition-gen)))
+    retry-true
+    (gen/not-empty
+     (gen/vector (->> :a
+                      (flow-condition-gen)
+                      (true-flow-condition-gen)
+                      (retry-flow-condition-gen))))
+    retry-mixed
+    (gen/vector (->> :a
+                     (flow-condition-gen)
+                     (retry-flow-condition-gen)
+                     (maybe-predicate)))
+    ss
+    (gen/vector (->> :a
+                     (flow-condition-gen)
+                     (flow-to-tasks-gen)
+                     (short-circuit-flow-condition-gen)
+                     (maybe-predicate)))
+    exceptions
+    (gen/vector (->> :a
+                     (flow-condition-gen)
+                     (flow-to-tasks-gen)
+                     (exception-flow-condition-gen)
+                     (maybe-predicate)))
+    mixed
+    (gen/vector (->> :a
+                     (flow-condition-gen)
+                     (flow-to-tasks-gen)
+                     (maybe-predicate)))]
+   (let [all [retry-false retry-true retry-mixed ss exceptions mixed]
+         flow-conditions (apply concat all)
+         downstream (mapcat :flow/to flow-conditions)
+         compiled (c/compile-fc-norms flow-conditions :a)
+         event {:onyx.core/compiled-norm-fcs compiled}
+         results (t/route-data event nil nil flow-conditions downstream)]
+     (is (not (seq (:flow results))))
+     (is (= :retry (:action results))))))


Exclusions are generated by default, don't check this as test.

--- test/onyx/generative/flow_conditions_gen_test.clj
+++ test/onyx/generative/flow_conditions_gen_test.clj
@@ -125,7 +125,6 @@
          event {:onyx.core/compiled-norm-fcs compiled}
          results (t/route-data event nil nil flow-conditions downstream)]
      (is (= (into #{} target-tasks) (into #{} (:flow results))))
-     (is (not (seq (:exclusions results))))
      (is (nil? (:action results))))))

 (deftest no-false-predicate-picks
@@ -148,7 +147,6 @@
          event {:onyx.core/compiled-norm-fcs compiled}
          results (t/route-data event nil nil flow-conditions downstream)]
      (is (= (into #{} (mapcat :flow/to true-fcs)) (into #{} (:flow results))))
-     (is (not (seq (:exclusions results))))
      (is (nil? (:action results))))))

 (deftest short-circuit
@@ -184,7 +182,6 @@
          event {:onyx.core/compiled-norm-fcs compiled}
          results (t/route-data event nil nil flow-conditions downstream)]
      (is (= (into #{} (:flow/to (first true-1))) (into #{} (:flow results))))
-     (is (not (seq (:exclusions results))))
      (is (nil? (:action results))))))

 (deftest retry-action
@@ -231,7 +228,6 @@
          event {:onyx.core/compiled-norm-fcs compiled}
          results (t/route-data event nil nil flow-conditions downstream)]
      (is (not (seq (:flow results))))
-     (is (not (seq (:exclusions results))))
      (is (= :retry (:action results))))))

 (deftest key-exclusion
@@ -254,7 +250,6 @@
          results (t/route-data event nil nil mixed downstream)
          matches (filter :pred/val mixed)
          excluded-keys (mapcat :flow/exclude-keys matches)]
-     (prn excluded-keys)
      (is (into #{} excluded-keys) (:exclusions results))
      (is (nil? (:action results))))))

@@ -289,7 +284,6 @@
          event {:onyx.core/compiled-norm-fcs compiled}
          results (t/route-data event nil nil fcs downstream)]
      (is (= (into #{} downstream) (into #{} (:flow/to results))))
-     (is (not (seq (:exclusions results))))
      (is (nil? (:action results))))))

 (deftest matching-none
@@ -323,5 +317,4 @@
          event {:onyx.core/compiled-norm-fcs compiled}
          results (t/route-data event nil nil fcs downstream)]
      (is (not (seq (:flow/to results))))
-     (is (not (seq (:exclusions results))))
-     (is (nil? (:action results))))))
+     (is (nil? (:action results))))))


print lines

print lines

--- src/atom_finder/util/writer-util.clj
+++ src/atom_finder/util/writer-util.clj
@@ -7,19 +7,23 @@

 (import '(atom_finder SanitaryASTWriterVisitor))

+(defn print-line-context
+  "Print the line and the lines around it"
+  ([filename line-num] (print-line-context 2 filename line-num))
+  ([n-lines filename line-num & {:keys [top-border] :or {top-border true}}]
+   (with-open [rdr (clojure.java.io/reader filename)]
+     (let [file-seq (line-seq rdr)
+           first-line (max 0 (- line-num n-lines 1))
+           lines-to-print (->> file-seq (drop first-line) (take (+ n-lines 1 n-lines)))]
+       (when top-border (println "===" filename "==="))
+       (doseq-indexed [line lines-to-print idx]
+                      (println (str (+ idx first-line) (if (= (+ idx first-line 1) line-num) " >> " "    ") line)))))))
+
 (defn print-node-context
   "Print the line that contains the node and the lines around it"
   ([node] (print-node-context 2 node))
   ([n-lines node]
-   (with-open [rdr (clojure.java.io/reader (.getContainingFilename node))]
-     (let [line-num  (start-line node)
-           file-seq (line-seq rdr)
-           first-line (max 0 (- line-num n-lines 1))
-           lines-to-print (->> file-seq (drop first-line) (take (+ n-lines 1 n-lines)))]
-       (println "===================================================")
-       (doseq-indexed [line lines-to-print idx]
-         (println (str (+ idx first-line) (if (= (+ idx first-line 1) line-num) " >> " "    ") line)))
-       (println "===================================================")))))
+   (print-line-context n-lines (.getContainingFilename node) (start-line node))))

 ;; mostly for use programmatically, tries to provide an
 ;; accurate representation of the AST


enable multipart parameters

enable multipart parameters

--- src/io/sarnowski/swagger1st/parser.clj
+++ src/io/sarnowski/swagger1st/parser.clj
@@ -6,7 +6,8 @@
             [io.sarnowski.swagger1st.mapper :refer [split-path]]
             [io.sarnowski.swagger1st.util.api :as api]
             [clj-time.format :as f]
-            [ring.middleware.params :refer [params-request]])
+            [ring.middleware.params :refer [params-request]]
+            [ring.middleware.multipart-params :refer [multipart-params-request]])
   (:import (org.joda.time DateTime)
            (java.io PrintWriter)
            (clojure.lang ExceptionInfo)))
@@ -69,8 +70,11 @@

 (defn extract-parameter-form
   "Extract a parameter from the request body form."
-  [{form-params :form-params} definition]
-  (get form-params (get definition "name")))
+  [{:keys [form-params multipart-params]} definition]
+  (let [param-name (get definition "name")]
+    (or
+      (get form-params param-name)
+      (get multipart-params param-name))))

 (defn extract-parameter-body
   "Extract a parameter from the request body."
@@ -317,7 +321,7 @@
 (defn parse
   "Executes all prepared functions for the request."
   [{:keys [parsers]} next-handler request]
-  (let [request (params-request request)]
+  (let [request (-> request params-request multipart-params-request)]
     (try
       (let [parameters (->> (get parsers (-> request :swagger :key))
                             ; execute all parsers of the request


clean task to remove resources/public/js

Cljsbuild clean has been deprecated.
Add lein stanza to clean path resources/public/js

--- src/leiningen/new/chestnut/project.clj
+++ src/leiningen/new/chestnut/project.clj
@@ -7,6 +7,8 @@
   :source-paths ["src/clj"{{{project-source-paths}}}]

   :test-paths [{{{clj-test-src-path}}}]
+
+  :clean-targets ^{:protect false} [:target-path :compile-path "resources/public/js"]

   :dependencies [[org.clojure/clojure "1.7.0"]
                  [org.clojure/clojurescript "1.7.145" :scope "provided"]


stop referencing clojure.spec

stop referencing clojure.spec

--- src/tile_game/board.cljc
+++ src/tile_game/board.cljc
@@ -1,8 +1,7 @@
 (ns tile-game.board
   (:require [tile-game.coordinates :as coords]
             [clojure.set :as set]
-            [clojure.string :as string]
-            [clojure.spec :as s]))
+            [clojure.string :as string]))

 (defn create-board [dim & opt]
   (let [board (vec (concat (range 1 (* dim dim)) '(0)))]


adjust contact latency

adjust contact latency

--- src/clj/ceres_analytics/measures.clj
+++ src/clj/ceres_analytics/measures.clj
@@ -258,7 +258,7 @@
          (pmap
           (fn [{:keys [target ts]}]
             (if-let [target-ts (:ts (mc/find-map-by-id @db "messages" target))]
-              (t/in-seconds (t/interval target-ts ts))
+              (/ (t/in-seconds (t/interval target-ts ts)) 3600)
               nil)))
          (remove nil?))
     :evolution


badge routes

badge routes

--- src/cljs/salava/badge/ui/routes.cljs
+++ src/cljs/salava/badge/ui/routes.cljs
@@ -14,7 +14,7 @@
             [reagent.session :as session]
             [salava.badge.ui.modal :as badgemodal]
             [salava.core.i18n :as i18n :refer [t]]
-            [salava.extra.application.ui.application :as app]))
+            #_[salava.extra.application.ui.application :as app]))

 (defn placeholder [content]
   (fn [site-navi params]
@@ -30,7 +30,7 @@
                                          [["/info/" :badge-id "/pic/embed"] embed-pic/handler]
                                          ["/import" imp/handler]
                                          [["/receive/" :badge-id] rec/handler]
-                                         ["/application" app/handler #_app-handler]]}))
+                                         ["/application" #_app/handler app-handler]]}))

 (defn ^:export navi [context]
   (let [app-handler (first (plugin-fun (session/get :plugins) "application" "handler"))


Minor code cleanup issues.

Minor code cleanup issues.

--- metlog-vault/src-client/metlog_client/metlog.cljs
+++ metlog-vault/src-client/metlog_client/metlog.cljs
@@ -26,21 +26,20 @@
     c))

 (defn ajax-get
-  ([ url callback params ]
+  ([ url params callback ]
    (ajax/GET url {:handler callback
                   :params params
-                  :error-handler (fn [ resp ]
-                                   (.log js/console (str "HTTP error, url: " url " resp: " resp)))}))
+                  :error-handler #(.log js/console (str "HTTP error, url: " url " resp: " %))}))
   ( [ url callback ]
-    (ajax-get url callback {})))
+    (ajax-get url {} callback)))

 (defn fetch-series-names [ cb ]
   (ajax-get "/series-names" cb))

 (defn fetch-series-data [ series-name query-window-secs cb ]
   (ajax-get (str "/data/" series-name)
-            cb
-            {:query-window-secs= query-window-secs}))
+            {:query-window-secs query-window-secs}
+            cb))

 (defn dom-node-width
   ([ node default-width ]


CMR-5106 Addresses PR comments.

CMR-5106 Addresses PR comments.

--- search-app/src/cmr/search/services/acls/granule_acls.clj
+++ search-app/src/cmr/search/services/acls/granule_acls.clj
@@ -159,18 +159,12 @@
   [context query-coll-ids provider-id collection-identifier]
   (let [colls-in-prov-cond (provider->collection-condition query-coll-ids provider-id)]
     (if-let [{:keys [concept-ids entry-titles access-value temporal]} collection-identifier]
-      (let [entry-titles-cond (provider+entry-titles->collection-condition
-                                context query-coll-ids provider-id entry-titles)
-            concept-ids-cond (provider->collection-condition concept-ids provider-id)
+      (let [concept-ids-cond (provider->collection-condition concept-ids provider-id)
             access-value-cond (some-> (access-value->query-condition access-value)
                                       q/->CollectionQueryCondition)
             temporal-cond (some-> temporal temporal->query-condition q/->CollectionQueryCondition)]
-        ;; If there's no entry title condition the other conditions must be scoped by provider
-        ;; In anycase we want to use concept ids instead of entry-titles, because entry-titles can and
-        ;; do frequently change, so to prevent temporary loss of permissions concept ids are used
-        ;; when present.  There really shouldn't be a case where entry-tiles exist and concept-ids do
-        ;; not.
-        (gc/and-conds (remove nil? [(or concept-ids-cond entry-titles-cond)
+
+        (gc/and-conds (remove nil? [(or concept-ids-cond colls-in-prov-cond)
                                     access-value-cond
                                     temporal-cond])))
       ;; No other collection info provided so every collection in provider is possible


sherpa client docs

sherpa client docs

--- sherpa-clojure/src/main/clojure/sherpa/sherpa_client.clj
+++ sherpa-clojure/src/main/clojure/sherpa/sherpa_client.clj
@@ -18,11 +18,21 @@
            [sherpa.client QueryManager]
            [sherpa.protocol Query QueryRequest DataRequest]))

+;; The SparqlClient protocol
 (defprotocol SparqlClient
-  (query [client sparql params props])
-  (close [client]))
+  "Abstract access to a SPARQL processor."
+  (query [client sparql params props]
+    "Execute a query on a SPARQL processor and return a sequence of results for the query.
+      sparql - query string
+      params - map of param names and values
+      props - map of query properties like: timeout")
+  (close [client] "Close the client."))

-(defn sherpa-client [connect-map]
+(defn sherpa-client
+  "Create a client that implements the SparqlClient protocol and talks using the Sherpa protocol to
+   a Sherpa server.  The connect-map should contain properties to specify which Sherpa server to
+   connect to, such as :host and :port."
+  [connect-map]
   (let [addr (InetSocketAddress. (InetAddress/getByName (:host connect-map)) (:port connect-map))
         _ (println "client connecting to " addr)
         transceiver (SaslSocketTransceiver. addr)


Properly access ::s/problems key in coercion-spec

--- modules/reitit-spec/src/reitit/coercion/spec.cljc
+++ modules/reitit-spec/src/reitit/coercion/spec.cljc
@@ -110,7 +110,7 @@
       (into-spec model name))
     (-open-model [_ spec] spec)
     (-encode-error [_ error]
-      (let [problems (::s/problems error)]
+      (let [problems (-> error :problems ::s/problems)]
         (-> error
             (update :spec (comp str s/form))
             (assoc :problems (mapv #(update % :pred stringify-pred) problems)))))


Elements should have empty-seq as :contents, not nil, so that there's no distinction between 'always empty' and 'happens to be empty'

--- modules/xml/src/main/clojure/clojure/data/xml.clj
+++ modules/xml/src/main/clojure/clojure/data/xml.clj
@@ -213,7 +213,7 @@

   clojure.lang.Keyword
   (as-elements [k]
-    [(Element. k {} nil)])
+    [(Element. k {} ())])

   java.lang.String
   (as-elements [s]


Include default setting for console threshold

--- src/leiningen/new/cljskel/project.clj
+++ src/leiningen/new/cljskel/project.clj
@@ -39,6 +39,7 @@
         :graphite-host ""
         :graphite-port 2003
         :graphite-post-interval-seconds 60
+        :logging-consolethreshold "info"
         :logging-filethreshold "info"
         :logging-level "info"
         :logging-path "/tmp"


add comments to implication-class-related methods in conexp.fca.graph

--- src/main/clojure/conexp/fca/graph.clj
+++ src/main/clojure/conexp/fca/graph.clj
@@ -112,11 +112,19 @@
     g (implication-classes g)))

 (defn implication-class
+  "Returns the implication class in `g` containing `edge`.
+
+  `g` must be an undirected graph, `edge` an edge not in `g`, but
+  connecting two vertices of `g`.
+  Then, this method returns the implication class containing `edge`.
+
+  Implication classes are classes of edges for which the directions in a transitive
+  orientation depend on each other, see also `implication-classes`.
+  They are described in Golumbic 1976,
+  \"The Complexity of Comparability Graph Recognition and Coloring\"."
   ([g edge]
-   ;(println edge)
    (implication-class g #{} #{} #{edge} #{edge}))
   ([g closed-src closed-dest open-src open-dest]
-   ;(println closed-src closed-dest open-src open-dest)
    (if (and (empty? open-src) (empty? open-dest))
      (union closed-src closed-dest)
      (if (not (empty? open-src))
@@ -125,21 +133,17 @@
                                     open-src))
              new-srcs (difference new-edges closed-src open-src)
              new-dests (difference new-edges closed-dest open-dest)]
-         ;(println new-edges)
-         ;(println (map lg/src new-srcs))
-         ;(println (map lg/dest new-dests))
          (recur g (union closed-src open-src) closed-dest new-srcs (union open-dest new-dests)))
        (let [new-edges (set (mapcat (fn [e] (filter (fn [d] (not (lg/has-edge? g (lg/src e) (lg/src d))))
                                                     (uber/find-edges g {:dest (lg/dest e)})))
                                     open-dest))
              new-srcs (difference new-edges closed-src open-src)
              new-dests (difference new-edges closed-dest open-dest)]
-         ;(println new-edges)
-         ;(println (map lg/src new-srcs))
-         ;(println (map lg/dest new-dests))
          (recur g closed-src (union closed-dest open-dest) (union open-src new-srcs) new-dests))))))

 (defn- decompose
+  "Recursively decomposes graphs as described in Golumbic 1976,
+  \"The Complexity of Comparability Graph Recognition and Coloring\"."
   ([g decomp]
    (decompose g decomp #(first (lg/edges %))))
   ([g decomp edge-selection]
@@ -153,6 +157,8 @@
        (recur g-next (conj decomp [B B-overline]) edge-selection)))))

 (defn- graph-decomposition
+  "Decomposes graphs as described in Golumbic 1976,
+  \"The Complexity of Comparability Graph Recognition and Coloring\"."
   ([g]
    (decompose g []))
   ([g scheme]
@@ -164,6 +170,16 @@
                                (lg/edges gr)))))))

 (defn transitive-orientation
+  "Generates a transitive orientation for an undirected graph.
+
+  `g` must be an undirected graph, the method returns a directed transitive
+  copy of `g`.
+
+  Optionally, a decomposition scheme may be given. This is a vector of edges
+  describing the order in which to take the edges.
+
+  See Golumbic 1976,
+  \"The Complexity of Comparability Graph Recognition and Coloring\"."
   ([g scheme]
    (uber/add-directed-edges*
      (uber/digraph)


GAWB-2189: adding a cancel-editing

GAWB-2189: adding a cancel-editing

--- src/cljs/main/broadfcui/page/workspace/method_configs/method_config_editor.cljs
+++ src/cljs/main/broadfcui/page/workspace/method_configs/method_config_editor.cljs
@@ -45,9 +45,9 @@
      (this :load-agora-method))
    :load-agora-method
    (fn [{:keys [props state]} & [method-ref]]
-     (let [{:keys [namespace name snapshotId]} (or method-ref props)]
+     (let [{:keys [methodNamespace methodName methodVersion]} (or method-ref props)]
        (endpoints/call-ajax-orch
-        {:endpoint (endpoints/get-agora-method namespace name snapshotId)
+        {:endpoint (endpoints/get-agora-method methodNamespace methodName methodVersion)
          :headers utils/content-type=json
          :on-done (fn [{:keys [success? get-parsed-response status-text]}]
                     (if success?
@@ -126,7 +126,7 @@
          (clear-both)]]))
    :-render-sidebar
    (fn [{:keys [props state this]}]
-     (let [{:keys [editing? loaded-config]} @state
+     (let [{:keys [editing? loaded-config inputs-outputs]} @state
            config (:methodConfiguration loaded-config)]
        [:div {:style {:width 290 :float "left"}}
         [:div {:ref "sidebar"}]
@@ -145,7 +145,11 @@
                [comps/SidebarButton {:style :light :color :button-primary
                                      :text "Edit Configuration" :icon :edit
                                      :disabled? (when locked? "The workspace is locked")
-                                     :onClick #(swap! state assoc :editing? true :prev-snapshot-id snapshot-id)}]
+                                     :onClick (fn []
+                                                (swap! state assoc :editing? true :original-config loaded-config
+                                                                                :original-inputs-outputs inputs-outputs)
+                                                (utils/log "LOADED CONFIG AT SAVING:  " loaded-config)
+                                                (utils/log "INPUTS OUTPUTS AT SAVING:  " inputs-outputs))}]
                [comps/SidebarButton {:style :light :color :exception-state :margin :top
                                      :text "Delete" :icon :delete
                                      :disabled? (when locked? "The workspace is locked")
@@ -169,7 +173,7 @@
                [comps/SidebarButton {:color :exception-state :margin :top
                                      :text "Cancel Editing" :icon :cancel
                                      :onClick (fn []
-                                                (this :load-new-method-template (:prev-snapshot-id @state))
+                                                (this :cancel-editing)
                                                 (swap! state assoc :editing? false))}]))]))]))
    :-render-main
    (fn [{:keys [state this]}]
@@ -186,9 +190,9 @@
         (create-section-header "Referenced Method")
         (create-section [MethodDetailsViewer
                          (merge {:ref "methodDetailsViewer"
-                                 :name (:methodName methodRepoMethod)
-                                 :namespace (:methodNamespace methodRepoMethod)
-                                 :snapshotId (:methodVersion methodRepoMethod)
+                                 :methodName (:methodName methodRepoMethod)
+                                 :methodNamespace (:methodNamespace methodRepoMethod)
+                                 :methodVersion (:methodVersion methodRepoMethod)
                                  :onSnapshotIdChange #(this :load-new-method-template %)}
                                 (utils/restructure config methods editing? wdl-parse-error))])
         (create-section-header "Root Entity Type")
@@ -298,9 +302,8 @@
                        :methodName method-name
                        :methodVersion new-snapshot-id}]
        (swap! state assoc :blocker "Updating...")
-       ((@refs "methodDetailsViewer") :load-agora-method {:namespace method-namespace
-                                                          :name method-name
-                                                          :snapshotId new-snapshot-id})
+       ((@refs "methodDetailsViewer") :load-agora-method method-ref)
+
        (endpoints/call-ajax-orch
         {:endpoint (endpoints/create-template method-ref)
          :payload method-ref
@@ -309,23 +312,28 @@
                     (let [response (get-parsed-response)]
                       (if success?
                         (endpoints/call-ajax-orch
-                         {:endpoint (endpoints/get-validated-workspace-method-config (:workspace-id props) (:config-id props))
-                          :on-done (fn [{:keys [success? get-parsed-response status-text]}]
-                                     (let [valid-response (get-parsed-response)]
+                         {:endpoint endpoints/get-inputs-outputs
+                          :payload (:methodRepoMethod response)
+                          :headers utils/content-type=json
+                          :on-done (fn [{:keys [success? get-parsed-response]}]
+                                     (swap! state dissoc :blocker :wdl-parse-error)
+                                     (let [template {:methodConfiguration (merge response config-namespace+name)}]
                                        (if success?
-                                         (endpoints/call-ajax-orch
-                                          {:endpoint endpoints/get-inputs-outputs
-                                           :payload (:methodRepoMethod response)
-                                           :headers utils/content-type=json
-                                           :on-done (fn [{:keys [success? get-parsed-response]}]
-                                                      (swap! state dissoc :blocker :wdl-parse-error)
-                                                      (let [template {:methodConfiguration (merge valid-response config-namespace+name)}]
-                                                        (if success?
-                                                          (swap! state assoc
-                                                                 :loaded-config valid-response
-                                                                 :inputs-outputs (get-parsed-response)))
-                                                        (swap! state assoc :error (:message (get-parsed-response)))))})
-                                         (swap! state assoc :error status-text))))})
+                                         (swap! state assoc
+                                                :loaded-config (assoc template
+                                                                 :invalidInputs {}
+                                                                 :validInputs {}
+                                                                 :invalidOutputs {}
+                                                                 :validOutputs {})
+                                                :inputs-outputs (get-parsed-response))
+                                         (swap! state assoc :error (:message (get-parsed-response))))))})
                         (do
                           (swap! state assoc :blocker nil :wdl-parse-error (:message response))
-                          (comps/push-error (style/create-server-error-message (:message response)))))))})))})+                          (comps/push-error (style/create-server-error-message (:message response)))))))})))
+   :cancel-editing
+   (fn [{:keys [state props refs]}]
+     (let [original-loaded-config (:original-config @state)
+           original-inputs-outputs (:original-inputs-outputs @state)
+           method-ref (-> original-loaded-config :methodConfiguration :methodRepoMethod)]
+       (swap! state assoc :loaded-config original-loaded-config :inputs-outputs original-inputs-outputs)
+       ((@refs "methodDetailsViewer") :load-agora-method method-ref)))})


userId -> email

userId -> email

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/summary/acl_editor.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/summary/acl_editor.cljs
@@ -27,7 +27,7 @@

 (defn- build-acl-vec [acl-map]
   (mapv
-    (fn [[k v]] {:userId k :accessLevel (access-level-to-index v)})
+    (fn [[k v]] {:email k :accessLevel (access-level-to-index v)})
     acl-map))

 (defn- render-acl-content [props state this]
@@ -53,7 +53,7 @@
                        :backgroundColor (when (< i (:count-orig @state)) (:background-gray style/colors))}
                :disabled (< i (:count-orig @state))
                :spellCheck false
-               :defaultValue (:userId acl-entry)})
+               :defaultValue (:email acl-entry)})
             (style/create-select
               {:ref (str "acl-value" i)
                :style {:float "right" :width column-width :height 33}
@@ -64,7 +64,7 @@
        [comps/Button {:text "Add new" :style :add
                       :onClick #(do
                                  (react/call :capture-ui-state this)
-                                 (swap! state update-in [:acl-vec] conj {:userId "" :accessLevel READER}))}]])
+                                 (swap! state update-in [:acl-vec] conj {:email "" :accessLevel READER}))}]])
     :dismiss-self (:dismiss-self props)
     :ok-button
     [comps/Button {:text "Save"
@@ -92,13 +92,13 @@
        (mapv
          (fn [i]
            (let [[user-id access-level] (common/get-text refs (str "acl-key" i) (str "acl-value" i))]
-             {:userId user-id :accessLevel (js/parseInt access-level)}))
+             {:email user-id :accessLevel (js/parseInt access-level)}))
          (range (count (:acl-vec @state))))))
    :persist-acl
    (fn [{:keys [props state]}]
      (swap! state assoc :saving? true)
      (let [filtered-acl (->> (:acl-vec @state)
-                          (filter #(not (empty? (:userId %))))
+                          (filter #(not (empty? (:email %))))
                           (map #(update % :accessLevel index-to-access-level)))]
        (endpoints/call-ajax-orch
          {:endpoint (endpoints/update-workspace-acl (:workspace-id props))
@@ -108,7 +108,7 @@
                      (swap! state dissoc :saving?)
                      (if success?
                        (do
-                         ((:update-owners props) (map :userId (filter #(= "OWNER" (:accessLevel %)) filtered-acl)))
+                         ((:update-owners props) (map :email (filter #(= "OWNER" (:accessLevel %)) filtered-acl)))
                          ((:dismiss-self props)))
                        (js/alert "Error saving permissions: " status-text)))})))
    :component-did-mount


[scrabble] address stylistic oddities, give training enough epochs to converge

--- examples/scrabble/src/scrabble/core.clj
+++ examples/scrabble/src/scrabble/core.clj
@@ -25,20 +25,21 @@

 ;; coders

-(defn num->bit-array [input & {:keys [bits]
-                               :or {bits 4}}]
+(defn num->bit-array
   "Takes a number, returns a vector of floats representing the number in
   binary. Optionally specify the number of bits for padding."
- (->> (clojure.pprint/cl-format nil (str "~" bits ",'0',B") input)
-      (mapv #(new Double (str %)))))
+  [input & {:keys [bits] :or {bits 4}}]
+  (->> (clojure.pprint/cl-format nil (str "~" bits ",'0',B") input)
+       (mapv #(new Double (str %)))))

-(defn char->bit-array [character]
+(defn char->bit-array
   "Takes a character, returns and bit vector with a 1.0 in the nth position
   where n is the offset from the character 'a'."
+  [character]
   (let [offset (- (int character) (int \a))
         begin (take offset (repeatedly #(new Double 0.0)))
         end (take (- 26 offset 1) (repeatedly #(new Double 0.0)))]
-  (into [] (concat begin [1.0] end))))
+    (into [] (concat begin [1.0] end))))

 ;; decoder

@@ -48,7 +49,9 @@
        clojure.string/join
        (Integer/parseInt 2)))

+
 (def training-data (into [] (for [k (keys scrabble-values)] (char->bit-array k))))
+
 ;; convert the "labels" of the scrabble pieces (scores) into floating-point bit-arrays
 (def training-labels (into [] (for [v (vals scrabble-values)] (num->bit-array v))))

@@ -59,7 +62,7 @@
 (def input-width (last (m/shape training-data)))
 (def output-width (last (m/shape training-labels)))
 (def hidden-layer-size 4)
-(def n-epochs 1) ;;epoch is a pass through the dataset
+(def n-epochs 100) ;;epoch is a pass through the dataset
 (def learning-rate 0.1)
 (def momentum 0.1)
 (def batch-size 1) ;;For this example a small batch size is ideal
@@ -80,9 +83,6 @@
   )

-(defn test-train-step
-  []
-  (net/train-step (first training-data) (first training-labels) (create-network) loss-fn))

 (defn train
   []
@@ -100,10 +100,12 @@

 (defn evaluate
   [network]
- (classify network \j)
- (classify network \k)
- (net/evaluate network training-data training-labels)
-  )
+  (do
+    (classify network \j)
+    (classify network \k)
+    (classify network \a)
+    (classify network \q)
+    (net/evaluate network training-data training-labels)))

 (defn train-and-evaluate


Fix kibit issue.

Fix kibit issue.

--- src/oc/storage/representations/org.clj
+++ src/oc/storage/representations/org.clj
@@ -42,9 +42,12 @@

 (defn change-link [org access-level user-id]
   (if (or (= access-level :author) (= access-level :viewer))
-    (assoc org :links
-      (conj (:links org)
-        (hateoas/link-map "changes" "GET" (str config/change-server-ws-url "/change-socket/user/" user-id) nil)))
+    (update-in org [:links] conj
+      (hateoas/link-map
+        "changes"
+        "GET"
+        (str config/change-server-ws-url "/change-socket/user/" user-id)
+        nil))
     org))

 (defn- org-links [org access-level]


Clean up metrics tagging.

Clean up metrics tagging.

--- src/onyx/lifecycle/metrics/metrics.clj
+++ src/onyx/lifecycle/metrics/metrics.clj
@@ -10,29 +10,22 @@
             [metrics.meters :as m])
   (:import [java.util.concurrent TimeUnit]))

-(defn new-lifecycle-latency [reg job-name task-name id lifecycle]
-  (let [timer ^com.codahale.metrics.Timer (t/timer reg ["job" job-name "task" task-name "peer-id"
-                                                        (str id) "task-lifecycle"
-                                                        (name lifecycle)])]
+(defn new-lifecycle-latency [reg tag lifecycle]
+  (let [timer ^com.codahale.metrics.Timer (t/timer reg (into tag ["task-lifecycle" (name lifecycle)]))]
     (fn [state latency-ns]
       (.update timer latency-ns TimeUnit/NANOSECONDS))))

-(defn new-read-batch [reg job-name task-name id lifecycle]
-  (let [throughput (m/meter reg ["job" job-name "task" task-name "peer-id"
-                                 (str id) "task-lifecycle" (name lifecycle) "throughput"])
-        timer ^com.codahale.metrics.Timer (t/timer reg ["job" job-name "task" task-name "peer-id"
-                                                        (str id) "task-lifecycle"
-                                                        (name lifecycle)])]
+(defn new-read-batch [reg tag lifecycle]
+  (let [throughput (m/meter reg (into tag ["task-lifecycle" (name lifecycle) "throughput"]))
+        timer ^com.codahale.metrics.Timer (t/timer reg (into tag ["task-lifecycle" (name lifecycle)]))]
     (fn [state latency-ns]
       (m/mark! throughput (count (:onyx.core/batch (task/get-event state))))
       (.update timer latency-ns TimeUnit/NANOSECONDS))))

-(defn new-write-batch [reg job-name task-name id lifecycle]
-  (let [throughput (m/meter reg ["job" job-name "task" task-name "peer-id"
-                                 (str id) "task-lifecycle" (name lifecycle) "throughput"])
+(defn new-write-batch [reg tag lifecycle]
+  (let [throughput (m/meter reg (into tag ["task-lifecycle" (name lifecycle) "throughput"]))
         timer ^com.codahale.metrics.Timer
-        (t/timer reg ["job" job-name "task" task-name "peer-id"
-                      (str id) "task-lifecycle" (name lifecycle)])]
+        (t/timer reg (into tag ["task-lifecycle" (name lifecycle)]))]
     (fn [state latency-ns]
       ;; TODO, for blockable lifecycles, keep adding latencies until advance?
       (.update timer latency-ns TimeUnit/NANOSECONDS)
@@ -66,9 +59,10 @@
         task-name (name (:onyx.core/task event))
         reg (:registry monitoring)
         _ (when-not reg (throw (Exception. "Monitoring component is not setup")))
-        cnt-replica-version (c/counter reg ["job" job-name "task" task-name "peer-id" (str id) "replica-version"])
-        cnt-epoch (c/counter reg ["job" job-name "task" task-name "peer-id" (str id) "epoch"])
-        epoch-rate (m/meter reg ["job" job-name "task" task-name "peer-id" (str id) "epoch-rate"])
+        tag ["job" job-name "task" task-name "peer-id" (str id)]
+        cnt-replica-version (c/counter reg (conj tag "replica-version"))
+        cnt-epoch (c/counter reg (conj tag "epoch"))
+        epoch-rate (m/meter reg  (conj tag "epoch-rate"))
         update-rv-epoch-fn (update-rv-epoch cnt-replica-version cnt-epoch epoch-rate)]
     {:onyx.core/monitoring (reduce
                             (fn [mon lifecycle]
@@ -76,9 +70,9 @@
                                      lifecycle
                                      (case lifecycle
                                        :lifecycle/unblock-subscribers update-rv-epoch-fn
-                                       :lifecycle/read-batch (new-read-batch reg job-name task-name id :lifecycle/read-batch)
-                                       :lifecycle/write-batch (new-write-batch reg job-name task-name id :lifecycle/write-batch)
-                                       (new-lifecycle-latency reg job-name task-name id lifecycle))))
+                                       :lifecycle/read-batch (new-read-batch reg tag :lifecycle/read-batch)
+                                       :lifecycle/write-batch (new-write-batch reg tag :lifecycle/write-batch)
+                                       (new-lifecycle-latency reg tag lifecycle))))
                             monitoring
                             lifecycles)}))


clojure: first go at function to assign unique periodic net vertex signatures

--- clojure/org/gavrog/clojure/pgraph_morphisms.clj
+++ clojure/org/gavrog/clojure/pgraph_morphisms.clj
@@ -65,3 +65,10 @@
                        (if (nil? key)
                          [0 k cl]
                          [(- (count cl)) (conj k key) cl]))))))))
+
+(defn node-signatures [net]
+  (let [pos (barycentric-positions net)
+        nodes (iterator-seq (.nodes net))
+        dia (diameter net)
+        shells (for [v nodes] (take dia (shell-positions net pos v)))]
+    (classify-recursively (zipmap nodes shells))))


Allow registry lookups by keyword or symbol alike

--- src/main/workflo/macros/registry.clj
+++ src/main/workflo/macros/registry.clj
@@ -63,7 +63,8 @@
           (reset! ~registry-sym (sorted-map)))
         (defn ~resolve-sym
           [~'name]
-          (let [~'definition (get (~registered-sym) ~'name)]
+          (let [~'name-sym   (symbol (namespace ~'name) (name ~'name))
+                ~'definition (get (~registered-sym) ~'name-sym)]
             (when (nil? ~'definition)
               (let [~'msg (str "Failed to resolve " ~(str name)
                                " '" ~'name "'")]


Message queue: clean up `handle1`

Message queue: clean up `handle1`

--- src/taoensso/carmine/message_queue.clj
+++ src/taoensso/carmine/message_queue.clj
@@ -218,38 +218,33 @@
 (defn handle1 "Implementation detail!"
   [conn qname handler [mid mcontent attempt :as poll-reply]]
   (when (and poll-reply (not= poll-reply "eoq-backoff"))
-    (let [qk (partial qkey qname)
-          hset-backoff
-          (fn [mid backoff-ms]
-            (when backoff-ms
-              (car/hset (qk :backoffs) mid (+ (System/currentTimeMillis)
-                                              backoff-ms))))
-
-          done  (fn [mid & [backoff-ms]] (wcar conn
-                                           (hset-backoff mid backoff-ms)
-                                           (car/sadd (qk :gc) mid)))
-
-          retry (fn [mid & [backoff-ms]] (wcar conn
-                                           (hset-backoff mid backoff-ms)
-                                           (car/hdel (qk :locks) mid)))
+    (let [qk   (partial qkey qname)
+          done (fn [status mid & [backoff-ms]]
+                 (wcar conn
+                   (when backoff-ms ; Retry or dedupe backoff, depending on type
+                     (car/hset (qk :backoffs) mid (+ (System/currentTimeMillis)
+                                                     backoff-ms)))
+                   (case status
+                     :success (car/sadd (qk :gc)    mid) ; Queue for GC
+                     :retry   (car/hdel (qk :locks) mid) ; Unlock
+                     )))

           error (fn [mid poll-reply & [throwable]]
-                (done mid)
-                (timbre/errorf
-                 (if throwable throwable (Exception. ":error handler response"))
-                 "Error handling %s queue message:\n%s" qname poll-reply))
+                  (done mid)
+                  (timbre/errorf
+                   (if throwable throwable (Exception. ":error handler response"))
+                   "Error handling %s queue message:\n%s" qname poll-reply))

           {:keys [status throwable backoff-ms]}
-          (let [result (try (handler {:message mcontent
-                                      :attempt attempt})
+          (let [result (try (handler {:message mcontent :attempt attempt})
                             (catch Throwable t {:status :error :throwable t}))]
             (when (map? result) result))]

       (case status
-        :success (done  mid backoff-ms)
-        :retry   (retry mid backoff-ms)
+        :success (done status mid backoff-ms)
+        :retry   (done status mid backoff-ms)
         :error   (error mid poll-reply throwable)
-        (do (done mid)
+        (do (done :success mid) ; For backwards-comp with old API
             (timbre/warnf "Invalid handler status: %s" status))))))

 ;;;; Workers


Use unicode right-pointing-triangle for error highlights

--- src/org/knotation/editor/update.cljs
+++ src/org/knotation/editor/update.cljs
@@ -40,7 +40,7 @@
                 in (::st/input elem)
                 ln-num (- (::st/line-number in) 1)]
             ;; (high/highlight-line! ed ln-num "line-error")
-            (.setGutterMarker ed ln-num "errors" (crate/html [:div {:style "color: #822"} ">>"])))
+            (.setGutterMarker ed ln-num "errors" (crate/html [:div {:style "color: #822"} "▶"])))

           nil)))))


using format /cc @drsnyder

using format /cc @drsnyder

--- src/vignette/util/image_response.clj
+++ src/vignette/util/image_response.clj
@@ -35,7 +35,8 @@
         (header "Content-Length" (content-length image))
         (cond->
           (:original image-map) (header "Content-Disposition"
-                                        (str "inline; filename=\""(:original image-map)"\";"
-                                             "filename*=utf=8' '\""(:original image-map)"\";")))))
+                                        (format "inline; filename=\"%s\"; filename*=utf-8' '%s"
+                                                (:original image-map)
+                                                (:original image-map))))))
   ([image]
     (create-image-response image nil)))


preserve punctuation

preserve punctuation

--- src-cljs/jasons-game/ui/pjs/main.cljs
+++ src-cljs/jasons-game/ui/pjs/main.cljs
@@ -39,7 +39,7 @@
                  :error-handler (fn [response] (js/alert response))}))

 (defn word-at-a-time [words]
-  (reverse (map (comp #(clojure.string/join " " %) reverse) (take-while #(< 0 (count %)) (iterate rest (reverse (split words #"\W")))))))
+  (reverse (map (comp #(clojure.string/join " " %) reverse) (take-while #(< 0 (count %)) (iterate rest (reverse (split words #"\s")))))))

 (defn say [thing words]
   (w/add-thing world {:type :word-balloon
@@ -73,7 +73,7 @@

 (defn mouse-released []
   (when-let [thing (w/get-thing-at-location world [(s/mouse-x) (s/mouse-y)])]
-    (say @thing (str "My name is " (:name @thing))))
+    (say @thing (str "Hi Jason! My name is " (:name @thing) ".")))
   (GET "/audio/ogg/base64/sound_test" {:handler (fn [response]
                                                   (dommy/append! (sel1 :body) [:audio {:autoplay true}
                                                                                [:source {:src (str "data:audio/ogg;base64," response), :type "audio/ogg"}]]))


Screen layout is changed a little.

Screen layout is changed a little.

--- src-cljs/polyomino_enclosure/gui.cljs
+++ src-cljs/polyomino_enclosure/gui.cljs
@@ -62,11 +62,11 @@
              [:div.col-md-6
               [:div.form-group
                (html/label :question "問題")
-               (html/text-area {:class "form-control", :rows "10", :on-change (fn [event] (om/update! cursor :question (-> event .-target .-value)))} :question question)]]
+               (html/text-area {:class "form-control", :rows "5", :on-change (fn [event] (om/update! cursor :question (-> event .-target .-value)))} :question question)]]
              [:div.col-md-6
               [:div.form-group
                (html/label :programs "解答")
-               (html/text-area {:class "form-control", :rows "10", :on-change (fn [event] (om/update! cursor :answer   (-> event .-target .-value)))} :answer   answer)]]]
+               (html/text-area {:class "form-control", :rows "5", :on-change (fn [event] (om/update! cursor :answer   (-> event .-target .-value)))} :answer   answer)]]]
             [:div
              [:button.btn.btn-default {:on-click (fn [event] (clear :answer :question))} "クリア"]
              (nbsp)


Refactor test

Refactor test

--- test/buildviz/teamcity/sync_test.clj
+++ test/buildviz/teamcity/sync_test.clj
@@ -9,28 +9,47 @@
   (fn [_] {:status 200
            :body (j/generate-string body)}))

+(defn- a-job [id project-name job-name]
+  {:id id
+   :projectName project-name
+   :name job-name})
+
+(defn- a-project [id & jobs]
+  [["http://teamcity:8000/httpAuth/app/rest/projects/the_project"
+    (successful-json-response {:buildTypes {:buildType jobs}})]])
+
+(defn- a-build [job-id build]
+  [[(format "http://teamcity:8000/httpAuth/app/rest/buildTypes/id:%s/builds/?fields=build(id,number,status,startDate,finishDate,revisions(revision(version,vcs-root-instance)))"
+            job-id)
+    (successful-json-response {:build [(merge {:revisions []}
+                                              build)]})]
+   [(format "http://teamcity:8000/httpAuth/app/rest/testOccurrences?locator=count:100,start:0,build:(id:%s)"
+            (:id build))
+    (successful-json-response {:testOccurrences []})]])
+
+(defn- capture-puts-to-buildviz-in [map-ref]
+  [[#"http://buildviz:8010/builds/(.+)/(.+)"
+    (fn [req]
+      (swap! map-ref #(assoc % (:uri req) (j/parse-string (slurp (:body req)) true)))
+      {:status 200 :body ""})]])
+
+(defn- serve-up [& routes]
+  (->> routes
+       (mapcat identity) ; flatten once
+       (into {})))
+
 (deftest test-main
   (testing "should sync a build"
-    (let [build-puts (atom {})]
-      (fake/with-fake-routes {"http://teamcity:8000/httpAuth/app/rest/projects/the_project"
-                              (successful-json-response {:buildTypes {:buildType [{:id "theId"
-                                                                                :projectName "theProject"
-                                                                                :name "theJob"}]}})
-                              "http://teamcity:8000/httpAuth/app/rest/buildTypes/id:theId/builds/?fields=build(id,number,status,startDate,finishDate,revisions(revision(version,vcs-root-instance)))"
-                              (successful-json-response {:build [{:id 42
-                                                                  :number 2
-                                                                  :status "SUCCESS"
-                                                                  :startDate "20160410T041049+0000"
-                                                                  :finishDate "20160410T041100+0000"
-                                                                  :revisions []}]})
-                              "http://teamcity:8000/httpAuth/app/rest/testOccurrences?locator=count:100,start:0,build:(id:42)"
-                              (successful-json-response {:testOccurrences []})
-                              #"http://buildviz:8010/builds/(.+)/(.+)"
-                              (fn [req]
-                                (swap! build-puts #(assoc % (:uri req) (j/parse-string (slurp (:body req)) true)))
-                                {:status 200 :body ""})}
+    (let [stored (atom {})]
+      (fake/with-fake-routes (serve-up (a-project "the_project" (a-job "theId" "theProject" "theJob"))
+                                       (a-build "theId" {:id 42
+                                                         :number 2
+                                                         :status "SUCCESS"
+                                                         :startDate "20160410T041049+0000"
+                                                         :finishDate "20160410T041100+0000"})
+                                       (capture-puts-to-buildviz-in stored))
         (with-out-str (sut/sync-jobs (url/url "http://teamcity:8000") (url/url "http://buildviz:8010") ["the_project"]))
         (is (= {:start 1460261449000
                 :end 1460261460000
                 :outcome "pass"}
-               (get @build-puts "/builds/theProject%20theJob/2")))))))
+               (get @stored "/builds/theProject%20theJob/2")))))))


remove redundant `when`

remove redundant `when`

--- src/braid/client/ui/views/header.cljs
+++ src/braid/client/ui/views/header.cljs
@@ -35,7 +35,7 @@
         [:a {:class (str class (when (= path @current-path) " active"))
              :href path
              :title title}
-         (when body body)]))))
+         body]))))

 (def left-headers
   [{:title "Inbox"


Adds another todo during lein populate

Adds another todo during lein populate

--- src/clj/todo_clj/models/migration.clj
+++ src/clj/todo_clj/models/migration.clj
@@ -25,4 +25,5 @@
                       (sql/drop-table-ddl :todos)))

 (defn populate []
-  (sql/insert! todo/spec :todos {:title "buy eggs" :position 123}))
+  (sql/insert! todo/spec :todos {:title "buy eggs" :position 1 :completed true})
+  (sql/insert! todo/spec :todos {:title "file tax return" :position 3}))


Save sketch on every run.

Save sketch on every run.

--- src/cljs/editor/quil_site/editor.cljs
+++ src/cljs/editor/quil_site/editor.cljs
@@ -55,6 +55,34 @@
       :no-code (set "alert-warning" "no form found under cursor")
       :clear (set "" ""))))

+(defn save-code [cb]
+  (let [code (.getValue @editor)]
+   (j/ajax
+    {:url "/sketches/create"
+     :method "POST"
+     :data (.stringify js/JSON #js {:cljs code})
+     :contentType "application/json"
+     :success (fn [resp]
+                (let [resp (js->clj resp :keywordize-keys true)]
+                  (cb resp)))})))
+
+(defn show-share-dialog [resp]
+  (let [path (str "/sketches/show/" (:id resp))
+        url (str (.-protocol js/location) "//" (.-host js/location) path)]
+    (j/val (j/$ "#share-dialog input") url)
+    (.modal (j/$ "#share-dialog") "show")))
+
+(defn update-url [resp]
+  (let [path (str "/sketches/show/" (:id resp))]
+    (when (not= path (.-pathname js/location))
+      (.pushState js/history
+                  #js {:source (:cljs resp)} "" path))))
+
+(defn share []
+  (save-code
+   #(do (update-url %)
+        (show-share-dialog %))))
+
 (defn compile
   ([] (compile (.getValue @editor)))
   ([code]
@@ -63,6 +91,7 @@
    (set-status {:type :clear})
    (.clearGutter @editor "CodeMirror-lint-markers")
    (c/run code (fn [res]
+                 (save-code update-url)
                  (cond (:error res) (set-status {:type :errors})
                        (not (empty? (:warnings res))) (set-status {:type :warnings})
                        :default (set-status {:type :ok}))
@@ -105,25 +134,6 @@
                            (set-status {:type :errors})
                            (set-errors [(:error selection)]))
       :default (set-status {:type :no-code}))))
-
-(defn show-share-dialog [resp]
-  (let [path (str "/sketches/show/" (:id resp))
-        url (str (.-protocol js/location) "//" (.-host js/location) path)]
-    (j/val (j/$ "#share-dialog input") url)
-    (when-let [history (.-history js/window)]
-      (.replaceState history
-                     #js {} "" path))
-    (.modal (j/$ "#share-dialog") "show")))
-
-(defn share []
-  (j/ajax
-   {:url "/sketches/create"
-    :method "POST"
-    :data (.stringify js/JSON #js {:cljs (.getValue @editor)})
-    :contentType "application/json"
-    :success (fn [resp]
-              (let [resp (js->clj resp :keywordize-keys true)]
-                (show-share-dialog resp)))}))

 (defn resize-iframe [message]
   (let [{:keys [width height]} message
@@ -208,7 +218,11 @@
                                             (.popover (j/$ "#share") "destroy")))
   (.on js/CodeMirror @editor "touchstart" #(do
                                             (hide-result-pane)
-                                            (.popover (j/$ "#share") "destroy"))))
+                                            (.popover (j/$ "#share") "destroy")))
+  (.addEventListener js/window
+                     "popstate"
+                     (fn [event] (when-let [source (.-source (.-state event))]
+                                   (set-editor-source source )))))

 (j/$ init)


Icon Symbol rendering is slow

Icon Symbol rendering is slow

--- src/cljs/gtfve/utils/google_maps.cljs
+++ src/cljs/gtfve/utils/google_maps.cljs
@@ -74,10 +74,7 @@
 (defn marker
   [[lat lng] & {:as options}]
   (Maps.Marker.
-   (clj->js (merge {:position (latlng lat lng)
-                    :icon {:path Maps.SymbolPath.CIRCLE
-                           :strokeColor "#FF0000"
-                           :scale 3}}
+   (clj->js (merge {:position (latlng lat lng)}
                    options))))

 (defn data-listen


small fix

small fix

--- src/cljs/salava/badge/ui/pending.cljs
+++ src/cljs/salava/badge/ui/pending.cljs
@@ -79,7 +79,7 @@
   (fn []
     [:div.col-md-12
      [:div.dropdown
-       [info "Set your badge visibility" "left"][:a.dropdown-toggle {:data-toggle "dropdown" :type "button" } (case @(cursor state [:visibility])
+       [:a.dropdown-toggle {:data-toggle "dropdown" :type "button" } (case @(cursor state [:visibility])
                                                                        "public" [:i.fa.fa-globe]
                                                                        "private" [:i.fa.fa-lock]
                                                                        "internal" [:i.fa.fa-group]
@@ -87,7 +87,8 @@
                                                                                "public" (t :badge/Public)
                                                                                "private" (t :badge/Private)
                                                                                "internal" (t :badge/Shared)
-                                                                                (t :badge/Public)) [:i.fa.fa-chevron-down] #_[:span.caret]]
+                                                                                (t :badge/Public)) [:i.fa.fa-chevron-down]]
+      [info "Set your badge visibility" "left"]
        [:ul.dropdown-menu
         [:li [:a {:href "#" :on-click #(do
                                          (.preventDefault %)


Remove macro require

Remove macro require

--- src/clojure_template/client/main.cljs
+++ src/clojure_template/client/main.cljs
@@ -1,5 +1,4 @@
 (ns clojure-template.client.main
-  (:require-macros [reagent.ratom :refer [reaction]])
   (:require [clojure-template.client.dev]
             [clojure-template.client.libs]
             [clojure-template.client.routing]))


New tests: test-return-file-existence, test-render-front-page-existence, and test-render-error-page-existence

--- test/emender_jenkins/server_test.clj
+++ test/emender_jenkins/server_test.clj
@@ -28,6 +28,24 @@
 ;

+(deftest test-return-file-existence
+    "Check that the emender-jenkins.server/return-file definition exists."
+    (testing "if the emender-jenkins.server/return-file definition exists."
+        (is (callable? 'emender-jenkins.server/return-file))))
+
+
+(deftest test-render-front-page-existence
+    "Check that the emender-jenkins.server/render-front-page definition exists."
+    (testing "if the emender-jenkins.server/render-front-page definition exists."
+        (is (callable? 'emender-jenkins.server/render-front-page))))
+
+
+(deftest test-render-error-page-existence
+    "Check that the emender-jenkins.server/render-error-page definition exists."
+    (testing "if the emender-jenkins.server/render-error-page definition exists."
+        (is (callable? 'emender-jenkins.server/render-error-page))))
+
+

 ;(get-api-command nil "/api")


Improve tests of repo= & minor test refactor

--- test/grafter/rdf/repository_test.clj
+++ test/grafter/rdf/repository_test.clj
@@ -12,23 +12,33 @@
            org.openrdf.repository.sparql.SPARQLRepository
            java.net.URI))

+(def quad-fixture-file-path "./test/grafter/rdf-types.trig")
+
+(def triple-fixture-file-path "./test/grafter/rdf-types.ttl")
+
 (deftest repo-test
-  (is (repo= (grafter.rdf/statements "./test/grafter/rdf-types.trig")
-             (repo "./test/grafter/rdf-types.trig")
-             (repo "./test/grafter/rdf-types.trig" (MemoryStore.))
-             (repo (file "./test/grafter/rdf-types.trig")))))
+  (is (repo= (grafter.rdf/statements quad-fixture-file-path)
+             (repo quad-fixture-file-path)
+             (repo quad-fixture-file-path)
+             (repo quad-fixture-file-path (MemoryStore.))
+             (repo (file quad-fixture-file-path)))))

 (deftest repo=test
   (testing "repo-like things coerce for equality checks"
-    (is (repo= (repo "./test/grafter/rdf-types.trig")
-               (grafter.rdf/statements "./test/grafter/rdf-types.trig")
-               "./test/grafter/rdf-types.trig"
-               (file "./test/grafter/rdf-types.trig"))))
+    (is (repo= (repo quad-fixture-file-path)
+               (grafter.rdf/statements quad-fixture-file-path)
+               quad-fixture-file-path
+               (file quad-fixture-file-path))))

   (testing "Inequality"
-    (is (not (repo= "./test/grafter/rdf-types.trig"
-                    "./test/grafter/rdf-types.ttl"))
+    (is (not (repo= quad-fixture-file-path
+                    triple-fixture-file-path))
         "Should not be equal because the trig file are quads and the ttl file are triples."))
+
+  (testing "Equivalence between triple file, repo and CONSTRUCT of the same data"
+    (repo= triple-fixture-file-path
+           (query (repo triple-fixture-file-path)
+                  "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o }")))

   (testing "An empty repo is equal to an empty repo"
     (is (repo= (repo (MemoryStore.))
@@ -75,7 +85,7 @@
      db)))

 (deftest query-test
-  (let [test-db (load-rdf-types-data "./test/grafter/rdf-types.ttl")]
+  (let [test-db (load-rdf-types-data triple-fixture-file-path)]
     (are [type f?]
         (is (f? (let [o (-> (query test-db (str "PREFIX : <http://example/> SELECT ?o WHERE {" type " :hasValue ?o . }"))
                             first
@@ -95,11 +105,11 @@
   repo it should be identical to the one read in."

     (testing "roundtripping ttl file"
-      (let [file "./test/grafter/rdf-types.ttl"]
+      (let [file triple-fixture-file-path]
         (is (= (set (statements (load-rdf-types-data file)))
                (set (statements file))))))

     (testing "roundtripping trig file"
-      (let [file "./test/grafter/rdf-types.trig"]
+      (let [file quad-fixture-file-path]
         (is (= (set (statements (load-rdf-types-data file)))
                (set (statements file))))))))


a little cleanup

a little cleanup

--- test/kioo/core_test.cljs
+++ test/kioo/core_test.cljs
@@ -228,10 +228,12 @@
                                              (do-> (content "success")
                                                    (after "after")
                                                    (before "before"))}) ]
-      (is (= "before
success
after" (render-dom comp)))))
+      (is (= "before
success
after"
+             (render-dom comp)))))
   (testing "Testing content, before then after"
     (let [comp (component "simple-div.html" {[:div]
                                              (do-> (content "success")
                                                    (before "before")
                                                    (after "after"))}) ]
-      (is (= "before
success
after" (render-dom comp))))))
+      (is (= "before
success
after"
+             (render-dom comp))))))


Update lein-droid

Update lein-droid

--- template/project.clj
+++ template/project.clj
@@ -3,6 +3,6 @@
   :url "https://github.com/oakes/play-clj"
   :license {:name "Public Domain"
             :url "http://unlicense.org/UNLICENSE"}
-  :dependencies [[lein-droid "0.3.1"]]
+  :dependencies [[lein-droid "0.3.3"]]
   :resource-paths ["resources"]
   :eval-in-leiningen true)


Adds subst2

Adds subst2

--- src/the_little_clojurian/chapter3.clj
+++ src/the_little_clojurian/chapter3.clj
@@ -8,9 +8,8 @@
     (fn [a lat]
       (cond (null? lat) '()
             (eq? (car lat) a) (cdr lat)
-            :else (conss (car lat)
-                        (rember a
-                                (cdr lat))))))
+            :else (conss (car lat) (rember a
+                                           (cdr lat))))))

   (is (= (rember 'and '(bacon lettuce and tomato)) '(bacon lettuce tomato)))
   (is (= (rember 'mint '(lamb chops and mint jelly)) '(lamb chops and jelly)))
@@ -87,3 +86,16 @@
          '()))
   (is (= (subst 'topping 'fudge '(ice cream with fudge for dessert))
          '(ice cream with topping for dessert))))
+
+(with-test
+  (def subst2
+    (fn [new o1 o2 lat]
+      (cond (null? lat) '()
+            (or (eq? (car lat) o1)
+                (eq? (car lat) o2)) (cons new (cdr lat))
+            :else (cons (car lat) (subst2 new o1 o2 (cdr lat))))))
+
+  (is (= (subst2 'vanilla 'chocolate 'banana '())
+         '()))
+  (is (= (subst2 'vanilla 'chocolate 'banana '(banana ice cream with chocolate topping))
+         '(vanilla ice cream with chocolate topping))))


Adds tup?

Adds tup?


extensions to big numbers

extensions to big numbers

--- src/unspun/screens/number_needed.cljs
+++ src/unspun/screens/number_needed.cljs
@@ -57,7 +57,7 @@
                   (draw-square {:size 50}))))
         ))

-(def testn 6)
+(def testn 3)

 (def row0 [0 0 0 0 0])
 (def row1 [0 0 1 0 0])
@@ -68,7 +68,104 @@

 (def row10 "row of 10" (vec (concat row5 [0] row5)))
 (def row15 "row of 15" (vec (concat row5 [0] row5 [0] row5)))
-(def rown [row0 row1 row2 row3 row4 row5])
+(def rown "access row0..row5 by index" [row0 row1 row2 row3 row4 row5])
+
+(defn row-n-m*
+  "Layout for row of length m with n icons showing"
+  [n m k]
+  (->> (range m)
+       (map-indexed #(if (< %1 n) 1 0))
+       (partition k)
+       (interpose 0)
+       (flatten)
+       (into [])))
+
+(defn row-n-m
+  "Layout for row of length m with n icons showing"
+  [n m]
+  (->> (range m)
+       (map-indexed #(if (< %1 n) 1 0))
+       (partition 5)
+       (interpose 0)
+       (flatten)
+       (into [])))
+
+(defn block-n-k
+  [n k]
+  (->>                                                      ;(row-n-m* n 20 20)
+    (range (* k (Math.ceil (/ n k))))
+    (map-indexed #(if (< %1 n) 1 0))
+    (partition-all k)
+    (partition-all 2)
+    (interpose (repeat k 0))
+    (flatten)
+    (partition-all k)
+    (map (partial partition-all 5))
+    (map (partial interpose [0]))
+    (map flatten)
+    (mapv vec)))
+
+(defn block-k-n
+  [n k]
+  (->>                                                      ;(row-n-m* n 20 20)
+    (range (* k (Math.ceil (/ n k))))
+    (map-indexed #(if (< %1 n) 1 0))
+    (partition-all k)
+    (partition-all 5)
+    (interpose (repeat k 0))
+    (flatten)
+    (partition-all k)
+    (map (partial partition-all 2))
+    (map (partial interpose [0]))
+    (map flatten)
+    (mapv vec)))
+
+(defn blocks
+  [n cols w h]
+  (->>                                                      ;(row-n-m* n 20 20)
+    (range (* cols (Math.ceil (/ n cols))))
+    (map-indexed #(if (< %1 n) 1 0))
+    (partition-all cols)
+    (partition-all h)
+    (interpose (repeat cols 0))
+    (flatten)
+    (partition-all cols)
+    (map (partial partition-all w))
+    (map (partial interpose [0]))
+    (map flatten)
+    (mapv vec)))
+
+(comment
+  (blocks 500 20 5 5)
+  )
+
+#_(defn row-n-m
+    "Layout for row of length m with n icons showing"
+    [n m]
+    (let [row []]
+      (for [col (range m)]
+        (loop [row []
+               i 0]
+          (if (< i m)
+            (recur (conj row (if (and (pos? i) (mod i 6)) 1 0)) (inc i))
+            row)))))
+
+(comment
+  (row-n-m 3 5)
+  ; => [1 1 1 0 0]
+  (block-n-k 3 5)
+  ;=> [[1 1 1 0 0]]
+  (block-n-k 13 5)
+  ;=> [[1 1 1 1 1] [1 1 1 1 1] [0 0 0 0 0] [1 1 1 0 0]]
+  (block-n-k 13 10)
+  ;=> [[1 1 1 1 1 0 1 1 1 1 1] [1 1 1 0 0 0 0 0 0 0 0]]
+  (block-n-k 43 15)
+  ;=>
+  #_[[1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1]
+     [1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1]
+     [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
+     [1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 0 0]]
+  )

 (def block10 "two rows of 5" [row5 row5])

@@ -86,10 +183,11 @@
                                 (append-block 10)
                                 (append-block 8)))))

+
 (def dice {1  [[1]]
            2  [[1 0]
                [0 1]]
-           3  [[1 1]
+           3   (blocks 500 20 5 5) #_[[1 1]
                [0 1]]
            4  [[1 1]
                [1 1]]
@@ -139,7 +237,7 @@
                row5
                nil
                row5
-               row2]
+               (row-n-m 2 5)]
            18 [row5
                row5
                nil
@@ -177,14 +275,23 @@
            40 block40
            })

+(defn layout25
+  [n]
+  (let [kk (fn [k] (* 5 (inc k)))]
+    (map-indexed #(cond
+                    (< (kk %1) n) row5
+                    (and (= (kk %1) n) (< (kk %1) (inc n))) (row-n-m (mod %1 5) 5)
+                    :else [0 0 0 0 0]) (range 5))))
+
+
 (defn dicen
   "layout n icons in an easy to count manner (dice-like for small n)"
   [n]
   (cond
-    (< n 23) (get dice n)
-    (< n 24) (append-block block10 n)
-    (< n 30) (append-block block20 n)
-    (< n 40) (append-block block30 n)
+    (< n 11) (get dice n)
+    ;(< n 24) (append-block block10 n)
+    ;(< n 30) (append-block block20 n)
+    ;(< n 40) (append-block block30 n)
     :else (append-block block40 0)
     ))

@@ -247,7 +354,7 @@
                    :borderBottomColor "black"}}
           (for [[i row] (zipmap (range) (dicen n))
                 :let [row (if (nil? row) [0 0 0 0 0] row)
-                      gap? (or (nil? row) (= row [0 0 0 0 0]))]]
+                      gap? (= row [0 0 0 0 0])]]
             (view {:key   (str "r" i)
                    :style {:flexDirection  "row"
                            :justifyContent "space-around"}}


Increase kubernetes timeout from 10 seconds to 120 seconds.

Avoids a lot of log spam.

--- scheduler/src/cook/kubernetes/compute_cluster.clj
+++ scheduler/src/cook/kubernetes/compute_cluster.clj
@@ -216,6 +216,8 @@
   (let [api-client (if (some? config-file)
                      (Config/fromConfig config-file)
                      (ApiClient.))]
+    ; Reset to a more sane timeout from the default 10 seconds.
+    (some-> api-client .getHttpClient (.setReadTimeout 120 TimeUnit/SECONDS))
     (when base-path
       (.setBasePath api-client base-path))
     (when (some? verifying-ssl)


om 0.8.0-beta1

om 0.8.0-beta1

--- Clojure-Websockets/MainApp/project.clj
+++ Clojure-Websockets/MainApp/project.clj
@@ -20,7 +20,7 @@
                  [org.clojure/clojurescript "0.0-2371"]
                  [tailrecursion/cljs-priority-map "1.1.0"]
                  [org.clojure/data.priority-map "0.0.5"]
-                 [om "0.8.0-alpha2"]
+                 [om "0.8.0-beta1"]
                  [com.cognitect/transit-clj  "0.8.259"]
                  [com.cognitect/transit-cljs "0.8.192"]
                  [clj-pid "0.1.1"]


[#2645] Fix compilation

[#2645] Fix compilation

--- backend/src/akvo/lumen/lib/aggregation/commons.clj
+++ backend/src/akvo/lumen/lib/aggregation/commons.clj
@@ -1,6 +1,7 @@
 (ns akvo.lumen.lib.aggregation.commons
   (:require [clojure.java.jdbc :as jdbc]
             [clojure.spec.alpha :as s]
+            [akvo.lumen.specs.db.dataset-version.column :as s.column]
             [clojure.tools.logging :as log]))

 (defn run-query [tenant-conn sql]
@@ -34,7 +35,7 @@
         add-column-name (fn [column-name]
                           (when column-name
                             (swap! column-names conj column-name)))]
-    (binding [akvo.lumen.specs.db.dataset-version.column/*columnName?* add-column-name]
+    (binding [s.column/*columnName?* add-column-name]
       (assert (= "Success!\n" (s/explain-str spec data)) (s/explain-str spec data))
       (deref column-names))))


Move wrap-x-frame-options to outside wrap-exceptions.

--- src/clojars/web.clj
+++ src/clojars/web.clj
@@ -84,8 +84,8 @@
         :workflows [(workflows/interactive-form)
                     registration/workflow]})
       (wrap-anti-forgery)
+      (wrap-exceptions)
       (wrap-x-frame-options)
-      (wrap-exceptions)
       (site)
       (wrap-resource "public")
       (wrap-file-info)))


removed unused file

removed unused file

--- src/copper/core.clj
+++ src/copper/core.clj
@@ -1,6 +0,0 @@
-(ns copper.core)
-
-(defn foo
-  "I don't do a whole lot."
-  [x]
-  (println x "Hello, World!"))


Increase minimum jdk version 1.7.0_25 -> 1.7.0_55

--- src/leiningen/new/cljskel/project.clj
+++ src/leiningen/new/cljskel/project.clj
@@ -81,7 +81,7 @@
         :postinstall {:scriptFile "scripts/rpm/postinstall.sh"}
         :preremove {:scriptFile "scripts/rpm/preremove.sh"}
         :postremove {:scriptFile "scripts/rpm/postremove.sh"}
-        :requires ["jdk >= 2000:1.7.0_25-fcs"]
+        :requires ["jdk >= 2000:1.7.0_55-fcs"]
         :mappings [{:directory "/usr/local/{{lower-name}}"
                     :filemode "444"
                     :username "{{lower-name}}"


use better method to get commity for tests

--- test/clj_money/models/prices_test.clj
+++ test/clj_money/models/prices_test.clj
@@ -31,7 +31,7 @@

 (deftest create-a-price
   (let [context (serialization/realize storage-spec price-context)
-        commodity (-> context :commodities first)
+        commodity (find-commodity context "AAPL")
         price (prices/create storage-spec {:commodity-id (:id commodity)
                                            :trade-date (t/local-date 2017 3 2)
                                            :price 12.34M})
@@ -58,7 +58,7 @@

 (deftest commodity-id-is-required
   (let [context (serialization/realize storage-spec price-context)
-        commodity (-> context :commodities first)
+        commodity (find-commodity context "AAPL")
         price (prices/create storage-spec {:trade-date (t/local-date 2017 3 2)
                                            :price 12.34M})
         prices (prices/search storage-spec {:commodity-id (:id commodity)
@@ -74,7 +74,7 @@

 (deftest trade-date-is-required
   (let [context (serialization/realize storage-spec price-context)
-        commodity (-> context :commodities first)
+        commodity (find-commodity context "AAPL")
         price (prices/create storage-spec {:commodity-id (:id commodity)
                                            :price 12.34M})
         prices (prices/search storage-spec {:commodity-id (:id commodity)
@@ -90,7 +90,7 @@

 (deftest trade-date-must-be-a-date
   (let [context (serialization/realize storage-spec price-context)
-        commodity (-> context :commodities first)
+        commodity (find-commodity context "AAPL")
         price (prices/create storage-spec {:commodity-id (:id commodity)
                                            :trade-date "notadate"
                                            :price 12.34M})
@@ -107,7 +107,7 @@

 (deftest trade-date-must-be-unique
   (let [context (serialization/realize storage-spec price-context)
-        commodity (-> context :commodities first)
+        commodity (find-commodity context "AAPL")
         price-1 (prices/create storage-spec {:commodity-id (:id commodity)
                                            :trade-date (t/local-date 2017 3 2)
                                            :price 12.34M})
@@ -131,7 +131,7 @@

 (deftest trade-date-can-be-a-string-date
   (let [context (serialization/realize storage-spec price-context)
-        commodity (-> context :commodities first)
+        commodity (find-commodity context "AAPL")
         price (prices/create storage-spec {:commodity-id (:id commodity)
                                            :trade-date "2017-03-02"
                                            :price 12.34M})
@@ -148,7 +148,7 @@

 (deftest price-is-required
   (let [context (serialization/realize storage-spec price-context)
-        commodity (-> context :commodities first)
+        commodity (find-commodity context "AAPL")
         price (prices/create storage-spec {:commodity-id (:id commodity)
                                            :trade-date (t/local-date 2017 3 2)})
         prices (prices/search storage-spec {:commodity-id (:id commodity)
@@ -164,7 +164,7 @@

 (deftest price-must-be-a-number
   (let [context (serialization/realize storage-spec price-context)
-        commodity (-> context :commodities first)
+        commodity (find-commodity context "AAPL")
         price (prices/create storage-spec {:commodity-id (:id commodity)
                                            :trade-date (t/local-date 2017 3 2)
                                            :price "notanumber"})
@@ -181,7 +181,7 @@

 (deftest price-can-be-a-string-number
   (let [context (serialization/realize storage-spec price-context)
-        commodity (-> context :commodities first)
+        commodity (find-commodity context "AAPL")
         price (prices/create storage-spec {:commodity-id (:id commodity)
                                            :trade-date (t/local-date 2017 3 2)
                                            :price "12.34"})


change jvm-warmup to lein-starting

change jvm-warmup to lein-starting

--- src-cljs/cljsbuild_ui/pages/main.cljs
+++ src-cljs/cljsbuild_ui/pages/main.cljs
@@ -268,9 +268,9 @@
   ;; TODO: update builds here
   )

-(defn- show-jvm-warmup! [prj-key bld-id]
+(defn- show-lein-startup! [prj-key bld-id]
   (let [bld-idx (bld-id->idx prj-key bld-id)]
-    (swap! state assoc-in [:projects prj-key :builds bld-idx :state] :jvm-warmup)))
+    (swap! state assoc-in [:projects prj-key :builds bld-idx :state] :lein-startup)))

 ;;------------------------------------------------------------------------------
 ;; Compiler Interface
@@ -320,7 +320,7 @@
   (swap! state assoc-in [:projects prj-key :state] :auto)

   ;; update the BuildRows state
-  (doall (map #(show-jvm-warmup! prj-key %) bld-ids))
+  (doall (map #(show-lein-startup! prj-key %) bld-ids))

   (remove-compiled-info! prj-key)

@@ -333,7 +333,7 @@
   (swap! state assoc-in [:projects prj-key :state] :once)

   ;; update the BuildRows state
-  (doall (map #(show-jvm-warmup! prj-key %) bld-ids))
+  (doall (map #(show-lein-startup! prj-key %) bld-ids))

   (remove-compiled-info! prj-key)

@@ -469,8 +469,8 @@
         [:i.fa.fa-exclamation-triangle] (warnings-state (count warnings))]
     :done-with-error
       [:span.errors-2718a [:i.fa.fa-times] "Compiling failed"]
-    :jvm-warmup
-      [:span [:i.fa.fa-gear.fa-spin] "JVM warmup..."]
+    :lein-startup
+      [:span [:i.fa.fa-gear.fa-spin] "Leiningen starting..."]
     :missing
       [:span [:i.fa.fa-minus-circle] "Output missing"]
     :waiting


Improve `clojurify-cljxml-with-no-attrs`

--- test/com/nomistech/clojure_the_language/c_800_libraries/s_120_clojure_data_xml/ss_010_s_120_clojure_data_xml_basics_test.clj
+++ test/com/nomistech/clojure_the_language/c_800_libraries/s_120_clojure_data_xml/ss_010_s_120_clojure_data_xml_basics_test.clj
@@ -153,13 +153,56 @@
     (throw (ex-info "cljxml has unexpected structure"
                     {})))
   (walk/prewalk (fn [x]
-                  (if (cljxml-with-no-attrs? x)
-                    (let [{:keys [tag content]} x]
-                      {tag content})
+                  (if (instance? clojure.data.xml.node.Element x)
+                    (if (empty? (:attrs x))
+                      (let [{:keys [tag content]} x]
+                        {tag content})
+                      (throw (ex-info "cljxml has unexpected structure"
+                                      {})))
                     x))
                 cljxml))

 (deftest clojurify-cljxml-with-no-attrs-test
+
+  (testing "Invalid data"
+    (testing "Must be a map"
+      (is (thrown-with-msg?
+           Exception
+           #"cljxml has unexpected structure"
+           (clojurify-cljxml-with-no-attrs 42))))
+    (testing "Must have :tag"
+      (is (thrown-with-msg?
+           Exception
+           #"cljxml has unexpected structure"
+           (clojurify-cljxml-with-no-attrs {:attrs {}
+                                            :content ["the-content-part-1"
+                                                      "the-content-part-2"]}))))
+    (testing "Must not have :attrs"
+      (is (thrown-with-msg?
+           Exception
+           #"cljxml has unexpected structure"
+           (clojurify-cljxml-with-no-attrs {:tag "the-tag"
+                                            :attrs {}}))))
+
+    (testing "Must not have :attrs in nested elements"
+      (is (thrown-with-msg?
+           Exception
+           #"cljxml has unexpected structure"
+           (clojurify-cljxml-with-no-attrs
+            (xml/element :x
+                         {}
+                         (xml/element :x1
+                                      {:a 1}
+                                      "x1 text")))))))
+
+  (testing "Simple valid data"
+    (is (= {:the-tag ["the-content-part-1"
+                      "the-content-part-2"]}
+           (clojurify-cljxml-with-no-attrs
+            (xml/element :the-tag
+                         {}
+                         "the-content-part-1"
+                         "the-content-part-2")))))

   (testing "Non-XML content"
     (let [actual   (clojurify-cljxml-with-no-attrs


small ui fix

small ui fix

--- src/cljs/salava/badge/ui/pending.cljs
+++ src/cljs/salava/badge/ui/pending.cljs
@@ -76,7 +76,7 @@

 (defn visibility-settings [visibility state]
   (fn []
-    [:div
+    [:div.col-md-12
      [:div.dropdown
        [:a.dropdown-toggle {:data-toggle "dropdown" :type "button" } (case @(cursor state [:visibility])
                                                                        "public" [:i.fa.fa-globe]


fixes #214

fixes #214

--- src/cljs/swarmpit/component/menu.cljs
+++ src/cljs/swarmpit/component/menu.cljs
@@ -213,7 +213,8 @@
                                        (state/update-value [:opened] (not opened) state/layout-cursor))})
         (comp/menu
           {:key   "menu"
-           :style menu-style}
+           :style menu-style
+           :listStyle {:paddingBottom "80px"}}
           (map
             (fn [menu-item]
               (let [icon (:icon menu-item)


bump browser-repl output-feature-set default

polyfills are not properly loaded at the REPL so it breaks when
requiring some packages couldn't be loaded from the browser-repl

--- src/main/shadow/cljs/devtools/api.clj
+++ src/main/shadow/cljs/devtools/api.clj
@@ -480,6 +480,7 @@
          :target :browser
          :output-dir (str (:cache-root config) "/builds/" (name build-id) "/js")
          :asset-path (str "/cache/" (name build-id) "/js")
+         :compiler-options {:output-feature-set :es-next}
          :modules
          {:repl {:entries '[shadow.cljs.devtools.client.browser-repl]}}
          :devtools