ui fixes

ui fixes

--- src/cljs/salava/social/ui/dashboard.cljs
+++ src/cljs/salava/social/ui/dashboard.cljs
@@ -223,7 +223,7 @@
      [:div.row_2;.block-content
       [:div.heading_1
        [:i.fa.fa-search.icon]
-       [:span.title (t :gallery/Explore)]]
+       [:a {:href (path-for "/gallery")} [:span.title (t :gallery/Explore)]]]
       [:div.content
        [:div.info-block.badge-connection
         [:a {:href (path-for "/gallery/badges")}
@@ -258,7 +258,7 @@
      [:div.row_2
       [:div
        [:div.heading_1 [:i.fa.fa-group.icon]
-        [:span.title (t :social/Connections)]]
+        [:a {:href (path-for "/connections")}[:span.title (t :social/Connections)]]]
        [:div.content;.connections-block;.block-content
         [user-connections-stats]
         [:div.info-block.badge-connection
@@ -295,8 +295,8 @@
        [:div.profile-block.row_1;.block-content
         [:div.heading_1
          [:i.fa.fa-user.icon]
-         [:span.title
-          (t :user/Profile)]]
+         [:a {:href (path-for "/user/profile" (get-in user [:user :id]))}[:span.title
+          (t :user/Profile)]]]
         [:div.content
          (when-not (not-activated?) [:a.btn.button {:href (path-for "/user/edit/profile")} (t :page/Edit)])
          [:div.visibility
@@ -319,7 +319,7 @@
   [:div {:class "box col-md-3"}
    [:div#box_3
     [:div.col-md-12.block
-     [:div.row_2.help;.getting-started.block-content
+     [:div.row_2.help
       [:div.heading_1
        [:i.fa.fa-info-circle.icon]
        [:span.title.help (t :core/Help)]]
@@ -327,7 +327,7 @@
        [:a {:href (str (path-for "/user/profile/") (session/get-in [:user :id]))}[:p (t :social/Iwanttoseeprofile)]]
        [:a {:href (str (path-for "/user/edit/profile"))}[:p (t :social/Iwanttoeditprofile)]]
        [:a {:href (str (path-for "/badge"))}[:p (t :social/Iwanttoseemysbadges)]]
-       (when (some #(= % :extra/application) (session/get :plugins))[:p (t :social/Iwanttoearnnewbadges)])
+       (when (some #(= % "extra/application") (session/get :plugins))[:p (t :social/Iwanttoearnnewbadges)])
        [:a {:href (str (path-for "/gallery/badges"))} [:p (t :social/Iwanttofindbadges)]]]]]]])

 (defn content [state]
@@ -340,9 +340,7 @@
     [notifications-block state]
     [badges-block state]
     [profile-block state]]
-
    [:div.row
-    ;[profile-block state]
     [explore-block state]
     [connections-block state]
     [help-block]]])


minor perf tweak in worker recompile (about 2ms)

--- src/main/shadow/cljs/devtools/server/worker/impl.clj
+++ src/main/shadow/cljs/devtools/server/worker/impl.clj
@@ -169,6 +169,16 @@
           (->> build-sources
                (map #(data/get-source-by-id build-state %))
                (filter #(= :cljs (:type %)))
+               ;; should filter more resources that don't contain hooks
+               ;; processing might become slow when processing too many namespaces?
+               ;; Bruce Hauman added ^:figwheel-hooks on the ns to filter
+               ;; but I think that puts unnecessary burden on the user to "tag" twice
+               ;; should this ever become a bottleneck we can optimize this by only checking
+               ;; for hooks once after compile and cache it
+               ;; FIXME: maybe add cache
+               (remove (fn [{:keys [resource-name] :as rc}]
+                         (or (str/starts-with? resource-name "cljs/")
+                             (str/starts-with? resource-name "clojure/"))))
                (map :ns)
                (map #(get-in compiler-env [::cljs-ana/namespaces %]))))
         )))


Added defpoly macro.

Added defpoly macro.


Depend on app-db for changes

Depend on app-db for changes

--- src/day8/re_frame/trace/panels/subs.cljs
+++ src/day8/re_frame/trace/panels/subs.cljs
@@ -23,7 +23,7 @@
      (doall
        (map (fn [me]
               (let [[query-v dyn-v :as inputs] (key me)]
-                @(val me)
+                @re-frame.db/app-db
                 ^{:key query-v}
                 [:div.subtree-wrapper {:style {:margin "10px 0"}}
                  [:div.subtree


Fix bind-by-fn which failed to resolve conflicting bindings.

'datascript.query.bind-by-fn now uses 'collapse-rels instead of 'conj
to incorporate the new relation when updating the context
relations. 'conj blindly adds the relation whereas 'collapse-rels will
properly handle cases of conflicting bindings.

Fixes the case where this query:

    (let [conn (ds/create-conn {})]
      (dq/q '[:find ?n
              :where [(identity 1) ?n]
                     [(identity 2) ?n]]
            @conn))

Would yield the resuld #{[1]} instead of #{}. The parent commit
provides tests of this and other failing cases.

--- src/datascript/query.cljc
+++ src/datascript/query.cljc
@@ -439,7 +439,7 @@
                            (reduce sum-rel))
                       (prod-rel production (empty-rel binding))))
                   (prod-rel (assoc production [:tuples] []) (empty-rel binding)))]
-    (update-in context [:rels] conj new-rel)))
+    (update-in context [:rels] collapse-rels new-rel)))

 ;;; RULES


handle refs in outgoing

handle refs in outgoing

--- src/dato/lib/outgoing.clj
+++ src/dato/lib/outgoing.clj
@@ -70,8 +70,8 @@
 (defn make-datascript-datoms [filtered-datoms db e->guid]
   (let [eid->tempid (zipmap (keys e->guid) (map (comp - inc) (range)))]
     (reduce (fn [{:keys [datoms tempid->guid]} {:keys [e a v added]}]
-              (let [ref? false ;; (dsu/ref-attr? db a)
-                    ;; TODO: figure out enums
+              (let [ref? (dsu/ref-attr? db a)
+                    ;; TODO: figure out enums, do they get sent with the schema?
                     enum? false ;; (and ref? (datomic-schema/enum-ns? a))
                     ]
                 {:datoms (conj datoms (ds/datom (eid->tempid e)


Assert render function is present Fixes #3.

--- src/dmohs/react/core.cljs
+++ src/dmohs/react/core.cljs
@@ -258,7 +258,10 @@
         fn-map (dissoc fn-map :trace?)
         call-fn (if trace?
                   (partial call-fn-with-trace (get fn-map :display-name "UnnamedComponent"))
-                  call-fn)]
+                  call-fn)
+        render-fn (:render fn-map)]
+    (assert (fn? render-fn)
+            (str "render is required and must be a function. render is: " (pr-str render-fn)))
     (-> fn-map
         (wrap-non-react-methods call-fn)
         (wrap-get-initial-state call-fn)


Unnecessary or (1 arity)

Unnecessary or (1 arity)

--- src/onyx/scheduling/balanced_task_scheduler.clj
+++ src/onyx/scheduling/balanced_task_scheduler.clj
@@ -39,8 +39,7 @@
        ;; task is allowed to be allocated to, we give it one peer and rotate it
        ;; to the back to possibly get more peers later.
        (and (< (get results least-allocated-task)
-               (or (get-in replica [:task-saturation job least-allocated-task]
-                           Double/POSITIVE_INFINITY)))
+               (get-in replica [:task-saturation job least-allocated-task] Double/POSITIVE_INFINITY))
             (not (cts/preallocated-grouped-task? replica job least-allocated-task)))
        (recur task-seq (update-in results [least-allocated-task] inc) (dec capacity))


Remove stale TODO

Remove stale TODO

--- src/expound/problems.cljc
+++ src/expound/problems.cljc
@@ -156,8 +156,6 @@
   (and
    (not= :instrument failure)
    (not= :check-failed failure)
-   ;; TODO: write test for this change
-   ;; was first, now last
    (= :ret (last (:path problem)))))

 (defn ^:private fspec-fn-failure? [failure problem]


drop unnecessary gen-class.

drop unnecessary gen-class.

--- src/cavm/h2.clj
+++ src/cavm/h2.clj
@@ -21,8 +21,7 @@
   (:require [cavm.h2-unpack-rows :as unpack])
   (:require [cavm.statement :refer [sql-stmt sql-stmt-result cached-statement]])
   (:require [cavm.conn-pool :refer [pool]])
-  (:require [cavm.lazy-utils :refer [consume-vec lazy-mapcat]])
-  (:gen-class))
+  (:require [cavm.lazy-utils :refer [consume-vec lazy-mapcat]]))

 ;
 ; Note that "bin" in this file is like a "segement" in the column store


Extend app-state

Extend app-state

--- frontend/src/crunsher/utils/lib.cljs
+++ frontend/src/crunsher/utils/lib.cljs
@@ -5,17 +5,9 @@

 (defonce app-state
          (atom
-           {:count   0
-            :pokemon [{:pokemon_id         4
-                       :id                 (rand-int 9999999999999999)
-                       :individual_attack  10
-                       :individual_defense 10
-                       :individual_stamina 10}
-                      {:pokemon_id         25
-                       :id                 (rand-int 9999999999999999)
-                       :individual_attack  10
-                       :individual_defense 10
-                       :individual_stamina 10}]}))
+           {:pokemon []
+            :user {:view :default
+                   :logged-in? false}}))

 ;;;; React compatibility


fixed pause/resume

fixed pause/resume

--- src/frontend/uploads.cljs
+++ src/frontend/uploads.cljs
@@ -31,23 +31,28 @@
    Can return: :stopped, :started, :paused, :unpaused"
   (let [upload-diff (data/diff (get (:uploads old-state) upload-id)
                                (get (:uploads new-state) upload-id))
-        new-upload-info (second upload-diff)]
+        old-upload-state (first upload-diff)
+        new-upload-state (second upload-diff)]

     (println upload-diff)
-    (println "old:" (get (:uploads old-state) upload-id))
-    (println "new:" (get (:uploads new-state) upload-id))
-    (if-not (nil? new-upload-info)
-      (let [k (first (keys new-upload-info))
-            v (first (vals new-upload-info))]
-        (cond
-          (= k :paused?)
-            (if v
-              :paused
-              :unpaused)
-          (= k :started?)
-             (if v
-               :started
-               :stopped))))))
+    (println "old:" old-upload-state)
+    (println "new:" new-upload-state)
+    (if (nil? old-upload-state)
+      (if (:started? new-upload-state)
+        :started
+        nil)
+      (if-not (nil? new-upload-state)
+        (let [k (first (keys new-upload-state))
+              v (first (vals new-upload-state))]
+          (cond
+            (= k :paused?)
+              (if v
+                :paused
+                :unpaused)
+            (= k :started?)
+               (if v
+                 :started
+                 :stopped)))))))

 (defn upload-file! [file]
   (let [new-upload blank-upload
@@ -94,13 +99,14 @@
            "file-upload"
            stream
            (.-name file)
-           (.-size file))
+           (.-size file)
+           upload-id)

-      (swap! app-state/app-state
-             assoc
-             :uploads
-             (merge (:uploads @app-state/app-state)
-                    (if (< (:num-of-uploads @app-state/app-state)
-                           (:upload-slots   @app-state/app-state))
-                      {upload-id (start-upload new-upload)}
-                      {upload-id new-upload})))))
+    (swap! app-state/app-state
+           assoc
+           :uploads
+           (merge (:uploads @app-state/app-state)
+                  (if (< (:num-of-uploads @app-state/app-state)
+                         (:upload-slots   @app-state/app-state))
+                    {upload-id (start-upload new-upload)}
+                    {upload-id new-upload})))))


engine: register metrics by path. final bit to fix #119

--- src/io/cyanite/engine.clj
+++ src/io/cyanite/engine.clj
@@ -52,7 +52,7 @@

       (q/consume! queues :writeq {}
                   (fn [metric]
-                    (index/register! index metric)
+                    (index/register! index (:path metric))
                     (store/insert! store metric)))
       (assoc this :planner planner :bucket buckets)))
   (stop [this]


[#666] Extend tenant name blacklist

[#666] Extend tenant name blacklist

--- backend/src/akvo/lumen/admin/add_tenant.clj
+++ backend/src/akvo/lumen/admin/add_tenant.clj
@@ -32,7 +32,11 @@

 (def blacklist ["admin"
+                "deck"
+                "ftp"
+                "mail"
                 "next"
+                "smtp"
                 "stage"
                 "test"
                 "www"])


Confirm SSE content-type header as well.

--- web/test/immutant/web/sse_test.clj
+++ web/test/immutant/web/sse_test.clj
@@ -62,12 +62,15 @@
     (is (= #{:done "bye!"} (set (drop 5 @result))))
     (stop server)))

-(deftest sse-encoding-should-be-utf8
+(deftest sse-should-be-utf8-and-have-proper-content-type
   (let [app (fn [req]
               (as-channel req
                 :on-open (fn [ch] (send! ch "foo" {:close? true}))))
         server (run app)
-        body-stream (:raw-body (get-response "http://localhost:8080"))]
+        response (get-response "http://localhost:8080")
+        body-stream (:raw-body response)]
+    (is (= "text/event-stream; charset=utf-8"
+          (get-in response [:headers :content-type])))
     (is body-stream)
     (is (= "data:foo\n\n"
           (String. (.toByteArray body-stream) "UTF-8")))


Consistency in keyword arguments

Consistency in keyword arguments

--- modules/entrance/src/modular/entrance.clj
+++ modules/entrance/src/modular/entrance.clj
@@ -291,7 +291,7 @@
   {(s/optional-key :session-timeout-in-seconds) s/Int
    (s/optional-key :boilerplate) (s/=> 1)})

-(defn new-default-protection-domain [opts]
+(defn new-default-protection-domain [& {:as opts}]
   (s/validate new-default-protection-domain-schema opts)
   (map->ProtectionDomain
    {:protector (if-let [boilerplate (:boilerplate opts)]
@@ -319,18 +319,20 @@
   (routes [this] (:routes this))
   (context [this] context))

-(defn new-mandatory-protected-bidi-routes
-  "Create a set of protected routes. The absence of a :protection-domain
-  dependency will cause an error. Routes can a bidi route structure, or
+(defn new-protected-bidi-routes
+  "Create a set of protected routes. Routes can a bidi route structure, or
   a function that takes the component and returns a bidi route
   structure."
-  [routes context]
-  (component/using (->ProtectedBidiRoutes routes context) [:protection-domain]))
-
-(defn new-protected-bidi-routes
-  "Create a set of protected routes. The absence of a :protection-domain
-  dependency will remove the protection. If protection is mandatory, use
-  new-mandatory-protected-bidi-routes instead. Routes can a bidi route
-  structure, or a function that takes the component and returns a bidi
-  route structure."  [routes context]
-  (->ProtectedBidiRoutes routes context))
+  [routes & {:as opts}]
+  (let [{:keys [context]}
+        (->> (merge {:context ""} opts)
+             (s/validate {:context s/Str}))]
+    (->ProtectedBidiRoutes routes context)))
+
+(defn new-mandatory-protected-bidi-routes
+  "Like new-protected-bidi-routes above, but the absence of
+  a :protection-domain dependency will cause an error."
+  [routes & {:as opts}]
+  (component/using
+   (apply new-protected-bidi-routes routes (apply concat (seq opts)))
+   [:protection-domain]))


typical-monitor-temperature uses temperature-as

--- src/test_utils/fracture_diagnostics.cljc
+++ src/test_utils/fracture_diagnostics.cljc
@@ -56,8 +56,6 @@
                    [:m :ft]                   #(* % (factors [:m :ft]))
                    [:kg :lb]                  #(* % (factors [:kg :lb]))
                    [:lb :kg]                  #(/ % (factors [:kg :lb]))
-                   [:F :C]                    #(/ (- % 32) 1.8)
-                   [:C :F]                    #(+ (* % 1.8) 32)
                    [:bbl :m3]                 #(/ % (factors [:m3 :bbl]))
                    [:m3 :bbl]                 #(* % (factors [:m3 :bbl]))}]
     (converter [from to])))
@@ -92,12 +90,15 @@

 ;; Because conversion between temperature units is not simply multiplicative, I define this function with a
 ;; unique body.
-(defn temperature-as [[magnitude from] to]
+(defn temperature-as [[magnitude from & location] to]
   (let [f->c #(/ (- % 32) 1.8)
-        c->f #(+ (* % 1.8) 32)]
-    (condp = [from to]
-      [:F :C] [(f->c magnitude) to]
-      [:C :F] [(c->f magnitude) to])))
+        c->f #(+ (* % 1.8) 32)
+        target-temperature (condp = [from to]
+                             [:F :C] (f->c magnitude)
+                             [:C :F] (c->f magnitude))]
+    (if location
+      (apply make-measurement target-temperature to location)
+      (make-measurement target-temperature to))))

 (defn typical-vertical-depth []
   (tuc/draw-normal 8000 1216))
@@ -411,13 +412,35 @@
                                   (magnitude (pressure-as (typical-monitor-pressure :psi) :kPa)))]
      (make-measurement pressure-magnitude pressure-unit))))

