refactored gzip middleware to remove at least some serious bugs

--- src/clojure/picard/middleware/gzip.clj
+++ src/clojure/picard/middleware/gzip.clj
@@ -16,6 +16,7 @@
     ChannelBuffers]))

 (def header-length (alength GzipUtils/header))
+(def trailer-length 8)

 (defn body->byte-array
   [body]
@@ -34,13 +35,15 @@

 (defn- mk-trailer
   [deflater crc]
-  (let [buf (byte-array 8)]
+  (let [buf (byte-array trailer-length)]
     (GzipUtils/writeTrailer deflater crc buf 0)
     buf))

 (defn- gzip-entire-body
-  [deflater crc body]
-  (let [baos (ByteArrayOutputStream.)
+  [body]
+  (let [deflater (Deflater. Deflater/DEFAULT_COMPRESSION true)
+        crc (CRC32.)
+        baos (ByteArrayOutputStream.)
         buf (byte-array 4092)
         bytes (body->byte-array body)]
     ;; write header
@@ -70,14 +73,14 @@
   (let [buf-len (alength buf)]
     (loop []
       (let [compressed-bytes (.deflate deflater buf 0 buf-len)]
-        (if-not (= 0 compressed-bytes)
+        (when-not (= 0 compressed-bytes)
           (let [channel-buffer (ChannelBuffers/copiedBuffer buf 0 compressed-bytes)]
             (downstream :body channel-buffer)
             (recur)))))))

-(defn- gzip-and-send
-  [state crc deflater downstream compressed-byte-buffer chunk]
-  (let [buffer-length (alength compressed-byte-buffer)
+(defn- gzip-and-send-chunk
+  [state downstream chunk deflater crc buf]
+  (let [buffer-length (alength buf)
         sent-header (:sent-header @state)]
     ;; update the crc and set the input
     (if (nil? chunk)
@@ -92,7 +95,7 @@
       (downstream :body (ChannelBuffers/wrappedBuffer GzipUtils/header)))

     ;; send the chunks
-    (send-chunks deflater downstream compressed-byte-buffer)
+    (send-chunks deflater downstream buf)

     ;; send the trailer if needed
     (when (nil? chunk)
@@ -109,50 +112,63 @@
 (defn encoder
   ([app] (encoder app default-opts))
   ([app opts]
-     (let [deflater (Deflater. Deflater/DEFAULT_COMPRESSION true)
-           crc (CRC32.)
-           compressed-byte-buffer (byte-array 4092)]
-       (defmiddleware
-         [state downstream upstream]
-         app
+     (defmiddleware
+       [state downstream upstream]
+       app

-         :upstream
-         (defstream
-           (request [[{accept-encoding-header "accept-encoding"} _ :as req]]
-             (let [accept-encoding-header (or accept-encoding-header "")
-                   accept-encodings (into #{} (string/split #"\s*,\s*" (string/trim accept-encoding-header)))
-                   accept-gzip? (contains? accept-encodings "gzip")]
-               (swap! state #(assoc % :accept-gzip? accept-gzip?))
-               (upstream :request req)))
+       :upstream
+       (defstream
+         (request [[{accept-encoding-header "accept-encoding"} _ :as req]]
+           ;; save off whether we accept gzip for this request and
+           ;; pass upstream
+           (let [accept-encoding-header (or accept-encoding-header "")
+                 accept-encodings (into #{} (string/split #"\s*,\s*" (string/trim accept-encoding-header)))
+                 accept-gzip? (contains? accept-encodings "gzip")]
+             (swap! state #(assoc % :accept-gzip? accept-gzip?))
+             (upstream :request req)))

-           (else [evt val]
-             (upstream evt val)))
+         ;; must pass all other events through, like pause/resume/abort
+         (else [evt val]
+           (upstream evt val)))

-         :downstream
-         (defstream
-           (response [[status {content-type-header "content-type" :as hdrs} body :as resp]]
-             ;; reset the checksum and the deflater
-             (.reset crc)
-             (.reset deflater)
+       :downstream
+       (defstream
+         (response [[status {content-type-header "content-type" :as hdrs} body :as resp]]
+           ;; send the resposne with appropriate headers
+           (let [content-type-header (content-type hdrs)
+                 gzip-content-type? (contains? (:gzip-content-types opts) content-type-header)]
+             (if-not (and gzip-content-type? (:accept-gzip? @state))
+               (downstream :response resp)
+               (let [hdrs (assoc hdrs "content-encoding" "gzip")]
+                 (if (= :chunked body)
+                   ;; chunked body, yank the content length header,
+                   ;; add the transfer encoding header, and set the
+                   ;; state so that chunks will gzip and allocate a
+                   ;; deflater, crc, and buffer for the exchange
+                   (let [hdrs (-> hdrs (assoc "transfer-encoding" "chunked") (dissoc "content-length"))]
+                     (swap! state #(assoc %
+                                     :gzip? true
+                                     :deflater (Deflater. Deflater/DEFAULT_COMPRESSION true)
+                                     :crc (CRC32.)
+                                     :buf (byte-array 4092)))
+                     (downstream :response [status hdrs body]))

-             ;; send the resposne with appropriate headers
-             (let [content-type-header (content-type hdrs)
-                   gzip-content-type? (contains? (:gzip-content-types opts) content-type-header)]
-               (if-not (and gzip-content-type? (:accept-gzip? @state))
-                 (downstream :response resp)
-                 (let [hdrs (assoc hdrs "content-encoding" "gzip")]
-                   (swap! state #(assoc % :gzip? true))
-                   (if (= :chunked body)
-                     (let [hdrs (-> hdrs (assoc "transfer-encoding" "chunked") (dissoc "content-length"))]
-                       (downstream :response [status hdrs body]))
-                     (let [gzipped-body (gzip-entire-body deflater crc body)
-                           hdrs (assoc hdrs "content-length" (.readableBytes gzipped-body))]
-                       (downstream :response [status hdrs gzipped-body])))))))
+                   ;; not chunked, gzip the whole thing and send it down
+                   (let [gzipped-body (gzip-entire-body body)
+                         hdrs (assoc hdrs "content-length" (.readableBytes gzipped-body))]
+                     (downstream :response [status hdrs gzipped-body])))))))

-           (body [chunk]
-             (if-not (:gzip? @state)
-               (downstream :body chunk)
-               (gzip-and-send state crc deflater downstream compressed-byte-buffer chunk)))
+         (body [chunk]
+           (if-not (:gzip? @state)
+             ;; not gziping, send chunk as is
+             (downstream :body chunk)

-           (else [evt val]
-             (downstream evt val)))))))
+             ;; gzip and send appropriate chunks
+             (let [deflater (:deflater @state)
+                   crc (:crc @state)
+                   buf (:buf @state)]
+               (gzip-and-send-chunk state downstream chunk deflater crc buf))))
+
+         ;; must pass all other events through, like pause/resume/abort
+         (else [evt val]
+           (downstream evt val))))))


Updating ingest to use content types defined in UMM lib.

--- src/cmr/ingest/services/validation.clj
+++ src/cmr/ingest/services/validation.clj
@@ -1,22 +1,18 @@
 (ns cmr.ingest.services.validation
   "Provides functions to validate concept"
   (:require [cmr.common.services.errors :as err]
-            [clojure.string :as s]))
-
-;; body element (metadata) of a request arriving at ingest app should be in xml format and mime type
-;; should be of the items in this def.
-(def CMR_VALID_CONTENT_TYPES
-  #{"application/echo10+xml", "application/iso_prototype+xml", "application/iso:smap+xml",
-    "application/iso19115+xml", "application/dif+xml"})
+            [clojure.string :as s]
+            [cmr.umm.mime-types :as umm-mime-types]))

 (defn- format-validation
   "Validates the format of the concept."
   [concept]
-  (let [content-type (:format concept)]
-    (if (contains? CMR_VALID_CONTENT_TYPES content-type)
+  (let [content-type (:format concept)
+        valid-types (umm-mime-types/concept-type->valid-mime-types (:concept-type concept))]
+    (if (contains? valid-types content-type)
       []
       [(format "Invalid content-type: %s. Valid content-types: %s."
-               content-type (s/join ", " CMR_VALID_CONTENT_TYPES))])))
+               content-type (s/join ", " valid-types))])))

 (defn- metadata-length-validation
   "Validates the metadata length is not unreasonable."


improved it quite a bit

improved it quite a bit

--- test/bluebell/utils/setdispatch_test.clj
+++ test/bluebell/utils/setdispatch_test.clj
@@ -60,13 +60,6 @@
   (merge a b))

 (def-set-method my-plus
-  "Returns a data structure representing string concatenation"
-  [[:string a]
-   [:string b]]
-
-  [:str-cat a b])
-
-(def-set-method my-plus
   "Actually concatenates the strings"
   [[:string a]
    [:string b]]
@@ -109,9 +102,7 @@
        (my-plus :a :b)))

   ;; Thrown because ambiguous
-  (is (thrown?
-       Throwable
-       (my-plus "a" "b")))
+  (is (= "ab" (my-plus "a" "b")))
   (is (= [:a :b :c]
          (my-plus [:a :b]
                   #{:c})))


End-to-end test for simple import of Jenkins job

--- test/buildviz/jenkins/sync_jobs_test.clj
+++ test/buildviz/jenkins/sync_jobs_test.clj
@@ -3,7 +3,9 @@
             [buildviz.util.url :as url]
             [cheshire.core :as j]
             [clj-http.fake :as fake]
-            [clj-time.core :as t]
+            [clj-time
+             [coerce :as tc]
+             [core :as t]]
             [clojure.test :refer :all]))

 (defn- successful-json-response [body]
@@ -20,9 +22,21 @@
 (defn- a-job-with-builds [job-name & builds]
   (let [job-builds [(format "http://jenkins:4321/job/%s/api/json?tree=allBuilds%%5Bnumber,timestamp,duration,result,actions%%5BlastBuiltRevision%%5BSHA1%%5D,remoteUrls,parameters%%5Bname,value%%5D,causes%%5BupstreamProject,upstreamBuild%%5D%%5D%%5D%%7B0,10%%7D"
                             job-name)
-                    (successful-json-response {:allBuilds []})]]
-    [job-builds]))
+                    (successful-json-response {:allBuilds builds})]
+        test-results (map (fn [build]
+                            [(format "http://jenkins:4321/job/%s/%s/testReport/api/json" job-name (:number build))
+                             (fn [_] {:status 404 :body ""})]) builds)]
+    (cons job-builds test-results)))

+(defn- provide-buildviz-and-capture-puts [latest-build-start map-ref]
+  [[#"http://buildviz:8010/builds/(.+)/(.+)"
+    (fn [req]
+      (swap! map-ref #(conj % [(:uri req)
+                               (j/parse-string (slurp (:body req)) true)]))
+      {:status 200 :body ""})]
+   ["http://buildviz:8010/status"
+    (successful-json-response (cond-> {}
+                                latest-build-start (assoc :latestBuildStart (tc/to-long latest-build-start))))]])

 (defn- serve-up [& routes]
   (->> routes
@@ -46,4 +60,18 @@
                                                     (a-job-with-builds "some_job"))
         (with-out-str (sut/sync-jobs (url/url "http://jenkins:4321") (url/url "http://buildviz:8010") beginning-of-2016)))
       (is (= []
+             @store))))
+
+  (testing "should sync a simple build"
+    (let [store (atom [])]
+      (fake/with-fake-routes-in-isolation (serve-up (a-view (a-job "some_job"))
+                                                    (a-job-with-builds "some_job" {:number "21"
+                                                                                :timestamp 1493201298062
+                                                                                :duration 10200
+                                                                                :result "SUCCESS"})
+                                                    (provide-buildviz-and-capture-puts beginning-of-2016 store))
+        (with-out-str (sut/sync-jobs (url/url "http://jenkins:4321") (url/url "http://buildviz:8010") beginning-of-2016)))
+      (is (= [["/builds/some_job/21" {:start 1493201298062
+                                      :end 1493201308262
+                                      :outcome "pass"}]]
              @store)))))


More idiomatic use of (into [] ..) in transducer examples

