Add docstrings and preconditions to verification middleware

--- src/com/puppetlabs/middleware.clj
+++ src/com/puppetlabs/middleware.clj
@@ -44,7 +44,12 @@
       (app new-req))))

 (defn verify-accepts-content-type
+  "Ring middleware that requires a request for the wrapped `app` to accept the
+  provided `content-type`. If the content type isn't acceptable, a 406 Not
+  Acceptable status is returned, with a message informing the client it must
+  accept the content type."
   [app content-type]
+  {:pre (string? content-type)}
   (fn [{:keys [headers] :as req}]
     (if (pl-http/acceptable-content-type
           content-type
@@ -54,17 +59,29 @@
                  pl-http/status-not-acceptable))))

 (defn verify-param-exists
+  "Ring middleware that checks the existence of the given `param` in the
+  request. If the param isn't specified, a 400 Not Found error is returned,
+  explaining that the param is missing."
   [app param]
+  {:pre (string? param)}
   (fn [{:keys [params] :as req}]
     (if (params param)
       (app req)
       (pl-http/error-response (str "missing " param)))))

 (def verify-accepts-json
+  "Ring middleware which requires a request for `app` to accept
+  application/json as a content type. If the request doesn't accept
+  application/json, a 406 Not Acceptable status is returned with an error
+  message indicating the problem."
   (fn [app]
    (verify-accepts-content-type app "application/json")))

 (defn verify-checksum
+  "Ring middleware which will verify that the content of the `payload` param
+  has the checksum specified in the `checksum` parameter. If no checksum is
+  provided, this check will be skipped. If the checksum doesn't match, a 400
+  Bad Request error is returned."
   [app]
   (fn [{:keys [params] :as req}]
     (let [expected-checksum (params "checksum")


Refactor condp to cond.

Refactor condp to cond.

--- src/dsbdp/data_processing_dsl.clj
+++ src/dsbdp/data_processing_dsl.clj
@@ -22,14 +22,15 @@
           (cond
             (symbol? data-proc-def-element)
               (let [s data-proc-def-element]
-                (condp not= nil
+                (cond
                   (ns-resolve 'clojure.core s)
                     (conj v (ns-resolve 'clojure.core s))
                   (ns-resolve 'dsbdp.byte-array-conversion s)
                     (conj v (ns-resolve 'dsbdp.byte-array-conversion s) 'input)
-                  (do
-                    (println "Could not resolve symbol:" s)
-                    v)))
+                  :default
+                    (do
+                      (println "Could not resolve symbol:" s)
+                      v)))
             (list? data-proc-def-element)
               (conj v (into '() (reverse (create-data-processing-sub-fn data-proc-def-element input offset))))
             :default (conj v data-proc-def-element)))


filter nils from select-many results

filter nils from select-many results

--- src/er_cassandra/model/select.clj
+++ src/er_cassandra/model/select.clj
@@ -154,6 +154,7 @@
         (s/map (fn [record-or-key-value]
                  (select-one session entity key record-or-key-value opts)))
         (s/realize-each)
+        (s/filter some?)
         return)))

 (defn select-many
@@ -191,6 +192,7 @@
           (s/map (fn [record-or-key-value]
                    (select-one-instance session entity key record-or-key-value opts)))
           (s/realize-each)
+          (s/filter some?)
           return))))

 (defn select-many-instances
@@ -229,6 +231,7 @@
                    (select-buffered session entity key record-or-key-value opts)))
           (s/realize-each)
           (s/concat)
+          (s/filter some?)
           return))))

 (defn select-many-cat


Confirmation tests

Confirmation tests

--- test/structural_typing/guts/f_type_repo.clj
+++ test/structural_typing/guts/f_type_repo.clj
@@ -1,5 +1,6 @@
 (ns structural-typing.guts.f-type-repo
   (:require [structural-typing.guts.type-repo :as subject]
+            [structural-typing.type :as type]
             [structural-typing.pred-writing.shapes.oopsie :as oopsie])
   (:require [structural-typing.guts.paths.substituting :refer [includes]])
   (:use midje.sweet))
@@ -33,4 +34,14 @@
   (let [repo (-> subject/empty-type-repo
                  (subject/hold-type :Unused [ {:b string?} ])
                  (subject/replace-error-handler oopsie/explanations))]
-    (subject/check-type repo :Unused nil) => (just (contains {:path []}))))
+    (subject/check-type repo :Unused nil) => (just (contains {:path []})))
+
+  (fact "empty structures are not misclassified as nil"
+    (let [repo (-> subject/empty-type-repo
+                   (subject/hold-type :Hash [ {:a even?} ])
+                   (subject/hold-type :Vec [ {[type/ALL] even?} ])
+                   (subject/replace-error-handler oopsie/explanations))]
+      (subject/check-type repo :Hash {}) => []
+      (subject/check-type repo :Hash []) => []
+      (subject/check-type repo :Vec {}) => []
+      (subject/check-type repo :Vec []) => [])))


Lots of commenting added to the resources namespace, because some of the coding is subtle.

--- src/kixi/hecuba/web/resources.clj
+++ src/kixi/hecuba/web/resources.clj
@@ -12,58 +12,105 @@

 (def base-media-types ["text/html" "application/json" "application/edn"])