+(def measured-at-location [:downhole :surface])
+
 (defn typical-monitor-temperature
-  ([] (let [units (rand-nth [:C :F])]
-        (typical-monitor-temperature units)))
-  ([units] (cond (= units :C)
-                 (value-from-typical-range 50 80)
-                 (= units :F)
-                 ((convert-units-f :C :F) (typical-monitor-temperature :C)))))
+  ([]
+   (let [temperature-unit (rand-temperature-unit)
+         measured-at      (rand-nth measured-at-location)]
+     (typical-monitor-temperature temperature-unit measured-at)))
+  ([unit-or-location]
+   (let [is-unit                        #{:C :F}
+         is-location                    (set measured-at-location)
+         [temperature-unit measured-at] (cond
+                                          (is-unit unit-or-location)
+                                          [unit-or-location (rand-nth measured-at-location)]
+                                          (is-location unit-or-location)
+                                          [(rand-temperature-unit) unit-or-location])]
+     (typical-monitor-temperature temperature-unit measured-at)))
+  ([temperature-unit measured-at]
+   (let [temperature-f-downhole (tuc/draw-normal 155.1 1.5)
+         temperature-f-surface  (rand-nth [(tuc/draw-normal 60 15)
+                                           (tuc/draw-normal 51 14)
+                                           (tuc/draw-normal 51 15)
+                                           (tuc/draw-normal 51 18)])]
+     (condp = measured-at
+       :downhole (condp = temperature-unit
+                   :F (make-measurement temperature-f-downhole temperature-unit measured-at)
+                   :C (temperature-as (typical-monitor-temperature :F measured-at) :C))
+       :surface (condp = temperature-unit
+                  :F (make-measurement temperature-f-surface temperature-unit measured-at)
+                  :C (temperature-as (typical-monitor-temperature :F measured-at) :C))))))

 (defn typical-slurry-rate
   ([]
@@ -608,45 +631,9 @@
        :W (make-measurement typical-energy power-unit) ;; assume energy expended for 1 s
        :hp (power-as (typical-power :W) :hp)))))

-(def measured-at-location [:downhole :surface])
-
-(defn typical-temperature
-  ([]
-   (let [temperature-unit (rand-temperature-unit)
-         measured-at      (rand-nth measured-at-location)]
-     (typical-temperature temperature-unit measured-at)))
-  ([unit-or-location]
-   (let [is-unit                        #{:C :F}
-         is-location                    (set measured-at-location)
-         [temperature-unit measured-at] (cond
-                                          (is-unit unit-or-location)
-                                          [unit-or-location (rand-nth measured-at-location)]
-                                          (is-location unit-or-location)
-                                          [(rand-temperature-unit) unit-or-location])]
-     (typical-temperature temperature-unit measured-at)))
-  ([temperature-unit measured-at]
-   (let [temperature-f-downhole (tuc/draw-normal 155.1 1.5)
-         temperature-f-surface  (rand-nth [(tuc/draw-normal 60 15)
-                                           (tuc/draw-normal 51 14)
-                                           (tuc/draw-normal 51 15)
-                                           (tuc/draw-normal 51 18)])
-         temperature-value      (condp = measured-at
-                                  :downhole
-                                  (condp = temperature-unit
-                                    :F temperature-f-downhole
-                                    :C ((convert-units-f :F :C) temperature-f-downhole))
-                                  :surface
-                                  (condp = temperature-unit
-                                    :F temperature-f-surface
-                                    :C ((convert-units-f :F :C) temperature-f-surface)))]
-     [temperature-value temperature-unit measured-at])))
-
 (defn generate-pair [units generate-units-f generate-measurement-f measurement-as-f]
   (let [unit        (generate-units-f)
         measurement (generate-measurement-f unit)]
     [measurement (measurement-as-f measurement (first (remove (partial = unit) units)))]))

-(generate-pair #{:bpm :m3-per-min}
-               rand-slurry-rate-unit
-               typical-slurry-rate
-               slurry-rate-as)
+(generate-pair #{:F :C} rand-temperature-unit typical-monitor-temperature temperature-as)


Add main ns to classpath for advanced compilation

--- src/adzerk/boot_cljs.clj
+++ src/adzerk/boot_cljs.clj
@@ -106,17 +106,20 @@
           select
           (sort-by :path)))))

-(defn- new-pod! []
-  (let [env (update-in (core/get-env) [:dependencies] into @deps)]
+(defn- new-pod! [tmp-src]
+  (let [env (-> (core/get-env)
+                (update-in [:dependencies] into @deps)
+                (update-in [:directories] conj (.getPath tmp-src)))]
     (future (doto (pod/make-pod env) assert-clojure-version!))))

 (defn- make-compiler
   [tmp-result cljs-edn]
-  {:pod         (new-pod!)
-   :initial-ctx {:tmp-src (core/tmp-dir!)
-                 :tmp-out tmp-result
-                 :main    (-> (read-cljs-edn cljs-edn)
-                              (assoc :ns-name (name (gensym "main"))))}})
+  (let [tmp-src (core/tmp-dir!)]
+    {:pod         (new-pod! tmp-src)
+     :initial-ctx {:tmp-src tmp-src
+                   :tmp-out tmp-result
+                   :main    (-> (read-cljs-edn cljs-edn)
+                                (assoc :ns-name (name (gensym "main"))))}}))

 (defn- compile-1
   [compilers task-opts tmp-result macro-changes {:keys [path] :as cljs-edn}]


founded bug test case

founded bug test case

--- test/hackerrank/time_conversion_test.clj
+++ test/hackerrank/time_conversion_test.clj
@@ -9,4 +9,8 @@

 (deftest time-conversion-test
   (testing "time-conversion"
-    (is (= (time-conversion "07:05:45PM") "19:05:45"))))
+    (is (= (time-conversion "07:05:45PM") "19:05:45"))
+    (is (= (time-conversion "12:05:45AM") "00:05:45"))
+    (is (= (time-conversion "12:05:45PM") "12:05:45"))
+  )
+)


Add convenience encode/decode functions.

--- src/multistream/codec.clj
+++ src/multistream/codec.clj
@@ -4,6 +4,8 @@
     [multistream.header :as header])
   (:import
     (java.io
+      ByteArrayInputStream
+      ByteArrayOutputStream
       InputStream
       OutputStream)))

@@ -254,15 +256,43 @@
   (map->MultiCodecFactory opts))

-
-;; ## Codec Utilities
-
-(defn write-header!
-  "Writes a multicodec header for `path` to the given stream. Returns the
-  number of bytes written."
-  [stream header]
-  (header/write! stream header))
-
+(defn encode
+  "Encodes the given value using either a direct codec or a multicodec factory
+  and the given selectors. Returns a byte array containing the encoded value,
+  or throws an exception on error."
+  ([codec value]
+   (encode (multi :codec codec) [:codec] value))
+  ([factory selectors value]
+   (let [baos (ByteArrayOutputStream.)]
+     (with-open [encoder (encoder-stream factory selectors baos)]
+       (write! encoder value))
+     (.toByteArray baos))))
+
+
+(defn decode
+  "Decodes the given byte array using either a direct codec or a multicodec
+  factory."
+  [codec-or-factory input]
+  (let [bais (ByteArrayInputStream. ^bytes input)]
+    (if (satisfies? CodecFactory codec-or-factory)
+      ; Use factory to decode against headers.
+      (with-open [decoder (decoder-stream codec-or-factory bais)]
+        (read! decoder))
+      ; Use direct codec.
+      (let [codec codec-or-factory
+            header (header/read! bais)]
+        (when-not (processable? codec header)
+          (throw (ex-info (str "Expected processable codec header but read "
+                               (pr-str header))
+                          {:header header})))
+        (with-open [decoder (->> bais
+                                 (decode-byte-stream codec header)
+                                 (decode-value-stream codec header))]
+          (read! decoder))))))
+
+
+
+;; ## Codec Implementation Utilities

 (defmacro defencoder
   "Define a new encoder stream record, filling in the protocol and `Closeable`


dont refer all from boot.util

dont refer all from boot.util

--- src/adzerk/boot_reload.clj
+++ src/adzerk/boot_reload.clj
@@ -5,7 +5,7 @@
    [clojure.set        :as set]
    [boot.pod           :as pod]
    [boot.file          :as file]
-   [boot.util          :refer :all]
+   [boot.util          :as util]
    [boot.core          :refer :all]
    [boot.from.backtick :refer [template]]))