--- src/semantic_csv/transducers.clj
+++ src/semantic_csv/transducers.clj
@@ -41,11 +41,9 @@
 ;; Here's an example using the mappify transducers.
 ;;
 ;;     => (with-open [in-file (io/reader "test/test.csv")]
-;;          (transduce
-;;            (mappify)
-;;            conj
-;;            []
-;;            (csv/parse-csv in-file))
+;;          (into []
+;;                (mappify)
+;;                (csv/parse-csv in-file))
 ;;
 ;;     [{:this "# some comment lines..."}
 ;;      {:this "1", :that "2", :more "stuff"}
@@ -83,11 +81,9 @@
 ;; Here's an example of structify:
 ;;
 ;;     => (with-open [in-file (io/reader "test/test.csv")]
-;;          (transduce
-;;            (structify)
-;;            conj
-;;            []
-;;            (csv/parse-csv in-file))
+;;          (into []
+;;                (structify)
+;;                (csv/parse-csv in-file))
 ;;
 ;;     ({:this "# some comment lines..."}
 ;;      {:this "1", :that "2", :more "stuff"}
@@ -130,11 +126,9 @@
 ;; This is a property of transducers.
 ;;
 ;;     => (with-open [in-file (io/reader "test/test.csv")]
-;;          (transduce
-;;            (comp (remove-comments) (mappify))
-;;            conj
-;;            []
-;;            (csv/parse-csv in-file)))
+;;          (into []
+;;                (comp (remove-comments) (mappify))
+;;                (csv/parse-csv in-file)))
 ;;
 ;;     ({:this "1", :that "2", :more "stuff"}
 ;;      {:this "2", :that "3", :more "other yeah"})
@@ -174,14 +168,11 @@
 ;; Let's try casting a numeric column using this function:
 ;;
 ;;     => (with-open [in-file (io/reader "test/test.csv")]
-;;          (transduce
-;;            (comp
-;;              (remove-comments)
-;;              (mappify)
-;;              (cast-with {:this #(Integer/parseInt %)}))
-;;            conj
-;;            []
-;;            (csv/parse-csv in-file)))
+;;          (into []
+;;                (comp (remove-comments)
+;;                      (mappify)
+;;                      (cast-with {:this #(Integer/parseInt %)}))
+;;                (csv/parse-csv in-file)))
 ;;
 ;;     ({:this 1, :that "2", :more "stuff"}
 ;;      {:this 2, :that "3", :more "other yeah"})
@@ -190,14 +181,11 @@
 ;; by passing a single casting function as the first argument.
 ;;
 ;;     => (with-open [in-file (io/reader "test/test.csv")]
-;;          (transduce
-;;            (comp
-;;              (remove-comments)
-;;              (mappify)
-;;              (cast-with #(Integer/parseInt %) {:only [:this :that]}))
-;;            conj
-;;            []
-;;            (csv/parse-csv in-file)))
+;;          (into []
+;;                (comp (remove-comments)
+;;                      (mappify)
+;;                      (cast-with #(Integer/parseInt %) {:only [:this :that]}))
+;;                (csv/parse-csv in-file)))
 ;;
 ;;     ({:this 1, :that 2, :more "stuff"}
 ;;      {:this 2, :that 3, :more "other yeah"})
@@ -254,11 +242,9 @@
 ;; Using this function, the code we've been building above is reduced to the following:
 ;;
 ;;     (with-open [in-file (io/reader "test/test.csv")]
-;;       (transduce
-;;         (process {:cast-fns {:this #(Integer/parseInt %)}})
-;;         conj
-;;         []
-;;         (csv/parse-csv in-file)))
+;;       (into []
+;;             (process {:cast-fns {:this #(Integer/parseInt %)}})
+;;             (csv/parse-csv in-file)))

 ;; <br/>
@@ -411,7 +397,7 @@
 ;;
 ;;     => (let [data [{:this "a" :that "b"}
 ;;                    {:this "x" :that "y"}]]
-;;          (transduce (vectorize) conj [] data))
+;;          (into [] (vectorize) data))
 ;;     (["this" "that"]
 ;;      ["a" "b"]
 ;;      ["x" "y"])
@@ -420,11 +406,10 @@
 ;;
 ;;     => (let [data [{:this "a" :that "b"}
 ;;                    {:this "x" :that "y"}]]
-;;          (transduce (vectorize {:header [:that :this]
-;;                      :prepend-header false})
-;;                     conj
-;;                     []
-;;                     data))
+;;          (into []
+;;                (vectorize {:header [:that :this]
+;;                           :prepend-header false})
+;;                data))
 ;;     (["b" "a"]
 ;;      ["y" "x"])

@@ -514,7 +499,7 @@
 ;;     (with-open [in-file (io/reader "test/test.csv")
 ;;                 out-file (io/writer "test-out.csv")]
 ;;       (->>
-;;         (transduce
+;;         (sequence
 ;;           (comp
 ;;             (remove-comments)
 ;;             (mappify)
@@ -525,8 +510,6 @@
 ;;                 (assoc row :jazz (* (:this row)
 ;;                                     (:that row)))))
 ;;             (vectorize))
-;;           conj
-;;           []
 ;;           (cd-csv/read-csv in-file))
 ;;         (cd-csv/write-csv out-file)))
 ;;


Updated docs in response to comment by @eightysteele

--- test/clj/forma/hadoop/predicate_test.clj
+++ test/clj/forma/hadoop/predicate_test.clj
@@ -87,7 +87,7 @@
         (sparse-windower (pixel-tap [[0 0 0 0 10]]) ["?s" "?l"] [5 2] "?v" 0))

 (fact
-  "A simpler test of sparse-windower"
+  "An illustrative test of sparse-windower uses simple, familiar pixel info"
   (let [val-src (let [src [["500" 28 8 0 0 10]
                            ["500" 28 8 0 1 20]]]
                   (<- [?s-res ?modh ?modv ?sample ?line ?val]


SQL output progress

SQL output progress

--- src/clj_hypergraph_db/sql_parser/uml_to_sql_persistance_manager.clj
+++ src/clj_hypergraph_db/sql_parser/uml_to_sql_persistance_manager.clj
@@ -86,6 +86,19 @@
 ;          (.println print-writer (str (tabs tab-count) "</" token-name ">"))
 ;          true)))))

+(defn get-foreign-key-from-path
+  "Only with unique associations"
+  [[assoc-name role key] current-instance current-class]
+  (if-let
+    [assoc-handle (-> @model :associations assoc-name :handle)]
+    (if-let [assoc-instance (first (hg-find-all (hg-incident @current-instance) (hg-incident-at assoc-handle 0)))]
+      (println assoc-instance)
+      #_(println (hg-link-target-at @assoc-instance (inc (.indexOf (-> @model :associations assoc-name :roles-order) role))))
+      nil
+      )
+    nil
+
+  ))

 (defn write-output-data
   [{{output-model-tables :tables} :output-model
@@ -100,16 +113,28 @@
         [{name :name body :body} extent-tables
          :let [iterator (iterator-create :class name)
                curent-instance (atom (iterator-next iterator))]]
-      #_(println body)
-      (println curent-instance)
-        (while @curent-instance
+      #_(println curent-instance)
+      (while @curent-instance
+        (doseq
+            [{mappings :mappings [table] :table} (find-all-items-by-type body :add-entity)
+             :let [columns (StringBuilder.) values (StringBuilder.)]]
           (doseq
-              [{mappings :mappings [table] :table} (find-all-items-by-type body :add-entity)
-               :let [columns (StringBuilder.) values (StringBuilder.)]]
-
+              [mapping mappings]
+            (if (= :mapping (:type mapping))
+              (do
+                (.append columns (-> mapping :column first))
+                (.append values (:name mapping))
+                )
+              ;else
+              (do
+                (.append columns (-> mapping :column first))
+                (.append values (get-foreign-key-from-path (:relation-path mapping) curent-instance name)))
+              )
             )
-          )
-          (reset! curent-instance (iterator-next iterator)))))
+          #_(println (.toString columns))
+          #_(println (.toString values)))
+        (reset! curent-instance (iterator-next iterator))
+        ))))

 ;:let [{extent-entity-name :name
 ;       extent-entity-mappings :mappings} (find-first-item-by-type body :add-entity)]


Update ancient lein profile dependencies

--- lein/profiles.clj
+++ lein/profiles.clj
@@ -15,10 +15,9 @@
                        [leiningen #= (leiningen.core.main/leiningen-version) :exclusions [cheshire
                                                                                com.fasterxml.jackson.core/jackson-core
                                                                                com.fasterxml.jackson.dataformat/jackson-dataformat-smile
-                                                                                #_commons-io
-                                                                                commons-logging
                                                                                commons-codec
                                                                                commons-io
+                                                                                commons-logging
                                                                                #_org.apache.httpcomponents/httpclient
                                                                                #_org.apache.httpcomponents/httpcore
                                                                                #_org.apache.maven.wagon/wagon-http
@@ -36,7 +35,7 @@
                        #_[org.clojure/tools.namespace "0.2.10"]
                        ;; I know I have a lot of projects that transitively rely on this, but they really shouldn't
                        #_[org.clojure/tools.nrepl "0.2.12" :exclusions [org.clojure/clojure]]
-                       [pjstadig/humane-test-output "0.8.1"]
+                       [pjstadig/humane-test-output "0.8.2"]
                        ;; Q: Is there any point to this next one?
                        #_[ritz/ritz-nrepl-middleware "0.7.0"]
                        ;; Q: Do I actually use this anywhere/for anything?
@@ -69,8 +68,8 @@
                      (require 'pjstadig.humane-test-output)
                      (pjstadig.humane-test-output/activate!)]
         ;;:local-repo "repo"
-        :plugins [[com.jakemccrary/lein-test-refresh "0.18.0"]
-                  [jonase/eastwood "0.2.3" :exclusions [org.clojure/clojure]]
+        :plugins [[com.jakemccrary/lein-test-refresh "0.20.0"]
+                  [jonase/eastwood "0.2.4" :exclusions [org.clojure/clojure]]
                   ;; Check for out-dated plugins in here using `lein ancient check-profiles`
                   [lein-ancient "0.6.10" :exclusions [cheshire
                                                       common-codec
@@ -78,7 +77,7 @@
                                                       org.clojure/clojure
                                                       #_org.clojure/tools.reader
                                                       slingshot]]
-                  [lein-kibit "0.1.3" :exclusions [org.clojure/clojure]]
+                  [lein-kibit "0.1.5" :exclusions [org.clojure/clojure]]
                   [lein-pprint "1.1.2"]
                   [mvxcvi/whidbey "1.3.1" :exclusions [org.clojure/clojure]]]
         :repl-options {:nrepl-middleware
@@ -89,4 +88,4 @@
                   :print-meta true
                   :color-scheme {}
                   :print-color true}}
-  :repl {:plugins [[cider/cider-nrepl "0.14.0" :exclusions [org.clojure/java.classpath]]]}}
+ :repl {:plugins [[cider/cider-nrepl "0.14.0" :exclusions [org.clojure/java.classpath]]]}}


lein: new lein-ring

lein: new lein-ring

--- lein_profiles.clj
+++ lein_profiles.clj
@@ -1,5 +1,5 @@
 {:user {:plugins [
-                  [lein-ring "0.9.3"]
+                  [lein-ring "0.9.4"]
                   [lein-ancient "0.6.7"]
                   [jonase/eastwood "0.2.1"]
                   [cider/cider-nrepl "0.9.0-SNAPSHOT"]


add highlight flurry

add highlight flurry

--- src/solar_system_of_js/core.cljs
+++ src/solar_system_of_js/core.cljs
@@ -35,6 +35,7 @@
                  :es6 {:alpha 0}
                  :es7 {:alpha 0}
                  :es8 {:alpha 0}}
+   :highlight-layer nil
    })

 ;; Current state of the application.
@@ -184,6 +185,20 @@
   (restore!)
   )

+(defn draw-highlight-layer!
+  [i]
+  (when i
+    (let [r (-> @state :js-face :r)
+          dr (get-core-dr r)
+          cr (- (get-core-radius i r) (/ dr 2))]
+
+      ;; highlight the layer
+      (line-width! dr)
+      (circle! 0 0 cr)
+      (stroke-style! "#1EA")
+      (stroke!))))
+
+
 (defn draw-es-captions!
   [{:keys [es3 es5 es6 es7 es8]}]
   (save!)
@@ -204,10 +219,7 @@
             at (/ a 3)]

         ;; highlight the layer
-        (line-width! dr)
-        (circle! 0 0 cr)
-        (stroke-style! "#1EA")
-        (stroke!)
+        (draw-highlight-layer! i)

         ;; point at layer
         (line-width! 5)
@@ -257,6 +269,7 @@
   (draw-js-core! (:js-core @state))
   (draw-js-face! (:js-face @state))
   (draw-es-captions! (:es-captions @state))
+  (draw-highlight-layer! (:highlight-layer @state))

   (restore!))

@@ -307,20 +320,14 @@
   (cond-> tween
     (keyword? tween) tweens))

-(defn resolve-callback
-  "If the callback is a state path, create the callback to set that path."
-  [callback]
-  (if-let [path (when (vector? callback) callback)]
-    #(swap! state assoc-in path %)
-    callback))
-
 (defn animate!
   "Pass given animation values to the given callback.
    Returns a channel that closes when done."
-  [{:keys [a b duration tween] :or {tween :swing} :as opts} callback]
+  [{:keys [a b duration tween] :or {tween :swing} :as opts} state-path]
   (let [tween (resolve-tween tween)
-        callback (resolve-callback callback)
         c (chan)
+        resolve-var #(if (= % :_) (get-in @state state-path) %)
+        a (resolve-var a)
         dv (- b a)]
     (tap tick-tap c)
     (go-loop [t 0]
@@ -330,7 +337,7 @@
                         (min 1)
                         (tween))
             v (+ a (* percent dv))]
-        (callback v)
+        (swap! state assoc-in state-path v)
         (when (< t duration)
           (recur t)))
       (untap tick-tap c))))
@@ -355,40 +362,54 @@
     [nil ;; no action for first slide
      #(go
         (<! (multi-animate!
-              {:a 900 :b 0 :duration 1} [:js-face :x]
-              {:a 1 :b 0 :duration 0.4} [:title :alpha])))
+              {:a :_ :b 0 :duration 1} [:js-face :x]
+              {:a :_ :b 0 :duration 0.4} [:title :alpha])))
      #(go
         (<! (multi-animate!
-              {:a 0 :b 400 :duration 2} [:cam :x]
-              {:a 0 :b -600 :duration 2} [:js-face :y]
-              {:a 0 :b 600 :duration 2} [:js-face :x]
-              {:a 0 :b (* 2 PI) :duration 2} [:js-face :angle]
-              {:a 1 :b 0 :duration 2} [:js-face :alpha]
-              {:a 0 :b 1 :duration 1} [:js-core :alpha]
-              {:a 1 :b 2 :duration 2} [:cam :zoom])))
+              {:a :_ :b 400 :duration 2} [:cam :x]
+              {:a :_ :b -600 :duration 2} [:js-face :y]
+              {:a :_ :b 600 :duration 2} [:js-face :x]
+              {:a :_ :b (* 2 PI) :duration 2} [:js-face :angle]
+              {:a :_ :b 0 :duration 2} [:js-face :alpha]
+              {:a :_ :b 1 :duration 1} [:js-core :alpha]
+              {:a :_ :b 2 :duration 2} [:cam :zoom])))
      (let [t 0.01
            low 0]
        [
         #(go
            (<! (animate!
-                 {:a 0 :b 1 :duration t} [:es-captions :es3 :alpha])))
+                 {:a :_ :b 1 :duration t} [:es-captions :es3 :alpha])))
         #(go
            (<! (multi-animate!
-                 {:a 1 :b low :duration t} [:es-captions :es3 :alpha]
-                 {:a 0 :b 1 :duration t} [:es-captions :es5 :alpha])))
+                 {:a :_ :b low :duration t} [:es-captions :es3 :alpha]
+                 {:a :_ :b 1 :duration t} [:es-captions :es5 :alpha])))
         #(go
            (<! (multi-animate!
-                 {:a 1 :b low :duration t} [:es-captions :es5 :alpha]
-                 {:a 0 :b 1 :duration t} [:es-captions :es6 :alpha])))
+                 {:a :_ :b low :duration t} [:es-captions :es5 :alpha]
+                 {:a :_ :b 1 :duration t} [:es-captions :es6 :alpha])))
         #(go
            (<! (multi-animate!
-                 {:a 1 :b low :duration t} [:es-captions :es6 :alpha]
-                 {:a 0 :b 1 :duration t} [:es-captions :es7 :alpha])))
+                 {:a :_ :b low :duration t} [:es-captions :es6 :alpha]
+                 {:a :_ :b 1 :duration t} [:es-captions :es7 :alpha])))
         #(go
            (<! (multi-animate!
-                 {:a 1 :b low :duration t} [:es-captions :es7 :alpha]
-                 {:a 0 :b 1 :duration t} [:es-captions :es8 :alpha])))
+                 {:a :_ :b low :duration t} [:es-captions :es7 :alpha]
+                 {:a :_ :b 1 :duration t} [:es-captions :es8 :alpha])))
         ])