-(defresource items-resource [typ querier commander detail-resource]
+(defn render-items-html
+  "Render some HTML for the text/html representation. Mostly this is for
+  debug, to be able to check the data without too much UI logic
+  involved."
+  [items]
+  (let [fields (remove #{:hecuba/name :hecuba/id :hecuba/href :hecuba/type}
+                       (distinct (mapcat keys items)))]
+    (let [DEBUG false]
+      (html [:body
+             [:h2 "Fields"]
+             [:ul (for [k fields] [:li (csk/->snake_case_string (name k))])]
+             [:h2 "Items"]
+             [:table
+              [:thead
+               [:tr
+                [:th "Name"]
+                (for [k fields] [:th (string/replace (csk/->Snake_case_string k) "_" " ")])
+                (when DEBUG [:th "Debug"])]]
+              [:tbody
+               (for [p items]
+                 [:tr
+                  [:td [:a {:href (:hecuba/href p)} (:hecuba/name p)]]
+                  (for [k fields] [:td (str (k p))])
+                  (when DEBUG [:td (pr-str p)])])]]]))))
+
+;; Now for the Liberator resources. These are heavily commented because
+;; Liberator isn't well-known. Check the Liberator website for more
+;; info: http://clojure-liberator.github.io/liberator/
+
+;; REST resource for items (plural) - .
+(defresource items-resource [typ querier commander item-resource]
+  ;; acts as both an index of existing items and factory for new ones
   :allowed-methods #{:get :post}

+  :exists? true ; This 'factory' resource ALWAYS exists
   :available-media-types base-media-types

-  ;; This 'factory' resource ALWAYS exists, but we piggyback on this decision point to find the items.
-  ;; TODO: don't do this!
-  :exists? (fn [{{route-params :route-params body :body routes :jig.bidi/routes} :request :as ctx}]
-             {::items
-              (map (fn [m] (assoc m :hecuba/href (path-for routes detail-resource :hecuba/id (:hecuba/id m))))
-                   (items querier (merge route-params {:hecuba/type typ})))})
+  :handle-ok ; do this upon a successful GET
+  (fn [{{mime :media-type} :representation {routes :jig.bidi/routes route-params :route-params} :request}]
+    (let [items
+          (->>
+           {:hecuba/type typ} ; form a 'where' clause starting with the type
+           (merge route-params) ; adding any route-params
+           (items querier) ; to query items
+           ;; which are adorned with hrefs, throwing bidi's path-for all the kv pairs we have!
+           (map #(assoc % :hecuba/href (apply path-for routes item-resource (apply concat %)))))]
+      (case mime
+        "text/html" (render-items-html items)
+        ;; Liberator's default rendering of application/edn seems wrong
+        ;; (it wraps the data in 'clojure.lang.PersistentArrayMap', so
+        ;; we override it here.
+        "application/edn" (pr-str (vec items))

-  :handle-ok (fn [{items ::items {mt :media-type} :representation :as ctx}]
-               (case mt
-                 "text/html"
-                 (let [debug false
-                       fields (remove #{:hecuba/name :hecuba/id :hecuba/href :hecuba/type}
-                                      (distinct (mapcat keys items)))]
-                   (html [:body
-                          [:h2 "Fields"]
-                          [:ul (for [k fields] [:li (csk/->snake_case_string (name k))])]
-                          [:h2 "Items"]
-                          [:table
-                           [:thead
-                            [:tr
-                             [:th "Name"]
-                             (for [k fields] [:th (string/replace (csk/->Snake_case_string k) "_" " ")])
-                             (when debug [:th "Debug"])]]
-                           [:tbody
-                            (for [p items]
-                              [:tr
-                               [:td [:a {:href (:hecuba/href p)} (:hecuba/name p)]]
-                               (for [k fields] [:td (str (k p))])
-                               (when debug [:td (pr-str p)])])]]]))
-                 "application/edn" (pr-str (vec items))
-                 items))
+        ;; The default is to let Liberator render our data
+        items)))

-  :handle-created (fn [{{routes :jig.bidi/routes} :request id :hecuba/id :as ctx}]
-                    (ring-response
-                     {:headers {"Location"
-                                (path-for routes detail-resource :hecuba/id id)}}))
+  :post! ; enact the 'side-effect' of creating an item
+  (fn [{{body :body} :request}]
+    {:hecuba/id ; add this entry to Liberator's context
+     (upsert! commander
+              (-> body
+                  ;; Prepare to read the body
+                  io/reader (java.io.PushbackReader.)
+                  ;; Read the body (can't repeat this so no transactions!)
+                  edn/read io!
+                  ;; Add the type prior to upserting
+                  (assoc :hecuba/type typ)))})

-  :post! (fn [{{body :body} :request}]
-           (let [payload (io! (edn/read (java.io.PushbackReader. (io/reader body))))]
-             {:hecuba/id (upsert! commander (assoc payload :hecuba/type typ))})))
+  :handle-created ; do this upon a successful POST
+  (fn [{{routes :jig.bidi/routes route-params :route-params} :request id :hecuba/id}]
+    (ring-response ; Liberator, we're returning an actual Ring map!
+     ;; We must return the new resource path in the HTTP Location
+     ;; header. Liberator doesn't do this for us, and clients might need
+     ;; to know where the new resource is located.
+     ;; See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.2
+     {:headers {"Location" (path-for routes item-resource (assoc route-params :hecuba/id id))}})))

+(defn render-item-html
+  "Render an item as HTML"
+  [item]
+  (html
+   [:body
+    [:h1 (:hecuba/name item)]
+    [:pre (pr-str item)]]))
+
+;; REST resource for individual items.
 (defresource item-resource [querier]
   :allowed-methods #{:get}
   :available-media-types base-media-types
-  :exists? (fn [{{{id :hecuba/id} :route-params body :body routes :jig.bidi/routes} :request :as ctx}]
-             (if-let [p (item querier id)] {::item p} false))
-  :handle-ok (fn [{item ::item {mt :media-type} :representation :as ctx}]
-               (case mt
-                 "text/html" (html [:h1 (:hecuba/name item)])
-                 item)))
+
+  :exists? ; iff the item exists, we bind it to ::item in order to save
+           ; an extra query later on - this is a common Liberator
+           ; pattern
+  (fn [{{{id :hecuba/id} :route-params body :body routes :jig.bidi/routes} :request}]
+    (when-let [itm (item querier id)] {::item itm}))
+
+  :handle-ok
+  (fn [{item ::item {mime :media-type} :representation}]
+    (case mime
+      "text/html" (render-item-html item)
+      ;; The default is to let Liberator render our data
+      item)))


remove support for :whitespace optimizations

they don't actually work in environments people tried
to use them for and don't provide any actual benefit

closes #408

--- src/main/shadow/build/closure.clj
+++ src/main/shadow/build/closure.clj
@@ -82,13 +82,15 @@
 (defn set-options
   [^CompilerOptions closure-opts opts state]

-  (when-let [level
-             (case (:optimizations opts)
-               :advanced CompilationLevel/ADVANCED_OPTIMIZATIONS
-               :whitespace CompilationLevel/WHITESPACE_ONLY
-               :simple CompilationLevel/SIMPLE_OPTIMIZATIONS
-               nil)]
-    (.setOptionsForCompilationLevel level closure-opts))
+  (when-let [level-kw (:optimizations opts)]
+    (when-let [level
+               (case level-kw
+                 :advanced CompilationLevel/ADVANCED_OPTIMIZATIONS
+                 :whitespace (throw (ex-info ":whitespace optimizations are not supported, use :simple or :advanced." {}))
+                 :simple CompilationLevel/SIMPLE_OPTIMIZATIONS
+                 :none nil
+                 (throw (ex-info "invalid :optimizations level" opts)))]
+      (.setOptionsForCompilationLevel level closure-opts)))

   (when (contains? opts :pretty-print)
     (.setPrettyPrint closure-opts (:pretty-print opts)))


Add test for f1-score.

Add test for f1-score.

--- project/analyze-data/test/analyze_data/score_model_test.clj
+++ project/analyze-data/test/analyze_data/score_model_test.clj
@@ -42,3 +42,6 @@

 (deftest accuracy-test
   (is (= 35/48 (test-ns/accuracy confusion-matrix))))
+
+(deftest f1-score-test
+  (is (= 5/7 (test-ns/f1-score confusion-matrix :a))))


Improve escaping ANSI codes

Improve escaping ANSI codes

--- src/net/sekao/nightcode/utils.clj
+++ src/net/sekao/nightcode/utils.clj
@@ -121,7 +121,7 @@
   (str/escape s {\return ""}))

 (defn remove-ansi [^String s]
-  (str/replace s #"\e\[\d*m" ""))
+  (str/replace s #"\e\[\d*." ""))

 (defn get-boot-path []
   (let [windows? (.startsWith (System/getProperty "os.name") "Windows")


Restrict internal methods' visibility

Restrict internal methods' visibility

--- src/nhl_score_api/html_parser.clj
+++ src/nhl_score_api/html_parser.clj
@@ -12,15 +12,15 @@
 (defn parse-games [dom-page]
   (html/select dom-page [:.sbGame]))

-(defn is-regulation-period? [dom-element]
+(defn- is-regulation-period? [dom-element]
   (and (= :b (:tag dom-element))
        (= " Period:" (last (:content dom-element)))))

-(defn is-overtime-period? [dom-element]
+(defn- is-overtime-period? [dom-element]
   (and (= :b (:tag dom-element))
        (= "OT Period:" (first (:content dom-element)))))

-(defn get-period-number
+(defn- get-period-number
   "Parses the period number from the given DOM element, or nil if none found.
   Returns 4 for overtime period."
   [dom-element]
@@ -40,7 +40,7 @@
 (defn- parse-goal-count [goal-count-str]
   (read-string (re-find #"\d+" goal-count-str)))

-(defn get-goal
+(defn- get-goal
   "Parses the goal information from the given DOM element, or nil if none found."
   [dom-element]
   (when (= "goalDetails" (:class (:attrs dom-element)))
@@ -51,10 +51,10 @@
           goal-count (parse-goal-count (first (:content (last content))))]
       {:team team :time time :scorer scorer :goal-count goal-count})))

-(defn add-period [goals period]
+(defn- add-period [goals period]
   (map #(assoc % :period period) goals))

-(defn parse-goals-rec
+(defn- parse-goals-rec
   "Parses given DOM elements and returns a collection of goals."
   [dom-elements current-period current-goals all-goals]
   (if (empty? dom-elements)


typo in copyright string

typo in copyright string

--- src/norman_sicily_static/util.clj
+++ src/norman_sicily_static/util.clj
@@ -17,7 +17,7 @@
    [:div {:class "container"}
     [:div {:class "footer-links"}
      [:p
-      "© 2015 - 2017 by Joe and Dawn Mayes. All Rights Reserved"
+      "© 2015 - 2017 by Joe and Dawn Hayes. All Rights Reserved"

       [:div {:id "license"}
        [:a {:rel "license" :href "http://creativecommons.org/licenses/by-nc-sa/4.0/"} [:img {:alt "Creative Commons License" :style "border-width:0;padding-bottom:10px" :src "https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png"}]] [:br ] "This " [:span {:xmlns:dct "http://purl.org/dc/terms/" :href "http://purl.org/dc/dcmitype/StillImage" :rel "dct:type"} "work"] " by " [:a {:xmlns:cc "http://creativecommons.org/ns#" :href "normansicily.org" :property "cc:attributionName" :rel "cc:attributionURL"} "Dawn Marie Hayes, Ph.D. and Joseph Hayes "] "is licensed under a" [:a {:rel "license" :href "http://creativecommons.org/licenses/by-nc-sa/4.0/"} "  Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License"]]]]]])


Warn of incomplete async BookKeeper write Will require a more complete recovery strategy, see issue referred to in comment.

--- src/onyx/state/log/bookkeeper.clj
+++ src/onyx/state/log/bookkeeper.clj
@@ -64,8 +64,10 @@
 (def HandleWriteCallback
   (reify AsyncCallback$AddCallback
     (addComplete [this rc lh entry-id ack-fn]
-      (when (= rc (BKException$Code/OK))
-        (ack-fn)))))
+      (if (= rc (BKException$Code/OK))
+        (ack-fn)
+        ;; TODO: should restart peer, see https://github.com/onyx-platform/onyx/issues/390
+        (warn "Unable to complete async write to bookkeeper. BookKeeper exception code:" rc)))))

 (defn compaction-transition
   "Transitions to a new compacted ledger, plus a newly created ledger created


Add a literal conversion for xmlschema strings

--- src/rdf-common/grafter/rdf/io.clj
+++ src/rdf-common/grafter/rdf/io.clj
@@ -103,6 +103,9 @@
 (defmethod literal-datatype->type "http://www.w3.org/TR/xmlschema11-2/#string" [^Literal literal]
   (s (.stringValue literal) (.getLanguage literal)))

+(defmethod literal-datatype->type "http://www.w3.org/2001/XMLSchema#string" [^Literal literal]
+  (s (.stringValue literal) (.getLanguage literal)))
+
 (defmethod literal-datatype->type "http://www.w3.org/2001/XMLSchema#dateTime" [^Literal literal]
   (-> literal .calendarValue .toGregorianCalendar .getTime))

@@ -221,13 +224,6 @@

   (sesame-rdf-type->type [this]
     this)
-
-  LiteralImpl
-  (->sesame-rdf-type [this]
-    this)
-
-  (sesame-rdf-type->type [this]
-    (literal-datatype->type this))

   Statement
   (->sesame-rdf-type [this]


State core docstring

State core docstring

--- src/xray_charlie_charlie/core.clj
+++ src/xray_charlie_charlie/core.clj
@@ -1,5 +1,6 @@
 (ns xray-charlie-charlie.core
-  "Marklogic XCC core functions: session management, querying..."
+  "Marklogic XCC core functions: session management, querying, type
+  conversion, transactions."
   (:require [clojure.data.json :as json])
   (:import [java.util.logging Logger]
            [com.marklogic.xcc ContentSourceFactory


[EN] Add logback-classic and exclude slf4j-nop

We discovered that some libraries set the logger to nop and that's
bad. It means if we don't set the logger then we don't get any
logging. This solution is suggested in the [Datomic
Docs](http://docs.datomic.com/configuring-logging.html).

--- resources/leiningen/new/kraken/project.clj
+++ resources/leiningen/new/kraken/project.clj
@@ -9,7 +9,9 @@
                  [com.novemberain/langohr "3.2.0"]
                  [democracyworks/datomic-toolbox "1.0.0" :exclusions [com.datomic/datomic-pro]]
                  [prismatic/schema "0.4.3"]
-                 [com.datomic/datomic-pro "0.9.5153"]
+                 [com.datomic/datomic-pro "0.9.5153" :exclusions [org.slf4j/slf4j-nop
+                                                                  org.slf4j/slf4j-log4j12]]
+                 [ch.qos.logback/logback-classic "1.1.3"]
                  [org.immutant/core "2.0.1"]
                  [democracyworks/kehaar "0.3.0"]]
   :plugins [[lein-immutant "2.0.0"]]


Basic test for function read-csv

Basic test for function read-csv

--- test/clj_mrazik/importer_test.clj
+++ test/clj_mrazik/importer_test.clj
@@ -80,3 +80,9 @@
         (is (= 0 (parse-use-it "No")))
         (is (= 2 (parse-use-it "with caution")))))

+(deftest test-read-csv
+    "Check the function read-cvs"
+    (testing "read-csv"
+        (is (seq? (read-csv "test/test.csv")))
+        (is (= 4 (count (read-csv "test/test.csv"))))))
+


Add tests for clean-image-tag

Add tests for clean-image-tag

--- test/comic_reader/scrape_test.clj
+++ test/comic_reader/scrape_test.clj
@@ -2,6 +2,14 @@
   (:require [net.cgrand.enlive-html :as html]
             [comic-reader.scrape :refer :all]
             [clojure.test :refer :all]))
+
+(deftest clean-image-tag-test
+  (is (= (clean-image-tag [:img {:src "abc"}])
+         [:img {:src "abc"}]))
+  (is (= (clean-image-tag [:img {:alt "def"}])
+         [:img {:alt "def"}]))
+  (is (= (clean-image-tag [:img {:src "def" :walrus "i am"}])
+         [:img {:src "def"}])))

 (deftest extract-image-tag-test
   (let [html (html/html [:div {} [:img {:src "dummy-img"


Fix tests.

Fix tests.

--- test/uxbox/tests/test_kvstore.clj
+++ test/uxbox/tests/test_kvstore.clj
@@ -17,12 +17,12 @@
     (let [{:keys [id] :as user} (th/create-user conn 1)]

       ;; Not exists at this moment
-      (t/is (nil? (kvs/retrieve-kvstore conn {:user id :key "foo"})))
+      (t/is (nil? (kvs/retrieve-kvstore conn {:user id :key "foo" :version -1})))

       ;; Creating new one should work as expected
       (with-server {:handler (urt/app)}
         (let [uri (str th/+base-url+ "/api/kvstore")
-              body {:key "foo" :value "bar"}
+              body {:key "foo" :value "bar" :version -1}
               params {:body body}
               [status data] (th/http-put user uri params)]
           (println "RESPONSE:" status data)
@@ -33,18 +33,18 @@
       ;; Should exists
       (let [data (kvs/retrieve-kvstore conn {:user id :key "foo"})]
         (t/is (= (:key data) "foo"))
-        (t/is (= (:value data) "bar")))
+        (t/is (= (:value data) "bar"))

-      ;; Overwriting shoudl work
-      (with-server {:handler (urt/app)}
-        (let [uri (str th/+base-url+ "/api/kvstore")
-              body {:key "foo" :value "baz"}
-              params {:body body}
-              [status data] (th/http-put user uri params)]
-          (println "RESPONSE:" status data)
-          (t/is (= 200 status))
-          (t/is (= (:key data) "foo"))
-          (t/is (= (:value data) "baz"))))
+        ;; Overwriting should work
+        (with-server {:handler (urt/app)}
+          (let [uri (str th/+base-url+ "/api/kvstore")
+                body (assoc data :key "foo" :value "baz")
+                params {:body body}
+                [status data] (th/http-put user uri params)]
+            (println "RESPONSE:" status data)
+            (t/is (= 200 status))
+            (t/is (= (:key data) "foo"))
+            (t/is (= (:value data) "baz")))))

       ;; Should exists and match the overwritten value
       (let [data (kvs/retrieve-kvstore conn {:user id :key "foo"})]


Added safe check in NegatedCondition on collection-concept-id.

--- src/cmr/search/services/collection_concept_id_extractor.clj
+++ src/cmr/search/services/collection_concept_id_extractor.clj
@@ -1,6 +1,7 @@
 (ns cmr.search.services.collection-concept-id-extractor
   "Defines protocols and functions to extract collection concept ids from the query constructs"
-  (:require [cmr.search.models.query :as qm]))
+  (:require [cmr.common.services.errors :as errors]
+            [cmr.search.models.query :as qm]))

 (defprotocol ExtractCollectionConceptId
   "Defines a function to extract collection concept ids into a vector."
@@ -19,6 +20,12 @@
     [{:keys [conditions]} context]
     (mapcat #(extract-collection-concept-ids % context) conditions))

+  cmr.search.models.query.NegatedCondition
+  (extract-collection-concept-ids
+    [{:keys [condition]} context]
+    (if-not (empty? (extract-collection-concept-ids condition context))
+      (errors/internal-error! "collection-concept-id should not be allowed in NegatedCondition.")))
+
   cmr.search.models.query.StringCondition
   (extract-collection-concept-ids
     [{:keys [field value]} context]


Add stop button support for show blackout.

--- src/afterglow/controllers/ableton_push.clj
+++ src/afterglow/controllers/ableton_push.clj
@@ -297,7 +297,7 @@
   {:pre [(<= 0 line 3)]}
   (midi/midi-sysex (:port-out controller) [240 71 127 21 (+ line 28) 0 0 247]))

-(defn- show-labels
+(defn show-labels
   "Illuminates all buttons with text labels, for development assistance."
   ([controller]
    (show-labels controller :bright :amber))
@@ -630,6 +630,14 @@
         (set-pad-velocity controller x y velocity)
         (aset (:last-grid-pads controller) index velocity)))))

+(defn update-effect-list
+  "Display information about the four most recently activated
+  effects."
+  [controller]
+  ;; TODO: Loop over the most recent four active cues, rendering information
+  ;;       about them.
+  )
+
 (defn update-interface
   "Determine the desired current state of the interface, and send any
   changes needed to get it to that state."
@@ -641,9 +649,7 @@
     (reset! (:next-text-buttons controller) {})
     (Arrays/fill (:next-top-pads controller) 0)

-    ;; TODO: Loop over the most recent four active cues, rendering information
-    ;;       about them.
-
+    (update-effect-list controller)
     (update-metronome-section controller)

     ;; Reflect the shift button state
@@ -677,6 +683,11 @@
     (swap! (:next-text-buttons controller)
            assoc (:user-mode control-buttons)
            (button-state (:user-mode control-buttons) :bright))
+
+    ;; Make the stop button visible, since we support it
+    (swap! (:next-text-buttons controller)
+           assoc (:stop control-buttons)
+           (button-state (:stop control-buttons) :dim))

     ;; Add any contributions from interface overlays, removing them
     ;; if they report being finished. Reverse the order so that the
@@ -949,6 +960,45 @@
                  (handle-note-off [this controller message]
                    false))))

+(defn- enter-stop-mode
+  "The user has asked to stop the show. Suspend its update task
+  and black it out until the stop button is pressed again."
+  [controller]
+
+  (with-show (:show controller)
+    (show/stop!)
+    (Thread/sleep (:refresh-interval (:show controller)))
+    (show/blackout-show))
+  (clear-interface controller)
+
+  (add-overlay controller
+               (reify IOverlay
+                 (captured-controls [this] #{29})
+                 (captured-notes [this] #{})
+                 (adjust-interface [this controller]
+                   (write-display-cell controller 0 1 "")
+                   (write-display-cell controller 0 2 "")
+                   (write-display-cell controller 1 1 "         *** Show")
+                   (write-display-cell controller 1 2 "Stop ***")
+                   (write-display-cell controller 2 1 "       Press Stop")
+                   (write-display-cell controller 2 2 "to resume.")
+                   (write-display-cell controller 3 1 "")
+                   (write-display-cell controller 3 2 "")
+                   (swap! (:next-text-buttons controller)
+                          assoc (:stop control-buttons)
+                          (button-state (:stop control-buttons) :bright))
+                   true)
+                 (handle-control-change [this controller message]
+                   (when (pos? (:velocity message))
+                     ;; End stop mode
+                     (with-show (:show controller)
+                       (show/start!))
+                     :done))
+                 (handle-note-on [this controller message]
+                   false)
+                 (handle-note-off [this controller message]
+                   false))))
+
 (defn add-button-held-feedback-overlay
   "Adds a simple overlay which keeps a control button bright as long
   as the user is holding it down."
@@ -970,6 +1020,12 @@
     9 ; Metronome button
     (when (pos? (:velocity message))
       (enter-metronome-showing controller))
+
+    ;; 28 ; Master button
+
+    29 ; Stop button
+    (when (pos? (:velocity message))
+      (enter-stop-mode controller))

     49 ; Shift button
     (swap! (:shift-mode controller) (fn [_] (pos? (:velocity message))))


Refactored query function to use a helper for making fetch option objects.

--- src/appengine_magic/services/datastore.clj
+++ src/appengine_magic/services/datastore.clj
@@ -233,6 +233,15 @@
     query-object))

+(defn- make-fetch-options-object [limit offset prefetch-size chunk-size]
+  (let [fetch-options-object (FetchOptions$Builder/withDefaults)]
+    (when limit (.limit fetch-options-object limit))
+    (when offset (.offset fetch-options-object offset))
+    (when prefetch-size (.prefetchSize prefetch-size))
+    (when chunk-size (.chunkSize chunk-size))
+    fetch-options-object))
+
+

 ;;; ----------------------------------------------------------------------------
 ;;; user functions and macros
@@ -343,19 +352,11 @@
                 :or {keys-only? false, filter [[]], sort [[]],
                      count-only? false, in-transaction? false}}]
   (let [query-object (make-query-object kind ancestor filter sort keys-only?)
-        fetch-options-object (FetchOptions$Builder/withDefaults)]
-    (when limit
-      (.limit fetch-options-object limit))
-    (when offset
-      (.offset fetch-options-object offset))
-    (when prefetch-size
-      (.prefetchSize prefetch-size))
-    (when chunk-size
-      (.chunkSize chunk-size))
-    (let [prepared-query (if (and in-transaction? *current-transaction*)
-                             (.prepare (get-datastore-service) *current-transaction*
-                                       query-object)
-                             (.prepare (get-datastore-service) query-object))]
-      (if count-only?
-          (.countEntities prepared-query)
-          (seq (.asIterable prepared-query fetch-options-object))))))
+        fetch-options-object (make-fetch-options-object limit offset prefetch-size chunk-size)
+        prepared-query (if (and in-transaction? *current-transaction*)
+                           (.prepare (get-datastore-service) *current-transaction*
+                                     query-object)
+                           (.prepare (get-datastore-service) query-object))]
+    (if count-only?
+        (.countEntities prepared-query)
+        (seq (.asIterable prepared-query fetch-options-object)))))


Hide subtitle if not used

Hide subtitle if not used

--- android/src/clojure/net/nightweb/views.clj
+++ android/src/clojure/net/nightweb/views.clj
@@ -140,7 +140,9 @@
             (if-let [title (get item :title)]
               (.setText text-top title)
               (.setText text-top (get item :body)))
-            (.setText text-bottom (get item :subtitle))
+            (if-let [subtitle (get item :subtitle)]
+              (.setText text-bottom subtitle)
+              (.setVisibility text-bottom android.view.View/GONE))
             tile-view))))
     (.setOnItemClickListener
       view


Job completion detection used previous replica

--- src/clj/onyx_dashboard/onyx_deployment.clj
+++ src/clj/onyx_dashboard/onyx_deployment.clj
@@ -167,7 +167,7 @@
         (let [entry (extensions/read-log-entry log position)]
           (if-let [new-replica (apply-log-entry send-fn! tracking-id entry replica)]
             (let [diff (extensions/replica-diff entry replica new-replica)
-                  new-incomplete-jobs (set (common/incomplete-jobs replica))]
+                  new-incomplete-jobs (set (common/incomplete-jobs new-replica))]
               (send-job-statuses send-fn! tracking-id incomplete-jobs new-incomplete-jobs)
               (log-notifications send-fn! new-replica diff log entry tracking-id)
               (send-log-entry send-fn! tracking-id entry)


better node edit form

better node edit form

--- src/cljs/swarmpit/component/node/edit.cljs
+++ src/cljs/swarmpit/component/node/edit.cljs
@@ -34,46 +34,90 @@
      :disabled        true
      :InputLabelProps {:shrink true}}))

+;(defn- form-role [value]
+;  (comp/text-field
+;    {:fullWidth       true
+;     :key             "role"
+;     :label           "Role"
+;     :select          true
+;     :value           value
+;     :variant         "outlined"
+;     :margin          "normal"
+;     :style           {:maxWidth "350px"}
+;     :InputLabelProps {:shrink true}
+;     :onChange        #(state/update-value [:role] (-> % .-target .-value) state/form-value-cursor)}
+;    (comp/menu-item
+;      {:key   "worker"
+;       :value "worker"} "worker")
+;    (comp/menu-item
+;      {:key   "manager"
+;       :value "manager"} "manager")))
+
 (defn- form-role [value]
-  (comp/text-field
-    {:fullWidth       true
-     :key             "role"
-     :label           "Role"
-     :select          true
-     :value           value
-     :variant         "outlined"
-     :margin          "normal"
-     :style           {:maxWidth "350px"}
-     :InputLabelProps {:shrink true}
-     :onChange        #(state/update-value [:role] (-> % .-target .-value) state/form-value-cursor)}
-    (comp/menu-item
-      {:key   "worker"
-       :value "worker"} "worker")
-    (comp/menu-item
-      {:key   "manager"
-       :value "manager"} "manager")))
+  (comp/form-control
+    {:component "fieldset"
+     :key       "role-f"
+     :style     {:width "200px"}}
+    (comp/form-label
+      {:key "rolel"} "Role")
+    (comp/radio-group
+      {:name     "role"
+       :key      "role-rg"
+       :value    value
+       :onChange #(state/update-value [:role] (-> % .-target .-value) state/form-value-cursor)}
+      (comp/form-control-label
+        {:control (comp/radio
+                    {:name  "manager-role"
+                     :color "primary"
+                     :key   "manager-role"})
+         :key     "mngr-role"
+         :value   "manager"
+         :label   "Manager"})
+      (comp/form-control-label
+        {:control (comp/radio
+                    {:name  "worker-role"
+                     :color "primary"
+                     :key   "worker-role"})
+         :key     "worker-role"
+         :value   "worker"
+         :label   "Worker"}))))

 (defn- form-availability [value]
-  (comp/text-field
-    {:fullWidth       true
-     :key             "availability"
-     :label           "Availability"
-     :select          true
-     :value           value
-     :variant         "outlined"
-     :margin          "normal"
-     :style           {:maxWidth "350px"}
-     :InputLabelProps {:shrink true}
-     :onChange        #(state/update-value [:availability] (-> % .-target .-value) state/form-value-cursor)}
-    (comp/menu-item
-      {:key   "active"
-       :value "active"} "active")
-    (comp/menu-item
-      {:key   "pause"
-       :value "pause"} "pause")
-    (comp/menu-item
-      {:key   "drain"
-       :value "drain"} "drain")))
+  (comp/form-control
+    {:component "fieldset"
+     :key       "availability-f"
+     :style     {:width "200px"}}
+    (comp/form-label
+      {:key "availabilityl"} "Availability")
+    (comp/radio-group
+      {:name     "availability"
+       :key      "availability-rg"
+       :value    value
+       :onChange #(state/update-value [:availability] (-> % .-target .-value) state/form-value-cursor)}
+      (comp/form-control-label
+        {:control (comp/radio
+                    {:name  "active"
+                     :color "primary"
+                     :key   "active"})
+         :key     "active-av"
+         :value   "active"
+         :label   "Active"})
+      (comp/form-control-label
+        {:control (comp/radio
+                    {:name  "pause"
+                     :color "primary"
+                     :key   "pause"})
+         :key     "pause-av"
+         :value   "pause"
+         :label   "Pause"})
+      (comp/form-control-label
+        {:control (comp/radio
+                    {:name  "drain"
+                     :color "primary"
+                     :key   "drain"})
+         :key     "drain-av"
+         :value   "drain"
+         :label   "Drain"}))))

 (defn- form-label-name [value index]
   (comp/text-field
@@ -182,7 +226,7 @@
               (comp/card-header
                 {:className "Swarmpit-form-card-header"
                  :key       "nech"
-                 :title     "Edit Node"})
+                 :title     (str "Editing " nodeName)})
               (comp/card-content
                 {:key "necc"}
                 (comp/grid
@@ -191,11 +235,15 @@
                    :spacing   40}
                   (comp/grid
                     {:item true
-                     :key  "neccciga"
+                     :key  "necccigar"
                      :xs   12
                      :sm   6}
-                    (form-name nodeName)
-                    (form-role role)
+                    (form-role role))
+                  (comp/grid
+                    {:item true
+                     :key  "necccigaa"
+                     :xs   12
+                     :sm   6}
                     (form-availability availability))
                   (comp/grid
                     {:item true


Added container cpu and memory data extraction support.

--- src/cmr/dev/env/manager/process/docker.clj
+++ src/cmr/dev/env/manager/process/docker.clj
@@ -5,7 +5,8 @@
     [clojure.string :as string]
     [cmr.dev.env.manager.process.core :as process]
     [taoensso.timbre :as log]
-    [trifl.fs :as fs]))
+    [trifl.fs :as fs]
+    [trifl.ps :as ps]))

 (defn- multi-flags
   [flag values]
@@ -65,3 +66,15 @@
 (defn pid
   [opts]
   (get-in (inspect opts) [:State :Pid]))
+
+(defn get-cpu-mem
+  [opts]
+  (ps/get-ps-info "%cpu,%mem" (pid opts)))
+
+(defn get-cpu
+  [opts]
+  (:%cpu (get-cpu-mem opts)))
+
+(defn get-mem
+  [opts]
+  (:%mem (get-cpu-mem opts)))


adding another rect

adding another rect

--- cartagena-web/src/cartagena_web/core.cljs
+++ cartagena-web/src/cartagena_web/core.cljs
@@ -14,10 +14,11 @@
    [:h1 "CARTAGENA"
     [:div
      [:svg
-      {:view-box "0 0 1000 800"
-       :width 1000
-       :height 800}
-      [:rect {:x 0 :y 0 :width 1000 :height 800 :stroke "black" :fill "none"}]]]]])
+      {:view-box "0 0 500 400"
+       :width "100%"
+       :height "100%"}
+      [:rect {:x 0 :y 0 :width "100%" :height "100%" :stroke "black" :stroke-width "1" :fill "tan"}]
+      [:rect {:x 5 :y 5 :width "80%" :height "65%" :stroke "black" :stroke-width "0.5" :fill "burlywood"}]]]]])

 (defn ^:export main []
   (when-let [app (. js/document (getElementById "app"))]


Fix `peer-group-scheduler-lag` being redefined for

`peer-group-shutdown-duration-ms`.

--- src/onyx/monitoring/metrics_monitoring.clj
+++ src/onyx/monitoring/metrics_monitoring.clj
@@ -99,14 +99,14 @@
                                                  (.get ^AtomicLong scheduler-lag)))
           number-peer-shutdowns (AtomicLong. 0)
           peer-group-num-peer-shutdowns (g/gauge-fn reg
-                                                    ["peer-group" "peers-shutting-down"]
-                                                    (fn []
+                                                    ["peer-group" "peers-shutting-down"]
+                                                    (fn []
                                                       (.get ^AtomicLong number-peer-shutdowns)))
           peers-shutdown-duration-ms (AtomicLong. 0)
-          peer-group-num-peer-shutdowns (g/gauge-fn reg
-                                                    ["peer-group" "peers-max-shutdown-duration-ms"]
-                                                    (fn []
-                                                      (.get ^AtomicLong peers-shutdown-duration-ms)))
+          peer-group-shutdown-duration-ms (g/gauge-fn reg
+                                                      ["peer-group" "peers-max-shutdown-duration-ms"]
+                                                      (fn []
+                                                        (.get ^AtomicLong peers-shutdown-duration-ms)))
           reporter (-> (JmxReporter/forRegistry reg)
                        (.inDomain "org.onyxplatform")
                        (.build))


Made compatible with Yellow dataset

Made compatible with Yellow dataset

--- taxi-rides-clj/src/taxi_rides_clj/core.clj
+++ taxi-rides-clj/src/taxi_rides_clj/core.clj
@@ -75,12 +75,13 @@
          (into {}))))
 ;(->> weather seq (take 10))

-(def col-mapping
-  {"VendorID"                [:int             :vendor-id]
+(def col-mapping-raw
+  {; Started from Green Taxi dataset
+   "VendorID"                [:int             :vendor-id]
    "lpep_pickup_datetime"    [:basic-datetime  :pickup-dt]
    "Lpep_dropoff_datetime"   [:basic-datetime  :dropoff-dt]
    "Store_and_fwd_flag"      [:keyword         :store-flag]
-   "RateCodeID"              [:int             :rate-code-id]
+   "RateCodeID"              [:keyword         :rate-code]
    "Pickup_longitude"        [:latlon          :pickup-lon]
    "Pickup_latitude"         [:latlon          :pickup-lat]
    "Dropoff_longitude"       [:latlon          :dropoff-lon]
@@ -96,8 +97,25 @@
    "Payment_type"            [:keyword         :payment-type]
    "Trip_type"               [:keyword         :trip-type]
    "Extra"                   nil
+   "improvement_surcharge"   nil

-   ; These are generated, not part of CSV
+   ; These are from Yellow Taxi dataset
+   "vendor_name"             [:keyword         :vendor-name]
+   "trip_pickup_datetime"    [:basic-datetime  :pickup-dt]
+   "trip_dropoff_datetime"   [:basic-datetime  :dropoff-dt]
+   "tip_amt"                 [:float           :paid-tip]
+   "fare_amt"                [:float           :paid-fare]
+   "tolls_amt"               [:float           :paid-tolls]
+   "total_amt"               [:float           :paid-total]
+   "rate_code"               [:keyword         :rate-code]
+   "start_lon"               [:latlon          :pickup-lon]
+   "start_lat"               [:latlon          :pickup-lat]
+   "end_lon"                 [:latlon          :dropoff-lon]
+   "end_lat"                 [:latlon          :dropoff-lat]
+   "store_and_forward"       [:keyword         :store-flag]
+   "surcharge"               nil
+
+   ; These are generated fields, not part of CSV. But also listed here to simplify ES mapping generation.
    :company      [:keyword  :company]
    :pickup-pos   [:geopoint :pickup-pos]
    :dropoff-pos  [:geopoint :dropoff-pos]
@@ -108,6 +126,9 @@
    :travel-h     [:float    :travel-h]
    :speed-kmph   [:float    :speed-kmph]})

+; Mapping CSV columns to lowercase to simplify schema definition
+(def col-mapping (into {} (for [[k v] col-mapping-raw] [(if (string? k) (string/lower-case k) k) v])))
+
 (def fields
   (->> (concat
          (for [weather-field (-> weather vals first keys)] [weather-field :float])
@@ -117,22 +138,32 @@
 (defn parse-trips [file]
   (with-open [in (-> file clojure.java.io/input-stream java.util.zip.GZIPInputStream.)]
     (let [doc-id-fields [:pickup-dt :dropoff-dt :pickup-lat :pickup-lon :dropoff-lat :dropoff-lon :travel-km :paid-total]
-          dataset (->> file str (re-find #"([a-z]+)[^/]+$") second)
-          [header & rows] (-> in slurp csv/read-csv)
-          header   (map string/trim header)
-          missing  (clojure.set/difference (->> col-mapping keys (filter string?) set) (-> header set))
-          check    (if-not (empty? missing) (throw (Exception. (str "Missing cols for " missing " at " file))))
-          drop-fields identity ; #(reduce dissoc % [:pickup-lat :pickup-lon :dropoff-lat :dropoff-lon])
-          header   (map col-mapping header)
-          n-cols   (count header)
-          round    (fn [n] (let [scale 1000.0] (-> n (* scale) Math/round (/ scale))))
-          to-int-str (fn [v] (if v (let [v (int v)] (str (if (< v 10) "0" "") v))))
-          deg2km   (/ 40075.0 360.0)
-          mile2km  (fn [mile] (-> mile (* 1.60934) round))
-          delta-km (fn [from to] (if (and from to) (-> (- to from) (* deg2km) round)))
-          dist     (fn [a b] (if (and a b) (Math/sqrt (+ (* a a) (* b b))) 0.0))
+          company           (first (filter #(.contains (str file) %) ["green" "yellow" "uber"]))
+          vendor-lookup     (if (= company "green") {1 "Creative Mobile Technologies" 2 "VeriFone"})
+          dataset           (->> file str (re-find #"([a-z]+)[^/]+$") second)
+          [header & rows]   (-> in slurp csv/read-csv)
+          header            (map (comp string/lower-case string/trim) header)
+          missing           (clojure.set/difference (-> header set) (->> col-mapping keys (filter string?) set))
+          check             (if-not (empty? missing) (throw (Exception. (str "Missing cols for " missing " at " file))))
+          drop-extra-fields identity ; #(reduce dissoc % [:pickup-lat :pickup-lon :dropoff-lat :dropoff-lon])
+          header            (map col-mapping header)
+          n-cols            (count header)
+          coalesce-to-zero #(or % 0.0)
+          round            #(let [scale 1000.0] (-> % (* scale) Math/round (/ scale)))
+          deg2km            (/ 40075.0 360.0)
+          mile2km          #(-> % (* 1.60934) round)
+          delta-km          (fn [from to] (if (and from to) (-> (- to from) (* deg2km) round)))
+          dist              (fn [a b]     (if (and a b)     (Math/sqrt (+ (* a a) (* b b))) 0.0))
+          filter-km-deltas #(if (< (dist (:dlat-km %) (:dlon-km %)) 0.2) (reduce dissoc % [:dlat-km :dlon-km]) %)
+          assoc-speed-kmph #(assoc % :speed-kmph (if-let [travel-h (:travel-h %)] (if (> travel-h 0.17) (round (/ (:travel-km %) travel-h)))))
+          assoc-travel-h   #(assoc % :travel-h   (let [pickup-time  (:pickup-time  %)
+                                                       dropoff-time (:dropoff-time %)]
+                                                   (if (and dropoff-time pickup-time (not= dropoff-time pickup-time))
+                                                     (round (let[delta (- dropoff-time pickup-time)]
+                                                              (if (pos? delta) delta (+ delta 24)))))))
           to-time  (fn [datetime]
-                     (let [time (apply + (map / (map #(->> % (apply str) ((:int parsers))) (->> datetime (drop 9) (partition 2))) [1.0 60.0 3600.0]))]
+                     (let [time-scales [1.0 60.0 3600.0]
+                           time (apply + (map / (map #(->> % (apply str) ((:int parsers))) (->> datetime (drop 9) (partition 2))) time-scales))]
                        (if (not= time 0.0) (min (round time) 23.999))))
           docs     (for [row rows :when (>= (count row) n-cols)]
                      (let [doc (into (sorted-map) (map (fn [h v] (if h [(second h) ((-> h first parsers) v)])) header row))]
@@ -142,7 +173,8 @@
                          (into           (weather (-> doc :pickup-dt (subs 0 8)))))))]
         (for [doc docs :when (pos? (:travel-km doc))]
           (-> doc
-              (assoc  :company       "Green")
+              (assoc  :company       company)
+              (update :vendor-name #(get vendor-lookup (:vendor-id doc) %))
               (update :travel-km     mile2km)
               (assoc  :pickup-pos    (if (:pickup-lon  doc) (mapv doc [:pickup-lon  :pickup-lat])))
               (assoc  :dropoff-pos   (if (:dropoff-lon doc) (mapv doc [:dropoff-lon :dropoff-lat])))
@@ -150,17 +182,16 @@
               (assoc  :dlon-km       (delta-km (:pickup-lon doc) (:dropoff-lon doc)))
               (assoc  :pickup-time   (to-time (:pickup-dt  doc)))
               (assoc  :dropoff-time  (to-time (:dropoff-dt doc)))
-              (update :paid-ehail   #(or % 0.0))
-              (#(assoc % :travel-h   (let [pickup-time  (:pickup-time  %)
-                                           dropoff-time (:dropoff-time %)]
-                                       (if (and dropoff-time pickup-time (not= dropoff-time pickup-time))
-                                         (round (let[delta (- dropoff-time pickup-time)]
-                                                  (if (pos? delta) delta (+ delta 24))))))))
-             ;(update :pickup-time  to-int-str)
-             ;(update :dropoff-time to-int-str)
-              (#(assoc % :speed-kmph (if-let [travel-h (:travel-h %)] (if (> travel-h 0.17) (round (/ (:travel-km %) travel-h))))))
-              (#(if (< (dist (:dlat-km %) (:dlon-km %)) 0.2) (reduce dissoc % [:dlat-km :dlon-km]) %))
-              drop-fields)))))
+              (update :paid-ehail    coalesce-to-zero)
+              (update :paid-tax      coalesce-to-zero)
+              assoc-travel-h
+              assoc-speed-kmph
+              filter-km-deltas
+              drop-extra-fields)))))
+
+;(time (->> #"green_.+\.csv\.gz$" find-files second parse-trips count))
+;(->> #"green_.+\.csv\.gz$" find-files first parse-trips (take 3) pprint)
+;(->> #"yellow_tripdata_2009-07\.csv\.gz$" find-files first parse-trips (take 3) pprint)
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (def es-types
@@ -182,8 +213,7 @@
   {:server      (or (System/getenv "ES_SERVER")      "192.168.0.100:9200")})

 ; curl -s 'http://localhost:9200/_template/*?pretty'
-; curl -XDELETE 'http://localhost:9200/_template/taxicab'
-; curl -XDELETE 'http://localhost:9200/taxicab-green-*'
+; curl -XDELETE 'http://localhost:9200/_template/taxicab' && curl -XDELETE 'http://localhost:9200/taxicab-green-*'
 (defn create-template [client template-name body]
   (let [url (str "_template/" template-name)]
     (if (= 404 (:status (s/request client {:url url :method :head})))
@@ -216,24 +246,24 @@
           p     (my-println-t "got " freqs)]
       freqs)))

-(defn store-green [n]
+(defn insert-files [dataset n-parallel]
   (let [p      (my-println (t/local-time) " Started...")
-        result (doall (->> #"green_tripdata_201.+\.csv\.gz$" find-files (my-pmap n insert-file)))
+        result (doall (->> (str dataset ".+\\.csv\\.gz$") re-pattern find-files (my-pmap n-parallel insert-file)))
         p      (my-println (t/local-time) " ...finished!")]
     result))
+
 ;(def results (store-green 6))

 ;(->> #"green_.+\.csv\.gz$" find-files (map insert-file))

-;(->> #"green_tripdata_201[^34].+\.csv\.gz$" find-files (map str))
-;(->> #"green_.+\.csv\.gz$" find-files first parse-trips (take 3) pprint)
+;(->> #"yellow_tripdata_2009-07\.csv\.gz$" find-files first parse-trips (take 3) pprint)
 ;(->> #"green_.+\.csv\.gz$" find-files (take 1) (map insert-file))
 ;(->> #"green_.+\.csv\.gz$" find-files (my-pmap 1 insert-file))
 ;(->> #"green_.+\.csv\.gz$" find-files (my-pmap 7 insert-file)))
 ;(->> #"green_.+\.csv\.gz$" find-files count)

-(defn -main [arg]
+(defn -main [dataset n-parallel]
   (do
-    (store-green ((:int parsers) arg))
+    (insert-files dataset ((:int parsers) n-parallel))
     (shutdown-agents)))


(defn parses)

(defn parses)

--- src/babel/latin.cljc
+++ src/babel/latin.cljc
@@ -20,13 +20,15 @@

 (def lexicon (edn2lexicon "src/babel/latin/lexicon.edn"))

-
 (defn generate [spec]
   (first (shuffle
           (filter #(not (fail? %))
                   (map (fn [val]
                          (unifyc spec val))
                        (flatten (vals lexicon)))))))
+
+(defn parse [surface]
+  [{:parses (morph/analyze surface lexicon)}])

 (defn fo [structure]
   (morph/conjugate (get-in structure [:root]) structure))


add corpus in EN

add corpus in EN

--- resources/duckling/corpus/en.time.clj
+++ resources/duckling/corpus/en.time.clj
@@ -163,7 +163,11 @@

   "wednesday of next week"
   "wednesday next week"
+  "wednesday after next"
   (datetime 2013 2 20 :day-of-week 3)
+
+  "friday after next"
+  (datetime 2013 2 22 :day-of-week 5)

   "monday of this week"
   (datetime 2013 2 11 :day-of-week 1)


Add benchmarking for update-servlet-response

--- ring-bench/src/ring/bench/servlet.clj
+++ ring-bench/src/ring/bench/servlet.clj
@@ -30,11 +30,35 @@
       (getCharacterEncoding [_] nil)
       (getInputStream       [_] (proxy [javax.servlet.ServletInputStream] [])))))

+(defn http-servlet-response []
+  (reify javax.servlet.http.HttpServletResponse
+    (setStatus [_ _])
+    (setHeader [_ _ _])
+    (addHeader [_ _ _])
+    (setContentType [_ _])
+    (getOutputStream [_]
+      (let [os (java.io.ByteArrayOutputStream.)]
+        (proxy [javax.servlet.ServletOutputStream] []
+          (close [] (.close os))
+          (flush [] (.flush os))
+          (write
+            ([b] (.write os b))
+            ([b off len] (.write os b off len))))))))
+
+(def ring-response
+  {:status  200
+   :headers {"Content-Type" "application/json"}
+   :body    "{\"hello\" \"world\"}"})
+
 (def bench-env
   {:benchmarks
-   [{:name :build-test, :fn `servlet/build-request-map, :args [:state/request]}]
+   [{:name :build,  :fn `servlet/build-request-map,       :args [:state/request]}
+    {:name :update, :fn `servlet/update-servlet-response, :args [:state/response :param/response]}]
    :states
-   {:request {:fn `http-servlet-request, :args []}}})
+   {:request  {:fn `http-servlet-request, :args []}
+    :response {:fn `http-servlet-response, :args []}}
+   :params
+   {:response ring-response}})

 (def bench-opts
   {:type :quick


Work on a way to have promise and completable creation not require acquiring

--- src/beehive/hive.clj
+++ src/beehive/hive.clj
@@ -130,6 +130,18 @@
     (catch RejectedException e
       {:rejected? true :rejected-reason (.keyword ^ToCLJ (.reason e))})))

+(defn just-completable [context]
+  (if (:rejected? context)
+    context
+    (Synchronous/getCompletable
+      (:beehive (meta context)) (:permit-count context) (:start-nanos context))))
+
+(defn just-promise [context]
+  (if (:rejected? context)
+    context
+    (Asynchronous/getPromise
+      (:beehive (meta context)) (:permit-count context) (:start-nanos context))))
+
 (defn completable
   "Attempts to acquires requested permits. If the permits are acquired, a
   completable that can be completed is returned. The completable is internally
@@ -257,4 +269,8 @@
    (let [^GuardRail guard-rail (:guard-rail beehive)]
      (if-let [rejected-reason (.acquirePermits ^GuardRail guard-rail permits nano-time)]
        {:rejected? true :rejected-reason (.keyword ^ToCLJ rejected-reason)}
-       {:start-nanos nano-time :permit-count permits}))))+       {:start-nanos nano-time :permit-count permits}))))
+
+(def acquire-promise (comp just-promise acquire))
+
+(def acquire-completable (comp just-promise completable))


Prettier urls.

Prettier urls.

--- src/benjals/core.clj
+++ src/benjals/core.clj
@@ -11,7 +11,7 @@
 (defroutes routes
   (GET "/teams" [] {:body (all)})
   (POST "/teams" {body :body} {:body (create body)})
-  (GET "/" [] (resp/redirect "/index.html"))
+  (GET "/" [] (resp/resource-response "index.html" {:root "public"}))
   (route/resources "/"))

 (def app


fundamental.clj: find-generators maps edges to words in both directions

--- clojure/org/gavrog/clojure/fundamental.clj
+++ clojure/org/gavrog/clojure/fundamental.clj
@@ -77,16 +77,24 @@
                           (rest glued))]
     [boundary edge2word gen2edge]))

+(defn- add-inverses [ds edge2word]
+  (into edge2word (for [[[D i] w] edge2word]
+                    [[(s ds i D) i] (inverse w)])))
+
 (defn- find-generators [ds]
-  (let [boundary (reduce (fn [bnd [D i]] (glue-boundary ds bnd D i))
-                         (initial-boundary ds)
-                         (inner-edges ds))]
-    (drop 1 (reduce (fn [[[on-bnd _ :as boundary] edge2word gen2edge] [D i]]
-                      (if (on-bnd [D i])
-                        (glue-generator ds boundary edge2word gen2edge D i)
-                        [boundary edge2word gen2edge]))
-                    [boundary {} {}]
-                    (for [D (elements ds), i (indices ds)] [D i])))))
+  (let [boundary
+        (reduce (fn [bnd [D i]] (glue-boundary ds bnd D i))
+                (initial-boundary ds)
+                (inner-edges ds))
+
+        [_ e2w g2e]
+        (reduce (fn [[[on-bnd _ :as boundary] e2w g2e] [D i]]
+                  (if (on-bnd [D i])
+                    (glue-generator ds boundary e2w g2e D i)
+                    [boundary e2w g2e]))
+                [boundary {} {}]
+                (for [D (elements ds), i (indices ds)] [D i]))]
+    [(add-inverses ds e2w) g2e]))

 (defn fundamental-group [ds]
   (let [[edge2word, gen2edge] (find-generators ds)]


Fix typo

Fix typo

--- test/caesium/magicnonce/secretbox_test.clj
+++ test/caesium/magicnonce/secretbox_test.clj
@@ -97,7 +97,7 @@
   ([scheme]
    (let [ptexts [(.getBytes "four score and ")
                  (.getBytes "seven years ago")]]
-     (repeated-keystream? ptexts schems)))
+     (repeated-keystream? ptexts scheme)))
   ([ptexts scheme]
    (let [just-ctext (fn [^bytes ptext]
                       (->> (scheme ptext)


correct commodities test

correct commodities test

--- test/clj_money/models/commodities_test.clj
+++ test/clj_money/models/commodities_test.clj
@@ -362,9 +362,13 @@
 (deftest deleting-a-commodity-deletes-the-prices
   (let [context (serialization/realize storage-spec commodity-with-prices-context)
         commodity (-> context :commodities first)
-        prices-before (prices/search storage-spec {:commodity-id (:id commodity)})
+        criteria {:commodity-id (:id commodity)
+                  :trade-date [:between
+                               (t/local-date 2016 1 1)
+                               (t/local-date 2016 12 31)]}
+        prices-before (prices/search storage-spec criteria)
         _ (commodities/delete storage-spec (:id commodity))
-        prices-after (prices/search storage-spec {:commodity-id (:id commodity)})]
+        prices-after (prices/search storage-spec criteria)]
     (is (not (empty? prices-before))
         "The commodity prices exist before delete")
     (is (empty? prices-after)


Make implementation functions private

Make implementation functions private

--- src/braid/lib/s3.clj
+++ src/braid/lib/s3.clj
@@ -54,7 +54,7 @@
                 :credential credential
                 :date date}}))))

-(defn get-signature
+(defn- get-signature
   [config utc-now path query-str]
   (let [{:keys [region api-secret bucket]} config]
     (->> ["AWS4-HMAC-SHA256"


[Remove] func bipolar-sigmoid

[Remove] func bipolar-sigmoid


[Add] pre-condition reftype

[Add] pre-condition reftype

--- src/clj_elm/core.clj
+++ src/clj_elm/core.clj
@@ -111,12 +111,12 @@
        (sign))))

 (defn update-exp [fn key exp]
-  {:pre [(fn? fn) (keyword? key) (map? @exp)]}
+  {:pre [(fn? fn) (keyword? key) (reftype? exp) (map? @exp)]}
   (reset! exp (assoc @exp key (fn (key @exp))))
   exp)

 (defn count-rate [pred fact exp]
-  {:pre [(= (Math/abs pred) (Math/abs fact) 1) (map? @exp)]}
+  {:pre [(= (Math/abs pred) (Math/abs fact) 1) (reftype? exp) (map? @exp)]}
   (match [pred fact]
     [ 1  1] (update-exp inc :TP exp)
     [ 1 -1] (update-exp inc :FP exp)
@@ -124,7 +124,7 @@
     [-1  1] (update-exp inc :FN exp)))

 (defn confusion-matrix [preds facts exp]
-  {:pre [(coll? preds) (coll? facts) (map? @exp)]}
+  {:pre [(coll? preds) (coll? facts) (reftype? exp) (map? @exp)]}
   (if (or (empty? preds) (empty? facts))
     (let [TP (:TP @exp) FP (:FP @exp)
           TN (:TN @exp) FN (:FN @exp)]
@@ -138,7 +138,7 @@

 (defn evaluation
   ([results facts exp]
-   {:pre [(coll? results) (coll? facts) (map? @exp)]}
+   {:pre [(coll? results) (coll? facts) (reftype? exp) (map? @exp)]}
    (let [numd (count results)]
      (confusion-matrix results facts exp))))

@@ -164,16 +164,17 @@
          (#(pmap (fn [feature] (predict % feature)) (:features test)))
          (#(evaluation (:classes test) % exp))))))

-(defn print-exp-data [expdata]
-  (print "L: " (:L expdata) "\n"
-         "length(train_negative): " (:length-train-negative expdata) "\n"
-         "length(test_negative): " (:length-test-negative expdata) "\n"
-         "length(train_positive): " (:length-train-positive expdata) "\n"
-         "length(test_positive): " (:length-test-positive expdata) "\n"
-         "TP: " (:TP expdata) ", FP: " (:FP expdata) ", TN: " (:TN expdata) ", FN: " (:FN expdata) "\n"
-         "Accracy: " (:Accuracy expdata "\n")
-         "Recall: " (:Recall expdata "\n")
-         "Precision: " (:Precision expdata) "\n\n"))
+(defn print-exp-data [exp]
+  {:pre [(reftype? exp) (map? @exp)]}
+  (print "L: " (:L exp) "\n"
+         "length(train_negative): " (:length-train-negative exp) "\n"
+         "length(test_negative): " (:length-test-negative exp) "\n"
+         "length(train_positive): " (:length-train-positive exp) "\n"
+         "length(test_positive): " (:length-test-positive exp) "\n"
+         "TP: " (:TP exp) ", FP: " (:FP exp) ", TN: " (:TN exp) ", FN: " (:FN exp) "\n"
+         "Accracy: " (:Accuracy exp "\n")
+         "Recall: " (:Recall exp "\n")
+         "Precision: " (:Precision exp) "\n\n"))

 (defn cross-validate
   ([dataset L k]
@@ -187,7 +188,6 @@
                    (:Accuracy eva)))
           (reduce +)
           (* (/ 1 k))))))
-

 (defn -main [& args]
   (if (= (count args) 8)


Validate repo files in resolve-locations

--- src/degasolv/cli.clj
+++ src/degasolv/cli.clj
@@ -149,8 +149,24 @@
        (map
          (fn slurp-url
            [url]
-           (edn/read-string
-             (default-slurp url)))
+           (let
+             [repo-data
+              (edn/read-string
+                (default-slurp url))
+              vetted-repo-data
+              (s/conform
+                ::r/map-repo
+                repo-data)]
+             (when (= ::s/invalid vetted-repo-data)
+               (throw (ex-info
+                        (str
+                          "Invalid requirement string in repo `"
+                          url
+                          "`: "
+                          (s/explain ::r/map-repo repo-data))
+                        (s/explain-data ::r/map-repo
+                                        repo-data))))
+             repo-data))
          repositories))
      result
      (resolve-dependencies


cleaning the repl api further

cleaning the repl api further

--- sidecar/src/figwheel_sidecar/system.clj
+++ sidecar/src/figwheel_sidecar/system.clj
@@ -145,7 +145,7 @@
   configuration contains an :nrepl-port key.

   This takes a figwheel configuration consisting
-  of :fighweel-options, :all-builds, and :build-ids.
+  of :figwheel-options, :all-builds, and :build-ids.

   If you only have a few components to add to this system then you can
   assoc them onto the created system before you start like so.
@@ -488,51 +488,63 @@
                     build)))
         (get builds (choose-repl-build-id system)))))

-(defn figwheel-cljs-repl* [system {:keys [build-id repl-options]}]
+(defn figwheel-cljs-repl* [system build-id repl-options]
   (when-let [build (choose-repl-build @system build-id)]
      (start-figwheel-repl system build repl-options)))

-(defn build-switching-cljs-repl* [system start-build-id]
+(defn build-switching-cljs-repl* [system start-build-id repl-options]
   (if (frepl/in-nrepl-env?)
-    (figwheel-cljs-repl* system start-build-id) ;; no build switching
+    (figwheel-cljs-repl* system start-build-id repl-options) ;; no build switching
     (loop [build-id start-build-id]
-      (figwheel-cljs-repl* system {:build-id build-id})
+      (figwheel-cljs-repl* system build-id repl-options)
       (let [builds (get-in @system [:figwheel-server :builds])]
         (when-let [chosen-build-id
                    (get-build-choice
                     (keep :id (filter config/optimizations-none? (vals builds))))]
           (recur chosen-build-id))))))

+(defn initial-repl-focus-build-id [system]
+  (when-let [build-key (first (all-build-keys system))]
+    (key->id build-key)))
+
 (defn cljs-repl*
   ([system] (cljs-repl* system nil))
-  ([system start-build-id]
-   (if (frepl/in-nrepl-env?)
-     (figwheel-cljs-repl* system {:build-id start-build-id})
-     (build-switching-cljs-repl* system start-build-id))))
+  ([system start-build-id] (cljs-repl* system nil {}))
+  ([system start-build-id repl-options]
+   (let [build-id (or
+                   start-build-id
+                   (initial-repl-focus-build-id @system))]
+     (if (frepl/in-nrepl-env?)
+       (figwheel-cljs-repl* system build-id repl-options)
+       (build-switching-cljs-repl* system build-id repl-options)))))

 ;; takes a FigwheelSystem
 (defn figwheel-cljs-repl
   ([figwheel-system]
    (figwheel-cljs-repl figwheel-system nil))
-  ([{:keys [system]} build-id]
-   (figwheel-cljs-repl* system {:build-id build-id})))
+  ([figwheel-system build-id]
+   (figwheel-cljs-repl figwheel-system build-id {}))
+  ([{:keys [system]} build-id repl-options]
+   (figwheel-cljs-repl* system build-id repl-options)))

 ;; takes a FigwheelSystem this will not work for nrepl
 (defn build-switching-cljs-repl
   ([figwheel-system] (build-switching-cljs-repl figwheel-system nil))
-  ([{:keys [system]} start-build-id]
-   (build-switching-cljs-repl* system start-build-id)))
-
-(defn initial-repl-focus-build-id [system]
-  (when-let [build-key (first (all-build-keys system))]
-    (key->id build-key)))
+  ([figwheel-system start-build-id]
+   (build-switching-cljs-repl figwheel-system start-build-id {}))
+  ([{:keys [system]} start-build-id repl-options]
+   (build-switching-cljs-repl* system start-build-id repl-options)))

 (defn cljs-repl
-  ([{:keys [system]}] (cljs-repl* system nil))
-  ([{:keys [system]} start-build-id] (cljs-repl* system
-                                                 (or
-                                                  start-build-id
-                                                  (initial-repl-focus-build-id @system)))))
+  ([figwheel-system] (cljs-repl figwheel-system nil {}))
+  ([figwheel-system start-build-id]
+   (cljs-repl figwheel-system start-build-id {}))
+  ([{:keys [system]} start-build-id repl-options]
+   (cljs-repl* system
+               (or
+                start-build-id
+                (initial-repl-focus-build-id @system))
+               repl-options)))

 ;; figwheel starting and stopping helpers


Looks nice for both NORMAL and DEBUG log levels

--- src/hangman/core.clj
+++ src/hangman/core.clj
@@ -299,4 +299,3 @@

 (defn -main [& args]
   (time (apply main args)) )
-


Removing the cancel aside cancel link.

Removing the cancel aside cancel link.

Cancelling will be done via the pricing page.

--- src-cljs/frontend/components/aside.cljs
+++ src-cljs/frontend/components/aside.cljs
@@ -261,9 +261,7 @@
       (when (pm/transferrable-or-piggiebackable-plan? plan)
         [{:type :subpage :title "Organizations" :href "#organizations" :subpage :organizations}])
       (when (or (pm/paid? plan) (pm/osx? plan))
-        [{:type :subpage :title "Billing info" :href "#billing" :subpage :billing}])
-      (when (pm/paid? plan)
-        [{:type :subpage :title "Cancel" :href "#cancel" :subpage :cancel}])))
+        [{:type :subpage :title "Billing info" :href "#billing" :subpage :billing}])))
    [{:type :heading :title "Organization"}
     {:type :subpage :href "#projects" :title "Projects" :subpage :projects}
     {:type :subpage :href "#users" :title "Users" :subpage :users}]))


Bump figwheel-server version

Bump figwheel-server version

--- re-view-template/resources/leiningen/new/re_view/project.clj
+++ re-view-template/resources/leiningen/new/re_view/project.clj
@@ -22,7 +22,7 @@
             :figwheel {:ring-handler figwheel-server.core/handler
                        :server-port  {{port}}}

-            :profiles {:dev {:dependencies [[figwheel-pushstate-server "0.1.1-SNAPSHOT"]]}}
+            :profiles {:dev {:dependencies [[figwheel-pushstate-server "0.1.2"]]}}

             :cljsbuild {:builds [{:id           "dev"
                                   :source-paths ["src"]


We now delete. Just missing tags

We now delete. Just missing tags

--- src/ardoq/swagger/update_swagger2.clj
+++ src/ardoq/swagger/update_swagger2.clj
@@ -30,19 +30,20 @@
           {}
           definitions))

-(defn create-or-update-operation [client {parent :component} {_id :_id :as model} wid path methods tags defs resource components]
+(defn create-or-update-operation [client {parent :component} {_id :_id :as model} wid path methods tags defs components]
   (doseq [child (:children parent)]
-    ;;We need to find if the name of the children parent and check if they fit with path+method
-    ;;If we got a child thats ont in the path+method list it should get deleted.
-    ;;Something link filtering the list of childs towards components then checking the name of each towards methods.
-    "This"
-    )
+    (let [resource (first (filter #(= (:_id %) child) components))]
+      (when-not (first (filter #(= (str (name path) "/" (name %)) (:name resource)) (keys methods)))
+        (println "Deleting!")
+        (println (:name resource))
+        (api/delete (api/map->Component resource) client)
+        )))
   (doall (keep
           (fn [[method-name method]]
             (if (not (= method-name (keyword "parameters")))
               (or (some-> (first (filter #(and
-                                           (= (:parent %) (:_id resource))
-                                           (= (str (:name resource) "/" (name method-name)) (:name %)))
+                                           (= (:parent %) (:_id parent))
+                                           (= (str (:name parent) "/" (name method-name)) (:name %)))
                                          components))
                           (assoc :description (common/generate-operation-description method defs))
                           (api/map->Component)
@@ -74,7 +75,7 @@
                 :paramters parameters
                 :component (-> (api/->Component path (or description "") (str wid) _id (api/type-id-by-name model "Resource") nil)
                     (api/create client))}
-        op (create-or-update-operation client parent model wid path methods tags defs nil nil)]
+        op (create-or-update-operation client parent model wid path methods tags defs nil)]
     (refs/create-resource-refs client parent params)
     (refs/create-refs client op defs securs)
     parent))
@@ -93,7 +94,7 @@
                 :component (-> (api/map->Component resource)
                                (api/update client))}
         ;;Create or update op here
-        op (create-or-update-operation client parent model wid path methods tags defs resource (:components workspace))]
+        op (create-or-update-operation client parent model wid path methods tags defs (:components workspace))]
     (refs/create-resource-refs client parent params)
     (refs/create-refs client op defs securs)
     parent))


CMR-1892: Fixed bug in options

CMR-1892: Fixed bug in options

--- search-app/src/cmr/search/services/parameters/conversion.clj
+++ search-app/src/cmr/search/services/parameters/conversion.clj
@@ -129,7 +129,7 @@

 (defmethod parameter->condition :keyword
   [_ _ value _]
-    (qm/text-condition :keyword (str/lower-case value)))
+  (qm/text-condition :keyword (str/lower-case value)))

 ;; Special case handler for concept-id. Concept id can refer to a granule or collection.
 ;; If it's a granule query with a collection concept id then we convert the parameter to :collection-concept-id
@@ -320,10 +320,11 @@
      :result-features (seq result-features)
      :echo-compatible? echo-compatible?
      :all-revisions? all-revisions?
-     :highlights-options {:begin-tag begin-tag
-                          :end-tag end-tag
-                          :snippet-length (when snippet-length (Integer. snippet-length))
-                          :num-fragments (when num-fragments (Integer. num-fragments))}}))
+     :highlights-options (when (or begin-tag end-tag snippet-length num-fragments)
+                           {:begin-tag begin-tag
+                            :end-tag end-tag
+                            :snippet-length (when snippet-length (Integer. snippet-length))
+                            :num-fragments (when num-fragments (Integer. num-fragments))})}))

 (defn parse-parameter-query
   "Converts parameters into a query model."


prevent https redirect loops on heroku

prevent https redirect loops on heroku

--- src/clj/conference_rating/handler.clj
+++ src/clj/conference_rating/handler.clj
@@ -105,9 +105,14 @@
    (GET "/" [] home-page)
    (not-found "Not Found")))

+(defn ring-settings [ssl-redirect-disabled]
+  (-> secure-api-defaults
+      (assoc-in [:security :ssl-redirect] (not ssl-redirect-disabled))
+      (assoc :proxy true)))
+
 (defn app [db ssl-redirect-disabled]
   (let [handler (-> (create-routes db)
-                    (wrap-defaults (assoc-in secure-api-defaults [:security :ssl-redirect] (not ssl-redirect-disabled)))
+                    (wrap-defaults (ring-settings ssl-redirect-disabled))
                     (json/wrap-json-response)
                     (json/wrap-json-body {:keywords? true}))]
     (if (env :dev) (-> handler


Issue #14 make convert-method hash-map.

Issue #14 make convert-method hash-map.

--- src/clj/http/async/client/request.clj
+++ src/clj/http/async/client/request.clj
@@ -39,17 +39,14 @@

 (def *CLIENT* nil)

-(defn- convert-method [method]
-  "Converts clj method (:get, :put, ...) to Async Client specific.
-   Defaults to :get"
-  (cond
-   (= method :get) "GET"
-   (= method :post) "POST"
-   (= method :put) "PUT"
-   (= method :delete) "DELETE"
-   (= method :head) "HEAD"
-   (= method :options) "OPTIONS"
-   :default "GET"))
+(def convert-method
+  ^{:doc   "Converts clj method (:get, :put, . ..) to Async Client specific."}
+  {:get     "GET"
+   :post    "POST"
+   :put     "PUT"
+   :delete  "DELETE"
+   :head    "HEAD"
+   :options "OPTIONS"})

 (defn get-encoding
   "Gets content encoding from headers, if Content-Type header not present


Fix copyright year on middleware ns.

Fix copyright year on middleware ns.

--- src/clojure/buddy/auth/middleware.clj
+++ src/clojure/buddy/auth/middleware.clj
@@ -1,4 +1,4 @@
-;; Copyright 2013 Andrey Antukh <niwi@niwi.be>
+;; Copyright 2013-2015 Andrey Antukh <niwi@niwi.be>
 ;;
 ;; Licensed under the Apache License, Version 2.0 (the "License")
 ;; you may not use this file except in compliance with the License.


Removed comment that resulted in compile time error

--- src/ofdb/service.clj
+++ src/ofdb/service.clj
@@ -48,7 +48,7 @@
   ([] @products)
   ([name] (filter #(re-matches (re-pattern (str ".*" name ".*")) (:name %)) (getproducts))))

-#_(defn addproduct [http_request])
+(defn addproduct [http_request])

 #_(defn add_product [product] (swap! products conj product))


Store system in an atom instead of using def and alter-var-root

Mostly, I just think this looks better.

--- src/clj/com/matthiasnehlsen/inspect.clj
+++ src/clj/com/matthiasnehlsen/inspect.clj
@@ -10,10 +10,12 @@
    [clj-time.format :as f]
    [clojure.core.async :as async :refer [<! chan put! mult tap pub sub timeout go-loop sliding-buffer]]))

+;; in-chan is multiplied into event-mult. That way, the matcher component can attach on start and detach on stop.
+;; With no channel tapped into the data, the messages are simply dropped.
 (def in-chan (chan (sliding-buffer 10000)))
 (def event-mult (mult in-chan))

-(def built-in-formatter (f/formatters :date-time))
+(def built-in-formatter (f/formatters :date-time)) ; used for timestamping the inspected messages

 (defn inspect
   "Send message to inspect sub-system with msg-type. Only does anything when system active"
@@ -29,19 +31,19 @@
    :http    (component/using (http/new-http-server conf) {:matcher :matcher})))

 ;; system with default port
-(def system (get-system {:port 8000}))
+(def system (atom (get-system {:port 8000})))

 (defn configure
   "override system with specified config (currently only :port)"
   [conf]
-  (def system (get-system conf)))
+  (reset! system (get-system conf)))

 (defn start
-  "start the inspect system and set active atom to true"
+  "start the inspect system"
   []
-  (alter-var-root #'system component/start))
+  (swap! system component/start))

 (defn stop
-  "stop the inspect system and set active atom to false"
+  "stop the inspect system"
   []
-  (alter-var-root #'system (fn [s] (when s (component/stop s)))))
+  (swap! system (fn [s] (when s (component/stop s)))))


Prepare registrerte kjøretøy diagram

Prepare registrerte kjøretøy diagram

--- src/clj_simple_chart/ssb/data/elbil.clj
+++ src/clj_simple_chart/ssb/data/elbil.clj
@@ -11,7 +11,7 @@

 (def data (->> (ssb/fetch 7849 {"Region"                        "Hele landet"
                                 "KjoringensArt"                 "Egentransport"
-                                [:DrivstoffType :as :drivstoff] ["El." "Bensin" "Diesel" "Annet drivstoff"]
+                                [:DrivstoffType :as :drivstoff] "*"
                                 [:ContentsCode :as :antall]     "Personbiler"
                                 [:Tid :as :dato]                "*"})
                (drop-columns [:Region :KjoringensArt :ContentsCodeCategory])
@@ -20,12 +20,9 @@
                ;(map #(update % :dato (fn [d] (str d "-12"))))
                (column-value->column :drivstoff)
                (contract-by-column :dato)
+               (drop-columns [:parafin :gass])
                (div-by 1000)
-               ;(map #(assoc % :el-hybrid (+ (:elektrisk %) (:annet %))))
-               ;(drop-columns [:elektrisk :annet])
-               (add-sum-column)
-               ;(add-relative-share)))
-               (yoy-change)))
+               (add-sum-column)))

 (def fossil (->> (ssb/fetch 7849
                             {"Region" "Oslo"


Add :created-at to build-resume-point parameter schema (#873)

--- src/onyx/schema.cljc
+++ src/onyx/schema.cljc
@@ -833,7 +833,7 @@
    :log-version s/Str})

 (s/defschema ResumeCoordinate
-  {:replica-version ReplicaVersion :epoch Epoch :tenancy-id TenancyId :job-id JobId})
+  {:replica-version ReplicaVersion :epoch Epoch :tenancy-id TenancyId :job-id JobId :created-at s/Int})

 (s/defschema LogEntry
   {:fn s/Keyword


Refactor export-button

Refactor export-button

--- src/cljs/koeeoadi/components/theme.cljs
+++ src/cljs/koeeoadi/components/theme.cljs
@@ -154,18 +154,22 @@

           (dom/i #js {:className "fa fa-edit fa-2x"}))))))

-(defn theme-export-button [theme-name button-text]
+(def export-button-text
+  {:emacs "Emacs (GUI Only)"
+   :vim "VIM (GUI Only)"})
+
+(defn theme-export-button [theme-name editor]
   (dom/button
     #js {:className "export-button"
-         :onClick   #(export-theme-file theme-name :emacs)}
-    button-text))
+         :onClick   #(export-theme-file theme-name editor)}
+    (editor export-button-text)))

 (defn theme-export [comp]
   (let [theme-name (:theme/name (om/props comp))]
     (dom/div #js {:className "row"}
       (dom/label nil "Export: ")
-      (theme-export-button theme-name "Emacs (GUI only)")
-      (theme-export-button theme-name "Vim (GUI only)"))))
+      (theme-export-button theme-name :emacs)
+      (theme-export-button theme-name :vim))))

 (defui Theme
   static om/IQuery


trying new ideas for transition computations

--- src/cljs/triboard/logic/transition.cljs
+++ src/cljs/triboard/logic/transition.cljs
@@ -37,19 +37,10 @@
   [x y]
   (and (< -1 x board/width) (< -1 y board/height)))

-;; TODO - Completely change the algorithm (solution 1):
-;; - We only need one pass... for each dimention
-;; - partition-by to get the zones of same color
-;; - partition size 3 step 1 to get the surroundings
-;; - filter on "one side exactly is :none" and you get the jumps
-
-;; TODO - Completely change the algorithm (solution 2):
-;; Search from the cells owned by a player... allows more incremental mode
-
 (defn- seek-jump-source-toward
   "Starting from the destination of a jump (an empty cell):
    * Search for valid source for the jump
-   * Collect the jumped cells along the way"                ;; TODO - Separate this? (could be faster)
+   * Collect the jumped cells along the way"
   [board [x-init y-init :as destination] [dx dy]]
   (loop [x (+ x-init dx)
          y (+ y-init dy)
@@ -135,7 +126,7 @@
   (let [b benchmark-board
         t (all-transitions b)]
     (time (dotimes [i 100] (all-transitions b)))
-    ;; TODO - 12300 turns in loop (55 ms for a transduce) => need better algo
+    ;; TODO - 122700 turns in loop for 100 iterations (6.5 ms for a transduce) => need better algo
     ;; The add-destination removal makes us gain around 50 ms
     ;; Getting rid of the systematic conj does not win anything
     ;; One dimentional array could gain us only 2-3 ms
@@ -147,3 +138,80 @@
                 ))
             ))
     ))
+
+;; -----------------------------------------
+;; Random experiments
+;; -----------------------------------------
+
+;; TODO - Completely change the algorithm (solution 1):
+;; - We only need one pass... for each dimention
+;; - partition-by to get the zones of same color
+;; - partition size 3 step 1 to get the surroundings
+;; - filter on "one side exactly is :none" and you get the jumps
+
+;; TODO - Completely change the algorithm (solution 2):
+;; Search from the cells owned by a player... allows more incremental mode
+
+
+#_(let [b (board/new-board)]
+    (time
+      (dotimes [i 100]
+        (doall (partition-by
+                 second
+                 (map
+                   (fn [c] [c (board/get-cell-at b c)])
+                   board/coordinates))))))
+
+
+#_(def columns
+  (mapv
+    (fn [x] (mapv vector (repeat x) (range board/height)))
+    (range board/width)))
+
+#_(def rows
+  (apply mapv vector columns))
+
+#_(defn jumpables
+  [board [x-init y-init :as init-coord] [dx dy :as direction]]
+  (loop [prev (board/get-cell-at board init-coord)
+         prev-pos init-coord
+         x (+ x-init dx)
+         y (+ y-init dy)
+         jumps []]
+    (if-not (in-board? x y)
+      jumps
+      (let [curr (board/get-cell-at board [x y])]
+        (if (= curr prev)
+          (recur prev prev-pos (+ x dx) (+ y dy) jumps)
+          (recur curr [x y] (+ x dx) (+ y dy)
+            (conj jumps
+              {:start prev-pos
+               :end [(- x dx) (- y dy)]
+               :owner prev}))
+          ))
+      )))
+
+
+
+#_(defn test-new-algo
+  []
+  (let [b (board/new-board)]
+    (keep (fn [[p c n]]
+            (cond
+              (and (player/player? (:owner p)) (= :none (:owner n)))
+              {:winner (:owner p)
+               :looser (:owner c)
+               :destination (:start n)
+               :taken []}
+
+              (and (player/player? (:owner n)) (= :none (:owner p)))
+              {:winner (:owner n)
+               :looser (:owner c)
+               :destination (:end p)
+               :taken []}
+
+              :else nil)
+            )
+      (partition 3 1 (jumpables b [0 0] [0 1])))
+    ))
+


Allow nil as valid return value

Allow nil as valid return value

--- src/com/palletops/api_builder/stage.clj
+++ src/com/palletops/api_builder/stage.clj
@@ -154,7 +154,9 @@
                                         ~(last elements))
                                       elements)))
                       (update-in [:post] (fnil conj [])
-                                 `(schema/validate ~(:return sig) ~'%))))))
+                                 `(or (schema/validate ~(:return sig) ~'%)
+                                      ;; nil could be valid
+                                      true))))))

 (defn sig-map
   "Take a sig element and convert it into a map."


Safe binding for *print-length*

Safe binding for *print-length*

--- src/pamela/utils.clj
+++ src/pamela/utils.clj
@@ -46,27 +46,28 @@
 ;; file-format's supported: edn json string
 ;; if input is a map, sort it
 (defn output-file [filename file-format data]
-  (let [is-stdout? (stdout? filename)
-        filename (if (and (not is-stdout?) (string? filename))
-                   (fs/expand-home filename)
-                   filename)
-        output-filename (if (not is-stdout?)
-                          (if (fs/absolute? filename)
-                            (fs/file filename)
-                            (fs/file (get-cwd) filename)))
-        data (if (map? data)
-               (into (sorted-map) data)
-               data)
-        out (cond
-              (= file-format "edn")
-              (with-out-str (pprint data))
-              (= file-format "json")
-              (with-out-str (json/pprint data))
-              :else
-              data)]
-    (if is-stdout?
-      (println out)
-      (spit output-filename out))))
+  (binding [*print-length* nil] ;;Just in case someone has this set in their environment
+    (let [is-stdout? (stdout? filename)
+          filename (if (and (not is-stdout?) (string? filename))
+                     (fs/expand-home filename)
+                     filename)
+          output-filename (if (not is-stdout?)
+                            (if (fs/absolute? filename)
+                              (fs/file filename)
+                              (fs/file (get-cwd) filename)))
+          data (if (map? data)
+                 (into (sorted-map) data)
+                 data)
+          out (cond
+                (= file-format "edn")
+                (with-out-str (pprint data))
+                (= file-format "json")
+                (with-out-str (json/pprint data))
+                :else
+                data)]
+      (if is-stdout?
+        (println out)
+        (spit output-filename out)))))

 (defn input-file [filename]
   (let [is-stdin? (stdout? filename)


Show HA starts as well as current positions

--- src/player/core.cljs
+++ src/player/core.cljs
@@ -39,7 +39,7 @@
   {:width         320
    :height        240
    :camera-width  320
-   :camera-height 120
+   :camera-height 240
    :scroll-x      0
    :scroll-y      0
    :walls         {0 {:type :white :x 0 :y 0 :w 256 :h 8}
@@ -48,22 +48,28 @@
                    3 {:type :white :x 160 :y 8 :w 8 :h 16}}
    :objects       {:ga {:type  :goomba
                         :state :right
-                        :x     8 :y 8}
+                        :x     8 :y 8
+                        :w     16 :h 16}
                    :gb {:type  :goomba
                         :state :right
-                        :x     32 :y 8}
+                        :x     32 :y 8
+                        :w     16 :h 16}
                    :gc {:type  :goomba
                         :state :right
-                        :x     12 :y 35}
+                        :x     12 :y 35
+                        :w     16 :h 16}
                    :gd {:type  :goomba
                         :state :right
-                        :x     64 :y 8}
+                        :x     64 :y 8
+                        :w     16 :h 16}
                    :ge {:type  :goomba
                         :state :right
-                        :x     96 :y 32}
+                        :x     96 :y 32
+                        :w     16 :h 16}
                    :m  {:type  :mario
                         :state :idle-right
-                        :x     200 :y 8}}})
+                        :x     200 :y 8
+                        :w     16 :h 16}}})

 (set! heval/frame-length (/ 1 30))
 (set! heval/time-units-per-frame 10000)