@@ -25,11 +25,11 @@
   (let [{:keys [ip port]}
         (pod/with-call-in pod (adzerk.boot-reload.server/start ~opts))
         host (if-not (= ip "0.0.0.0") ip "localhost")]
-    (with-let [url (format "ws://%s:%d" host port)]
-      (info "<< started reload server on %s >>\n" url))))
+    (util/with-let [url (format "ws://%s:%d" host port)]
+      (util/info "<< started reload server on %s >>\n" url))))

 (defn- write-cljs! [f url on-jsload]
-  (info "Writing %s...\n" (.getName f))
+  (util/info "Writing %s...\n" (.getName f))
   (->> (template
          ((ns adzerk.boot-reload
             (:require
@@ -52,7 +52,7 @@
   (let [ns 'adzerk.boot-reload
         spec (-> in-file slurp read-string)]
     (when (not= :nodejs (-> spec :compiler-options :target))
-      (info "Adding :require %s to %s...\n" ns (.getName in-file))
+      (util/info "Adding :require %s to %s...\n" ns (.getName in-file))
       (io/make-parents out-file)
       (-> spec
         (update-in [:require] conj ns)


Removed beat accents to hear each note better

--- src/aeolian/midi/drums.clj
+++ src/aeolian/midi/drums.clj
@@ -6,6 +6,7 @@
 (def beat stick)

 (def four-beat-metro (str "%%MIDI drum dddd " beat " " beat " " beat " " beat " ""\n"))
+(def no-accents "%%MIDI nobeataccents")
 (def first-beat-emphasis "%%MIDI beatstring pmmm\n")

-(def drum-track (str "%%MIDI program 32\n" first-beat-emphasis four-beat-metro "%%MIDI drumon\n%%MIDI gchord c\n"))
+(def drum-track (str "%%MIDI program 32\n" first-beat-emphasis four-beat-metro no-accents "%%MIDI drumon\n%%MIDI gchord c\n"))


Add replace and output

Add replace and output

--- src/aurora/interpreter.cljs
+++ src/aurora/interpreter.cljs
@@ -1,10 +1,15 @@
 (ns aurora.interpreter)

+;; todo
+
+;; efficient implementation of stack queries (maybe only compile the watched fn?)
+;; efficient implementation of cursors (maybe via side-vars)
+
 ;; interpreter

 (defrecord Cursor [path value])

-(defn run-pipe [program node inputs stack]
+(defn run-pipe [program node inputs output stack]
   (let [vars #js {}
         calls #js []
         frame #js {:id (:id node) :vars vars :calls calls}]
@@ -14,75 +19,93 @@
       (aset vars id value))
     (doseq [{:keys [id inputs node]} (:nodes node)]
       (assert (not= :pipe (:type node)) "No inline pipes")
-      (aset vars id (run-node program node (map #(aget vars %) inputs) calls))) ; note calls, not stack
+      (aset vars id (run-node program node (map #(aget vars %) inputs) output calls))) ; note calls, not stack
     (let [result (aget vars (-> node :nodes last :id))]
       (aset frame "result" result) ; return
       result)))

-(defn run-node [program node inputs stack]
+(defn run-node [program node inputs output stack]
   (case (:type node)
-    :data (run-data program node inputs stack)
-    :match (run-match program node inputs stack)
-    :ref (run-ref program node inputs stack)))
-
-(defn run-data [program node inputs stack]
+    :return (run-return program node inputs output stack)
+    :data (run-data program node inputs output stack)
+    :ref (run-ref program node inputs output stack)
+    :match (run-match program node inputs output stack)
+    :replace (run-replace program node inputs output stack)
+    :output (run-output program node inputs output stack)))
+
+(defn run-return [program node inputs output stack]
+  (assert (= 1 (count inputs)))
+  (first inputs))
+
+(defn run-data [program node inputs output stack]
   (assert (empty? inputs))
-  (Cursor. [] (run-data* program node inputs stack)))
-
-(defn run-data* [program node inputs stack]
+  (Cursor. [] (run-data* program node inputs output stack)))
+
+(defn run-data* [program node inputs output stack]
   (case (:kind node)
     :value (:value node)
     :vector (into []
                   (for [value (:value node)]
-                    (run-data* program value inputs stack)))
+                    (run-data* program value inputs output stack)))
     :map (into {}
                (for [[key value] (:value node)]
-                 [(run-data* program key inputs stack) (run-data* program value inputs stack)]))))
-
-(defn run-ref [program node inputs stack]
+                 [(run-data* program key inputs output stack) (run-data* program value inputs output stack)]))))
+
+(defn run-ref [program node inputs output stack]
   (case (:kind node)
     :cljs (Cursor. [] (apply (:fn node) (map :value inputs)))
-    :pipe (run-pipe program (get program (:id node)) inputs stack)))
+    :pipe (run-pipe program (get program (:id node)) inputs output stack)))

 (defrecord MatchFailure [])

 (defn check [bool]
   (when-not bool (throw (MatchFailure.))))

-(defn run-match [program node inputs stack]
+(defn run-match [program node inputs output stack]
   (assert (= 1 (count inputs)))
   (let [input (first inputs)]
     (loop [branches (:branches node)]
       (if-let [[{:keys [pattern inputs node]} & branches] (seq branches)]
         (try
           (let [vars #js {}]
-            (run-match-pattern program pattern (:path input) (:value input) stack vars)
-            (run-node program node (map #(aget vars %) inputs) stack))
+            (run-match-pattern program pattern (:path input) (:value input) output stack vars)
+            (run-node program node (map #(aget vars %) inputs) output stack))
           (catch MatchFailure _
             (recur branches)))
         (throw (MatchFailure.))))))

-(defn run-match-pattern [program pattern input-path input-value stack vars]
+(defn run-match-pattern [program pattern input-path input-value output stack vars]
   (condp = (:type pattern)
     :match/any nil
     :match/bind (do (aset vars (:var pattern) (Cursor. input-path input-value))
-                  (run-match-pattern program (:pattern pattern) input-path input-value stack vars))
+                  (run-match-pattern program (:pattern pattern) input-path input-value output stack vars))
     :data (case (:kind pattern)
             :value (check (= input-value (:value pattern)))
             :vector (let [value (:value pattern)]
                       (check (vector? input-value))
                       (check (= (count input-value) (count value)))
                       (dotimes [i (count value)]
-                        (run-match-pattern program (nth value i) (conj input-path i) (nth input-value i) stack vars)))
+                        (run-match-pattern program (nth value i) (conj input-path i) (nth input-value i) output stack vars)))
             :map (let [value (:value pattern)]
                    (check (map? input-value))
                    (doseq [key-pattern (keys value)]
                      (let [key (:value key-pattern)]
                        (check (contains? input-value key))
-                       (run-match-pattern program (get value key-pattern) (conj input-path key) (get input-value key) stack vars)))))
-    (check (:value (run-node program pattern [(Cursor. input-path input-value)] stack)))))
+                       (run-match-pattern program (get value key-pattern) (conj input-path key) (get input-value key) output stack vars)))))
+    (check (:value (run-node program pattern [(Cursor. input-path input-value)] output stack)))))
+
+(defn run-replace [program node inputs output stack]
+  (swap! output assoc-in (:path (first inputs)) (:value (second inputs))))
+
+(defn run-output [program node inputs output stack]
+  (swap! output update-in (:path node) cons (:value (first inputs))))
+
+(assoc-in {} [] :foo)

 ;; ast
+
+(def return
+  {:type :return})

 (defn pipe [id inputs & nodes]
   {:type :pipe
@@ -125,6 +148,13 @@
 (def any
   {:type :match/any})

+(def replace
+  {:type :replace})
+
+(defn output [path]
+  {:type :output
+   :path path})
+
 ;; examples

 (def example-a
@@ -137,7 +167,7 @@
 (def example-b
   #{(pipe "root" ["x"]
           "result" ["x"] (match (data-map (data-value "a") (bind "a" (cljs-ref number?)) (data-value "b") (bind "b" (cljs-ref number?))) ["a" "b"] (cljs-ref -)
-                                      (data-vector (bind "x" any) (data-value "foo")) ["x"] (cljs-ref identity)))})
+                                      (data-vector (bind "x" any) (data-value "foo")) ["x"] return))})

 (def example-c
   #{(pipe "root" ["x"]
@@ -159,27 +189,33 @@
           "even?" ["x-1"] (pipe-ref "even?")
           "result" ["even?"] (cljs-ref not))})

-(defn run-example [example inputs]
+(def example-d
+  #{(pipe "root" ["x"]
+          "c" ["x"] (match (data-map (data-value "counter") (bind "c" any)) ["c"] return)
+          "one" [] (data-value 1)
+          "c+1" ["c" "one"] (cljs-ref +)
+          "nil" ["c" "c+1"] replace)})
+
+(defn run-example [example input]
   (let [stack #js []
-        program (into {} (for [pipe example] [(:id pipe) pipe]))]
+        program (into {} (for [pipe example] [(:id pipe) pipe]))
+        output (atom input)]
     (try
-      [(run-pipe program (get program "root") (map #(Cursor. [] %) inputs) stack) (aget stack 0)]
-      (catch :default e [e (aget stack 0)]))))
-
-(set! *print-meta* true)
-
-(run-example example-a [1 4 2])
-
-(run-example example-b [{"a" 1 "b" 2}])
-(run-example example-b [{"a" 1 "c" 2}])
-(run-example example-b [{"a" 1 "b" "foo"}])
-(run-example example-b [[1 "foo"]])
-(run-example example-b [[1 2]])
-
-(run-example example-c [0])
-(run-example example-c [1])
-(run-example example-c [7])
-(run-example example-c [10])
+      [(run-pipe program (get program "root") [(Cursor. [] input)] output stack) @output (aget stack 0)]
+      (catch :default e [e @output (aget stack 0)]))))
+
+(run-example example-b {"a" 1 "b" 2})
+(run-example example-b {"a" 1 "c" 2})
+(run-example example-b {"a" 1 "b" "foo"})
+(run-example example-b [1 "foo"])
+(run-example example-b [1 2])
+
+(run-example example-c 0)
+(run-example example-c 1)
+(run-example example-c 7)
+(run-example example-c 10)
+
+(run-example example-d {"counter" 0})

 (defn print-stack
   ([frame]
@@ -191,12 +227,13 @@
    (when (js* "('result' in ~{frame})") ; seriously?
      (println (.join (make-array indent) " ") "<=" (.-id frame) (.-result frame)))))

-(defn print-example [example inputs]
-  (let [[result stack] (run-example example inputs)]
+(defn print-example [example input]
+  (let [[result output stack] (run-example example input)]
     (print-stack stack)
+    (println output)
     (println result)))

-(print-example example-b [[1 "foo"]])
 (print-example example-b [1 "foo"])
-(print-example example-c [10])
-
+(print-example example-b 1)
+(print-example example-c 10)
+


~(defn generate-for-verbcoach): allow supplying an optional spec

--- src/babel/italiano/lab.cljc
+++ src/babel/italiano/lab.cljc
@@ -240,7 +240,7 @@
 ;; (take 10 (generate-for-verbcoach))
 (defn generate-for-verbcoach
   "generate sentences efficiently given specific constraints."
-  []
+  [& [spec]]

   (let [basic-grammar
         #{"sentence-nonphrasal-head"}
@@ -251,9 +251,7 @@
           "vp-pronoun-nonphrasal"}

         chiamarsi-grammar
-        #{"s-aux"
-          "sentence-phrasal-head"
-          "vp-aux-phrasal-complement"
+        #{"sentence-phrasal-head"
           "vp-pronoun-phrasal"
           "vp-32"}

@@ -273,7 +271,7 @@
           "vp-pronoun-nonphrasal"}

         create-index-fn
-        (fn [verb-set grammar]
+        (fn [grammar]
           (let [verbcoach-pronouns
                 (fn [v]
                   (or
@@ -298,13 +296,8 @@
                       (for [[k vals] (:lexicon model)]
                         (let [filtered-vals
                               (filter
-                               (fn [v]
-                                 (or
-                                  (and (= :verb (u/get-in v [:synsem :cat]))
-                                       (or (= true (u/get-in v [:synsem :aux]))
-                                           (contains? verb-set
-                                                      (u/get-in v [:italiano :italiano]))))
-                                  (verbcoach-pronouns v)))
+                               #(or (= :verb (u/get-in % [:synsem :cat]))
+                                    (verbcoach-pronouns %))
                                vals)]
                           (if (not (empty? filtered-vals))
                             [k filtered-vals]))))
@@ -316,7 +309,9 @@
         rule-matcher
         {:top
          basic-grammar
-
+
+         ;; example of a specific root's influence on grammar to be
+         ;; be used for generation.
          {:root {:italiano {:italiano "chiamarsi"}}}
          chiamarsi-grammar

@@ -348,13 +343,8 @@
                       nil
                       (get rule-matcher key-in-rule-matcher))))
                 (keys rule-matcher))))
-
-        verb-set #{"arrabbiarsi" "chiamarsi" "fermarsi" "parlare" "sedersi"}
-        specs (map (fn [root]
-                     {:root {:italiano {:italiano root}}})
-                   verb-set)
-        tense-specs [
-                     {:synsem {:cat :verb
+
+        tense-specs [{:synsem {:cat :verb
                                :sem {:tense :present
                                      :aspect :perfect}
                                :subcat []}}
@@ -370,16 +360,29 @@
                                :subcat []}}
                      {:synsem {:cat :verb
                                :sem {:tense :present
-                                     :aspect :simple}}}
-                     ]
-        ]
-
+                                     :aspect :simple}}}]]
     (repeatedly
      #(do
         (println
-         (let [chosen-spec
-               (unify (first (shuffle specs))
-                      (first (shuffle tense-specs)))]
+         (let [tense-spec (first (shuffle tense-specs))
+               tense-spec
+               (let [result (unify spec tense-spec)]
+                 (if (not (= :fail result))
+                   result
+                   spec))
+
+               root-spec
+               (let [example-verbs #{"arrabbiarsi" "chiamarsi" "dormire" "fermarsi" "parlare" "sedersi"}
+
+                     unif
+                     (unify spec
+                            {:root {:italiano {:italiano
+                                               (first (shuffle example-verbs))}}})]
+                 (if (not (= :fail unif))
+                   unif
+                   spec))
+
+               chosen-spec (unify root-spec tense-spec)]
            (let [generate-with-grammar-set
                  (rule-matcher-reducer chosen-spec)
                  grammar
@@ -389,7 +392,7 @@
                          (:grammar model))]
              (morph (binding [babel.generate/println? false
                               babel.generate/truncate? false
-                              babel.generate/index-fn (create-index-fn verb-set grammar)
+                              babel.generate/index-fn (create-index-fn grammar)
                               babel.generate/lexical-filter
                               (fn [lexeme] (= false (u/get-in lexeme [:italiano :exception] false)))
                               babel.generate/grammar grammar]


Find class optimization

Find class optimization

--- src/carambar/repository.clj
+++ src/carambar/repository.clj
@@ -55,9 +55,8 @@
   "Find CLASSNAME from repo"
   [classname]
   (flatten (for [e @repo
-                 :let [f (filter #(match-class-exactly? classname %) (:classes e))]
-             :when (not-empty f)]
-         f)))
+                :let [f (filter #(match-class-exactly? classname %) (:classes e))]]
+            f)))

 (defn create-cache []
   (for [path (filter #(.endsWith % ".jar") boot-classpath)]


to* is exclusive in contains

to* is exclusive in contains

--- src/celestial/hosts_api.clj
+++ src/celestial/hosts_api.clj
@@ -69,8 +69,9 @@
   {:pre [(> from -1) (if type (p/type-exists! type) true)]}
   (let [systems (if type (p/get-system-index :type type) (into [] (p/all-systems)))
         to* (min to (count systems))]
+    (println to* (contains? systems to*))
     (when-not (empty? systems)
-      (if (and (contains? systems from) (contains? systems to*))
+      (if (and (contains? systems from) (contains? systems (- to* 1)))
         {:meta {:total (count systems)} :systems (map (juxt identity p/get-system) (subvec systems from to*))}
         (throw+ {:type ::non-legal-range :message (<<  "No legal systems in range ~{from}:~{to*} try between ~{0}:~(count systems)")})))))


admin not used

admin not used

--- src/celestial/users_api.clj
+++ src/celestial/users_api.clj
@@ -3,7 +3,7 @@
     [cemerick.friend.credentials :as creds]
     [celestial.persistency :as p])
   (:use
-    [celestial.roles :only (roles roles-m admin)]
+    [celestial.roles :only (roles roles-m)]
     [clojure.core.strint :only (<<)]
     [slingshot.slingshot :only  [throw+ try+]]
     [swag.model :only (defmodel wrap-swag defv defc)]


Fix incorrect template loading

Fix incorrect template loading

--- src/clj/sparqlab/layout.clj
+++ src/clj/sparqlab/layout.clj
@@ -7,7 +7,7 @@

 (declare ^:dynamic *app-context*)

-(parser/set-resource-path!  (clojure.java.io/resource "templates"))
+(parser/set-resource-path! (clojure.java.io/resource "templates"))

 (filters/add-filter! :markdown (fn [content] [:safe (md-to-html-string content)]))

@@ -15,13 +15,6 @@
                      (fn [content]
                        (let [wrapped (md-to-html-string content)]
                          [:safe (subs wrapped 3 (- (count wrapped) 4))])))
-
-(def template-name
-  (comp
-    (memfn getName)
-    io/as-file
-    io/resource
-    (partial str "templates/")))

 (defn render
   "renders the HTML template located relative to resources/templates"
@@ -31,7 +24,7 @@
       (parser/render-file
         template
         (assoc params
-          :page (template-name template)
+          :page template
           :servlet-context *app-context*)))
     "text/html; charset=utf-8"))


Remove type from http status response to avoid nil problems when status code is missing

--- src/clj_gatling/httpkit.clj
+++ src/clj_gatling/httpkit.clj
@@ -19,6 +19,6 @@
                                      (ThreadPoolExecutor. pool-size pool-size 60 TimeUnit/SECONDS queue factory)))

 (defn async-http-request [url user-id context callback]
-  (let [check-status (fn [{:keys [^long status]}]
+  (let [check-status (fn [{:keys [status]}]
                         (callback (= 200 status)))]
     (http/get url {:worker-pool httpkit-callback-pool :client (get-httpkit-client user-id)} check-status)))


It is already optimized

It is already optimized

--- src/cljam/pileup/pileup.clj
+++ src/cljam/pileup/pileup.clj
@@ -68,13 +68,12 @@
             parts)))))

 (defn first-pos
+  "Return a position of first alignment in left-right, or nil."
   [rdr ^String rname ^Long left ^Long right]
-  ;; TODO: :depth :first-only を新設し、最初の一個を見付けるのに特化させる
-  (let [^clojure.lang.LazySeq alns (io/read-alignments rdr {:chr rname
-                                                            :start left
-                                                            :end right
-                                                            :depth :shallow})]
-    (:pos (first alns))))
+  (:pos (first (io/read-alignments rdr {:chr rname
+                                        :start left
+                                        :end right
+                                        :depth :shallow}))))

 (defn pileup
   ([^cljam.bam.reader.BAMReader rdr ^String rname]


Missed fields can be owned without answering questions

--- src/cljs/db_quiz/logic.cljs
+++ src/cljs/db_quiz/logic.cljs
@@ -7,16 +7,12 @@
             [clojure.set :refer [intersection union]]
             [clj-fuzzy.jaro-winkler :refer [jaro-winkler]]))

-; ----- Private functions -----
-
-(defn- change-ownership
+(defn change-ownership
   [ownership field-id app-state]
   (assoc-in app-state [:board field-id :ownership] ownership))

-(def ^:private make-active
+(def make-active
   (partial change-ownership :active))
-
-; ----- Public functions -----

 (defn find-connecting-path
   "Finds if there is a continuous path connecting 3 sides of the boards
@@ -122,6 +118,14 @@
   [app-state]
   (update app-state :on-turn (partial toggle [:player-1 :player-2])))

+(defn test-winner
+  [owner current-field]
+  (let [state (swap! app-state (partial change-ownership owner current-field))
+        winner (find-winner (:board state))]
+    (when winner
+      (do (swap! app-state #(assoc % :winner winner))
+          (set! (.-location js/window) "/#end")))))
+
 (defn turn
   [& {:keys [answer answer-matched? correct-answer]}]
   (let [mark-fn (partial match-answer answer-matched?)]
@@ -138,23 +142,24 @@
         new-ownership (if answer-matched? on-turn :missed)]
     (when (nil? verdict)
       ; Test if the game is over:
-      (if-let [winner (find-winner (:board (swap! app-state
-                                                  (partial change-ownership new-ownership current-field))))]
-        (do (swap! app-state #(assoc % :winner winner))
-            (set! (.-location js/window) "/#end"))
-        (turn :answer answer
-              :answer-matched? answer-matched?
-              :correct-answer correct-answer)))))
+      (test-winner new-ownership current-field)
+      (turn :answer answer
+            :answer-matched? answer-matched?
+            :correct-answer correct-answer))))

 (defn pick-field
   "A player picks a field with id on board."
   [id]
   (let [{:keys [board current-field loading? on-turn verdict]} @app-state
         ownership (get-in board [id :ownership])]
-    (when (and (= ownership :default) (nil? current-field) (not loading?) (nil? verdict))
-      (swap! app-state (comp (partial make-active id)
-                             restart-timer
-                             (fn [app-state] (assoc app-state :current-field id)))))))
+    (when (and (nil? current-field) (not loading?) (nil? verdict))
+          (case ownership
+                :default (swap! app-state (comp (partial make-active id)
+                                                restart-timer
+                                                (fn [app-state] (assoc app-state :current-field id))))
+                :missed (do (test-winner on-turn id)
+                            (swap! app-state (comp toggle-player
+                                                   deselect-current-field)))))))

 (defonce timeout-updater
   (js/setInterval (fn []


Put hover info inside div and replace p with span

--- src/cljs/zetawar/views.cljs
+++ src/cljs/zetawar/views.cljs
@@ -272,12 +272,13 @@
                 :title (translate :configure-faction-tip)}]]]))))

 (defn status-info [{:as view-ctx :keys [conn translate]}]
-  (let [[hover-q hover-r] @(subs/hover-hex conn)]
-    [:p.hidden-xs.hidden-sm
-     (translate :hover-tile-location)
-     (if hover-q
-       (str hover-q ", " hover-r)
-       (translate :none))]))
+  [:div
+   (let [[hover-q hover-r] @(subs/hover-hex conn)]
+     [:span.hidden-xs.hidden-sm
+      (translate :hover-tile-location)
+      (if hover-q
+        (str hover-q "," hover-r)
+        (translate :none))])])

 (def armor-type-abbrevs
   {:unit-type.armor-type/personnel "P"


Function to test on which side of a line a point is situated

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

--- src/conexp/layout/force.clj
+++ src/conexp/layout/force.clj
@@ -41,6 +41,28 @@
   "Rotates given vector by pi/2 in positive direction."
   [[a b]]
   [(- b) a])
+
+(defn- side-number
+  "Returns +1 if node (first argument) is situated on the left of
+  line (given by two points as second argument), -1 otherwise."
+  ;; intermediate function; will be deleted later
+  [[x y] [[x_1 y_1] [x_2 y_2]]]
+    (with-doubles [x y x_1 y_1 x_2 y_2]
+      (let [r (/ (+ (* (- x x_1) (- x_2 x_1))
+		    (* (- y y_1) (- y_2 y_1)))
+		 (+ (square (- x_2 x_1)) (square (- y_2 y_1)))),
+	    perp-x (+ x_1 (* r (- x_2 x_1)))]
+	(cond
+	 (< x perp-x) 1,
+	 :else -1))))
+
+(defn- unit-vector
+  "Returns unit vector between first and second point."
+  [[x_1 y_1] [x_2 y_2]]
+  (with-doubles [x_1 y_1 x_2 y_2]
+    (let [length (distance [x_1 y_1] [x_2 y_2])]
+      [(/ (- x_2 x_1) length), (/ (- y_2 y_1) length)])))
+

 ;; Repulsive Energy and Force


Fixes errors when pgsql is unavailable

Fixes errors when pgsql is unavailable

--- src/onyx/plugin/pgsql.clj
+++ src/onyx/plugin/pgsql.clj
@@ -4,7 +4,6 @@

   (:require [clojure.java.jdbc :as jdbc]
             [clojure.string :as str]))