+     #(go
+        (let [chans [(multi-animate!
+                       {:a :_ :b 0 :duration 0.01} [:es-captions :es8 :alpha]
+                       {:a :_ :b 200 :duration 1} [:cam :x]
+                       {:a :_ :b 1.3 :duration 1} [:cam :zoom]
+                       {:a :_ :b 1 :duration 1} [:transpiler :x]
+                       )
+                     (go
+                       (<! (timeout 50))
+                       (doseq [i [1 2 3 4 3 2 1 2 3 4 3 2 1 2 3 4 nil]]
+                         (swap! state assoc :highlight-layer i)
+                         (<! (timeout 70))))]]
+          (doseq [c chans]
+            (<! c))))
      ])))

 (def num-slides


cleanup modal, popover, and tooltip helpers

--- frontend/utils.cljs
+++ frontend/utils.cljs
@@ -123,8 +123,8 @@
   (mwarn "Please remove the modal on" selector)
   (let [jq (aget js/window "$")
         $node (jq selector)
-        modal (aget $node "modal")]
-    (.call modal $node #js {:open true})))
+        $modal (aget $node "modal")]
+    (.call $modal $node #js {:open true})))

 ;; TODO: get rid of bootstrap popovers
 (defn popover
@@ -134,8 +134,8 @@
   (mwarn "Please remove the popover on" selector)
   (let [jq (aget js/window "$")
         $node (jq selector)
-        popover (aget $node "popover")]
-    (.call popover $node (clj->js options))))
+        $popover (aget $node "popover")]
+    (.call $popover $node (clj->js options))))

 ;; TODO: get rid of bootstrap tooltips
 (defn tooltip
@@ -145,7 +145,7 @@
   (mwarn "Please remove the tooltip on" selector)
   (let [jq (aget js/window "$")
         $node (jq selector)
-        popover (aget $node "tooltip")]
+        $tooltip (aget $node "tooltip")]
     (if options
-      (.call popover $node (clj->js options))
-      (.call popover $node))))
+      (.call $tooltip $node (clj->js options))
+      (.call $tooltip $node))))


Fix typo

Fix typo

--- src/madison/spec/core.clj
+++ src/madison/spec/core.clj
@@ -62,7 +62,7 @@
    (s/with-gen ::person-id
                #(gen/frequency [[10 gen/pos-int]
                                 [1 gen/uuid]]))