@@ -101,7 +107,7 @@
         new-seen (roll/see-config (:seen-configs world) config)]
     (assoc world :configs new-configs
                  :seen-configs new-seen
-                 ;:explored #{}
+                 :explored #{}
                  :now (:entry-time config))))

 (defn reset-world [w]
@@ -646,6 +652,7 @@
                                      ha-defs (:ha-defs wld)
                                      cfg (current-config wld)
                                      has (:objects cfg)
+                                     ha-starts (:objects desc)
                                      polys (apply concat (vals (:seen-polys wld)))

                                      editor (get props :editor)
@@ -684,8 +691,8 @@
                                                                               (fn [w]
                                                                                (let [[sx sy] (view->world props (.-scrollLeft n) (+ (.-scrollTop n) container-h))]
                                                                                #_(println "update from scroll:"
-                                                                                (.-scrollLeft n) (+ (.-scrollTop n) container-h)
-                                                                                "->" sx sy)
+                                                                                (.-scrollLeft n) (+ (.-scrollTop n) container-h)
+                                                                                "->" sx sy)
                                                                                (assoc w :scroll-x sx
                                                                                :scroll-y sy))))))}
                                             [:svg {:width               (* world-w x-scale)
@@ -712,6 +719,27 @@
                                                       ;todo: grab handles
                                                       ])
                                                    (:walls desc))]