-

 (def ht-byte (.getBytes (str "\t") "UTF-8"))
 (def nl-byte (.getBytes (str "\n") "UTF-8"))
@@ -19,50 +18,53 @@
             '[org.postgresql.copy CopyManager
                                   PGCopyOutputStream])
     true
-    (catch Throwable _ false)))
+    (catch Throwable e
+      (println "unabable to include postgresql: " (.getMessage e))
+      false)))

-(defn- column->sql-value
-  "Coerces a column a format that's understood by the PostgreSQL COPY TEXT format."
-  [col]
-  (let [xform-escape (fn [x]
-                       (cond
-                         (string? x)
-                         (.replace x "\\" "\\\\")
+(when available?
+  (defn- column->sql-value
+    "Coerces a column a format that's understood by the PostgreSQL COPY TEXT format."
+    [col]
+    (let [xform-escape (fn [x]
+                         (cond
+                           (string? x)
+                           (.replace x "\\" "\\\\")

-                         (= (type x) PGobject)
-                         (.replace (.toString (cast PGobject x)) "\\" "\\\\")
+                           (= (type x) PGobject)
+                           (.replace (.toString (cast PGobject x)) "\\" "\\\\")

-                         :else
-                         x))
-        xform-null (fn [x]
-                     (if (nil? x) "\\N" x))
+                           :else
+                           x))
+          xform-null (fn [x]
+                       (if (nil? x) "\\N" x))

-        xform (comp str
-                    xform-null
-                    xform-escape
-                    jdbc/sql-value)]
-    (xform col)))
+          xform (comp str
+                      xform-null
+                      xform-escape
+                      jdbc/sql-value)]
+      (xform col)))

-(defn copy
-  "Uses PostgreSQL CopyManager to quickly load batches of rows into our destination table. Transaction
+  (defn copy
+    "Uses PostgreSQL CopyManager to quickly load batches of rows into our destination table. Transaction
    is guaranteed to be committed after function returns."
-  [table cols conn rows]
+    [table cols conn rows]

-  (let [pgconn (.unwrap (:connection conn) PgConnection)
-        copyman (.getCopyAPI pgconn)
-        copy (.copyIn copyman (str "COPY " table " FROM STDIN"))
-        ostream (PGCopyOutputStream. copy)]
+    (let [pgconn (.unwrap (:connection conn) PgConnection)
+              copyman (.getCopyAPI pgconn)
+              copy (.copyIn copyman (str "COPY " (name table) " FROM STDIN"))
+              ostream (PGCopyOutputStream. copy)]

-    (doseq [row rows]
-      (loop [values (map #(% row) cols)]
-        (let [cur (column->sql-value (first values))
-              more (next values)
-              buf (.getBytes cur "UTF-8")]
-          (.write ostream buf)
+          (doseq [row rows]
+            (loop [values (map #(% row) cols)]
+              (let [cur (column->sql-value (first values))
+                    more (next values)
+                    buf (.getBytes cur "UTF-8")]
+                (.write ostream buf)

-          (when more
-            (.write ostream ht-byte)
-            (recur more))))
+                (when more
+                  (.write ostream ht-byte)
+                  (recur more))))

-      (.write ostream nl-byte))
-    (.endCopy ostream)))
+            (.write ostream nl-byte))
+          (.endCopy ostream))))


Somehow managed to not commit this line in local-bufs functionality.

--- src/overtone/sc/synth.clj
+++ src/overtone/sc/synth.clj
@@ -111,7 +111,7 @@
     ;;Add link back to MaxLocalBufs ugen (always at root of tree) if
     ;;ugen is a local-buf.
     (if (= "LocalBuf" (:name ugen))
-      (assoc ugen :inputs (concat (:inputs ugen) {:src 0 :index 0}))
+      (assoc ugen :inputs (concat (:inputs ugen) [{:src 0 :index 0}]))
       ugen)))

 ; TODO: Currently the output rate is hard coded to be the same as the


Added "(throw (Exception.))" in place of "error"

--- resources/code/1.3.3.3.clj
+++ resources/code/1.3.3.3.clj
@@ -6,4 +6,4 @@
           (and (negative? b-value) (positive? a-value))
            (search f b a)
           :else
-           (error "Values are not of opposite sign" a b))))
+           (throw (Exception. "Values are not of opposite sign")))))