-  (pprint/pprin`t (gen/sample (s/gen ::person-id) 5))
+  (pprint/pprint (gen/sample (s/gen ::person-id) 5))
    ; Create updated house nested map
             {:street  "563 Willow Ave",
              :city    "Milwakuee",


Fix non-reloadable React component

Fix non-reloadable React component

--- src/text_justification/core.cljs
+++ src/text_justification/core.cljs
@@ -9,7 +9,6 @@

 (defonce page-width 11)
 (defonce space-char (gstring/unescapeEntities " ")) ;; \u00A0 ?
-(defonce target-el (dom/getElement "justified-text"))

 (defn get-text-el []
   (dom/getElement "text"))
@@ -52,10 +51,6 @@
 ;; remove listeners from text area
 (let [ old-node (get-text-el) new-node (.cloneNode old-node true)]
   (.replaceChild (.-parentNode old-node) new-node old-node)
-  ; (set! (.-value new-node) "Bleh Bleh Bleh Bleh aaabbbccc\n\naaa bbb")
-  ; (set! (.-value new-node) "")
-  ; (set! (.-value new-node) "aaabbbccc111 a")
-  ; (set! (.-value new-node) "aaabbbccc11 -1 a")
   )

 ;; add keyup listner to text-el
@@ -77,7 +72,7 @@

 (defn text-justified-component []
-  [:p
+  [:div
   (for [[id line] (map-indexed vector @model/state)]
     ^{:key id} [line-component id line])])


deleted non working example  - for now no examples

--- src/examples/dodo.clj
+++ src/examples/dodo.clj
@@ -1,62 +0,0 @@
-(ns examples.dodo (:use forex.binding forex.utils))
-
-(defn take-by [n coll]
-  (lazy-seq
-    (when-let [s (and (>= (count coll) n) (seq coll))]
-      (cons (take n s) (take-by n (rest s))))))
-
-(defn trader-stop [order]
-  (if (open? order)
-    (if (below (price) green)inter
-      (close-order order)
-					;every 10 seconds, udpate stoploss
-      (if (zero? (% i 10)) (modify order (green) 0)))))
-
-(defn trade! [direction price sl]
-  (let [lots (min 10 (/ (* .03 (free-margin)) (dollars (abs (- price sl)))))]
-    (trader-stop! (market-order {:direction direction :price price :lots lots :sl sl}))))
-
-(defn peak-type [item]
-  (let [[a b c m d e f] item]
-    (cond
-      (and (< a b) (< b c) (< c m) (< d m) (< e d) (< f e)) :peak ;3x3
-      (and (< b c) (< c m) (< d m) (< e d) (< f e)) :peak	  ;2x3
-      (and (< a b) (< b c) (< c m) (< d m) (< e d)) :peak	  ;3x2
-      (and (> a b) (> b c) (> c m) (> d m) (> e d) (> f e)) :valley ;3x3
-      (and (> a b) (> b c) (> c m) (> d m) (> e d) ) :valley ;3x2
-      (and (> b c) (> c m) (> d m) (> e d) (> f e)) :valley ;2x3
-      true nil)))
-(defn middle [i] (/ (+ (close i) (open i)) 2.0))
-(defn sharp-map
-  ([upto] (sharp-map upto 0))
-  ([upto from]
-     "determine a peak or valley in the range from where it crosses up to where it previously crossed"
-     (is (>= upto (+ from 7)))
-     (map peak-type (take-by 7 (map #(middle %) (range from (+ upto 8)))))))
-
-
-(defn close? [condition]
-					;if distance from violet line is less than ten pips -good
-  (<= (abs (- violet  (price))) 10))
-(defn momentum? []
-  ;;make sure it is still above - wait later for real momentum test!
-  (> black violet))
-
-
-(defn rainbow-scalper []
-  (cond
-   (cross? large5 small5)
-					;wait for large1 and green to actually cross
-   (let [condition (wait-for-entrance)]
-					;once it crosses, test sharpness and if it is 'close enough' and if momentum is 'good enough/
-     (if (and (sharp? condition) (close? condition) (momentum? condition))
-       (trade! (opposite trend) price)))
-
-   (= (cross? large1 green1 ) trend)
-					;determine if large5 and small5 are 'close enought'
-   (if (close? large5 small5)
-
-					;wait for large1 and green1 to cross back to enter
-     (let [condition (wait-for-cross (opposite trend))]
-       (if (and (sharp? condition) (close? condition) (momentum? condition))
-	 (trade! (opposite trend) price))))))


removed unnecessary (and ) function calls

--- dev/seed.clj
+++ dev/seed.clj
@@ -63,10 +63,10 @@
 (defn covers?
  "Determines if a point is covered by the seed data"
   ([x y]
-   (and (and (>= x (:left data))
-             (<= x (:right data)))
-        (and (>= y (:bottom data))
-             (<= y (:top data)))))
+   (and (>= x (:left data))
+        (<= x (:right data))
+        (>= y (:bottom data))
+        (<= y (:top data))))
   ([point]
    (covers? (first point)(second point))))


Double-starts of edges silently fail

Double-starts of edges silently fail

--- src/engulf/formulas/http_benchmark.clj
+++ src/engulf/formulas/http_benchmark.clj
@@ -175,17 +175,16 @@
      (fn req-resp [res]
        (when (= @state :started) ; Discard results and don't recur when stopped
          (lc/enqueue res-ch res)
-         (run-repeatedly this)))))
+         (run-repeatedly this)))))
   Formula
-  (start-relay [this]
-
-    )
+  (start-relay [this ingress]
+    (when (compare-and-set! state :initialized :started)
+
+      ))
   (start-edge [this]
-    (if (not (compare-and-set! state :initialized :started))
-      (throw (Exception. (str "Expected state :initialized, not: ") @state))
-      (do
-        (dotimes [t (Integer/valueOf (:concurrency params))] (run-repeatedly this))
-        (lc/map* (partial edge-aggregate params) (lc/partition-every 250 res-ch)))))
+    (when (compare-and-set! state :initialized :started)
+     (dotimes [t (Integer/valueOf (:concurrency params))] (run-repeatedly this))
+     (lc/map* (partial edge-aggregate params) (lc/partition-every 250 res-ch))))
   (stop [this]
     (reset! state :stopped)
     (lc/close res-ch)


Add matting to narrow sketch

Add matting to narrow sketch

--- spectacles/src/spectacles/kaleidoscope.clj
+++ spectacles/src/spectacles/kaleidoscope.clj
@@ -47,7 +47,11 @@
   (q/rect 0 0 (q/width) (q/height))
   (q/image (:logo state) (- (/ (q/width) 2) 100) (- (/ (q/height) 2) 100))
   (draw-dots 300 300 1 (:ldots state) q/rect)
-  (draw-dots (/ (q/width) 2) (/ (q/height) 2) -1 (:rdots state) q/ellipse))
+  (draw-dots (/ (q/width) 2) (/ (q/height) 2) -1 (:rdots state) q/ellipse)
+  (q/fill 0 0 0 255)
+  (q/rect 0 0 (/ (q/width) 4) (q/height))
+  (q/rect (* 0.75 (q/width)) 0 (q/width) (q/height)))
+

 (defn update-position [m]
   (-> m
@@ -76,11 +80,12 @@
                  :rdots (update-dots rdots))))

 ;; (q/defsketch practice
-;;     :title "Kaleidoscope"
-;;     :size :fullscreen
-;;     :setup setup
-;;     :draw draw
-;;     :update update
-;;     :features [:keep-on-top]
-;;     :middleware [m/fun-mode m/navigation-2d])
+;;      :title "Kaleidoscope"
+;;      :size :fullscreen
+;;      :setup setup
+;;      :draw draw
+;;      :update update
+;;      :features [:keep-on-top]
+;;      :middleware [m/fun-mode m/navigation-2d])

+


fix issue when reaching /login and failing

this could happen when already logged in

--- src/foosball/auth.clj
+++ src/foosball/auth.clj
@@ -1,6 +1,7 @@
 (ns foosball.auth
   (:require [cemerick.friend :as friend]
             [cemerick.friend.openid :as openid]
+            [ring.util.response :as response]
             [foosball.models.domains :as d]
             [foosball.util :as util]))

@@ -36,7 +37,8 @@
                        {:allow-anon? true
                         :default-landing-uri "/user/assign-player"
                         :workflows [(openid/workflow :openid-uri "/login"
-                                                     :credential-fn (partial credential-fn db))]}))
+                                                     :credential-fn (partial credential-fn db)
+                                                     :login-failure-handler (constantly (response/redirect "/")))]}))

 (comment  {:name "Yahoo" :url "http://me.yahoo.com/"}
           {:name "AOL" :url "http://openid.aol.com/"}


Only show "Read the story" for shopify

Only show "Read the story" for shopify

--- src-cljs/frontend/components/features.cljs
+++ src-cljs/frontend/components/features.cljs
@@ -92,9 +92,12 @@
      employee-title
      " at "
      [:span.customer-company-name company-name]
-     " – "
-     [:a.customer-story {:href (str "/stories/" company-short)}
-      "Read the story"]]]])
+     ;; HACK: there's only one story right now, and the others are 404ing.
+     (when (= company-short "shopify")
+       [:span
+        " – "
+        [:a.customer-story {:href (str "/stories/" company-short)}
+         "Read the story"]])]]])

 (defrender features [app owner]
   (html


success was not a success -> fixed naming; killed more excess code

--- src/midje/unprocessed.clj
+++ src/midje/unprocessed.clj
@@ -16,47 +16,42 @@
 (defmulti ^{:private true} check-result (fn [actual call]
                                           (:desired-check call)))

-(letfn [(base-result [type actual call]
-          {:type type
-           :binding-note (:binding-note call)
-           :position (:position call)
-           :actual actual })]
-
-  (defn- failure [type actual call]
-    (assoc (base-result type actual call) :expected (:expected-result-text-for-failures call)))
-
-  (defn- success [type actual call]
-    (assoc (base-result type actual call) :expected (:expected-result call) )))
+(defn- fail [type actual call]
+  {:type type
+   :binding-note (:binding-note call)
+   :position (:position call)
+   :actual actual
+   :expected (:expected-result-text-for-failures call)})

 (defmethod check-result :check-match [actual call]
   (cond (extended-= actual (:expected-result call))
         (report {:type :pass})

         (fn? (:expected-result call))
-        (report (merge (failure :mock-expected-result-functional-failure actual call)
-                       (if (chatty-checker? (:expected-result call))
-                         (do
-                           (let [chatty-result ((:expected-result call) actual)]
-                             (if (map? chatty-result)
-                               chatty-result
-                               {:actual actual
-                                :notes ["Midje program error. Please report."
-                                        (str "A chatty checker returned "
-                                             (pr-str chatty-result)
-                                             " instead of a map.")]})))
-                         {:actual actual})))
-        :else
-        (report (success :mock-expected-result-failure actual call))))
+        (let [failure (fail :mock-expected-result-functional-failure actual call)]
+          (report (if-not (chatty-checker? (:expected-result call))
+                    failure
+                    (merge failure
+                      (let [chatty-result ((:expected-result call) actual)]
+                        (if (map? chatty-result)
+                          chatty-result
+                          {:notes ["Midje program error. Please report."
+                                   (str "A chatty checker returned "
+                                     (pr-str chatty-result)
+                                     " instead of a map.")]}))))))
+    :else (report (assoc
+                  (fail :mock-expected-result-failure actual call)
+                  :expected (:expected-result call) ))))

 (defmethod check-result :check-negated-match [actual call]
    (cond (not (extended-= actual (:expected-result call)))
          (report {:type :pass})

         (fn? (:expected-result call))
-        (report (failure :mock-actual-inappropriately-matches-checker actual call))
+        (report (fail :mock-actual-inappropriately-matches-checker actual call))

         :else
-        (report (failure :mock-expected-result-inappropriately-matched actual call))))
+        (report (fail :mock-expected-result-inappropriately-matched actual call))))

 (defn expect*
   "The core function in unprocessed Midje. Takes a map describing a


🙅🏻 Add warning and disable option if no profile pic added

Remove warning from list screen

Signed-off-by: Shivek Khurana <ae036b02ef2f3d9f073f7930137ecb248a31c067@status.im>

--- src/status_im/ui/screens/privacy_and_security_settings/views.cljs
+++ src/status_im/ui/screens/privacy_and_security_settings/views.cljs
@@ -30,6 +30,7 @@
                           webview-allow-permission-requests?
                           opensea-enabled?
                           profile-pictures-visibility]} [:multiaccount]
+                  has-picture              [:profile/has-picture]
                   supported-biometric-auth [:supported-biometric-auth]
                   keycard?                 [:keycard-multiaccount?]
                   auth-method              [:auth-method]
@@ -135,6 +136,7 @@
      [quo/list-item
       {:size                :small
        :title               (i18n/label :t/show-profile-pictures-to)
+       :disabled            (not has-picture)
        :accessibility-label :show-profile-pictures-to
        :accessory           :text
        :accessory-text      (get titles profile-pictures-show-to)


support use of *env* in baked jars

support use of *env* in baked jars

--- dev/cake.clj
+++ dev/cake.clj
@@ -10,12 +10,12 @@
 (def ^{:dynamic true} *opts*         nil)
 (def ^{:dynamic true} *args*         nil)
 (def ^{:dynamic true} *pwd*          nil)
-(def ^{:dynamic true} *env*          nil)
+(def ^{:dynamic true} *env*          (into {} (System/getenv)))
 (def ^{:dynamic true} *vars*         nil)
 (def ^{:dynamic true} *File*         nil)
-(def ^{:dynamic true} *root*        (System/getProperty "cake.project"))
-(def ^{:dynamic true} *global-root* (.getPath (File. (System/getProperty "user.home") ".cake")))
-(def ^{:dynamic true} *classloader* nil)
+(def ^{:dynamic true} *root*         (System/getProperty "cake.project"))
+(def ^{:dynamic true} *global-root*  (.getPath (File. (System/getProperty "user.home") ".cake")))
+(def ^{:dynamic true} *classloader*  nil)

 (def test-classloader nil)


Add message after restart

Add message after restart

--- dev/user.clj
+++ dev/user.clj
@@ -13,7 +13,8 @@

 (defn go []
   (figwheel/start-figwheel!)
-  (restart-server))
+  (restart-server)
+  (prn "Application restartet."))

 (def browser-repl figwheel/cljs-repl)


Add Create Database Stuff to user Namespace

--- dev/user.clj
+++ dev/user.clj
@@ -36,6 +36,9 @@
   (startup)
   (reset))

+(defn create-database []
+  (d/create-database (:db-uri system)))
+
 (defn connect []
   (d/connect (:db-uri system)))

@@ -58,6 +61,7 @@
        (reduce +)))

 (comment
+  (create-database)
   (load-schema)
   (def conn (connect))
   (api/create-standard-workbook conn)


Add clojure.repl to user for ease of development

--- dev/user.clj
+++ dev/user.clj
@@ -1,5 +1,6 @@
 (ns user
   (:require [clojure.tools.namespace.repl :refer [refresh]]
+            [clojure.repl :refer :all]
             [leiningen.highlight :as hl]
             [ring.server.standalone :refer [serve]]))


new line!

new line!

--- dev/user.clj
+++ dev/user.clj
@@ -84,4 +84,4 @@
                   (re-find #"/thumb/" line) (c/route-matches alr/thumbnail-route (request :get line))
                   :else (c/route-matches alr/original-route (request :get line)))
           (println line))
-      (recur (rest lines))))))+      (recur (rest lines))))))


dispatch :editor-update-render-state only if changed

--- cljs/src/worker/plastic/worker/editor/layout.cljs
+++ cljs/src/worker/plastic/worker/editor/layout.cljs
@@ -45,10 +45,12 @@
       (if-not (editor/parsed? editor)
         editor
         (let [independent-top-level-locs (map zip/down (map zip-utils/independent-zipper (editor/get-top-level-locs editor)))
-              render-state {:order (map #(zip-utils/loc-id %) independent-top-level-locs)}]
-          (main-dispatch :editor-update-render-state (:id editor) render-state)
+              old-render-stae (editor/get-render-state editor)
+              new-render-state {:order (map #(zip-utils/loc-id %) independent-top-level-locs)}]
+          (if (not= old-render-stae new-render-state)
+            (main-dispatch :editor-update-render-state (:id editor) new-render-state))
           (-> editor
-            (editor/set-render-state render-state)
+            (editor/set-render-state new-render-state)
             (update-forms-layout-if-needed independent-top-level-locs)))))))

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


Remove clean from lein aliases

Remove clean from lein aliases

Fixes #95 Maybe not the best solution but better than broken behaviour
for now.

--- src/leiningen/new/re_frame/project.clj
+++ src/leiningen/new/re_frame/project.clj
@@ -50,17 +50,13 @@
                              :linux   "xdg-open"}}}

   :aliases {"dev"          ["with-profile" "dev" "do"
-                            ["clean"]
                             ["run" "-m" "shadow.cljs.devtools.cli" "watch" "app"]]
             "prod"         ["with-profile" "prod" "do"
-                            ["clean"]
                             ["run" "-m" "shadow.cljs.devtools.cli" "release" "app"]]
             "build-report" ["with-profile" "prod" "do"
-                            ["clean"]
                             ["run" "-m" "shadow.cljs.devtools.cli" "run" "shadow.cljs.build-report" "app" "target/build-report.html"]
                             ["shell" "open" "target/build-report.html"]]
             "karma"        ["with-profile" "prod" "do"
-                            ["clean"]
                             ["run" "-m" "shadow.cljs.devtools.cli" "compile" "karma-test"]
                             ["shell" "karma" "start" "--single-run" "--reporters" "junit,dots"]]}


update schema

update schema

--- src/pc/datomic/schema.clj
+++ src/pc/datomic/schema.clj
@@ -31,6 +31,7 @@
    ;; TODO: more layer types
    (enum :layer.type/rect)
    (enum :layer.type/group)
+   (enum :layer.type/text)

    (attribute :layer/start-x
               :db.type/long)
@@ -72,6 +73,15 @@
    (attribute :layer/current-sy
               :db.type/long)

+   (attribute :layer/font-family
+              :db.type/string)
+
+   (attribute :layer/text
+              :db.type/string)
+
+   (attribute :layer/font-size
+              :db.type/long)
+
    ;; Use the layer's uuid so that the frontend can track children
    ;; Wonder what happens if we make a layer a child of one of its children...
    (attribute :layer/child


Disable verbose output

Disable verbose output

--- src/plan_schema/core.cljc
+++ src/plan_schema/core.cljc
@@ -894,7 +894,7 @@
                  (read-json-str data)
                  #?(:clj (read-string data)
                     :cljs "not implemented yet")))
-        _ (println "DEBUG DATA\n" (with-out-str (pprint data)))
+        ;_ (println "DEBUG DATA\n" (with-out-str (pprint data)))
         result (if (:error data)
                  data
                  (if (= network-type :htn)
@@ -903,7 +903,7 @@
                    #_(coerce-tpn data)
                    (records/coerce data))
                  )
-        _ (println "DEBUG RESULT\n" (with-out-str (pprint result)))
+        ;_ (println "DEBUG RESULT\n" (with-out-str (pprint result)))
         out (if (:error result)
               result
               (if (su/error? result)


Update test to address PR comment

Update test to address PR comment

--- system-int-test/test/cmr/system_int_test/search/collection_keyword_search_test.clj
+++ system-int-test/test/cmr/system_int_test/search/collection_keyword_search_test.clj
@@ -531,7 +531,7 @@
                             (assoc :DirectoryNames
                                    [(um/map->DirectoryNameType
                                      {:ShortName "CMR2654DNSN1" :LongName "CMR2654DNLN1"})])
-                            (assoc :ISOTopicCategories ["inlandWaters"])
+                            (assoc :ISOTopicCategories ["environment" "health"])
                             (assoc :ShortName "CMR2652SN1")
                             (assoc :EntryTitle "CMR2652ET1"))
                         {:format :umm-json
@@ -573,12 +573,16 @@
         "CMR2652NOAKW"
         []

-        "testing iso-topic-category search"
+        "testing iso-topic-category search - biota"
         "biota"
         [coll2]

-        "testing iso-topic-category search again"
-        "inlandWaters"
+        "testing iso-topic-category search - environment"
+        "environment"
+        [coll1]
+
+        "testing iso-topic-category search - health"
+        "health"
         [coll1]))

     (testing "json query searchs"


support :show-notes for (fo)

support :show-notes for (fo)

--- src/babel/english/morphology.cljc
+++ src/babel/english/morphology.cljc
@@ -9,7 +9,8 @@
 (declare get-string)
 (declare plural-en)

-(defn fo [input & {show-notes :show-notes}]
+(defn fo [input & {:keys [show-notes]
+                          :or {show-notes true}}]
   (cond

    (= input :fail)
@@ -20,12 +21,8 @@

    (and (map? input)
         (map? (get-in input [:english])))
-   (get-string (get-in input [:english]))
-
-   ;; TODO: this is the tricky part about combining fo and get-string.
-   (and (map? input)
-        (get-in input [:english]))
-   (get-string input)
+   (get-string (get-in input [:english])
+               :show-notes show-notes)

    (or (seq? input)
        (vector? input))
@@ -37,11 +34,13 @@
    true
    ""))

-(defn get-string [word & {show-notes :show-notes}]
+(defn get-string [word & {:keys [show-notes]
+                          :or {show-notes true}}]
   (log/debug (if (map? word) (str "get-string: " (strip-refs word))))
   (cond
+
    (ref? word)
-   (get-string @word)
+   (get-string @word :show-notes show-notes)

    (= word :top)
    ".."
@@ -58,24 +57,31 @@
         (= (get-in word '(:infl)) :past)
         (string? (get-in word '(:a :past))))
    (str (get-in word '(:a :past)) " "
-        (get-string (get-in word '(:b))))
+        (get-string (get-in word '(:b))
+                    :show-notes show-notes))

    ;; :note is used for little annotations that are significant in italian but not in english
    ;; e.g. gender signs (♂,♀) on nouns like "professore" and "professoressa".
    (and (string? (get-in word '(:english)))
         (string? (get-in word '(:note))))
-   (str (trim (get-string (dissoc word :note))) " (" (trim (get-in word '(:note))) ")")
+   (str (trim (get-string (dissoc word :note)
+                          :show-notes show-notes))
+        (if (not (= false show-notes))
+          (str " (" (trim (get-in word '(:note))) ")")))

    (= (get-in word '(:a)) :top)
    (str
-    ".." " " (get-string (get-in word '(:b))))
+    ".." " " (get-string (get-in word '(:b))
+                         :show-notes show-notes))

    ;; show elipsis (..) if :b is not specified.
    (and
     (= (get-in word '(:b)) :top)
-    (string? (get-string (get-in word '(:a)))))
+    (string? (get-string (get-in word '(:a))
+                         :show-notes show-notes)))
    (str
-    (get-string (get-in word '(:a)))
+    (get-string (get-in word '(:a))
+                :show-notes show-notes)
     " " "..")

    ;; show elipsis (..) if :a is not specified.
@@ -83,7 +89,8 @@
     (= (get-in word '(:b)) :top)
     (string? (get-in word '(:a :english))))
    (str
-    (get-string (get-in word '(:a :english)))
+    (get-string (get-in word '(:a :english))
+                :show-notes show-notes)
     " " "..")

    (string? word)
@@ -109,7 +116,7 @@
     (string? (get-in word '(:b :past)))
     (= (get-in word '(:a :infl)) :past))
    (join " " (list (get-in word '(:a :past))
-                          (get-in word '(:b :past))))
+                   (get-in word '(:b :past))))

    ;; (could have) + (do X) => "could have done X"
    (and
@@ -122,7 +129,8 @@
    ;; recursive call after inflecting '(:b :a) to past.
    (get-string {:a (get-in word '(:a))
                   :b {:a (get-in word '(:b :a :past-participle))
-                      :b (get-in word '(:b :b))}})
+                      :b (get-in word '(:b :b))}}
+               :show-notes show-notes)

    ;; (could have) + (make X) => "could have made X"
    (and
@@ -135,12 +143,13 @@
    ;; recursive call after inflecting '(:b :a) to past.
    (get-string {:a (get-in word '(:a))
                   :b {:a (get-in word '(:b :a :past))
-                      :b (get-in word '(:b :b))}})
+                      :b (get-in word '(:b :b))}}
+               :show-notes show-notes)
    (and
     (get-in word [:a])
     (get-in word [:b]))
-   (let [string-a (get-string (get-in word [:a]))
-         string-b (get-string (get-in word [:b]))]
+   (let [string-a (get-string (get-in word [:a]) :show-notes show-notes)
+         string-b (get-string (get-in word [:b]) :show-notes show-notes)]
      (log/debug (str "A AGR1: " (strip-refs (get-in word [:a]))))
      (log/debug (str "A AGR2: " (strip-refs (get-in word [:a :agr]))))
      (log/debug (str "A AGR3: " (strip-refs (get-in word [:a :agr :number]))))
@@ -164,9 +173,9 @@

        true
        (join " "
-             [(str (get-string (get-in word '(:a)))
+             [(str (get-string (get-in word '(:a)) :show-notes show-notes)
                    (get-in word [:punctuation :middle]))
-              (get-string (get-in word '(:b)))])))
+              (get-string (get-in word '(:b)) :show-notes show-notes)])))

    ;; TODO: this seems wrong: how could :infl == :english?
    (and (= :english (get-in word '(:infl)))
@@ -184,10 +193,10 @@
    ""

    (= true (get-in word '(:a :hidden)))
-   (get-string (get-in word '(:b)))
+   (get-string (get-in word '(:b)) :show-notes show-notes)

    (= true (get-in word '(:b :hidden)))
-   (get-string (get-in word '(:a)))
+   (get-string (get-in word '(:a) :show-notes show-notes))

    (and (= (get-in word '(:infl)) :conditional)
         (get-in word '(:english))
@@ -318,7 +327,7 @@
            (and (= person :2nd) (= number :sing)
                 (string? (get-in word [:past :2sing])))
            (get-in word '[:past :2sing])
-
+
            (and (= person :3rd) (= number :sing)
                 (string? (get-in word [:past :3sing])))
            (get-in word '(:past :3sing))
@@ -337,9 +346,11 @@

            ;; default
            (string? (get-in word [:past :english]))
-           (get-in word [:past :english])
-
-
+           (str (get-in word [:past :english])
+                (if (and (not (= false show-notes))
+                         (string? (get-in word [:past :note])))
+                  (str " (" (trim (get-in word '(:past :note))) ")")))
+
            true word)) ;; not enough agreement specified to conjugate.

    ;; regular past
@@ -363,6 +374,7 @@

            true
            (str stem "ed"))) ;; "play"->"played"
+
    (and
     (= :present (get-in word '(:infl)))
     (string? (get-in word '(:english))))
@@ -470,9 +482,9 @@
     (= (get-in word '(:cat) :noun))
     (string? (get-in word '(:english))))
    (trim (str (get-in word '(:english)) " "
-              (if (get-in word '(:note))
-                (get-in word '(:note))
-                "")))
+              (if (and (get-in word '(:note))
+                       (not (= false show-notes)))
+                (get-in word '(:note)))))

    ;; TODO: remove support for deprecated :root - use :sing instead.
    (and
@@ -552,7 +564,8 @@

 (declare fo-ps-en)

-(defn fo-ps-en [expr]
+(defn fo-ps-en [expr & {:keys [show-notes]
+                        :or {show-notes true}}]
   "show the phrase-structure of a phrase structure tree, e.g [hh21 'mangiare (to eat)' [cc10 'il (the)' 'pane(bread)']]"
   ;; [:first = {:head,:comp}] will not yet be found in expr, so this head-first? will always be false.
   (let [head-first? (= :head (get-in expr [:first]))]
@@ -627,8 +640,8 @@
      (and
       (map? expr)
       (:english expr))
-     (str (get-string (get-in expr '(:english))))
-
+     (str (get-string (get-in expr '(:english))
+                      :show-notes show-notes))
      true
      expr)))


oops, forgot default for `:width`

oops, forgot default for `:width`

--- src/re_com/typeahead.cljs
+++ src/re_com/typeahead.cljs
@@ -258,7 +258,8 @@
       {:pre [(validate-args-macro typeahead-args-desc args "typeahead")]}
       (let [{:as state :keys [suggestions waiting? suggestion-active-index external-model]} @state-atom
             last-data-source (:data-source state)
-            latest-external-model (deref-or-value model)]
+            latest-external-model (deref-or-value model)
+            width (or width "250px")]
         (when (not= last-data-source data-source)
           (swap! state-atom change-data-source data-source))
         (when (not= latest-external-model external-model)


Make chart-state an atom.

Make chart-state an atom.

--- src-cljs/kixi/hecuba/web/chart.cljs
+++ src-cljs/kixi/hecuba/web/chart.cljs
@@ -23,60 +23,89 @@

 ;;;;;;;;;;; Data ;;;;;;;;;;;

-(def mock-data {:external-humidity     [{"month" "Jan" "reading" 0.8}
-                                        {"month" "Feb" "reading" 0.9}
-                                        {"month" "Mar" "reading" 0.8}
-                                        {"month" "Apr" "reading" 0.75}
-                                        {"month" "May" "reading" 0.65}
-                                        {"month" "Jun" "reading" 0.50}
-                                        {"month" "Jul" "reading" 0.55}
-                                        {"month" "Aug" "reading" 0.6}
-                                        {"month" "Sep" "reading" 0.66}
-                                        {"month" "Oct" "reading" 0.68}
-                                        {"month" "Nov" "reading" 0.71}
-                                        {"month" "Dec" "reading" 0.9}]
-                :external-temperature  [{"month" "january" "reading" 6}
-                                        {"month" "february" "reading" 10}
-                                        {"month" "march" "reading" 12}
-                                        {"month" "april" "reading" 15}
-                                        {"month" "may" "reading" 18}
-                                        {"month" "june" "reading" 20}
-                                        {"month" "july" "reading" 25}
-                                        {"month" "august" "reading" 31}
-                                        {"month" "september" "reading" 20}
-                                        {"month" "october" "reading" 17}
-                                        {"month" "november" "reading" 12}
-                                        {"month" "december" "reading" 9}]})
+(def mock-data {"01"     [{"month" "Jan" "reading" 0.8}
+                          {"month" "Feb" "reading" 0.9}
+                          {"month" "Mar" "reading" 0.8}
+                          {"month" "Apr" "reading" 0.75}
+                          {"month" "May" "reading" 0.65}
+                          {"month" "Jun" "reading" 0.50}
+                          {"month" "Jul" "reading" 0.55}
+                          {"month" "Aug" "reading" 0.6}
+                          {"month" "Sep" "reading" 0.66}
+                          {"month" "Oct" "reading" 0.68}
+                          {"month" "Nov" "reading" 0.71}
+                          {"month" "Dec" "reading" 0.9}]
+                "02"     [{"month" "january" "reading" 6}
+                          {"month" "february" "reading" 10}
+                          {"month" "march" "reading" 12}
+                          {"month" "april" "reading" 15}
+                          {"month" "may" "reading" 18}
+                          {"month" "june" "reading" 20}
+                          {"month" "july" "reading" 25}
+                          {"month" "august" "reading" 31}
+                          {"month" "september" "reading" 20}
+                          {"month" "october" "reading" 17}
+                          {"month" "november" "reading" 12}
+                          {"month" "december" "reading" 9}]})

-(def app-state
-  {:selected []
-   :devices []})
+;;;;;;;;; Utils ;;;;;;;;;;;;;;;;;;;;;;

-(defn remove-chart []
+(defn- fetch-data
+  "The data need to be a vector."
+  [cursor opts]
+  (om/update!
+   cursor #(assoc % :data (get mock-data (:selected cursor)))))
+
+(defn- remove-chart []
   (.remove (first (nodelist-to-seq (.getElementsByTagName js/document "svg")))))

-(defn select-device [data device-name]
-  (.log js/console device-name)
+(defn- select-device!
+  [cursor device-id]
+  (.log js/console device-id)
  ; (remove-chart)
- ;  (om/transact! app [:selected] (constantly device-name))
-  )
+  (om/update!
+   cursor #(assoc % :selected (vector device-id))))

-;;;;;;;;;;; List of devices for axis plots ;;;;;;;;;;
+;;;;;;;;;; Components ;;;;;;;;;;;;;;;;;
+
+(def chart-state
+  (atom {:selected ["01"]
+         :property "rad003"
+         :devices [{:hecuba/name "01"
+                    :name "External temperature"}
+                   {:hecuba/name "02"
+                    :name "External humidity"}
+                   {:hecuba/name "03"
+                    :name "Ambient temperature"}]
+         :data (get mock-data "01")}))
+
+;;;;;;;;;;; Component 1:  List of devices for axis plots ;;;;;;;;;;

 (defn device-list-item
   [devices]
-  (fn [data owner]
+  (fn [cursor owner]
     (om/component
-    (let [device-name  (for [device devices] (get data device))]
-      (apply dom/input #js {:type "checkbox" :onClick #(select-device data (str device-name))}
-            (str device-name))))))
+    (let [device-details  (for [device devices] (get cursor device))
+          device-id       (nth device-details 0) ;; TODO Sersiously need to change the way elements are accessed
+          device-name     (str (nth device-details 1))
+          selected        (= device-id (first (:selected cursor)))]
+      (apply dom/input #js {:className (when selected "selected")
+                            :type "checkbox"
+                            :onClick #(select-device! data device-id)}
+            device-name)))))

-;;;;;;;;;; Chart UI ;;;;;;;;;;
+;;;;;;;;;; Component 2: Chart UI ;;;;;;;;;;

 (defn chart-item
   [device-details]
-  (fn [data opts]
+  (fn [cursor opts]
     (reify
+      om/IInitState
+      (init-state [_]
+        (om/update! cursor #(assoc % :selected "01")))
+      om/IWillMount
+      (will-mount [_]
+        (go (fetch-data cursor opts)))
       om/IRender
       (render [this]
         (dom/div #js {:id "chart"}))
@@ -84,7 +113,9 @@
       (did-mount [_ owner]
         (let [Chart        (.-chart dimple)
               svg          (.newSvg dimple "#chart" 400 350)
-              dimple-chart (Chart. svg (clj->js (:external-humidity mock-data)))]
+              measurements (:data cursor)
+              dimple-chart (Chart. svg (clj->js measurements))]
+          (.log js/console measurements)
           (.setBounds dimple-chart 60 30 300 300)
           (.addCategoryAxis dimple-chart "x" "month")
           (.addMeasureAxis dimple-chart "y" "reading")
@@ -94,31 +125,26 @@
 ;;;;;;;;;;; Bootstrap ;;;;;;;;;;;;

 (defn create-form-and-chart [model-path device-item chart-item]
-  (fn [data owner]
+  (fn [cursor owner]
     (reify
       om/IRender
       (render [_]
         (dom/div #js {:className "devices"}
+                 (dom/h3 nil (str "Metering data - " (get-in cursor [:property])))
+                 (dom/h4 nil "Select devices to be plotted on the chart:")
                  (dom/form #js {:className "devices-form"}
                            (om/build-all device-item
-                                         (get-in data model-path)
+                                         (get-in cursor model-path)
                                          {:key :hecuba/name})
-                           (om/build chart-item data)))))))
+                           (om/build chart-item cursor)))))))

-(go (let [external-temp     {:hecuba/name "01"
-                             :name "External temperature"
-                             :data (:external-temperature mock-data)}
-          external-humidity {:hecuba/name "02"
-                             :name "External humidity"
-                             :data (:external-humidity mock-data)}]
-      (let [init-state (update-in app-state [:devices]
-                                  #(vec (concat % [external-temp external-humidity])))]
-        (om/root init-state (create-form-and-chart [:devices]
+(om/root chart-state (create-form-and-chart [:devices]
                                                    (device-list-item [:hecuba/name :name])
                                                    (chart-item [:hecuba/name :name :data]))
-                 (.getElementById js/document "app")))))
+                 (.getElementById js/document "app"))

+


[core] Attempt fix of message errors (group-id no longer necessary)

--- src/braid/core/common/schema.cljc
+++ src/braid/core/common/schema.cljc
@@ -7,7 +7,6 @@
   "A new message, before saved into thread - what the client sends"
   {:id uuid?
    :thread-id uuid?
-   :group-id uuid?
    :user-id uuid?
    :content string?
    :created-at inst?


Read inbox minimum allowed date from environment, fallback to inline value.

--- src/oc/storage/config.clj
+++ src/oc/storage/config.clj
@@ -106,4 +106,4 @@
     :table-prefix dynamodb-table-prefix
   })

-(defonce inbox-minimum-date "2019-10-28T00:00:00.000Z")+(defonce inbox-minimum-date (or (env :inbox-minimum-date) "2019-10-28T00:00:00.000Z"))


partial implementation of NEXT Design

partial implementation of NEXT Design

--- src/clj/game/cards-identities.clj
+++ src/clj/game/cards-identities.clj
@@ -267,6 +267,22 @@
                                :effect (effect (play-instant target))}}}]
      {:events {:agenda-scored nasol :agenda-stolen nasol}})

+   "NEXT Design: Guarding the Net"
+   (let [ndhelper (fn nd [n] {:prompt (msg "When finished, click NEXT Design: Guarding the Net to draw back up to 5 cards in HQ. "
+                                           "Choose a piece of ICE in HQ to install:")
+                              :choices {:req #(and (:side % "Corp") (= (:type %) "ICE") (= (:zone %) [:hand]))}
+                              :effect (req (corp-install state side target nil)
+                                           (when (< n 3)
+                                             (resolve-ability state side (nd (inc n)) card nil)))})]
+     {:events {:pre-first-turn {:req (req (= side :corp))
+                                :msg "install up to 3 pieces of ICE and draw back up to 5 cards"
+                                :effect (effect (resolve-ability (ndhelper 1) card nil)
+                                                (update! (assoc card :fill-hq true)))}}
+      :abilities [{:req (req (:fill-hq card))
+                   :msg (msg "draw " (- 5 (count (:hand corp))) " cards")
+                   :effect (effect (draw (- 5 (count (:hand corp))))
+                                   (update! (dissoc card :fill-hq)))}]})
+
    "Nisei Division: The Next Generation"
    {:events {:psi-game {:msg "gain 1 [Credits]" :effect (effect (gain :corp :credit 1))}}}


Upgrade Leela's ability for better interaction with Gang Sign, and for accessing cards returned to HQ during a multi-access. Fixes #1271.

--- src/clj/game/cards-identities.clj
+++ src/clj/game/cards-identities.clj
@@ -263,7 +263,8 @@
                  :effect (req (draw state :corp) (swap! state assoc-in [:per-turn (:cid card)] true))}]}

    "Leela Patel: Trained Pragmatist"
-   {:events {:agenda-scored
+   {:flags {:slow-hq-access (req true)}
+    :events {:agenda-scored
              {:effect (req (toast state :runner
                                   (str "Click Leela Patel: Trained Pragmatist to add 1 unrezzed card to HQ.") "info")
                            (update! state :runner (update-in card [:bounce-hq] #(inc (or % 0)))))}


remove trash-cost bonus from state after playing Product Recall

--- src/clj/game/cards-operations.clj
+++ src/clj/game/cards-operations.clj
@@ -429,7 +429,8 @@
                      (gain state :corp :credit tcost)
                      (resolve-ability state side
                        {:msg (msg "trash " (card-str state c) " and gain " tcost " [Credits]")}
-                      card nil))))}
+                      card nil)
+                     (swap! state update-in [:bonus] dissoc :trash))))}

    "Psychographics"
    {:req (req tagged) :choices :credit :prompt "How many credits?"


fix incorrect placement of task id sanity check for spout acking

--- src/clj/backtype/storm/daemon/executor.clj
+++ src/clj/backtype/storm/daemon/executor.clj
@@ -306,9 +306,9 @@
         tuple-action-fn (fn [task-id ^Tuple tuple]
                           (let [id (.getValue tuple 0)
                                 [stored-task-id spout-id tuple-finished-info start-time-ms] (.remove pending id)]
-                            (when-not (= stored-task-id task-id)
-                              (throw-runtime "Fatal error, mismatched task ids: " task-id " " stored-task-id))
                             (when spout-id
+                              (when-not (= stored-task-id task-id)
+                                (throw-runtime "Fatal error, mismatched task ids: " task-id " " stored-task-id))
                               (let [time-delta (time-delta-ms start-time-ms)]
                                 (condp = (.getSourceStreamId tuple)
                                     ACKER-ACK-STREAM-ID (.add event-queue #(ack-spout-msg executor-data (task-datas task-id)


update recipient count on badge import

update recipient count on badge import

--- src/clj/salava/badge/importer.clj
+++ src/clj/salava/badge/importer.clj
@@ -146,24 +146,29 @@
 (defn upload-badge [ctx uploaded-file user-id]
   (log/info "upload-badge: got new upload from user id" user-id)
   (try
-    (db/save-user-badge! ctx
-                         (-> {:id user-id :emails (user/verified-email-addresses ctx user-id)}
-                             (p/file->badge uploaded-file)
-                             (assoc :status "accepted")))
+    (->> (db/save-user-badge! ctx
+                              (-> {:id user-id :emails (user/verified-email-addresses ctx user-id)}
+                                  (p/file->badge uploaded-file)
+                                  (assoc :status "accepted")))
+         (b/update-recipient-count ctx user-id) ;;update recipient count and create badge connection
+         )
     {:status "success" :message "badge/Badgeuploaded" :reason "badge/Badgeuploaded"}
     (catch Throwable ex
       (log/error "upload-badge: upload failed")
       (log/error (.toString ex))
       {:status "error" :message "badge/Errorwhileuploading" :reason (.getMessage ex)})))

+;;TODO Update recipient count and also make user badge connection
 (defn upload-badge-via-assertion [ctx assertion user]
   (let [user-id (:id user)]
     (log/info "assertion-badge-upload: got new upload from user id " user-id)
     (try
-      (db/save-user-badge! ctx
-                           (-> {:id user-id :emails (user/verified-email-addresses ctx user-id)}
-                               (p/str->badge assertion)
-                               (assoc :status "accepted")))
+      (->> (db/save-user-badge! ctx
+                                (-> {:id user-id :emails (user/verified-email-addresses ctx user-id)}
+                                    (p/str->badge assertion)
+                                    (assoc :status "accepted")))
+           (b/update-recipient-count ctx user-id) ;;update recipient count and create badge connection
+           )
       {:status "success" :message "badge/Badgeuploaded" :reason "badge/Badgeuploaded"}
       (catch Throwable ex
         (log/error "assertion-badge-upload: upload failed")


Added comments to specification related backend functions.

--- src/clj_formal_specifications_app/spec.clj
+++ src/clj_formal_specifications_app/spec.clj
@@ -1,6 +1,8 @@
 (ns clj-formal-specifications-app.spec)

 (defn get-ns-name
+  "If the given string starts with the ns macro call, returns the first
+  parameter given to it, which is the name of the namespace."
   [s]
   (re-find #"(?<=\(ns\s)[a-zA-Z0-9\.-]+(?=[\s\(\)])" s))

@@ -23,6 +25,8 @@
                    :contents (str @(var-get (val spec-ref-entry)))}))

 (defn assoc-to-spec
+  "Associates a map-entry to spec, if map-entry is action or specification
+  related ref."
  [spec map-entry]
   (cond
    (action-entry? map-entry)
@@ -34,6 +38,7 @@
    :else spec))

 (defn ns-spec
+  "Gets all public vars from ns, then uses them to build a specification map."
   [ns]
   (reduce assoc-to-spec
           {:namespace ns :actions #{} :data #{}}


Speed up feed-str

Speed up feed-str

--- src/cljs/asciinema_player/vt.cljs
+++ src/cljs/asciinema_player/vt.cljs
@@ -815,7 +815,7 @@
   (reduce (fn [vt input] (feed-one vt input)) vt inputs))

 (defn feed-str [vt str]
-  (let [codes (map #(.charCodeAt % 0) str)]
+  (let [codes (mapv #(.charCodeAt str %) (range (count str)))]
     (feed vt codes)))

 (defn compact-line


Update action-types map.

Update action-types map.

--- src/cljs/hatnik/web/client/components.cljs
+++ src/cljs/hatnik/web/client/components.cljs
@@ -35,7 +35,10 @@
             :alt "email"}
    "github-issue" {:text "issue"
                    :icon "/img/github-icon.png"
-                   :alt "github"}})
+                   :alt "github"}
+   "github-pull-request" {:text "pull requst"
+                          :icon "/img/github-icon.png"
+                          :alt "github"}})

 (defn render-action-type [type]
   (let [{:keys [text icon alt]} (action-types type)]


Refactor

Refactor

--- src/cljs/gc_api_browser/core.cljs
+++ src/cljs/gc_api_browser/core.cljs
@@ -41,6 +41,13 @@
                           (assoc :response resp)
                           (update :history #(conj % (select-keys m [:request :response])))))))

+(defn render-request-and-response [app]
+  (dom/div nil
+           (om/build request/component (:request app)
+                     {:opts {:handle-new-response-fn (partial handle-new-response app)}})
+           (when-let [resp (:response app)]
+             (om/build response/component resp))))
+
 (defn main []
   (om/root
     (fn [app _]
@@ -67,11 +74,7 @@
                                (dom/h2 #js {:className "u-text-light u-margin-Am u-text-center"}
                                        (get-in app [:request :text])))
                    (if (get-in app [:request :schema])
-                     (dom/div nil
-                              (om/build request/component (:request app)
-                                        {:opts {:handle-new-response-fn (partial handle-new-response app)}})
-                              (when-let [resp (:response app)]
-                                (om/build response/component resp)))
-                     (dom/h1 nil "Select a JSON Schema" (schema-select/schema-file (:request app))))))))
+                     (render-request-and-response app)
+                     (schema-select/schema-file (:request app)))))))
     app-state
     {:target (.getElementById js/document "app")}))


un-debug

un-debug

--- src/clojure/com/zensol/cisql/db_access.clj
+++ src/clojure/com/zensol/cisql/db_access.clj
@@ -12,13 +12,13 @@

 (def products ["mysql" "postgresql" "sqlite"])

-;; (def ^:private dbspec (atom nil))
+(def ^:private dbspec (atom nil))

-;; (def ^:private current-catalog (atom nil))
+(def ^:private current-catalog (atom nil))

-;; (def ^:private db-info-data (atom nil))
+(def ^:private db-info-data (atom nil))

-;; (def ^:private last-frame-label (atom nil))
+(def ^:private last-frame-label (atom nil))

 (defn- resolve-connection [db]
   (let [conn (jdbc/db-connection db)


Add event loop pairs

Add event loop pairs

This breaks the spirit behind unit tests, even though they don't realize
it. The brain-dead reader/writer functions I'm supplying throw
exceptions that the unit tests really don't have a good way to find out
about.

--- src/com/frereth/server/system.clj
+++ src/com/frereth/server/system.clj
@@ -1,11 +1,14 @@
 (ns com.frereth.server.system
   (:require
+   [clojure.core.async :as async]
+   [com.frereth.common.async-zmq :as async-zmq]
    [com.frereth.common.util :as util]
    [com.stuartsierra.component :as component]
    [component-dsl.system :as cpt-dsl]
    [schema.core :as s]
    [taoensso.timbre :as log])
-  (import [com.stuartsierra.component SystemMap]))
+  (import [com.frereth.common.async_zmq EventPair EventPairInterface]
+          [com.stuartsierra.component SystemMap]))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Schema
@@ -28,20 +31,49 @@
     {;; Almost definitely want to maximize this thread count
      ;; Although that really depends on the environment.
      ;; It makes sense for a production server.
-     ;; For a local one...probably not so much
+     ;; For a local one...probably not so much.
+     ;; Q: Why not?
+     ;; A: Well, context switches come to mind. I'm not
+     ;; sure whether I buy that that would be an issue.
      :context {:thread-count (-> (util/core-count) dec (max 1))}

      :action-socket (assoc-in default-sock [:url :port] 7841)
+     :action-loop {:_name "Action!"}
+     :action-loop-interface {:in-chan (async/chan)
+                             :external-reader (fn [_]
+                                                (throw (ex-info "Not Implemented" {})))
+                             :external-writer (fn [_ _2]
+                                                (throw (ex-info "Not Implemented" {})))}
+
      :auth-socket (assoc-in default-sock [:url :port] 7843)
+     :auth-loop {:_name "authcz"}
+     :auth-loop-interface {:in-chan (async/chan)
+                           :external-reader (fn [_]
+                                              (throw (ex-info "Not Implemented" {})))
+                           :external-writer (fn [_ _2]
+                                              (throw (ex-info "Not Implemented" {})))}
+
      :control-socket (assoc default-sock
                             :url {:protocol :inproc
-                                  :address (name (gensym))})}))
+                                  :address (name (gensym))})
+     :control-loop {:_name "control"}
+     :control-loop-interface {:in-chan (async/chan)
+                              :external-reader (fn [_]
+                                                 (throw (ex-info "Not Implemented" {})))
+                              :external-writer (fn [_ _2]
+                                                 (throw (ex-info "Not Implemented" {})))}}))

 (defn structure []
   '{:action-socket com.frereth.common.zmq-socket/ctor
+    :action-loop com.frereth.common.async-zmq/ctor
+    :action-loop-interface com.frereth.common.async-zmq/ctor-interface
     :auth-socket com.frereth.common.zmq-socket/ctor
+    :auth-loop com.frereth.common.async-zmq/ctor
+    :auth-loop-interface com.frereth.common.async-zmq/ctor-interface
     :context com.frereth.common.zmq-socket/ctx-ctor
     :control-socket com.frereth.common.zmq-socket/ctor
+    :control-loop com.frereth.common.async-zmq/ctor
+    :control-loop-interface com.frereth.common.async-zmq/ctor-interface
     :done com.frereth.server.sentinal/ctor
     :logger com.frereth.server.logging/ctor
     ;; For auth
@@ -49,8 +81,14 @@

 (defn dependencies []
   {:action-socket {:ctx :context}
+   :action-loop-interface {:ex-sock :action-socket}
+   :action-loop {:interface :action-loop-interface}
    :auth-socket {:ctx :context}
+   :auth-loop-interface {:ex-sock :auth-socket}
+   :auth-loop {:ex-sock :auth-socket, :interface :auth-loop-interface}
    :control-socket {:ctx :context}
+   :control-loop-interface {:ex-sock :control-socket}
+   :control-loop {:ex-sock :action-socket, :interface :action-loop-interface}
    :principal-manager [:control-socket]})

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


Forget snippet for actions.

Forget snippet for actions.

--- src/ombs/view/actions.clj
+++ src/ombs/view/actions.clj
@@ -5,6 +5,9 @@
     [ombs.core :as core]
     )
   )
+
+(h/defsnippet parts-snip "../resources/public/parts.html" [:#parts-row] [parts]
+  [:.parts] (h/set-attr :value (str parts)))
 (defn fill-parts [parts match]
   (if (= 0 parts)
     nil


Now it works, we don't need tests

Now it works, we don't need tests

--- src/orbitingnews/core.clj
+++ src/orbitingnews/core.clj
@@ -9,7 +9,7 @@
             [orbitingnews.twitter :as twitter]
             [hiccup.core :as dom]
             [hiccup.page :as page]
-            [clojure.core.async :as async :refer :all]
+            [clojure.core.async :as async :refer [<! >! chan go put! alts! take!]]
             [cognitect.transit :as transit])
   (:gen-class))


Make hyphenate more robust

Make hyphenate more robust

--- src/clj/hyphen_keeper/hyphenate.clj
+++ src/clj/hyphen_keeper/hyphenate.clj
@@ -1,5 +1,6 @@
 (ns hyphen-keeper.hyphenate
-  (:require [clojure.java.io :as io])
+  (:require [clojure.java.io :as io]
+            [clojure.string :as string])
   (:import ch.sbs.jhyphen.Hyphenator))

 (def hyphenator (new Hyphenator (io/file "/usr/share/hyphen/hyph_de_DE.dic")))
@@ -9,4 +10,6 @@
   ([spelling text]
    (hyphenate spelling text \-))
   ([spelling text hyphen]
-   (.hyphenate hyphenator text hyphen nil)))
+   (if (string/blank? text)
+     ""
+     (.hyphenate hyphenator text hyphen nil))))


debugging

debugging

--- src/clj/rumahsewa141/middleware.clj
+++ src/clj/rumahsewa141/middleware.clj
@@ -13,7 +13,9 @@
             [buddy.auth.accessrules :refer [restrict]]
             [buddy.auth :refer [authenticated?]]
             [buddy.auth.backends.session :refer [session-backend]]
-            [ring.util.response :refer [redirect]])
+            [ring.util.response :refer [redirect]]
+            [selmer.middleware :refer [wrap-error-page]]
+            [prone.middleware :refer [wrap-exceptions]])
   (:import [javax.servlet ServletContext]))

 (defn wrap-context [handler]
@@ -93,4 +95,6 @@
             (assoc-in [:security :anti-forgery] false)
             (dissoc :session)))
       wrap-context
-      wrap-internal-error))
+      wrap-internal-error
+      wrap-error-page
+      wrap-exceptions))


Remove unnecessary code

Remove unnecessary code

--- src/cljc/gyptis/vega_templates.cljc
+++ src/cljc/gyptis/vega_templates.cljc
@@ -185,7 +185,7 @@
              :range "width",
              ;; manually set domain because vega.js will re-order
              ;; the domain if we try to pass in the field as in y below
-             :domain (u/dedup (map #(get % *x*) data))}
+             :domain {:data *table* :field *x* :sort false}}
             {:name "y",
              :type "linear",
              :range "height",
@@ -229,7 +229,7 @@
                  :scales
                  ^:replace [{:name "x",
                              :type "ordinal",
-                             :domain (u/dedup (map #(get % *x*) data)),
+                             :domain {:data *table* :field *x* :sort false},
                              :range "width"}
                             {:name "y",
                              :type "linear",
@@ -283,7 +283,7 @@
                                                 :type "ordinal",
                                                 :padding 0.2,
                                                 :range "width",
-                                                :domain (u/dedup (map #(get % *x*) data))}
+                                                :domain {:data *table* :field *x* :sort false}}
                                                {:name "y",
                                                 :type "linear",
                                                 :range "height",


Remove print statement

Remove print statement

--- src/clojure/paredit_widget/core.clj
+++ src/clojure/paredit_widget/core.clj
@@ -95,7 +95,6 @@

 (defn exec-paredit!
   [k w buffer enable-default? enable-advanced?]
-  (println k)
   (when-let [cmd (or (and enable-default?
                           (default-keymap k))
                      (and @enable-advanced?


new splash message

new splash message

--- src/clojure_getting_started/web.clj
+++ src/clojure_getting_started/web.clj
@@ -10,7 +10,7 @@
 (defn splash []
   {:status 200
    :headers {"Content-Type" "text/plain"}
-   :body (pr-str ["Hallo Du," :from 'Heroku])})
+   :body (pr-str "Hier gibt's noch nix zu gucken, geh'n se weiter ...")})

 (defroutes app
   (GET "/camel" {{input :input} :params}


Use some instead of reduce to pick resolver on connect

--- src/com/wsscode/pathom/connect.cljc
+++ src/com/wsscode/pathom/connect.cljc
@@ -50,15 +50,14 @@
                        :attrs   attrs
                        :missing missing})))
              (sort-by (comp count :missing))
-             (reduce (fn [_ {:keys [sym attrs]}]
-                       (if-not (contains? dependency-track [sym attrs])
-                         (let [e       (try
-                                         (p/entity (update env ::dependency-track (fnil conj #{}) [sym attrs]) attrs)
-                                         (catch Throwable _ {}))
-                               missing (set/difference (set attrs) (set (keys e)))]
-                           (when-not (seq missing)
-                             (reduced {:e (select-keys e attrs) :f sym})))))
-               nil))
+             (some (fn [{:keys [sym attrs]}]
+                     (if-not (contains? dependency-track [sym attrs])
+                       (let [e       (try
+                                       (p/entity (update env ::dependency-track (fnil conj #{}) [sym attrs]) attrs)
+                                       (catch Throwable _ {}))
+                             missing (set/difference (set attrs) (set (keys e)))]
+                         (when-not (seq missing)
+                           {:e (select-keys e attrs) :f sym}))))))
         (throw (ex-info (str "Attribute " k " is defined but requirements could not be met.")
                  {:attr k :entity e :requirements (keys attr-resolvers)}))))))


Fix failing test.

Fix failing test.

--- src/leiningen/xjc.clj
+++ src/leiningen/xjc.clj
@@ -3,5 +3,4 @@

 (defn xjc
   [project & args]
-  (plugin/xjc-task project)
-  project)
+  (plugin/xjc-task project))


Add re-frame-10x title to popout window

Add re-frame-10x title to popout window

--- src/day8/re_frame_10x/events.cljs
+++ src/day8/re_frame_10x/events.cljs
@@ -248,7 +248,7 @@

         d (.-document w)]
     (.open d)
-    (.write d "

")
+    (.write d "<title>re-frame-10x</title>

")
     (goog.object/set w "onload" #(mount w d))
     (.close d)))


Added new methods to start game

Added new methods to start game

  - Fixed minor bugs with options

--- src/retro_fever/core.cljs
+++ src/retro_fever/core.cljs
@@ -73,13 +73,22 @@
     (game-loop (/ 1000 (:ups opts))
                update-fn render-fn)))

+(defmethod game cljs.core/PersistentHashMap
+  [{:keys [game-state scene-lens]} & options]
+  (apply (partial game game-state scene-lens) options))
+
+(defmethod game cljs.core/PersistentArrayMap
+  [{:keys [game-state scene-lens]} & options]
+  (apply (partial game game-state scene-lens) options))
+
 (defmethod game cljs.core/Atom
   [game-state & options]
   (let [scene-view (if (vector? (first options)) (first options) nil)
         options (if scene-view (rest options) options)]
-    (game
-     (if (empty? scene-view)
-       (fn [] (swap! game-state scene/update))
-       (fn [] (swap! game-state update-in scene-view scene/update)))
-     (fn [context] (scene/render (get-in @game-state scene-view) context))
-     options)))
+    (apply
+     (partial game
+       (if (empty? scene-view)
+         (fn [] (swap! game-state scene/update))
+         (fn [] (swap! game-state update-in scene-view scene/update)))
+       (fn [context] (scene/render (get-in @game-state scene-view) context)))
+       options)))


fully async alia session

fully async alia session

--- src/er_cassandra/session/alia.clj
+++ src/er_cassandra/session/alia.clj
@@ -8,6 +8,9 @@
    [qbits.alia.policy.load-balancing :as lb]
    [qbits.alia.manifold :as aliam]
    [qbits.hayt :as h]
+   [cats.core :refer [mlet return >>=]]
+   [cats.context :refer [with-context]]
+   [cats.labs.manifold :refer [deferred-context]]
    [er-cassandra.session :as s])
   (:import
    [er_cassandra.session
@@ -54,6 +57,7 @@
     (alia/shutdown cluster)))

 (defnk ^:private create-alia-session*
+  "returns a Deferred<com.datastax.driver.core/Session>"
   [contact-points
    datacenter
    keyspace
@@ -68,17 +72,19 @@

         _ (info "create-alia-session*" args)
         cluster (alia/cluster cluster-args)
-        alia-session (alia/connect cluster)]
-
-    (when (not-empty init-statements)
-      (doseq [stmt init-statements]
-        (as-> stmt %
-          (str/replace % "${keyspace}" keyspace)
-          (alia/execute alia-session %))))
-
-    (alia/execute alia-session (str "USE " keyspace ";"))
-
-    alia-session))
+        alia-session (alia/connect cluster)
+
+        init-fns (for [stmt init-statements]
+                   (fn [_]
+                     (as-> stmt %
+                       (str/replace % "${keyspace}" keyspace)
+                       (alia/execute alia-session %))
+                     (return deferred-context true)))]
+
+    (with-context deferred-context
+      (mlet [_ (apply >>= (return true) init-fns)
+             _ (alia/execute alia-session (str "USE " keyspace ";"))]
+        (return alia-session)))))

 (defrecord AliaSession [keyspace alia-session]
   Session
@@ -95,9 +101,11 @@

 (defnk create-session
   [contact-points datacenter keyspace :as args]
-  (->AliaSession
-   keyspace
-   (create-alia-session* args)))
+  (with-context deferred-context
+    (mlet [datastax-session (create-alia-session* args)]
+      (->AliaSession
+       keyspace
+       datastax-session))))

 (defn mutated-tables
   [spy-session]
@@ -121,15 +129,29 @@
       (throw (ex-info "truncate-spy-tables is only for *_test keyspaces"
                       {:keyspace ks
                        :mutated-tables mts})))
-    (doseq [mt mts]
-      (s/execute spy-session (h/truncate mt)))
-    (s/reset-spy-log spy-session)))
+
+    (info "truncating spy tables")
+
+    (with-context deferred-context
+      (mlet [:let [tfns (for [mt mts]
+                          (fn [_]
+                            (info "truncating: " mt)
+                            (s/execute spy-session (h/truncate mt))
+                            (return deferred-context true)))]
+
+             _ (if (not-empty tfns)
+                 (apply >>= (return true) tfns)
+                 (return true))]
+
+        (s/reset-spy-log spy-session)
+        (return true)))))

 (defrecord AliaSpySession [keyspace alia-session spy-log-atom truncate-on-close]
   Session
   (execute [this statement]
     (s/execute this statement {}))
   (execute [_ statement opts]
+    (info "spying" statement opts)
     (swap! spy-log-atom conj statement)
     (execute* alia-session statement opts))
   (execute-buffered [this statement]
@@ -138,10 +160,11 @@
     (swap! spy-log-atom conj statement)
     (execute-buffered* alia-session statement opts))
   (close [self]
-    (when truncate-on-close
-      (debug "truncating spy tables")
-      (truncate-spy-tables self))
-    (shutdown-session-and-cluster alia-session))
+    (with-context deferred-context
+      (mlet [_ (if truncate-on-close
+                 (truncate-spy-tables self)
+                 (return true))]
+        (shutdown-session-and-cluster alia-session))))

   KeyspaceProvider
   (keyspace [_] keyspace)
@@ -152,48 +175,39 @@

 (defnk create-spy-session
   [contact-points datacenter keyspace {truncate-on-close nil} :as args]
-  (->AliaSpySession
-   keyspace
-   (create-alia-session* (dissoc args :truncate-on-close))
-   (atom [])
-   truncate-on-close))
-
-(defn with-spy-session-reset*
-  "start an alia spy-session, call a function and truncate
-  all tables which were touched during the function"
-  [spy-session f]
-  (try
-    (f)
-    (finally
-      (truncate-spy-tables spy-session))))
-
-(defmacro with-spy-session-reset
-  [spy-session & body]
-  `(with-spy-session-reset*
-     ~spy-session
-     (fn [] ~@body)))
+  (with-context deferred-context
+    (mlet [datastax-session (create-alia-session* (dissoc args :truncate-on-close))]
+      (->AliaSpySession
+       keyspace
+       datastax-session
+       (atom [])
+       truncate-on-close))))

 ;; a test-session is just a spy-session which will initialise it's keyspace
 ;; if necesary and will truncate any used tables when closed
 (defnk create-test-session
   [{contact-points nil} {port nil} {datacenter nil} keyspace :as args]
-  (let [session
-        (create-spy-session
-           (merge
-            args
-            {:contact-points (or contact-points ["localhost"])
-             :port (or port
-                       (some-> (env :cassandra-port) Integer/parseInt)
-                       9042)
-             :datacenter datacenter
-             :init-statements
-             [(str "CREATE KEYSPACE IF NOT EXISTS "
-                   "  \"${keyspace}\" "
-                   "WITH replication = "
-                   "  {'class': 'SimpleStrategy', "
-                   "   'replication_factor': '1'} "
-                   " AND durable_writes = true;")]
-
-             :truncate-on-close true}))]
-    [session
-     (fn [] (s/close session))]))
+  (with-context deferred-context
+    (mlet [session
+           (create-spy-session
+            (merge
+             args
+             {:contact-points (or contact-points ["localhost"])
+              :port (or port
+                        (some-> (env :cassandra-port) Integer/parseInt)
+                        9042)
+              :datacenter datacenter
+              :init-statements
+              [(str "CREATE KEYSPACE IF NOT EXISTS "
+                    "  \"${keyspace}\" "
+                    "WITH replication = "
+                    "  {'class': 'SimpleStrategy', "
+                    "   'replication_factor': '1'} "
+                    " AND durable_writes = true;")]
+
+              :truncate-on-close true}))]
+      (return
+       [session
+        ;; TODO this fn needs to be async friendly now
+        ;; since we are returning a Deferred<session>
+        (fn [] (s/close session))]))))