+                                             [:g {:key "object-starts"}
+                                              (map (fn [[id {x :x y :y w :w h :h state :state}]]
+                                                     [:g {:key id :opacity "0.25"}
+                                                      [:rect {:x     x :y (- world-h h y)
+                                                              :width w :height h
+                                                              :fill  "brown"
+                                                              :key   "sprite"}]
+                                                      (when (contains? sel [:objects id])
+                                                        [:rect {:x            x :y (- world-h h y)
+                                                                :width        w :height h
+                                                                :fill         "url(#diagonal-stripe-1)"
+                                                                :opacity      "0.5"
+                                                                :stroke       "black"
+                                                                :stroke-width 2
+                                                                :key          "selected"}])
+                                                      [:text {:width    200 :x x :y (- world-h y 5)
+                                                              :fontSize 8
+                                                              :fill     "lightgrey"
+                                                              :key      "name"}
+                                                       (str id " " state)]])
+                                                   ha-starts)]
                                              [:g {:key "objects"}
                                               (map (fn [{{x :x y :y w :w h :h} :v0 id :id :as ha}]
                                                      [:g {:key id}


Fix misplaced doc string. Thanks Eastwood!

--- src/posthere/app.clj
+++ src/posthere/app.clj
@@ -21,8 +21,9 @@
 ;; Reload code dynamically with each web request in development
 (defonce hot-reload (or (env :hot-reload) false))

-(defn- route-for [request]
+(defn- route-for
   "Get the URL for the request from a ring request map."
+  [request]
   (get-in request [:route-params :*]))

 (defn- strip-prefix-slash


Update data.cljs

Update data.cljs

I've put the bit about predicted range on a separate line and added the bit about all survival rates are high. This is the key point I think that they wanted highlighted in the parent workshop. Can we highlight in pink like for key points?

--- src/prais2/data.cljs
+++ src/prais2/data.cljs
@@ -562,8 +562,10 @@
               "(0-16 years old). "
               "This data is updated annually and covers the most recent 3 year report period.")]
      [:p "Previous reporting periods can be selected at the bottom of the table.
-    Clicking on a hospital code will bring up specific information for that hospital along with an interpretation of its survival rate. It is only valid to compare a hospital's survival rate to its predicted range and not to other hospitals [link to Everything Else]."]
+    Clicking on a hospital code will bring up specific information for that hospital along with an interpretation of its survival rate. "]
      [:p "You can use your mouse to hover over the chart to bring up more explanation."]
+     [:p "It is only valid to compare a hospital's survival rate to its predicted range and not to other hospitals [link to Everything Else]. The survival rate for all hospitals is very high."]
+
      ]
     (table1 app data event-bus)]])


style updates for hero unit and screenshot layout

--- frontend/components/language_landing.cljs
+++ frontend/components/language_landing.cljs
@@ -13,7 +13,7 @@
   (:require-macros [frontend.utils :refer [defrender html]]))

 (defn arrow-class [selected-testimonial]
-  (case selected-testimonial
+  (case selected-testimonial
     0 "arrowLeft"
     1 "arrowCenter"
     2 "arrowRight"
@@ -62,8 +62,9 @@
                  [:div.languages-head
                   [:img {:src (:logo-path template)}]
                   [:h1 (:headline template)]
-                  [:div.languages-screenshots]]
-                 [:div.languages-body.remove-margin
+                  [:div.languages-screenshots]
+                  [:div.hero-shadow]]
+                 [:div.languages-body
                   [:div.languages-features
                    [:div.center-text
                     [:h3 "FEATURES"
@@ -71,7 +72,7 @@
                     ]
                    (map-indexed
                      (fn [i feature] [feature (:features template)]
-                       (if (odd? i)
+                       (if (odd? i)
                          [:div.feature
                           [:div.feature-image
                            [:img {:src (:icon feature)}]
@@ -79,28 +80,28 @@
                           [:div.feature-copy
                            [:h4.feature-title (:title feature)
                             ]
-                           [:p.feature-description (:feature feature)]
+                           [:p.feature-description (:feature feature)]
                            ]
-
+
                           ]
                          [:div.feature
                           [:div.feature-copy
                            [:h4.feature-title (:title feature)
                             ]
-                           [:p.feature-description (:feature feature)]
+                           [:p.feature-description (:feature feature)]
                            ]
                           [:div.feature-image
                            [:img {:src (:icon feature)}]
                            ]
                           ]))
                      (:features template))
-
-                   [:div.button
+
+                   [:div.button
                     [:a {:href (:docs-link template)} "Read documentation on " (:language template)]]
                    ]
                   ]
                  [:div.languages-testimonials {:class (arrow-class selected-testimonial)}
-                  [:div.languages-body.remove-margin
+                  [:div.languages-body
                    [:div.center-text
                     [:h3 "TESTIMONIALS"
                      ]
@@ -108,31 +109,31 @@
                    [:div.testimonial-authors
                     (map-indexed (fn [i testimonial] [:img {:src (:img testimonial) :on-click #(put! controls-ch [:language-testimonial-tab-selected {:index i}])}])
                                  (:testimonials template))]
-                   [:div.testimonial-box
+                   [:div.testimonial-box
                     [:div.testimonial
                      [:p.testimonial-text (get-in template [:testimonials selected-testimonial :text])]
-
+
                      [:div.testimonial-author "—" (get-in template [:testimonials selected-testimonial :author])]
                      [:div.testimonial-author-title (get-in template [:testimonials selected-testimonial :title])]]
                     ]
                    ]
                   ]
-
+
                  [:div.languages-cta
                   [:div.languages-body
                    [:h3
-                    "How do I start using my " (:language template) " app with CircleCI?"]
+                    "How do I start using my " (:language template) " app with CircleCI?"]
                    [:div.languages-cta-steps
                     [:div.languages-cta-step
                      [:div.step-number "1"]
                      [:div
                       "Start by signing up "
-                      [:br]
+                      [:br]
                       "using GitHub"]
                      ]
                     [:div.languages-cta-step
                      [:div.step-number "2"]
-                     [:div
+                     [:div
                       "Run one of your Ruby projects on Circle"]]
                     [:div.languages-cta-step
                      [:div.step-number "3"]
@@ -151,5 +152,5 @@
                     [:div.language-cta-trial "14-day free trial"]
                     ]
                    ]]
-
+
                  ])))))


Add explanatory text

Add explanatory text

--- frontend/components/project_settings.cljs
+++ frontend/components/project_settings.cljs
@@ -1103,8 +1103,14 @@
             input-path (fn [& ks] (apply conj state/inputs-path :aws :keypair ks))]
         (html
          [:div.aws-page
-          [:h2 "AWS settings for " (vcs-url/project-name (:vcs_url project))]
+          [:h2 "AWS keys for " (vcs-url/project-name (:vcs_url project))]
           [:div.aws-page-inner
+           [:p "Set your AWS keypair to be used for authenticating against AWS services during your build. "
+            "Credentials are installed on your containers into the " [:code "~/.aws/config"] " and "
+            [:code "~/.aws/credentials"] " properties files. These are read by common AWS libraries such as "
+            [:a {:href "http://aws.amazon.com/documentation/sdk-for-java/"} "the Java SDK"] ", "
+            [:a {:href "https://boto.readthedocs.org/en/latest/"} "Python's boto"] ", and "
+            [:a {:href "http://rubygems.org/gems/aws-sdk"} "the Ruby SDK"] "."]
            [:form
             [:input#access-key-id
              {:required true, :type "text", :value (or access_key_id "")