fixing error catching

fixing error catching

--- src/celestial/common.clj
+++ src/celestial/common.clj
@@ -74,8 +74,10 @@
    "Wraps validation error responses in the API layer"
    [& body]
   `(try+ ~@body
-    (catch (and (map? ~'%) (contains? ~'% :errors)) e# (bad-req e#))
-    (catch Throwable e#
+    (catch (and (map? ~'%) (or (contains? ~'% :errors) (contains? ~'% :msg))) e#
+      (info e#)
+      (bad-req e#))
+    (catch Object e#
       (error e#)
       (bad-req "Error happend, please contact admin"))
    )


add `:recompile-dependents` knob to `cljs.closure/build`

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -1050,7 +1050,8 @@
              (assoc-in [:opts :emit-constants] emit-constants)
              (assoc :target (:target opts))
              (assoc :js-dependency-index (deps/js-dependency-index all-opts))))
-         (binding [comp/*dependents* (atom {:recompile #{} :visited #{}})
+         (binding [comp/*dependents* (when-not (false? (:recompile-dependents opts))
+                                       (atom {:recompile #{} :visited #{}}))
                    ana/*cljs-static-fns*
                    (or (and (= (:optimizations opts) :advanced)
                             (not (false? (:static-fns opts))))


CLJ-2043 fix s/form of s/conformer

CLJ-2043 fix s/form of s/conformer

Signed-off-by: Stuart Halloway <4dc50fc3bc007be011b5445f3f79298b9eeb51b7@cognitect.com>

--- src/clj/clojure/spec.clj
+++ src/clj/clojure/spec.clj
@@ -652,8 +652,8 @@
   (possibly converted) value or :clojure.spec/invalid, and returns a
   spec that uses it as a predicate/conformer. Optionally takes a
   second fn that does unform of result of first"
-  ([f] `(spec-impl '~f ~f nil true))
-  ([f unf] `(spec-impl '~f ~f nil true ~unf)))
+  ([f] `(spec-impl '(conformer ~(res f)) ~f nil true))
+  ([f unf] `(spec-impl '(conformer ~(res f) ~(res unf)) ~f nil true ~unf)))

 (defmacro fspec
   "takes :args :ret and (optional) :fn kwargs whose values are preds


Fix wording for "not in" lint.

Fix wording for "not in" lint.

--- src/clj/fleetdb/lint.clj
+++ src/clj/fleetdb/lint.clj
@@ -99,7 +99,7 @@
            (lint #(= 3 (count %)) where (str op " clause has 2 arguments"))
            (let [[_ attr vals] where]
              (lint-attr attr)
-             (lint sequential? vals (str "vals for" op "must be in a sequence"))
+             (lint sequential? vals (str "vals for " op " must be in a sequence"))
              (domap lint-val vals)))
        :else
          (fail "unrecognized where operation" op))))


Drop an ugly xml handling hack which is no longer needed

with newer versions of clojure.data.xml

--- src/clj/mdr2/dtb/xml.clj
+++ src/clj/mdr2/dtb/xml.clj
@@ -54,13 +54,6 @@
                 source_date multimedia_type encoded_size]
          :as production}]
   (cond
-    ;; FIXME: this is a gross hack using one bug to work around
-    ;; another one. Once clojure properly handles xml namespaces this
-    ;; will probably not work anymore and should no longer be needed.
-    ;; The basic problem is the the default xml namespace is not
-    ;; loaded, so emit will die. So we just rename the namespaced
-    ;; xml:lang attribute into a not namespaced
-    (= node :xml/lang) :xml:lang
     (title-node? node) (update-title-node node title)
     (meta-node? node "dc:creator") (update-meta-node node creator)
     (meta-node? node "dc:title") (update-meta-node node title)


Forgot a newline in the alert email

Forgot a newline in the alert email

--- src/clj/medusa/alert.clj
+++ src/clj/medusa/alert.clj
@@ -59,6 +59,7 @@
                          "If you have any problems, please ask for help on the #telemetry IRC channel or on Slack in #fx-metrics. We'll give you a hand."
                          "\n\n"
                          "What this is:"
+                         "\n"
                          "We have a system called cerberus[1] that compares Telemetry collected on different Nightly builds and "
                          "looks for sudden changed in value distributions using the Bhattacharyya Distance[2]. It found such a "
                          "change in " metric_name " on " date " so it asked its buddy medusa[3] to send this email to the "


Truncate long test failure messages.

Truncate long test failure messages.

Lucene's MAX_TERM_LENGTH is 32766 bytes. Occasionally, test failure messages
will exceed this. We now truncate such messages so that they do not exceed the
limit.

Fixes #43

--- src/clj/runbld/store.clj
+++ src/clj/runbld/store.clj
@@ -17,6 +17,8 @@

 (def MAX_INDEX_BYTES (* 1024 1024 1024))

+(def MAX_TERM_LENGTH 32766)
+
 (defn make-connection
   [{:keys [url http-opts] :as args}]
   (http/make args))
@@ -82,6 +84,14 @@
        (name newest)
        (create-timestamped-index conn (format "%s-" idx) body)))))

+(defn truncate-message [{:keys [message] :as doc}]
+  (let [bytes (.getBytes message "UTF-8")
+        truncated (if (> (count bytes) MAX_TERM_LENGTH)
+                    (String. (byte-array (take MAX_TERM_LENGTH bytes))
+                             "UTF-8")
+                    message)]
+    (merge doc {:message truncated})))
+
 (s/defn create-build-doc :- StoredBuild
   [opts result test-report]
   (merge
@@ -96,7 +106,7 @@
                                      :message
                                      :summary])]
               (update (:report test-report)
-                      :failed-testcases #(map f %))))}))
+                      :failed-testcases #(map (comp truncate-message f) %))))}))

 (s/defn save-build!
   [opts


fix typo

fix typo

--- src/clj/tictag/slack.clj
+++ src/clj/tictag/slack.clj
@@ -16,15 +16,9 @@
   (stop [component]
     (when-let [pool (:threadpool component)]
       (cp/shutdown pool))
-    (dissoc component ::threadpool))
+    (dissoc component ::threadpool)))

 (timbre/refer-timbre)
-
-(dh/defretrypolicy
-  {:backoff-ms [250 5000 2]
-   :max-retries 8
-   :retry-if (fn [{:keys [error]} e]
-               (or error e))})

 (def oauth-access-token-url "https://slack.com/api/oauth.access")
 (def oauth-authorization-url "https://slack.com/oauth/authorize")
@@ -45,18 +39,28 @@
   (if (utils/success? resp)
     (get-in resp [:body :ok])))

+(dh/defretrypolicy retry-policy
+  {:backoff-ms [250 5000]
+   :max-retries 8
+   :retry-if (fn [{:keys [error]} exception]
+               (or error exception))})
+
 (defn post [client cmd opts]
-  (let [resp (http/post (method-url cmd) opts)]
-    (cp/future
-      pool
-      (let [resp (update @resp :body json/parse-string true)]
+  (cp/future
+    (::threadpool client)
+    (dh/with-retry {:policy retry-policy}
+      (let [resp (-> cmd
+                     (method-url)
+                     (http/post opts)
+                     (deref)
+                     (update :body json/parse-string true))]
         (when (success? resp)
           resp)))))

 (defn im-open [client token user-id]
   (:body @(post client "im.open" {:form-params {:token token :user user-id}})))

-(defn users-info [token user-id]
+(defn users-info [client token user-id]
   (:body @(post client "users.info" {:form-params {:token token :user user-id}})))

 (defn channels [client token]


Get scenario name from config instead of hard coding it

--- src/clj_gatling/core.clj
+++ src/clj_gatling/core.clj
@@ -15,7 +15,8 @@
   "OK")

 (def test-scenario
-  {:requests [{:name "Request1" :fn run-request}
+  {:name "Test scenario"
+   :requests [{:name "Request1" :fn run-request}
               {:name "Request2" :fn run-request}]})

 (defmacro bench [expr]
@@ -29,7 +30,7 @@
       (bench
         (map #(assoc (bench ((:fn %) id)) :name (:name %) :id id) (:requests scenario)))
       {:result :requests})
-    :id id))
+    :id id :name (:name scenario)))

 (defn run-simulation [users]
   (println (str "Run simulation with " users " users"))
@@ -49,14 +50,14 @@
     (GatlingConfiguration/setUp conf)
     (ReportsGenerator/generateFor "out" (FileDataReader. "23"))))

-(defn map-request [request]
+(defn map-request [scenario-name request]
   (let [start (.toString (:start request))
         end (.toString (:end request))
         execution-start start
         request-end start
         response-start end
         execution-end end]
-    ["REQUEST" "Scenario name" (.toString (:id request)) "" (:name request) execution-start request-end response-start execution-end "OK" "\u0020"]))
+    ["REQUEST" scenario-name (.toString (:id request)) "" (:name request) execution-start request-end response-start execution-end "OK" "\u0020"]))

 (defn flatten-one-level [coll]
   (mapcat #(if (sequential? %) % [%]) coll))
@@ -64,8 +65,8 @@
 (defn map-scenario [scenario]
   (let [start (.toString (:start scenario))
         end (.toString (:end scenario))
-        requests (apply concat (map #(vector (map-request %)) (:requests scenario)))]
-    (conj requests ["SCENARIO" "Scenario name" (.toString (:id scenario)) start end])))
+        requests (apply concat (map #(vector (map-request (:name scenario) %)) (:requests scenario)))]
+    (conj requests ["SCENARIO" (:name scenario) (.toString (:id scenario)) start end])))

 (defn create-result-lines [result]
   (let [timestamp (unparse-local (formatter "yyyyMMddhhmmss") (LocalDateTime.))


add missing inc-and-update for commodity import

--- src/clj_money/import.clj
+++ src/clj_money/import.clj
@@ -176,8 +176,10 @@
 (defmethod process-record :commodity
   [{:keys [entity storage] :as context} commodity _]
   (let [to-create (assoc commodity :entity-id (:id entity))
-        created (commodities/create storage  to-create)]
-    (update-in context [:commodities] #((fnil conj []) % created))))
+        created (commodities/create storage to-create)]
+    (-> context
+        (update-in [:commodities] #((fnil conj []) % created))
+        (inc-and-update-progress :commodity))))

 (defn process-callback
   "Top-level callback processing


Use needed namespae.

Use needed namespae.

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -1,5 +1,6 @@
 (ns clojush.evaluate
-  (:use [clojush util pushstate random globals individual])
+  (:use [clojush util pushstate random globals individual]
+        clojush.pushgp.genetic-operators)
   (:require [clojure.math.numeric-tower :as math]
             [clj-random.core :as random]))


Removing println

Removing println

--- modules/entrance/src/modular/entrance.clj
+++ modules/entrance/src/modular/entrance.clj
@@ -116,7 +116,6 @@
              assoc uuid
              {:username username
               :expiry (+ (.getTime (java.util.Date.)) (* expiry-seconds 1000))})
-      (println "added sessoin, sessions is" (:sessions this))
       {"session" {:value uuid
                   :max-age (* expiry-seconds 1000)}}))
   (get-session [this cookies]


fixed om template and snippet implementations

--- src/kioo/om.clj
+++ src/kioo/om.clj
@@ -44,10 +44,10 @@
   (snippet* path (list sel trans) args om-emit-opts))

 (defmacro template [path args trans]
-  (snippet* path trans args om-emit-opts))
+  (snippet* path (list trans) args om-emit-opts))

 (defmacro defsnippet [sym path sel args trans]
-  `(def sym ~(snippet* path (list sel trans) args om-emit-opts)))
+  `(def ~sym ~(snippet* path (list sel trans) args om-emit-opts)))

 (defmacro deftemplate [sym path args trans]
-  `(def sym ~(snippet* path args om-emit-opts)))
+  `(def ~sym ~(snippet* path (list trans) args om-emit-opts)))


Update Clojure game template

Update Clojure game template

--- src/clojure/leiningen/new/game_clojure/core.clj
+++ src/clojure/leiningen/new/game_clojure/core.clj
@@ -10,8 +10,7 @@
   :on-render
   (fn [screen entities]
     (clear!)
-    (render! screen)
-    (draw! screen entities)))
+    (render! screen entities)))

 (defgame {{app-name}}
   :on-create


In ants, avoid strange flash when running tests in iTerm2.

--- src/com/nomistech/clojure_the_language/ants_by_rich_hickey.clj
+++ src/com/nomistech/clojure_the_language/ants_by_rich_hickey.clj
@@ -213,100 +213,105 @@
         (alter p assoc :pher (* evap-rate (:pher @p))))))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; UI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(import
- '(java.awt Color Graphics Dimension)
- '(java.awt.image BufferedImage)
- '(javax.swing JPanel JFrame))
+
+(comment
+  (do
+
+    (import
+     '(java.awt Color Graphics Dimension)
+     '(java.awt.image BufferedImage)
+     '(javax.swing JPanel JFrame))

 ;pixels per world cell
-(def scale 5)
-
-(defn fill-cell [#^Graphics g x y c]
-  (doto g
-    (.setColor c)
-    (.fillRect (* x scale) (* y scale) scale scale)))
-
-(defn render-ant [ant #^Graphics g x y]
-  (let [black (. (new Color 0 0 0 255) (getRGB))
-        gray (. (new Color 100 100 100 255) (getRGB))
-        red (. (new Color 255 0 0 255) (getRGB))
-        [hx hy tx ty] ({0 [2 0 2 4]
-                        1 [4 0 0 4]
-                        2 [4 2 0 2]
-                        3 [4 4 0 0]
-                        4 [2 4 2 0]
-                        5 [0 4 4 0]
-                        6 [0 2 4 2]
-                        7 [0 0 4 4]}
-                       (:dir ant))]
-    (doto g
-      (.setColor (if (:food ant)
-                   (new Color 255 0 0 255)
-                   (new Color 0 0 0 255)))
-      (.drawLine (+ hx (* x scale)) (+ hy (* y scale))
-                 (+ tx (* x scale)) (+ ty (* y scale))))))
-
-(defn render-place [g p x y]
-  (when (pos? (:pher p))
-    (fill-cell g x y (new Color 0 255 0
-                          (int (min 255 (* 255 (/ (:pher p) pher-scale)))))))
-  (when (pos? (:food p))
-    (fill-cell g x y (new Color 255 0 0
-                          (int (min 255 (* 255 (/ (:food p) food-scale)))))))
-  (when (:ant p)
-    (render-ant (:ant p) g x y)))
-
-(defn render [g]
-  (let [v (dosync (apply vector (for [x (range dim) y (range dim)]
-                                  @(place [x y]))))
-        img (new BufferedImage (* scale dim) (* scale dim)
-                 (. BufferedImage TYPE_INT_ARGB))
-        bg (. img (getGraphics))]
-    (doto bg
-      (.setColor (. Color white))
-      (.fillRect 0 0 (. img (getWidth)) (. img (getHeight))))
-    (dorun
-     (for [x (range dim) y (range dim)]
-       (render-place bg (v (+ (* x dim) y)) x y)))
-    (doto bg
-      (.setColor (. Color blue))
-      (.drawRect (* scale home-off) (* scale home-off)
-                 (* scale nants-sqrt) (* scale nants-sqrt)))
-    (. g (drawImage img 0 0 nil))
-    (. bg (dispose))))
-
-(def panel (doto (proxy [JPanel] []
-                   (paint [g] (render g)))
-             (.setPreferredSize (new Dimension
-                                     (* scale dim)
-                                     (* scale dim)))))
-
-(def animator (agent nil))
-
-(defn animation [x]
-  (when running
-    (send-off *agent* #'animation))
-  (. panel (repaint))
-  (. Thread (sleep animation-sleep-ms))
-  nil)
-
-(def evaporator (agent nil))
-
-(defn evaporation [x]
-  (when running
-    (send-off *agent* #'evaporation))
-  (evaporate)
-  (. Thread (sleep evap-sleep-ms))
-  nil)
+    (def scale 5)
+
+    (defn fill-cell [#^Graphics g x y c]
+      (doto g
+        (.setColor c)
+        (.fillRect (* x scale) (* y scale) scale scale)))
+
+    (defn render-ant [ant #^Graphics g x y]
+      (let [black (. (new Color 0 0 0 255) (getRGB))
+            gray (. (new Color 100 100 100 255) (getRGB))
+            red (. (new Color 255 0 0 255) (getRGB))
+            [hx hy tx ty] ({0 [2 0 2 4]
+                            1 [4 0 0 4]
+                            2 [4 2 0 2]
+                            3 [4 4 0 0]
+                            4 [2 4 2 0]
+                            5 [0 4 4 0]
+                            6 [0 2 4 2]
+                            7 [0 0 4 4]}
+                           (:dir ant))]
+        (doto g
+          (.setColor (if (:food ant)
+                       (new Color 255 0 0 255)
+                       (new Color 0 0 0 255)))
+          (.drawLine (+ hx (* x scale)) (+ hy (* y scale))
+                     (+ tx (* x scale)) (+ ty (* y scale))))))
+
+    (defn render-place [g p x y]
+      (when (pos? (:pher p))
+        (fill-cell g x y (new Color 0 255 0
+                              (int (min 255 (* 255 (/ (:pher p) pher-scale)))))))
+      (when (pos? (:food p))
+        (fill-cell g x y (new Color 255 0 0
+                              (int (min 255 (* 255 (/ (:food p) food-scale)))))))
+      (when (:ant p)
+        (render-ant (:ant p) g x y)))
+
+    (defn render [g]
+      (let [v (dosync (apply vector (for [x (range dim) y (range dim)]
+                                      @(place [x y]))))
+            img (new BufferedImage (* scale dim) (* scale dim)
+                     (. BufferedImage TYPE_INT_ARGB))
+            bg (. img (getGraphics))]
+        (doto bg
+          (.setColor (. Color white))
+          (.fillRect 0 0 (. img (getWidth)) (. img (getHeight))))
+        (dorun
+         (for [x (range dim) y (range dim)]
+           (render-place bg (v (+ (* x dim) y)) x y)))
+        (doto bg
+          (.setColor (. Color blue))
+          (.drawRect (* scale home-off) (* scale home-off)
+                     (* scale nants-sqrt) (* scale nants-sqrt)))
+        (. g (drawImage img 0 0 nil))
+        (. bg (dispose))))
+
+    (def panel (doto (proxy [JPanel] []
+                       (paint [g] (render g)))
+                 (.setPreferredSize (new Dimension
+                                         (* scale dim)
+                                         (* scale dim)))))
+
+    (def animator (agent nil))
+
+    (defn animation [x]
+      (when running
+        (send-off *agent* #'animation))
+      (. panel (repaint))
+      (. Thread (sleep animation-sleep-ms))
+      nil)
+
+    (def evaporator (agent nil))
+
+    (defn evaporation [x]
+      (when running
+        (send-off *agent* #'evaporation))
+      (evaporate)
+      (. Thread (sleep evap-sleep-ms))
+      nil)

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; use ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(comment
-  ;; demo
-  ;; (load-file "/Users/rich/dev/clojure/ants.clj")
-  (do
-    (def frame (doto (new JFrame) (.add panel) .pack .show))
-    (def ants (setup))
-    (send-off animator animation)
-    (dorun (map #(send-off % behave) ants))
-    (send-off evaporator evaporation)))
-
+    (do
+      ;; demo
+      ;; (load-file "/Users/rich/dev/clojure/ants.clj")
+      (do
+        (def frame (doto (new JFrame) (.add panel) .pack .show))
+        (def ants (setup))
+        (send-off animator animation)
+        (dorun (map #(send-off % behave) ants))
+        (send-off evaporator evaporation))))
+  )
+


Update HTTP query validation

Update HTTP query validation

--- src/com/puppetlabs/puppetdb/http/experimental/event_counts.clj
+++ src/com/puppetlabs/puppetdb/http/experimental/event_counts.clj
@@ -4,7 +4,7 @@
             [com.puppetlabs.puppetdb.query.event-counts :as event-counts]
             [cheshire.core :as json])
   (:use     [com.puppetlabs.jdbc :only (with-transacted-connection)]
-            [com.puppetlabs.middleware :only [verify-param-exists verify-accepts-json]]
+            [com.puppetlabs.middleware :only [verify-accepts-json validate-query-params]]
             [net.cgrand.moustache :only [app]]))

 (defn produce-body
@@ -40,5 +40,5 @@
   "Ring app for querying for summary information about resource events."
   (-> routes
       verify-accepts-json
-      (verify-param-exists "query")
-      (verify-param-exists "summarize-by")))
+      (validate-query-params {:required ["query" "summarize-by"]
+                              :optional ["counts-filter" "count-by"]})))


CMR-183: Fixed broken doseq

CMR-183: Fixed broken doseq

--- src/cmr/common/cache.clj
+++ src/cmr/common/cache.clj
@@ -65,13 +65,11 @@
 (defn reset-caches
   "Clear all caches."
   [context]
-  (doall (map (fn [[k v]]
-                (debug "Clearing cache " k)
-                (reset-cache v))
-              (get-in context [:system :caches]))))
+  (doseq [[k v] (get-in context [:system :caches])]
+    (reset-cache v)))

 (defn update-cache
-  "Update the cache contents with the output of the given funciton, f. f takes the
+  "Update the cache contents with the output of the given function, f. f takes the
   current cache as its input and returns the new cache."
   [cmr-cache f]
   (swap! (:atom cmr-cache) f)


STORM-2105: some style changes

STORM-2105: some style changes

--- storm-core/src/clj/org/apache/storm/ui/core.clj
+++ storm-core/src/clj/org/apache/storm/ui/core.clj
@@ -394,10 +394,10 @@
                                            sup-avail-cpu (max (- sup-total-cpu (.get_used_cpu s)) 0.0)]]
                                  [sup-total-mem sup-total-cpu sup-avail-mem sup-avail-cpu]))
                              [0.0 0.0 0.0 0.0])
-           totalMem (nth resourceSummary 0)
-           totalCpu (nth resourceSummary 1)
-           availMem (nth resourceSummary 2)
-           availCpu (nth resourceSummary 3)]
+           total-mem (nth resourceSummary 0)
+           total-cpu (nth resourceSummary 1)
+           avail-mem (nth resourceSummary 2)
+           avail-cpu (nth resourceSummary 3)]
        {"user" user
         "stormVersion" STORM-VERSION
         "supervisors" (count sups)
@@ -408,12 +408,12 @@
         "executorsTotal" total-executors
         "tasksTotal" total-tasks
         "schedulerDisplayResource" (*STORM-CONF* Config/SCHEDULER_DISPLAY_RESOURCE)
-        "totalMem" totalMem
-        "totalCpu" totalCpu
-        "availMem" availMem
-        "availCpu" availCpu
-        "memAssignedPercentUtil" (if (and (not (nil? totalMem)) (> totalMem 0.0)) (format "%.1f" (* (/ (- totalMem availMem) totalMem) 100.0)) 0.0)
-        "cpuAssignedPercentUtil" (if (and (not (nil? totalCpu)) (> totalCpu 0.0)) (format "%.1f" (* (/ (- totalCpu availCpu) totalCpu) 100.0)) 0.0)})))
+        "totalMem" total-mem
+        "totalCpu" total-cpu
+        "availMem" avail-mem
+        "availCpu" avail-cpu
+        "memAssignedPercentUtil" (if (and (not (nil? total-mem)) (> total-mem 0.0)) (format "%.1f" (* (/ (- total-mem avail-mem) total-mem) 100.0)) 0.0)
+        "cpuAssignedPercentUtil" (if (and (not (nil? total-cpu)) (> total-cpu 0.0)) (format "%.1f" (* (/ (- total-cpu avail-cpu) total-cpu) 100.0)) 0.0)})))

 (defn convert-to-nimbus-summary[nimbus-seed]
   (let [[host port] (.split nimbus-seed ":")]


better to  shutdown the server first

better to  shutdown the server first

--- src/pc/init.clj
+++ src/pc/init.clj
@@ -45,5 +45,5 @@
   (println (pretty-now) "done"))

 (defn shutdown []
-  (pc.datomic/shutdown)
-  (pc.server/shutdown))
+  (pc.server/shutdown)
+  (pc.datomic/shutdown))


minor styling

minor styling

--- src/quick_chess/core.cljs
+++ src/quick_chess/core.cljs
@@ -179,7 +179,9 @@
        (let [color (get-in init-colors [row col])]
          (update-in hmap
                     [:board row col]
-                    assoc :color color :text "")))
+                    assoc
+                    :color color
+                    :text "")))
      state
      positions)))

@@ -228,7 +230,8 @@
              state
              [:string-map (:turn state) (:piece-str @text-state)])]
     (swap! app-state (handle-deselection pos positions))
-    (swap! text-state assoc
+    (swap! text-state
+           assoc
            :move-to {}
            :piece-str "")))

@@ -268,7 +271,8 @@
             (update-string-map piece-str to-pos)
             (move from-pos to-pos)
             (handle-deselection from-pos positions)))
-    (swap! text-state assoc
+    (swap! text-state
+           assoc
            :move-to {}
            :piece-str ""
            :text "")))


Speed up TCP handler slightly

Speed up TCP handler slightly

Iterates over states and events separately; a tad faster than iterating
over concat.

--- src/riemann/transport.clj
+++ src/riemann/transport.clj
@@ -94,10 +94,13 @@
   "Handles a msg with the given core."
   [core msg]
   (try+
-   ;; Send each event/state to each stream
-   (doseq [event  (concat (:events msg) (:states msg))
-           stream (:streams core)]
-     (stream event))
+    ;; Send each event/state to each stream
+    (doseq [event  (:states msg)
+            stream (:streams core)]
+      (stream event))
+    (doseq [event (:events msg)
+            stream (:streams core)]
+      (stream event))

    (if (:query msg)
      ;; Handle query
@@ -106,6 +109,7 @@
          {:ok true :events (search i ast)}
          {:ok false :error "no index"}))

+      ; Otherwise just return an ack
       {:ok true})

    ;; Some kind of error happened


update for docker-clj interface changes

update for docker-clj interface changes

--- src/dokkaa_builder/apps.clj
+++ src/dokkaa_builder/apps.clj
@@ -15,9 +15,6 @@
 (defn generate-host-port [host]
   (+ 10000 (rand-int 1000)))

-(defn port-binding [host-port container-port]
-  {(str container-port "/tcp") [{"HostPort" (str host-port)}]})
-
 (defn app->id [app-name user]
   (get-in @apps [(keyword app-name) :instances 0 :id]))

@@ -25,7 +22,7 @@
   (let [app-name (keyword app-name)
         cli (choose-client)
         host-port (generate-host-port (.host cli))
-        port-bindings (port-binding host-port port)]
+        port-bindings {host-port port}]
     (if (nil? (app-name @apps))
       (let [id (docker/run cli image :tag tag
                                      :cmd command


Make /about/version slightly more friendly if anyone runs 4clojure from something other than a git checkout. Not sure how much value this has, but it seemed like a good idea.

--- src/foreclojure/version.clj
+++ src/foreclojure/version.clj
@@ -6,11 +6,13 @@
 ;; fetch this at load time rather than on demand, so that it's accurate even
 ;; if someone checks out a different revision to poke at without restarting
 ;; the server (eg to diagnose bugs in a release)
-(def sha (:out (sh "git" "rev-parse" "--verify" "HEAD")))
+(def sha (not-empty (:out (sh "git" "rev-parse" "--verify" "HEAD"))))

 (def-page version []
-  [:p "SHA: "
-   [:a {:href (str "http://github.com/dbyrne/4clojure/commit/" sha)} sha]])
+  (if sha
+    [:p "SHA: "
+     [:a {:href (str "http://github.com/dbyrne/4clojure/commit/" sha)} sha]]
+    [:p "No git repository found"]))

 (defroutes version-routes
   (GET ["/about/version"] [] (version)))


Remove comments

Remove comments

--- src/graphql_clj/visitor.clj
+++ src/graphql_clj/visitor.clj
@@ -130,7 +130,7 @@
         (assoc :state (-> result :document section :state))
         (update-in [:document section] dissoc :state))))

-(defn- schema-definition ;; TODO extract to validator
+(defn- schema-definition
   "Given a parsed schema document, return the schema definition that defines the entry point
    types (schema and optionally mutation). Can return nil, in which case the default type
    `Query` will be used and mutations will be disabled."
@@ -140,7 +140,7 @@
            (filter #(= :schema-definition (:node-type %)))
            first))

-(defn- upsert-schema-entrypoint ;; TODO extract to validator
+(defn- upsert-schema-entrypoint
   [type-system-definitions root-query-name]
   (let [grouped (group-by #(= root-query-name (:type-name %)) type-system-definitions)
         entrypoint (intro/upsert-root-query (first (get grouped true)) root-query-name)
@@ -158,7 +158,7 @@
 (defmethod of-type :default [{:keys [type-name]}]
   type-name)

-(defn- root-fields ;; TODO extract to validator
+(defn- root-fields
   "Given a parsed schema document, return [root-name {root-field Type}]
    When validating queries, we need to know the types of the root fields to map to the same specs
    that we registered when parsing the schema.  Similar for mutations."
@@ -195,7 +195,7 @@
   [sym type node-type bindings & body]
   `(def ~sym (nodevisitor ~type ~node-type ~bindings ~@body)))

-(defn initial-state [schema]                                ;; TODO extract to validator
+(defn initial-state [schema]
   (let [{:keys [mutation-type] :as schema-definition} (schema-definition schema)
         schema-definition (or schema-definition {:node-type :schema-definition :query-type {:name "Query"}})
         root-query-name   (get-in schema-definition [:query-type :name])


[Fixes: #9181] Reset edit mailserver on add pressed

Signed-off-by: Andrea Maria Piana <39e16ece3c2d27e1889178b15ddb376e524032f8@gmail.com>

--- src/status_im/events.cljs
+++ src/status_im/events.cljs
@@ -174,8 +174,10 @@

 (handlers/register-handler-fx
  :mailserver.ui/add-pressed
- (fn [cofx _]
-   (navigation/navigate-to-cofx cofx :edit-mailserver nil)))
+ (fn [{:keys [db] :as cofx} _]
+   (fx/merge cofx
+             {:db (dissoc db :mailserver.edit/mailserver)}
+             (navigation/navigate-to-cofx :edit-mailserver nil))))

 (handlers/register-handler-fx
  :mailserver.ui/save-pressed


Rename some things.

Rename some things.

--- src/subticket/service.clj
+++ src/subticket/service.clj
@@ -111,7 +111,7 @@
   [usernames expiration]
   (and (not (empty? usernames)) (java-time/before? expiration (java-time/instant))))

-(defn- extend
+(defn- extend-session
   [session]
   (log/info :msg session)
   (assoc session :expiration (java-time/plus (java-time/instant) (java-time/seconds (Integer/parseInt (:subticket-session-length-in-seconds env))))))
@@ -133,7 +133,7 @@
    (fn [context]
      (if (ok? context)
        (let [session (or (get-in context [:request :session]) {})]
-         (assoc-in context [:response :session] (extend session)))
+         (assoc-in context [:response :session] (extend-session session)))
        context))})

 (def add-user-to-session
@@ -143,7 +143,7 @@
      (if (ok? context)
        (let [usernames (get-in context [:request :session :usernames])
              new-user (get-in context [:response :body :username])]
-         (assoc-in context [:response :session] (extend {:usernames (conj usernames new-user)})))
+         (assoc-in context [:response :session] (extend-session {:usernames (conj usernames new-user)})))
        context))})

 (defn logins [handler] [(body-params/body-params)
@@ -185,7 +185,7 @@
 ;      ^:interceptors [(body-params/body-params) http/html-body]
 ;      ["/about" {:get about-page}]]]])