(PE-5211) Update trapperkeeper-webserver-jetty9 for pe-console-services

--- configs/pe-console-services/pe-console-services.clj
+++ configs/pe-console-services/pe-console-services.clj
@@ -7,7 +7,7 @@
                  [puppetlabs/classifier "{{{pe-classifier-version}}}"]
                  ;[puppetlabs/pe-activity-service "{{{pe-classifier-version}}}"]
                  ;[puppetlabs/pe-trapperkeeper-proxy "{{{pe-trapperkeeper-proxy}}}"]
-                 [puppetlabs/trapperkeeper-webserver-jetty9 "0.5.1"]]
+                 [puppetlabs/trapperkeeper-webserver-jetty9 "0.5.2"]]

   :uberjar-name "console-services-release.jar"


Cleanup requires

Cleanup requires

--- test/github_changelog/conventional_test.clj
+++ test/github_changelog/conventional_test.clj
@@ -2,8 +2,7 @@
   (:require [clojure.test :refer :all]
             [github-changelog
              [conventional :as conventional]
-             [schema-generators :as g]]
-            [clojure.test.check.generators :as gen]))
+             [schema-generators :as g]]))

 (def repo-url "https://github.company.com/user/repo")
 (def jira-url "http://dev.clojure.org/jira/")


core parinfer compatibility

core parinfer compatibility

--- src/semantic_csv/core.clj
+++ src/semantic_csv/core.clj
@@ -235,7 +235,7 @@
         (let [first-row# (first rows#)
               rest-rows# (rest rows#)]
           (cons first-row# (->> rest-rows# ~@forms))))
-        ~data)))
+      ~data)))

 ;; This macro generalizes the `:except-first` option of the `cast-with` function for arbitrary processing,
 ;; operating on every row _except_ for the first.