-(def ^:private key (DatatypeConverter/parseHexBinary (:subticket-secret-key env)))
+(def ^:private session-key (DatatypeConverter/parseHexBinary (:subticket-secret-key env)))
 ;; Consumed by subticket.server/create-server
 ;; See http/default-interceptors for additional options you can configure
 (def service {:env :prod
@@ -207,7 +207,7 @@
               ;; Root for resource interceptor that is available by default.
               ::http/resource-path "/public"
               ;; session as encrypted cookie
-              ::http/enable-session {:store (cookie/cookie-store {:key key :readers clojure.core/*data-readers*})}
+              ::http/enable-session {:store (cookie/cookie-store {:key session-key :readers clojure.core/*data-readers*})}

               ;; Either :jetty, :immutant or :tomcat (see comments in project.clj)
               ::http/type :jetty


AWS mandates having several azs under an LB

--- src/terraboot/cluster.clj
+++ src/terraboot/cluster.clj
@@ -226,7 +226,9 @@
         cluster-output-of (output-of-fn cluster-unique)
         private-subnets (mapv #(cluster-id-of "aws_subnet" (stringify "private-" %)) azs)
         public-subnets (mapv #(cluster-id-of "aws_subnet" (stringify "public-" %)) azs)
+        ;; these subnets are both slightly artificial hacks to put different azs under load balancers
         elb-subnets (mapv #(remote-output-of "vpc" (stringify "subnet-public-" % "-id")) elb-azs)
+        elb-private-subnets (mapv #(remote-output-of "vpc" (stringify "subnet-private-" % "-id")) elb-azs)
         elb-listener (account-elb-listener account-number)]
     (merge-in
      (remote-state region bucket profile "vpc")
@@ -487,7 +489,7 @@
                    :alb [{:name "internal-tasks"
                           :internal true
                           :listeners (map #(assoc % :account-number account-number) slave-internal-alb-listeners)
-                          :subnets private-subnets
+                          :subnets elb-private-subnets
                           :security-groups (concat [(cluster-id-of "aws_security_group" "slave-alb-sg")]
                                                    remote-default-sgs)}] })
              (vpc/private_route53_record (str cluster-name "-slaves") vpc-name


♻ Extract api/enrich-congregation

♻ Extract api/enrich-congregation

Why:
- Separate the pure function and the database access

--- src/territory_bro/api.clj
+++ src/territory_bro/api.clj
@@ -200,7 +200,8 @@
                        :name (:congregation/name congregation)}))
                (validate-congregation-list))))))

-(defn- fetch-congregation [conn state user-id congregation]
+(defn- merge-congregation-details [congregation state user-id]
+  ;; TODO: fine-grained permission checks
   (let [cong-id (:congregation/id congregation)]
     {:id (:congregation/id congregation)
      :name (:congregation/name congregation)
@@ -213,11 +214,18 @@
      :congregation-boundaries (sequence (vals (get-in state [::congregation-boundary/congregation-boundaries cong-id])))
      :regions (sequence (vals (get-in state [::region/regions cong-id])))
      :card-minimap-viewports (sequence (vals (get-in state [::card-minimap-viewport/card-minimap-viewports cong-id])))
-     :users (->> (user/get-users conn {:ids (congregation/get-users state cong-id)})
-                 (map (fn [user]
-                        (-> (:user/attributes user)
-                            (assoc :id (:user/id user))
-                            (assoc :sub (:user/subject user))))))}))
+     :users (for [user-id (congregation/get-users state cong-id)]
+              {:id user-id})}))
+
+(defn- enrich-congregation [congregation conn]
+  (let [user-ids (->> (:users congregation)
+                      (map :id))]
+    (-> congregation
+        (assoc :users (->> (user/get-users conn {:ids user-ids})
+                           (map (fn [user]
+                                  (-> (:user/attributes user)
+                                      (assoc :id (:user/id user))
+                                      (assoc :sub (:user/subject user))))))))))

 (def ^:private validate-congregation (s/validator Congregation))

@@ -236,7 +244,9 @@
               congregation (congregation/get-my-congregation state cong-id user-id)]
           (when-not congregation
             (forbidden! "No congregation access"))
-          (ok (-> (fetch-congregation conn state user-id congregation)
+          (ok (-> congregation
+                  (merge-congregation-details state user-id)
+                  (enrich-congregation conn)
                   (format-for-api)
                   (validate-congregation))))))))

@@ -251,7 +261,9 @@
                            (congregation/get-unrestricted-congregation state cong-id))]
         (when-not congregation
           (forbidden! "No demo congregation"))
-        (ok (-> (fetch-congregation conn state user-id congregation)
+        (ok (-> congregation
+                (merge-congregation-details state user-id)
+                (enrich-congregation conn)
                 (assoc :id "demo")
                 (assoc :name "Demo Congregation")
                 (assoc :permissions {:viewCongregation true})


great ebo

great ebo

--- src/bluebell/utils/ebo.clj
+++ src/bluebell/utils/ebo.clj
@@ -5,8 +5,7 @@
             [clojure.core :as c]
             [bluebell.utils.pareto :as pareto]
             [bluebell.utils.core :as utils]
-            [clojure.set :as cljset])
-  (:refer-clojure :exclude [and or not]))
+            [clojure.set :as cljset]))

 (declare filter-positive)
 (declare check-valid)
@@ -22,7 +21,7 @@
 (spec/def ::pred fn?)
 (spec/def ::key any?)
 (spec/def ::desc string?)
-(spec/def ::spec #(c/or (spec/spec? %)
+(spec/def ::spec #(or (spec/spec? %)
                         (keyword? %)))
 (spec/def ::valid? boolean?)

@@ -73,7 +72,7 @@
         pos-failures (filter (complement pred)
                              (:pos arg-spec))
         neg-failures (filter pred (:neg arg-spec))]
-    (if (c/and (empty? pos-failures)
+    (if (and (empty? pos-failures)
                (empty? neg-failures))
       (assoc arg-spec :valid? true)
       (merge arg-spec
@@ -186,8 +185,8 @@
   (if (= (count a) (count b))
     (let [cmps (:arg-spec-comparisons state)
           pairs (set (map (comp (partial get cmps) vector) a b))]
-      (c/and (contains? pairs :subset)
-             (c/not (contains? pairs :superset))))
+      (and (contains? pairs :subset)
+             (not (contains? pairs :superset))))
     false))

 (defn- compute-overload-dominates? [state]
@@ -258,7 +257,7 @@
       :default (first e))))

 (defn- resolve-overload [state args]
-  {:pre [(c/not (:dirty? state))]}
+  {:pre [(not (:dirty? state))]}
   (let [arity (count args)
         overloads (:overloads state)]
     (if-let [m (get overloads arity)]
@@ -292,7 +291,7 @@
 (defn make-overload-fn [sym]
   (let [state-atom (atom (init-overload-state sym))]
     (fn [& args]
-      (c/or (perform-special-op state-atom args)
+      (or (perform-special-op state-atom args)
             (perform-evaluation state-atom args)))))

 (defn- reset-state [state]
@@ -352,7 +351,7 @@
 (defmacro def-overload [sym arg-list & body]
   {:pre [(symbol? sym)]}
   (let [p (spec/conform ::def-overload-arg-list arg-list)]
-    (if (= p ::spec/invalid)
+    (if (= p ::speinvalid)
       (throw (ex-info
               "Bad def-overload arg list"
               {}))
@@ -382,7 +381,7 @@
 ;;;------- Misc -------
 (defn check-valid [arg-spec]
   {:pre [(spec/valid? ::arg-spec arg-spec)]}
-  (when (c/not (:valid? arg-spec))
+  (when (not (:valid? arg-spec))
     (throw (ex-info
             (str "Invalid arg-spec '" (:desc arg-spec) "'")
             arg-spec)))
@@ -411,6 +410,6 @@

 (def-arg-spec map-arg (pred map?))

-(def-arg-spec empty-arg (pred (fn [x] (c/and (coll? x)
+(def-arg-spec empty-arg (pred (fn [x] (and (coll? x)
                                              (empty? x)))))


better CLJS compstibility

better CLJS compstibility

--- src/calfpath/internal.cljc
+++ src/calfpath/internal.cljc
@@ -19,7 +19,8 @@
 (defn expected
   ([expectation found]
     (throw (ex-info
-             (str "Expected " expectation ", but found (" (class found) ") " (pr-str found)))))
+             (str "Expected " expectation ", but found (" (type found) ") " (pr-str found))
+             {:found found})))
   ([pred expectation found]
     (when-not (pred found)
       (expected expectation found))))
@@ -73,12 +74,12 @@
 (def ^:const uri-match-end-index :calfpath/uri-match-end-index)

-(definline get-uri-match-end-index
+(defmacro get-uri-match-end-index
   [request]
   `(or (get ~request uri-match-end-index) 0))

-(definline assoc-uri-match-end-index
+(defmacro assoc-uri-match-end-index
   [request end-index]
   `(assoc ~request uri-match-end-index ~end-index))

@@ -98,7 +99,7 @@
           default-expr {:status 405
                         :headers {"Allow"        method-string
                                   "Content-Type" "text/plain"}
-                        :body (format "405 Method not supported. Only %s is supported." method-string)}]
+                        :body (str "405 Method not supported. Only " method-string " is supported.")}]
       `(if (identical? ~method-keyword (:request-method ~request))
          ~expr
          ~default-expr)))
@@ -373,7 +374,7 @@
                          (partial-match (persistent! path-params) actual-index))
                        (full-match (persistent! path-params)))
                      (let [token (get pattern-tokens token-index)]
-                       (if (instance? String token)
+                       (if (string? token)
                          ;; string token
                          (when (string/starts-with? actual-uri token)
                            (recur path-params (unchecked-add actual-index (count token)) (unchecked-inc token-index)))


Enable subentries in the subtoc

Enable subentries in the subtoc

--- src/catalog/layout/fop.clj
+++ src/catalog/layout/fop.clj
@@ -71,13 +71,23 @@
    (h1 :inhalt)
    (keep #(toc-entry items %) formats)])

-(defn sub-toc-entry [items fmt genre]
-  (when (genre items)
-    [:fo:block {:text-align-last "justify"}
-     [:fo:basic-link {:internal-destination (hash [fmt genre])}
-      (str (layout/translations genre) " ")
+(defn- sub-sub-toc-entry [items fmt genre subgenre]
+  (when-let [items (subgenre items)]
+    [:fo:block {:text-align-last "justify" :start-indent "1em"}
+     [:fo:basic-link {:internal-destination (hash [fmt genre subgenre])}
+      (str (layout/translations subgenre) " ")
       [:fo:leader {:leader-pattern "dots"}]
-      [:fo:page-number-citation {:ref-id (hash [fmt genre])}]]]))
+      [:fo:page-number-citation {:ref-id (hash [fmt genre subgenre])}]]]))
+
+(defn- sub-toc-entry [items fmt genre]
+  (when-let [items (genre items)]
+    [:fo:block
+     [:fo:block {:text-align-last "justify"}
+      [:fo:basic-link {:internal-destination (hash [fmt genre])}
+       (str (layout/translations genre) " ")
+       [:fo:leader {:leader-pattern "dots"}]
+       [:fo:page-number-citation {:ref-id (hash [fmt genre])}]]]
+     (keep #(sub-sub-toc-entry items fmt genre %) layout/subgenres)]))

 (defn sub-toc [items fmt]
   [:fo:block


Make the hostname of print-instances more useful when the owning instance is on EC2

--- src/circle/backend/ec2.clj
+++ src/circle/backend/ec2.clj
@@ -32,6 +32,26 @@
                                              DescribeInstanceAttributeRequest
                                              ModifyInstanceAttributeRequest)))

+;; http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html?r=1890
+(def aws-metadata-url "http://169.254.169.254/latest/meta-data/")
+
+(defn self-metadata
+  "Returns metadata about the current instance. attr is a string/keyword"
+  [attr]
+  (try
+    (let [resp (http/get (format "%s/%s" aws-metadata-url attr) {:throw-exceptions false
+                                                                 :socket-timeout 1000
+                                                                 :conn-timeout 1000})]
+      (when (= 200 (-> resp :status))
+        (-> resp :body)))
+    (catch Exception e
+      nil)))
+
+(defn self-instance-id
+  "If the local box is an EC2 instance, returns the instance id, else nil."
+  []
+  (self-metadata "instance-id"))
+
 (defmacro with-ec2-client
   [client & body]
   `(let [~client (AmazonEC2Client. aws-credentials)]
@@ -347,7 +367,7 @@
                                 :public-key public-key
                                 :private-key private-key) instance-ids)
     (add-tags instance-ids {:username (env/username)
-                            :hostname (env/hostname)
+                            :hostname (or (self-instance-id) (env/hostname))
                             :timestamp (str (java.util.Date.))})
     instance-ids))

@@ -394,24 +414,4 @@
     (let [request (doto (ModifyInstanceAttributeRequest.)
                     (.setInstanceId instance-id)
                     (.setInstanceInitiatedShutdownBehavior (name value)))]
-      (.modifyInstanceAttribute client request))))
-
-;; http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html?r=1890
-(def aws-metadata-url "http://169.254.169.254/latest/meta-data/")
-
-(defn self-metadata
-  "Returns metadata about the current instance. attr is a string/keyword"
-  [attr]
-  (try
-    (let [resp (http/get (format "%s/%s" aws-metadata-url attr) {:throw-exceptions false
-                                                                 :socket-timeout 1000
-                                                                 :conn-timeout 1000})]
-      (when (= 200 (-> resp :status))
-        (-> resp :body)))
-    (catch org.apache.http.conn.ConnectTimeoutException e
-      nil)))
-
-(defn self-instance-id
-  "If the local box is an EC2 instance, returns the instance id, else nil."
-  []
-  (self-metadata "instance-id"))+      (.modifyInstanceAttribute client request))))


Add first try for using reducers.

Add first try for using reducers.

--- src/dsbdp/main.clj
+++ src/dsbdp/main.clj
@@ -13,6 +13,7 @@
   (:require
     (clj-assorted-utils [util :refer :all])
     (clojure.core [async :as async])
+    (clojure.core [reducers :as reducers])
     (clojure.tools [cli :refer :all])
     (dsbdp
       [data-processing-dsl :refer :all]
@@ -206,6 +207,12 @@
                         (fn []
                           (doseq [data (pmap direct-proc-fn (repeat in-data))]
                             (.inc out-cntr)))
+                      (.endsWith scenario "-reducers-map")
+                        (fn []
+                          (loop []
+                            (doseq [data (into [] (reducers/map direct-proc-fn (repeat (* queue-size 1) in-data)))]
+                              (.inc out-cntr))
+                            (recur)))
                       (.endsWith scenario "-async-pipeline")
                         (if
                           (and