touched up section B and added links

touched up section B and added links

--- src/tutorial/untangled_tutorial/B_UI.cljs
+++ src/tutorial/untangled_tutorial/B_UI.cljs
@@ -55,6 +55,16 @@
   "
   (dc/mkdn-pprint-source WidgetWithHook)
   "
+  ## ClojureScript and React – HTML differences
+
+  Here are some common things you'll want to know how to do that are different when rendering with Om/ClojureScript:
+
+  - Inline styles are specified with real maps `(dom/p #js { :style {:backgroundColor \"rgb(120,33,41)\"} } ...)`
+  - CSS class names are specified with `:className` instead of `:class`.
+  - Any time there are adjacent elements of the same type in the DOM, they should each have a unique `:key`
+  attribute. This is typically generated by a function you supply to the Om factory function, but you can
+  also do it manually.
+
   ## Element factory

   In order to render components on the screen you need an element factory.
@@ -139,10 +149,16 @@
   with an edn map as the first argument. That map is accessed using `om/props` on `this` within the subcomponent. Data
   is passed from component to component through `props`.

+  ### Don't forget the React DOM Key!
+
   You might notice something new here: the `om/factory` function is supplied with an additional map `{:keyfn :name}`.
   The factory function can be optionally supplied with two keywords: `:keyfn` and `:validator`. `:keyfn` produces the
   React key property
   from component props (here it's `:name`), while `:validator`takes a function that asserts the validity of the props received.
+
+  The key is critical, as it helps React figure out the DOM diff. If you see warning about elements missing
+  keys (or having the same key) it means you have adjacent elements in the DOM of the same type, and React cannot
+  figure out what to do to make sure they are properly updated.

   ## Play With It

@@ -232,9 +248,9 @@
         (.attr "height" (fn [d] (.-size d))))
     (-> selection
         .exit
-        (.transition)
+        .transition
         (.style "opacity" "0")
-        (.remove))
+        .remove)
     false))

 (defui D3Thing
@@ -321,20 +337,24 @@
 (defcard-doc
   "

-  The things to note for this example are:
+  The things to note for this stateful example are:

   - We override the React lifecycle method `shouldComponentUpdate` to do the actual D3 update, and then return false.
-  This ensures React and D3 don't fight over the DOM for the component.
+  This ensures React and D3 don't fight over the DOM for the component (since we're asking React to never change
+  it).
   - We also override `componentDidMount` to do an initial render in D3.
   - Note: As of Om 1.0.0 Alpha 30 the method of obtaining the properties differs a bit, as shown. This may have
-  changed since this writing.
+  changed since this writing. If the example is failing please check the docs and report a bug.

   ## Important Notes and Further Reading

   - Remember to use `#js` (shown as `clj->js` in many examples) to transform attribute maps for passing to DOM elements
-  - Use *cljs* maps as input to your own Elements
+  - Use *cljs* maps as input to your own Elements: `(my-ui-thing {:a 1})` and `(dom/div #js { :data-x 1 } ...)`.
   - Extract properties with `om/props`. This is the same for stateful (with queries) or stateless components.
-  - Add parent-generated things (like callbacks) using `om/computed`.
-
-  TODO: Add links to various docs
+  - Add parent-generated things (like callbacks) using `om/computed` and pull them from the component with
+    `(om/get-computed)`.
+
+
+  You may do additional [UI exercises](#!/untangled_tutorial.B_UI_Exercises), or continue on to the
+  [next chapter](#!/untangled_tutorial.C_App_Database) on the client database.
   ")


Story ID: develop Summary: failed filter only shows namespaces that have failures or errors

--- src/untangled_spec/reporters/browser.cljs
+++ src/untangled_spec/reporters/browser.cljs
@@ -166,7 +166,9 @@
                               (ui-filters {:report/filter current-filter
                                            :set-filter! set-filter!})
                               (dom/ul #js {:className "test-list"}
-                                      (mapv (comp ui-test-namespace
-                                                  #(assoc % :report/filter current-filter))
-                                            (:namespaces test-report-data)))
+                                      (->> (:namespaces test-report-data)
+                                           (remove #(when (= :failed current-filter)
+                                                      (not (#{:failed :error} (:status %)))))
+                                           (mapv (comp ui-test-namespace
+                                                       #(assoc % :report/filter current-filter)))))
                               (ui-test-count test-report-data)))))


Removed code to set up remote figwheel clients

We have now proved that apps can be made in CLSJ in CLJS so no need to
have small apps compiled on the server anymore

--- src/webapp/framework/server/systemfns.clj
+++ src/webapp/framework/server/systemfns.clj
@@ -1632,7 +1632,7 @@

 (def o2 (Object.))
-(defn server-set-up-hosted-figwheel-clients []
+(comment defn server-set-up-hosted-figwheel-clients []
   (future (locking o2
             (if (= @server-set-up-hosted-figwheel-clients? false)
               (do
@@ -1797,7 +1797,7 @@
   (let [client-data-atom    (if server-side-realtime-clients  (get @server-side-realtime-clients  client-data-session-id))
         response-atom       (if client-data-atom  client-data-atom )
         ]
-      (server-set-up-hosted-figwheel-clients)
+      ;(server-set-up-hosted-figwheel-clients)
 ;    (if (not *hosted-mode*)
       (set-up-server-listeners)


[refactor] Simplify getting back to a root zipper

--- src/mranderson/move.clj
+++ src/mranderson/move.clj
@@ -193,7 +193,7 @@
          found-nodes []]
     (if-let [found-node (z/find-next-depth-first loc (partial after-platfrom-marker? platform))]
       (recur (z/replace found-node (symbol (str (name platform) "_require"))) (conj found-nodes found-node))
-      [found-nodes (z/of-string (z/root-string loc))])))
+      [found-nodes (z/edn (z/root loc))])))

 (defn- restore-platform-specific-subforms [platform replaced-nodes ns-form]
   (loop [form             ns-form


added flatline when Runner max hand size below 0 at end of his turn

--- src/node/game/core.cljs
+++ src/node/game/core.cljs
@@ -276,9 +276,11 @@
   (when (= side :corp) (draw state :corp)))

 (defn end-turn [state side]
+  (system-msg state side (str "is ending his or her turn"))
+  (when (and (= side :runner) (< (get-in @state [:runner :max-hand-size]) 0))
+    (flatline state))
   (trigger-event state side :turn-ends nil)
-  (swap! state assoc :end-turn true)
-  (system-msg state side (str "is ending his or her turn")))
+  (swap! state assoc :end-turn true))

 (defn add-prop [state side card key n]
   (update! state side (update-in card [key] #(+ % n))))


improving price event fetch

improving price event fetch

--- src/pe_fp_core/core.clj
+++ src/pe_fp_core/core.clj
@@ -109,6 +109,7 @@
 (defn rs->price-event
   [price-event-rs]
   (-> price-event-rs
+      (ucore/replace-if-contains :fs_id        :price-event/fs-id)
       (ucore/replace-if-contains :type_id      :price-event/fs-type-id)
       (ucore/replace-if-contains :street       :price-event/fs-street)
       (ucore/replace-if-contains :city         :price-event/fs-city)
@@ -137,10 +138,11 @@
    distance-within
    event-date-after
    sort-by
-   max-results]
+   max-results
+   min-distance-diff-fs]
   (let [sort-by-clause (reduce (fn [clause [col dir]] (format "%s%s %s," clause col dir)) "" sort-by)
         sort-by-clause (.substring sort-by-clause 0 (dec (count sort-by-clause)))
-        qry (str "select fs.type_id, f.gallon_price, f.octane, f.is_diesel, "
+        qry (str "select fs.id as fs_id, fs.type_id, f.gallon_price, f.octane, f.is_diesel, "
                  "f.purchased_at, fs.latitude, fs.longitude, fs.street, fs.city, fs.state, fs.zip, "
                  (format "ST_Distance(fs.location, ST_Geomfromtext('POINT(%s %s)', 4326)::geography) as distance" longitude latitude)
                  (format " from %s f, %s fs" fpddl/tbl-fplog fpddl/tbl-fuelstation)
@@ -149,10 +151,25 @@
                  " and f.deleted_at is null and fs.deleted_at is null"
                  (format " order by %s" sort-by-clause)
                  (format " limit %s" max-results))
-        args (if (not (nil? event-date-after)) [(c/to-timestamp event-date-after)] [])]
-    (j/query db-spec
-             (vec (concat [qry] args))
-             :row-fn rs->price-event)))
+        args (if (not (nil? event-date-after)) [(c/to-timestamp event-date-after)] [])
+        rs (j/query db-spec (vec (concat [qry] args)) :row-fn rs->price-event)]
+    (let [filtered-rs (reduce (fn [[fs-ids distances events]
+                                   {fs-id :price-event/fs-id
+                                    dist :price-event/fs-distance
+                                    :as evt}]
+                                (let [new-fs-ids (assoc fs-ids fs-id fs-id)
+                                      new-distances (assoc distances dist dist)]
+                                  (if (nil? (get fs-ids fs-id))
+                                    (if (nil? (get distances dist))
+                                      [new-fs-ids new-distances (conj events evt)]
+                                      [new-fs-ids new-distances events])
+                                    [new-fs-ids new-distances events])))
+                              [{} {} []]
+                              rs)
+          events (nth filtered-rs 2)]
+      (ucore/remove-matches events
+                            #(<= (Math/abs (- (:price-event/fs-distance %1)
+                                              (:price-event/fs-distance %2))) min-distance-diff-fs)))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Fuel purchase log-related definitions.


Add IQR, re-do fivenum a bit

Add IQR, re-do fivenum a bit

--- src/clj/clojurewerkz/statistiker/descriptive.clj
+++ src/clj/clojurewerkz/statistiker/descriptive.clj
@@ -1,15 +1,9 @@
 (ns clojurewerkz.statistiker.descriptive
+  (:import [org.apache.commons.math3.stat.descriptive.rank Percentile])
   (:require [clojurewerkz.statistiker.fast-math :refer :all]))

-(defn get-rank
-  [amount percentile]
-  (assert (<= percentile 100))
-  (-> (* (/ percentile 100) (dec amount))
-      Math/ceil
-      int))
-
 (def percentiles
-  {:min 0
+  {:min 1
    :max 100
    :median 50
    :25 25
@@ -17,10 +11,17 @@

 (defn fivenum
   [values]
-  (let [sorted (sort values)
-        amount (count values)]
-    {:min    (nth sorted (get-rank amount 0))
-     :25     (nth sorted (get-rank amount 25))
-     :median (nth sorted (get-rank amount 50))
-     :75     (nth sorted (get-rank amount 75))
-     :max    (nth sorted (get-rank amount 100) )}))
+  (let [p (Percentile.)]
+    (.setData p (double-array values))
+    (reduce (fn [acc [k v]]
+              (assoc acc k (.evaluate p (double v))))
+            {}
+            percentiles)))
+
+(defn iqr
+  [values]
+  (let [p              (Percentile.)
+        _              (.setData p (double-array values))
+        first-quartile (.evaluate p (double 25))
+        third-quartile (.evaluate p (double 75))]
+    (- third-quartile first-quartile)))


add function `hosts` to retrieve only hosts information

Also tested on Cassandra 2 - it works without changes

--- src/clojure/clojurewerkz/cassaforte/metadata.clj
+++ src/clojure/clojurewerkz/cassaforte/metadata.clj
@@ -357,8 +357,15 @@
   (when-let [hosts (.getAllHosts cluster-meta)]
     (non-nil-coll #(get-host-info % detailed?) hosts)))

+(defn hosts
+  "Returns information about hosts in cluster associated with session.
+  Verbosity is regulated by :detailed? parameter that is equal to false by default"
+  [^Session session & {:keys [detailed?] :or {detailed? false}}]
+  (when-let [cluster-meta ^Metadata (get-cluster-meta session)]
+    (get-hosts-impl cluster-meta detailed?)))
+
 (defn cluster
-  "Describes cluster.
+  "Describes cluster associated with session.
   Verbosity is regulated by :detailed? parameter that is equal to false by default"
   [^Session session & {:keys [detailed?] :or {detailed? false}}]
   (when-let [cluster-meta ^Metadata (get-cluster-meta session)]


Added boolean value validation; Updated README.

--- src/cmr/search/services/parameter_validation.clj
+++ src/cmr/search/services/parameter_validation.clj
@@ -167,6 +167,16 @@
         [(on-msg/invalid-orbit-number-msg)]))
     []))

+
+(defn boolean-value-validation
+  [concept-type params]
+  (let [bool-params (select-keys params [:downloadable])]
+    (mapcat
+      (fn [[key value]]
+        (if (or (= "true" value) (= "false" value))
+          []
+          [(format "Parameter %s must take value of true of false, but was %s" key value)]))
+      bool-params)))

 (def parameter-validations
   "A list of the functions that can validate parameters. They all accept parameters as an argument


Tests for parallel CbO do not run if pcbo is not present

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

--- src/conexp/contrib/tests/algorithms/concepts.clj
+++ src/conexp/contrib/tests/algorithms/concepts.clj
@@ -8,14 +8,20 @@

 (ns conexp.contrib.tests.algorithms.concepts
   (:require [conexp.main :as cm])
-  (:use conexp.contrib.algorithms.concepts)
+  (:use [conexp.contrib.exec :only (program-exists?)]
+        conexp.contrib.algorithms.concepts)
   (:use clojure.test
         clojure.contrib.def))

 ;;;

-(defvar- concepts-methods (remove #(.startsWith (name %) "default")
-                                  (keys (methods concepts))))
+(defvar- concepts-methods (let [invalid-methods #{}
+                                invalid-methods (when-not (program-exists? "pbco")
+                                                  (conj invalid-methods :pcbo))]
+                            (remove #(or (.startsWith ^String (name %) "default")
+                                         (contains? invalid-methods %))
+                                    (keys (methods concepts)))))
+
 (defvar- test-runs 50)

 (deftest test-concepts


Refactor server starting code

Refactor server starting code

Remove the non-recommended (run-dmc) function instead wrapping
stacktrace manually.

--- src/env_logger/handler.clj
+++ src/env_logger/handler.clj
@@ -5,8 +5,9 @@
             [compojure.route :as route]
             [env-logger.config :refer [get-conf-value]]
             [env-logger.db :as db]
-            [immutant.web :refer [run run-dmc]]
+            [immutant.web :as web]
             [ring.middleware.defaults :refer :all]
+            [ring.middleware.stacktrace :refer [wrap-stacktrace]]
             [selmer.parser :refer [render-file]]))

 (defroutes routes
@@ -49,8 +50,9 @@
                                            false) :proxy true)
                           (assoc-in site-defaults [:security :anti-forgery]
                                     false))
+        handler (if production?
+                  ;; TODO fix CSRF tokens
+                  (wrap-defaults routes defaults-config)
+                  (wrap-stacktrace (wrap-defaults routes defaults-config)))
         opts {:host ip :port port}]
-    (if production?
-      ;; TODO fix CSRF tokens
-      (run (wrap-defaults routes defaults-config) opts)
-      (run-dmc (wrap-defaults routes defaults-config) opts))))
+    (web/run handler opts)))


refactor validation for flat entities

refactor validation for flat entities

--- src/gangway/validation.clj
+++ src/gangway/validation.clj
@@ -1,39 +1,34 @@
 (ns gangway.validation
   (:require [clojure.data.json :as json]
+            [clojure.pprint :refer [pprint]]
             [hatch]
             [schema.core :as s]
-            [navigator.validation :as nav-val]
             [oarlock.validation :as oar-val]))

 (defn construct-data
-  "Constructs a namespaced map out of an incoming json message"
-  [msg]
-  (let [entity-type (get-in msg [:header :entity-type])]
-    (if (get-in msg [:header :entity-id])
-      (let [id-key (keyword (str entity-type "-id"))
-            id-sk-key (keyword (str entity-type "/id-sk"))
-            id (str (get-in msg [:header :entity-id id-key]))]
-        (merge {id-sk-key id}
-               (hatch/slam-all (get-in msg [:payload :entity]) (keyword entity-type))))
-      (hatch/slam-all (get-in msg [:payload :entity]) (keyword entity-type)))))
+  "Combines route-params with incoming json message"
+  [msg rp]
+  (pprint msg)
+  (merge msg {:id-sk (:id-sk rp)
+              :id-sk-origin (keyword (:id-sk-origin rp))}))

 (defn validator
-  [entity-type validation-map data]
+  [validation-map entity-type data]
   (let [validation (entity-type validation-map)]
     (if validation
       (try
         (s/validate
          validation
          data)
-        (catch Exception e (.getMessage e)))
-      data)))
+        {:valid true :data data}
+        (catch Exception e {:valid false :error (.getMessage e)}))
+      {:valid true :data data})))

 (def validation-maps
   {:assert
    {:task           oar-val/validations
     :perf-asmt      oar-val/validations
-    :user2perf-asmt oar-val/validations
-    :user2comp      nav-val/validations}})
+    :user2perf-asmt oar-val/validations}})

 (defn valid-json?
   "Evaluates given message string to determine if it's valid JSON.
@@ -50,13 +45,19 @@
 (defn valid?
   "Runs a validation function to check if a message is valid.
   Returns true or false."
-  [msg]
-  (let [op (keyword (:operation msg))
-        entity-type (keyword (:entity-type msg))
+  [msg rp op]
+  (let [entity-type (keyword (:entity-type rp))
         validation-map (get-in validation-maps [op entity-type])]
-    (if (nil? validation-map)
-      true
-      ;;We need some new validation here
-      #_(if (nil? (first (validation-fn (construct-data msg))))
-        true
-        false))))
+    (if (valid-json? msg)
+      (let [parsed-msg (json/read-str msg :key-fn keyword)
+            data (construct-data parsed-msg rp)]
+        (if (nil? validation-map)
+          true
+          (validator validation-map entity-type data))))))
+
+(comment
+
+  (def msg {:name "flarp" :version "v2" :description "this is a description"})
+  (def rp {:id-sk "392" :id-sk-origin "showevidence" :entity-type "task" :qid "showevidence"})
+
+  )


fix invalid aget use - fixes #17

fix invalid aget use - fixes #17

--- src/jx/reporter/karma.cljs
+++ src/jx/reporter/karma.cljs
@@ -2,7 +2,8 @@
   (:require [cljs.test]
             [clojure.data]
             [fipp.clojure]
-            [clojure.string :as s])
+            [clojure.string :as s]
+            [goog.object :as o])
   (:require-macros [jx.reporter.karma :as karma]))

 (def karma (volatile! nil))
@@ -18,7 +19,7 @@
     (.result @karma (clj->js m))))

 (defn- coverage-result []
-  #js {"coverage" (aget js/window "__coverage__")})
+  #js {"coverage" (o/get js/window "__coverage__")})

 (defn- karma-complete! []
   (when (karma?)


Style changes

Style changes

--- test/caesium/byte_bufs_test.clj
+++ test/caesium/byte_bufs_test.clj
@@ -14,24 +14,27 @@

 (defspec buflen-spec
   1000
-  (prop'/for-all [n gen/pos-int
-                  g (gen/elements ways-of-getting-a-buf-of-len-n)]
-                 (= n (bb/buflen (g n)))))
+  (prop'/for-all
+   [n gen/pos-int
+    g (gen/elements ways-of-getting-a-buf-of-len-n)]
+   (= n (bb/buflen (g n)))))

 (defspec slice-buflen-spec
   1000
-  (prop'/for-all [n gen/pos-int
-                  start (gen/choose 0 n)
-                  end (gen/choose start n)
-                  g (gen/elements ways-of-getting-a-buf-of-len-n)]
-                 (= n (bb/buflen (g n)))))
+  (prop'/for-all
+   [n gen/pos-int
+    start (gen/choose 0 n)
+    end (gen/choose start n)
+    g (gen/elements ways-of-getting-a-buf-of-len-n)]
+   (= n (bb/buflen (g n)))))

 (defspec wrapped-array-buflen-spec
   1000
-  (prop'/for-all [n gen/pos-int
-                  start (gen/choose 0 n)
-                  slicelen (gen/choose 0 (- n start))]
-                 (= slicelen
-                    (-> (byte-array n)
-                        (ByteBuffer/wrap start slicelen)
-                        (bb/buflen)))))
+  (prop'/for-all
+   [n gen/pos-int
+    start (gen/choose 0 n)
+    slicelen (gen/choose 0 (- n start))]
+   (= slicelen
+      (-> (byte-array n)
+          (ByteBuffer/wrap start slicelen)
+          (bb/buflen)))))


add test placeholders

add test placeholders

--- test/clj_money/trading_test.clj
+++ test/clj_money/trading_test.clj
@@ -71,6 +71,27 @@
         "The lot transaction is valud")
     (is (= "Purchase 100 shares of APPL at 10.000" (-> result :transaction :description)) "The transaction description describes the purchase")))

+(deftest purchase-requires-a-commodity-id
+  (is false "need to write the test"))
+
+(deftest purchase-requires-an-account-id
+  (is false "need to write the test"))
+
+(deftest account-id-must-reference-a-commodities-account
+  (is false "need to write the test"))
+
+(deftest purchase-requires-a-trade-date
+  (is false "need to write the test"))
+
+(deftest purchase-trade-date-can-be-a-date-string
+  (is false "need to write the test"))
+
+(deftest purchase-requires-a-number-of-shares
+  (is false "need to write the test"))
+
+(deftest purchase-requires-a-value
+  (is false "need to write the test"))
+
 (deftest a-purchase-creates-a-lot-record
   (let [context (serialization/realize storage-spec purchase-context)
         ira (-> context :accounts first)
@@ -201,6 +222,33 @@
         "The result contains the transaction record")
     (is (empty? (-> result :transaction validation/error-messages))
         "The transaction is valid")))
+
+(deftest sales-requires-an-account-id
+  (is false "need to write the test"))
+
+(deftest sale-account-id-must-reference-a-commodities-account
+  (is false "need to write the test"))
+
+(deftest sales-requires-a-commodity-id
+  (is false "need to write the test"))
+
+(deftest sales-requires-a-trade-date
+  (is false "need to write the test"))
+
+(deftest sale-trade-date-can-be-a-date-string
+  (is false "need to write the test"))
+
+(deftest sales-requires-a-number-of-shares
+  (is false "need to write the test"))
+
+(deftest sales-requires-a-value
+  (is false "need to write the test"))
+
+(deftest sales-requires-a-capital-gains-account-id
+  (is false "need to write the test"))
+
+(deftest sales-requires-a-capital-loss-account-id
+  (is false "need to write the test"))

 (deftest selling-a-commodity-for-a-profit-increases-the-balance-of-the-account
   (let [context (serialization/realize storage-spec purchase-context)
@@ -331,7 +379,5 @@

 ; Selling a commodity updates a lot record (FILO updates the most recent, FIFO updates the oldest)
 ; Selling a commodity creates a transaction record
-; Selling a commodity for a profit credits the capital gains account
 ; Selling a commodity for a loss debits the capital gains account
 ; A commodity transaction can have a fee
-; input must be valid


Add tests for marked edges and crossings

--- test/cljs/fatlip/core_test.cljs
+++ test/cljs/fatlip/core_test.cljs
@@ -17,9 +17,8 @@
                {:duration 10
                 :groups [{:characters #{:e :f :x}}]}]
         graph (f/make-sparse-graph input)
-        ordered-graph (get (f/order-graph graph) 19)
-        ;; _ (println (:succs graph))
-        ]
+        orderings (f/order-graph graph)
+        ordered-graph (get orderings 0)]
     (is (= (count (:layers graph)) (count (:layers ordered-graph)) 4) "Number of layers")
     (is (= (count (-> graph :layers (get 0) :nodes))
            (count (-> ordered-graph :layers (get 0) :nodes))
@@ -44,4 +43,6 @@
            (count (mapcat (fn [[_ es]] es) (:preds graph)))
            14)
         "Number of edges")
+    (is (= (count (:marked ordered-graph)) 1) "Number of marked edges")
+    (is (= (:crossings ordered-graph) 5) "Number of crossings")
   ))


Decomplect slide into slide-direction and slide-tile

--- src/tile_game/board.clj
+++ src/tile_game/board.clj
@@ -61,20 +61,25 @@
       coords
       start)))

-(defn slide [board arg]
-  (let [tile (if (contains? dir-delta arg)
-               (coords->tile board
-                             (coord-add board
-                                        (tile->coords board 0)
-                                        (dir-delta arg)))
-               arg)
-        empty-pos (tile->index board 0)
+(defn slide-tile [board tile]
+  (let [empty-pos (tile->index board 0)
         pos (tile->index board tile)]
     (if (adjacent? board 0 tile)
       (assoc board
         empty-pos tile
         pos 0)
       board)))
+
+(defn slide-direction [board direction]
+  (->> (dir-delta direction)
+       (coord-add board (tile->coords board 0))
+       (coords->tile board)
+       (slide-tile board)))
+
+(defn slide [board arg]
+  (if (contains? dir-delta arg)
+    (slide-direction board arg)
+    (slide-tile board arg)))

 (defn dijkstra-map [dmap coords seen cost]
   (if (empty? (set/difference coords seen))
@@ -120,7 +125,7 @@
                                                  (conj (set avoid) tile))]
                                (concat zero-path (list tile))))]
             (recur (concat path moves)
-                   (reduce slide board moves))))))))
+                   (reduce slide-tile board moves))))))))

 (defn solved-tiles [board]
   (let [solution (create-board (dimension board))]
@@ -142,7 +147,7 @@
   (let [path (move-to board tile goal solved)]
     (if (empty? more)
       path
-      (concat path (apply move-sequence (reduce slide board path) more)))))
+      (concat path (apply move-sequence (reduce slide-tile board path) more)))))

 (defn solve-tile [board tile]
   (let [solved (set (solved-tiles board))


Just thread the command channel to allow propagation

--- src/tile_game/grid.cljs
+++ src/tile_game/grid.cljs
@@ -32,16 +32,16 @@
             :value size :min 2 :max 8
             :on-change (fn [e] (swap! app-state assoc :size (.-target.value e)))}]])

-(defn render-tile [[x y] tile]
+(defn render-tile [[x y] tile command]
   (if-not (zero? tile)
     (let [fill-color (nth colors tile)]
-      [:g {:key (str "tile-" tile) :on-click #(slide! tile)}
+      [:g {:key (str "tile-" tile) :on-click #(async/put! command tile)}
        [:rect {:x (+ x 0.05) :y (+ y 0.05) :width 0.9 :height 0.9 :fill fill-color}]
        [:text {:x (+ 0.5 x) :y (+ 0.65 y)
                :font-family "Verdana" :font-size 0.4 :text-anchor "middle"}
         (str tile)]])))

-(defn tile-grid [run-solver]
+(defn tile-grid [command]
   (let [{:keys [board size analysis-mode]} @app-state
         dim (b/dimension board)]
     [:center
@@ -49,7 +49,7 @@
      [:svg {:view-box (str "0 0 " dim " " dim) :width 800 :height 800}
       (for [x (range dim) y (range dim)]
         (let [tile (nth board (+ (* y dim) x))]
-          (render-tile [x y] tile)))]
+          (render-tile [x y] tile command)))]
      [:h4 (if (b/solved? board) "Solved!" "Slide tiles with arrow keys or clicking on tile")]
      (board-size-slider size)
      [:div
@@ -62,7 +62,7 @@
           "Solved!"
           [:div
            (str "Suggested Moves: " (b/solve-next board))
-           [:div [:button {:on-click run-solver} "Run solver!"]]]))]
+           [:div [:button {:on-click #(async/put! command :solve)} "Run solver!"]]]))]
      [:p
       "© 2017 Charles L.G. Comstock "
       [:a {:href "https://github.com/dgtized/tile-game"} "(github)"]]]))
@@ -90,7 +90,7 @@
           (slide! key))
         (recur new-cancel)))
     (recur cancel))
-  (fn [] (tile-grid #(async/put! command :solve))))
+  (fn [] (tile-grid command)))

 (def codename
   {37 :left


In tests, http server is stopped in a (finally)

--- test/ctia/test_helpers/core.clj
+++ test/ctia/test_helpers/core.clj
@@ -79,11 +79,13 @@
   ;; This starts the server on a random port, once for each
   ;; (test), which _might_ briefly use up a lot of ports
   (with-properties ["ctia.http.port" (available-port)]
-    (main/start-ctia :join? false
-                     :silent? true)
-    (test)
-    ;; explicitly stop the http-server
-    (http-server/stop!)))
+    (try
+      (main/start-ctia :join? false
+                       :silent? true)
+      (test)
+      (finally
+        ;; explicitly stop the http-server
+        (http-server/stop!)))))

 (defn fixture-schema-validation [f]
   (schema/with-fn-validation


Tidied view test namespace

Tidied view test namespace

--- test/lonelyplanet/view_test.clj
+++ test/lonelyplanet/view_test.clj
@@ -1,15 +1,7 @@
 (ns lonelyplanet.view-test
   (:require [clojure.test :refer :all]
             [lonelyplanet.view :refer :all]
-
-            [net.cgrand.enlive-html :refer :all]
-            [clojure.zip :as z]))
-
-;(def sa-content (assoc (second (:content (gen-parser (gen-reader "resources/test" "destinations.xml"))))
-;                  :meta {:placename "South Africa"
-;                         :place-id "355611"
-;                         :route '("355611" "355064" nil nil)}))
-
+            [net.cgrand.enlive-html :refer :all]))

 (defn lv
   "Quick utility function to create html pages from destination data, saving


Update how we extract the content from the body

Pull the text/html part b/c that matches what we were testing before
Update body counts to reflect reality

--- test/runbld/test/email_test.clj
+++ test/runbld/test/email_test.clj
@@ -41,6 +41,12 @@
   (is (= "foo@q***.dom"
          (email/obfuscate-addr "foo@bar.quux.dom"))))

+(defn find-content [body]
+  (:content (some #(and (map? %)
+                        (.contains (:type %) "text/html")
+                        %)
+                  body)))
+
 (deftest attached
   (testing "failures present"
     (let [email (atom [])]
@@ -61,10 +67,13 @@
             (is (= 1 (:exit-code res)))
             (is (= 1 (-> build-doc :process :exit-code)))
             (is (= 2 (count (store/get-failures opts (:id build-doc)))))
-            (is (.contains (-> @email :body first :content)
-                           "com.example.AppTest testBad")
-                (with-out-str
-                  (clojure.pprint/pprint @email)))))))))
+            (let [body (:body @email)
+                  content (find-content body)]
+              (when (is content body)
+                (is (.contains content
+                               "com.example.AppTest testBad")
+                    (with-out-str
+                      (clojure.pprint/pprint @email)))))))))))

 (deftest log
   (testing "log present"
@@ -87,9 +96,12 @@
                          "test/fail-gradle-no-task.bat"
                          "test/fail-gradle-no-task.bash"))))]
               (is (= 1 (-> build-doc :process :exit-code)))
-              (is (.contains (-> @email :body first :content)
-                             "Cannot expand ZIP")
-                  (-> @email :body first :content))))
+              (let [body (:body @email)
+                    content (find-content body)]
+                (when (is content body)
+                  (is (.contains content "Cannot expand ZIP")))
+                (is (= 3 (count body))
+                    (pr-str @email)))))
           (testing "with gradle task"
             (let [out (java.io.StringWriter.)
                   [opts res build-doc]
@@ -104,8 +116,9 @@
                          "test/fail-gradle-with-task.bat"
                          "test/fail-gradle-with-task.bash"))))]
               (is (= 1 (-> build-doc :process :exit-code)))
-              (is (.contains (-> @email :body first :content)
-                             ":core:integTest")
-                  (-> @email :body first :content))
-              (is (= 2 (count (:body @email)))
-                  (pr-str @email)))))))))
+              (let [body (:body @email)
+                    content (find-content body)]
+                (when (is content body)
+                  (is (.contains content ":core:integTest")))
+                (is (= 4 (count body))
+                    (pr-str @email))))))))))


s/(= false/(false?/

s/(= false/(false?/

--- test/simple_check/core_test.clj
+++ test/simple_check/core_test.clj
@@ -37,7 +37,7 @@

 (deftest bad-reverse-test
   (testing "bad reverse implementation fails"
-           (is (= false
+           (is (false?
                   (let [g (sc/gen-int 100)
                         v (sc/gen-vec g 100)]
                     (:result (sc/quick-check 100 #(= (reverse %) %) v)))))))
@@ -51,7 +51,7 @@

 (deftest bad-remove
   (testing "foo"
-           (is (= false
+           (is (false?
                   (let [g (sc/gen-int 100)
                         v (sc/gen-vec g 100)]
                     (:result (sc/quick-check 100 first-is-gone v)))))))


(maint) Add codedir to list of Puppet settings

--- src/clj/puppetlabs/services/config/puppet_server_config_core.clj
+++ src/clj/puppetlabs/services/config/puppet_server_config_core.clj
@@ -27,6 +27,7 @@
     :certdir
     :certname
     :cert-inventory
+    :codedir ; This is not actually needed in Puppet Server, but it's needed in PE (file sync)
     :csrdir
     :csr-attributes
     :dns-alt-names


Parse subtitles to sentences

Parse subtitles to sentences

--- src/teach_friends/core.clj
+++ src/teach_friends/core.clj
@@ -55,9 +55,48 @@

 (defn lexer [] )

+(def time-regex #"(\d{2}:\d{2}:\d{2},\d{3}) --> (\d{2}:\d{2}:\d{2},\d{3})[\r\n]([^\r]+)[\r\n]([^\r]+)")
+
+(defn time-to-ms [time]
+  (let [parts (re-seq #"\d+" time)]
+    (+
+      (* (Integer. (nth parts 0)) 3600000)
+      (* (Integer. (nth parts 1)) 60000)
+      (* (Integer. (nth parts 2)) 1000)
+         (Integer. (nth parts 3)))))
+
+(defn parse-sentence [number from to sentence]
+  {:number number
+   :from from
+   :to to
+   :sentence sentence})
+
+(defn sentence? [sentence]
+  (let [last-three-chars (subs (string/reverse sentence) 0 3)
+        last-char (subs last-three-chars 0 1)]
+    (if (or (= last-char "!") (= last-char "?"))
+      true
+      (if (not (= last-char "."))
+        false
+        (if (= last-three-chars "...")
+          false
+          true)))))
+
+(defn parse-time-block [acc [_ from to first-sentence second-sentence]]
+  (let [acc-count (count acc)]
+    (if (string/blank? second-sentence)
+      (conj acc (parse-sentence (+ acc-count 1) (time-to-ms from) (time-to-ms to) first-sentence))
+      (if (sentence? first-sentence)
+        (-> (conj acc (parse-sentence (+ acc-count 1) (time-to-ms from) (time-to-ms to) first-sentence))
+            (conj (parse-sentence (+ acc-count 2) (time-to-ms from) (time-to-ms to) second-sentence)))
+        (conj acc (parse-sentence (+ acc-count 1) (time-to-ms from) (time-to-ms to) (str first-sentence " " second-sentence)))))))
+
 (defn -main
   "I don't do a whole lot ... yet."
   [& args]
-  (println (make-search-tree (get-stopwords))))
+  ;(println (string/split (slurp "resources/Friends.S02E05.srt") time-regex)))
+  ;(println (->> (re-seq time-regex (slurp "resources/Friends.S02E05.srt")) (take 4))))
+  (println (->> (re-seq time-regex (slurp "resources/Friends.S02E05.srt")) (take 5) (reduce parse-time-block []))))
+  ;(println (make-search-tree (get-stopwords))))
   ;(println (string/join "\n" (get-all-words-from-srt (get-srt) (get-stopwords)))))
   ;(println (set/intersection (set (get-stopwords)) (get-all-words-from-srt (get-srt) (get-stopwords)))))


....redesigning

....redesigning

--- src/conexp/contrib/gui/editors/context_editor/context_editor.clj
+++ src/conexp/contrib/gui/editors/context_editor/context_editor.clj
@@ -139,7 +139,28 @@
        keep-both-img (get-image-icon-or-string "context-editor/keep-both.png" "8<")
        cut-attribute-img (get-image-icon-or-string "context-editor/cut-attribute.png" "-A")
        cut-object-img (get-image-icon-or-string "context-editor/cut-object.png" "-O")
-       cut-both-img (get-image-icon-or-string "context-editor/cut-both.png" "-OA")]
+       cut-both-img (get-image-icon-or-string "context-editor/cut-both.png" "-OA")
+       clarify-attribute-img (get-image-icon-or-string "context-editor/clarify-attribute.png"
+                                "cA")
+       clarify-object-img (get-image-icon-or-string "context-editor/clarify-object.png" "cO")
+       clarify-both-img (get-image-icon-or-string "context-editor/clarify-both.png" "cOA")
+       reduce-attribute-img (get-image-icon-or-string "context-editor/reduce-attribute.png"
+                                "rA")
+       reduce-object-img (get-image-icon-or-string "context-editor/reduce-object.png" "rO")
+       reduce-both-img (get-image-icon-or-string "context-editor/reduce-both.png" "rOA")
+       transitiy-closure-img (get-image-icon-or-string "context-editor/transitive-closure.png"
+                               "trans")
+       dual-context-img (get-image-icon-or-string "context-editor/dual-context.png" "dual")
+       inverse-context-img (get-image-icon-or-string "context-editor/inverse-context.png" "inv")
+       sum-img (get-image-icon-or-string "context-editor/sum.png" "sum")
+       product-img (get-image-icon-or-string "context-editor/product.png" "prod")
+       semi-product-img (get-image-icon-or-string "context-editor/semi-product.png" "semi")
+       xia-product-img (get-image-icon-or-string "context-editor/xia-product.png" "Xia")
+       union-img (get-image-icon-or-string "context-editor/union.png" "union")
+       intersection-img (get-image-icon-or-string "context-editor/intersection.png" "inter")
+       composition-img (get-image-icon-or-string "context-editor/composition.png" "comp")
+       apposition-img (get-image-icon-or-string "context-editor/appositon.png" "ap")
+       subposition-img (get-image-icon-or-string "context-editor/subpositon.png" "sub")]

   (defn get-current-second-operand-context
@@ -201,7 +222,6 @@
                            :tip  "Use a copy of this context as second operand",
                            :no-return #(reset! second-operand (get-context (get-ectx %))) }
                         )
-        (add-separator)
         (add-button-box {:name add-attribute-img,
                          :tip "Adds a new attribute column to the context",
                          :f add-new-attribute}
@@ -228,18 +248,36 @@
                         {:name cut-both-img,
                          :tip "Remove all selected rows and columns from the context",
                          :f cut-objects-attributes})
-        (add-button- "Clarify attributes" (cc-1 clarify-attributes))
-        (add-button- "Clarify objects"    (cc-1 clarify-objects))
-        (add-button- "Clarify context"    (cc-1 clarify-context))
-        (add-separator)
-        (add-button- "Reduce attributes"  (cc-1 reduce-context-attributes))
-        (add-button- "Reduce objects"     (cc-1 reduce-context-objects))
-        (add-button- "Reduce context"     (cc-1 reduce-context))
-        (add-separator)
-        (add-button- "Transitive closure" (cc-1 context-transitive-closure))
-        (add-separator)
-        (add-button- "Dual context"    (cc-1 dual-context)) ;todo: keep order!
-        (add-button- "Inverse context" (cc-1 invert-context))
+        (add-button-box {:name clarify-attribute-img,
+                         :tip "Clarify the attribute columns of the context",
+                         :f (cc-1 clarify-attributes)}
+                        {:name clarify-object-img,
+                         :tip "Clarify the object rows of the context",
+                         :f (cc-1 clarify-objects)}
+                        {:name clarify-both-img,
+                         :tip "Clarify both objects and attributes of the context",
+                         :f (cc-1 clarify-context)}
+                        {:spacer 3}
+                        {:name reduce-attribute-img,
+                         :tip "Reduce the attribute columns of the context",
+                         :f (cc-1 reduce-context-attributes)}
+                        {:name reduce-object-img,
+                         :tip "Reduce the object rows of the context",
+                         :f (cc-1 reduce-context-objects)}
+                        {:name reduce-both-img,
+                         :tip "Reduce both objects and attributes of the context",
+                         :f (cc-1 reduce-context)})
+        (add-button-box {:name transitiy-closure-img,
+                         :tip "Apply transitive closure to the context",
+                         :f (cc-1 context-transitive-closure)}
+                        {:spacer 3}
+                        {:name dual-context-img,
+                         :tip "Flip objects and attributes",
+                         :f (cc-1 dual-context)}
+                        {:name inverse-context-img,
+                         :tip "Flip all crosses",
+                         :f (cc-1 invert-context)})
+
         (add-separator)
         (add-button- "Context sum"          (cc-2 context-sum))
         (add-button- "Context product"      (cc-2 context-product))


Add database url to loading schemas logs

--- src/yetibot/core/db.clj
+++ src/yetibot/core/db.clj
@@ -18,7 +18,7 @@
 (defn start [& [opts]]
   (if (conf-valid? (get-config :yetibot :db))
     (do
-      (info "☐ Loading Datomic schemas")
+      (info "☐ Loading Datomic schemas at" (:datomic-url (get-config :yetibot :db)))
       (dc/start (merge opts {:uri (:datomic-url (get-config :yetibot :db))
                              :schemas (filter identity (schemas))}))
       (info "☑ Datomic connected"))


bump development version

bump development version

--- synapse-lib/project.clj
+++ synapse-lib/project.clj
@@ -1,4 +1,4 @@
-(defproject com.brunobonacci/synapse "0.3.1"
+(defproject com.brunobonacci/synapse "0.4.0-SNAPSHOT"

   :description "Smart container linking system for Docker, Kubernetes et al."

@@ -8,7 +8,7 @@
             :url "http://www.apache.org/licenses/LICENSE-2.0"}

   :dependencies [[org.clojure/clojure "1.7.0"]
-                 [com.brunobonacci/synapse-core "0.3.0"]
+                 [com.brunobonacci/synapse-core "0.4.0-SNAPSHOT"]
                  ]

   :profiles {:dev {:dependencies [[midje "1.6.3"]]


increase # of tests for roundtrip-np-grammar and add comment

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -77,8 +77,15 @@
 (deftest forbid-mispelling
  (is (empty? (parse (fo "la donna difficila") np-grammar))))

+;; <roundtrip parsing tests>
+;; these tests will not pass if you
+;; don't have enough linguistic material
+;; (grammar + lexicon) to generate
+;; enough 'do-this-many' sentences to test.
+;; The 'do-this-many' is controlled by each
+;; deftest's 'do-this-many' below.
 (deftest roundtrip-np-grammar
-  (let [do-this-many 20
+  (let [do-this-many 100
         expressions (take do-this-many
                            (generate-all {:synsem {:sem {:spec {:def :top}
                                                          :mod {:pred :top}


+TODO

+TODO

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -24,6 +24,8 @@
 (write-lexicon "it" (grammar/compile-lexicon))
 (def model @@(get models :it))

+;; TODO: consider removing special-purpose grammars like grammar/np-grammar
+;; and just use model instead.
 (def np-grammar (delay (grammar/np-grammar)))

 (defmacro deftest [test-name & arguments]


whitespace

whitespace

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -273,8 +273,8 @@
         ;; Change the above generic noun-phrase spec to something more specific
         ;; if this test fails and you want to investigate why:
         ;; 1. To prevent adjectives, use: [:synsem :sem :mod]=[].
-        ;; 2. Possible values of [:synsem :sem :spec :def] are: {:def, :indef, :partitivo, possessive}
-
+        ;; 2. Possible values of [:synsem :sem :spec :def] are:
+        ;;    {:def, :indef, :partitivo, possessive}.
         expressions (take do-this-many
                           (repeatedly #(italiano/generate
                                         spec @np-grammar)))]


Add a better error message for storage types that expect a map with keywords

--- pigpen-core/src/main/clojure/pigpen/runtime.clj
+++ pigpen-core/src/main/clojure/pigpen/runtime.clj
@@ -122,6 +122,9 @@
   [fields]
   (fn [rf]
     (fn [result [input]]
+      (when-not (map? input)
+        (throw (ex-info "Expected map with keyword keys."
+                        {:input input})))
       (rf result (map input fields)))))

 (defn indexed-field-selector->bind


Got the status metrics working

Got the status metrics working

--- 2-collectors/clojure-collector/src/snowplow/clojure_collector.clj
+++ 2-collectors/clojure-collector/src/snowplow/clojure_collector.clj
@@ -42,6 +42,7 @@
  (-> routes
    (wrap-cookies)
    (wrap-reload '(snowplow.clojure-collector responses)) ; TODO: disable this in production
+   (#(expose-metrics-as-json % "/status"))
    (instrument)))

 (def start-server


Added correct ranges.

Added correct ranges.

--- src/main/cljc/x124_analyze_reversi/mbastian.cljc
+++ src/main/cljc/x124_analyze_reversi/mbastian.cljc
@@ -14,7 +14,7 @@
 (defn analyze [board color]
   (into {}
         (let [directions [[1 0] [1 1] [0 1] [-1 1] [-1 0] [-1 -1] [0 -1] [1 -1]]]
-          (for [i (range 4) j (range 4) d directions
+          (for [i (range (count board)) j (range (count (board i))) d directions
                 :let [b (boardwalk board color [i j] d)]
                 :when (not-empty b)]
             [[i j] (set b)]))))


Disable testing with exemplar files until we know how to update them

--- test/transit/verify.clj
+++ test/transit/verify.clj
@@ -234,7 +234,7 @@
   [proc encoding opts]
   (let [transit-exemplars (exemplar-transit encoding)]
     (filter #((:pred %) proc encoding opts)
-            [{:pred (constantly true)
+            [#_{:pred (constantly true)
               :desc "exemplar file"
               :input transit-exemplars
               :test-name :exemplar-file


Source locations.

Source locations.

--- EkekoAspectJ/src/damp/ekeko/aspectj/weaverworld.clj
+++ EkekoAspectJ/src/damp/ekeko/aspectj/weaverworld.clj
@@ -366,8 +366,31 @@

-
+;; SourceLocation
+
+(defn
+  sourcelocation-filename-startline-endline-column-offset
+  "Non-relational. Unifies ?filename with the name of the file for the given ?sourcelocation,
+   ?startline with the line at which it starts, ?endline with the line at which it ends,
+   ?column with the column at which it starts, and ?offset with its offset."
+  [?sourcelocation ?filename ?startline ?endline ?column ?offset]
+  (all
+    (equals ?filename (.getSourceFileName ?sourcelocation))
+    (equals ?startline (.getLine ?sourcelocation))
+    (equals ?endline (.getEndLine ?sourcelocation))
+    (equals ?column (.getColumn ?sourcelocation))
+    (equals ?offset (.getOffset ?sourcelocation))))
+
 ;; Pointcuts
+
+(defn
+  advice-sourcelocation
+  "Relation between an advice and its location in the source code (an ISourceLocation)."
+  [?advice ?location]
+  (all
+    (advice ?advice)
+    (equals ?location (.getSourceLocation ?advice))))
+

 (defn
   advice-pointcut
@@ -683,8 +706,6 @@

 ;;todo:
-;;super-type info
-;;location info
 ;;take into account kinds of advice
 ;;implicit precedence, precedence assumption
 ;;inter-aspect-shadow: done (certain?)


add some untested code

add some untested code

--- dada-swt/src/main/clojure/org/dada/swt/nattable.clj
+++ dada-swt/src/main/clojure/org/dada/swt/nattable.clj
@@ -27,6 +27,57 @@

   [org.dada.core Metadata Model]
   ))
+
+;;--------------------------------------------------------------------------------
+;; hopefully this code will bridge between a DADA View and a GL EventList - untested...
+;;--------------------------------------------------------------------------------
+;; (defn #^EventList make-dada-gl-event-list [#^Model model]
+;;   (let [extant (ArrayList.)
+;; 	extinct (ArrayList.)
+;; 	publisher (ListEventAssembler/createListEventPublisher)
+;; 	read-write-lock (.createReadWriteLock (J2SE50LockFactory.))
+;; 	list-event-assenbler (atom nil)
+;; 	pk-fn (.getPrimaryGetter (.getMetadata model))
+;; 	pk-comparator (proxy [Comparable][]
+;; 			     (#^int compareTo [#^Comparable lhs #^Comparable rhs] (.compareTo (pk-fn lhs)(pk-fn rhs)))
+;; 			     (#^boolean equals [lhs rhs] (.equals  (pk-fn lhs)(pk-fn rhs))))
+;; 	insert (fn [#^Update update]
+;; 		   (let [datum (.getNewValue update)
+;; 			 index (- (Math/abs (Collections/binarySearch extant datum pk-comparator)) 1)]
+;; 		     (.insert extant index datum)
+;; 		     (.elementInserted list-event-assenbler index datum)))
+;; 	alter (fn [#^Update update]
+;; 		  (let [datum (.getNewValue update)
+;; 			index (Collections/binarySearch extant datum pk-comparator)
+;; 			old-value (.get extant index)]
+;; 		    (.set extant index datum)
+;; 		    (.elementUpdated list-event-assenbler index datum)))
+;; 	delete (fn [#^Update update]
+;; 		   (let [datum (.getOldValue update)
+;; 			 index (Collections/binarySearch extant datum pk-comparator)
+;; 			 old-value (.remove extant index)]
+;; 		     (.elementDeleted list-event-assenbler index old-value datum)))
+;; 	event-list (proxy [EventList][]
+;; 			  ;; 1
+;; 			  (#^ListEventPublisher getPublisher [] publisher)
+;; 			  ;; 2
+;; 			  (#^ReadWriteLock getReadWriteLock [] read-write-lock)
+;; 			  ;; 3
+;; 			  (#^int size [] (.size extant))
+;; 			  ;; 4
+;; 			  (#^void addListEventListener [#^ListEventListener listener] (.addListEventListener @list-event-assenbler listener))
+;; 			  ;; 5
+;; 			  (#^Objectget [#^int index] (.get extant index)))
+;; 	view (proxy [View][]
+;; 		    (#^void update [#^Collection indertions  #^Collection alterations #^Collection deletions]
+;; 			    (doall (map insert insertions))
+;; 			    (doall (map alter alterations))
+;; 			    (doall (map delete deletions))))]
+;;     (swap! list-event-assenbler (fn [old new] new) (ListEventAssembler. event-list publisher))
+;;     (doall (map insert (.getExtant (.registerView model view))))
+;;     event-list))
+
+;; (def event-list (make-dada-gl-event-list my-model))

 ;;--------------------------------------------------------------------------------
 ;; see http://nattable.org/drupal/docs/basicgrid


Prevent warning

Prevent warning

--- integration-tests/src/test/clojure/immutant/integs/context_path.clj
+++ integration-tests/src/test/clojure/immutant/integs/context_path.clj
@@ -16,6 +16,7 @@
 ;; 02110-1301 USA, or see the FSF site: http://www.fsf.org.

 (ns immutant.integs.context-path
+  (:refer-clojure :exclude [get])
   (:use fntest.core
         clojure.test
         [slingshot.slingshot :only [try+]])


:lipstick: More usability improvements for dropdown component.

--- frontend/src/uxbox/main/ui/components/dropdown.cljs
+++ frontend/src/uxbox/main/ui/components/dropdown.cljs
@@ -12,19 +12,19 @@
   (let [children (gobj/get props "children")
         on-close (gobj/get props "on-close")

-        on-document-clicked
+        on-click
         (fn [event]
           (on-close))

-        on-document-keyup
+        on-keyup
         (fn [event]
           (when (= (.-keyCode event) 27) ; ESC
             (on-close)))

         on-mount
         (fn []
-          (let [lkey1 (events/listen js/document EventType.CLICK on-document-clicked)
-                lkey2 (events/listen js/document EventType.KEYUP on-document-keyup)]
+          (let [lkey1 (events/listen js/document EventType.CLICK on-click)
+                lkey2 (events/listen js/document EventType.KEYUP on-keyup)]
             #(do
                (events/unlistenByKey lkey1)
                (events/unlistenByKey lkey2))))]
@@ -34,6 +34,9 @@

 (mf/defrc dropdown
   [props]
+  (assert (fn? (gobj/get props "on-close")) "missing `on-close` prop")
+  (assert (boolean? (gobj/get props "show")) "missing `show` prop")
+
   (when (gobj/get props "show")
     [:div.dropdown
      (mf/element dropdown-container props)]))


Fixed doc comments in macros. Fixed in-tx-as and in-ro-tx-as macros - they now function.

--- lambdalf-lib/src/main/clojure/alfresco/transact.clj
+++ lambdalf-lib/src/main/clojure/alfresco/transact.clj
@@ -24,28 +24,30 @@
   []
   (.getTransactionService (c/alfresco-services)))

-(defmacro in-tx [& body]
+(defmacro in-tx
   "Runs the given forms within a read/write Alfresco transaction, automatically completing it (committing or rolling back), retrying and/or cleaning up as required. To force a rollback, simply throw an exception."
+  [& body]
   `(let [cb# (reify RetryingTransactionHelper$RetryingTransactionCallback
                (~'execute [~'this] ~@body))]
      (-> (transaction-service)
          (.getRetryingTransactionHelper)
          (.doInTransaction cb# false false))))  ; R/W transaction and does not require a new transaction

-(defmacro in-ro-tx [& body]
+(defmacro in-ro-tx
   "Runs the given forms within a read/only Alfresco transaction."
+  [& body]
   `(let [cb# (reify RetryingTransactionHelper$RetryingTransactionCallback
                (~'execute [~'this] ~@body))]
      (-> (transaction-service)
          (.getRetryingTransactionHelper)
          (.doInTransaction cb# true false))))  ; R/O transaction and does not require a new transaction

-; NOTE: THESE AREN'T EXPANDING PROPERLY!!
-; Need to read up more on how macros get expanded and when/where components within them get evaluated.
-(defmacro in-tx-as [user & body]
+(defmacro in-tx-as
   "Runs the given forms as the given user within a read/write Alfresco transaction."
-  `(a/run-as ~user (in-tx ~@body)))
+  [user & body]
+  `(alfresco.auth/run-as ~user (alfresco.transact/in-tx ~@body)))

-(defmacro in-ro-tx-as [user & body]
+(defmacro in-ro-tx-as
   "Runs the given forms as the given user within a read/only Alfresco transaction."
-  `(a/run-as ~user (in-ro-tx ~@body)))
+  [user & body]
+  `(alfresco.auth/run-as ~user (alfresco.transact/in-ro-tx ~@body)))


(TK-82) Added queue-max-size integration-style tests

This commit adds a couple of integration-style tests which attempt to
exercise the `queue-max-size` setting under sufficiently high request
load to show the effect of filling the queue on connection attempts.

--- test/clj/puppetlabs/trapperkeeper/services/webserver/jetty9_core_test.clj
+++ test/clj/puppetlabs/trapperkeeper/services/webserver/jetty9_core_test.clj
@@ -1,12 +1,16 @@
 (ns puppetlabs.trapperkeeper.services.webserver.jetty9-core-test
-  (:import (org.eclipse.jetty.server.handler ContextHandlerCollection))
+  (:import
+    (org.eclipse.jetty.server.handler ContextHandlerCollection)
+    (org.apache.http ConnectionClosedException)
+    (java.util.concurrent ExecutionException))
   (:require [clojure.test :refer :all]
             [clojure.java.jmx :as jmx]
             [ring.util.response :as rr]
-            [puppetlabs.http.client.sync :as http-client]
+            [puppetlabs.http.client.sync :as http-sync]
             [puppetlabs.trapperkeeper.services.webserver.jetty9-core :as jetty]
             [puppetlabs.trapperkeeper.testutils.webserver
-             :refer [with-test-webserver with-test-webserver-and-config]]))
+              :refer [with-test-webserver with-test-webserver-and-config]]
+            [puppetlabs.kitchensink.core :as ks]))

 (deftest handlers
   (testing "create-handlers should allow for handlers to be added"
@@ -22,7 +26,7 @@
 (defn validate-gzip-encoding-when-gzip-requested
   [body port]
   ;; The client/get function asks for compression by default
-  (let [resp (http-client/get (format "http://localhost:%d/" port))]
+  (let [resp (http-sync/get (format "http://localhost:%d/" port))]
     (is (= (slurp (resp :body)) body))
     (is (= (get-in resp [:orig-content-encoding]) "gzip")
         (format "Expected gzipped response, got this response: %s"
@@ -31,7 +35,7 @@
 (defn validate-no-gzip-encoding-when-gzip-not-requested
   [body port]
   ;; The client/get function asks for compression by default
-  (let [resp (http-client/get (format "http://localhost:%d/" port)
+  (let [resp (http-sync/get (format "http://localhost:%d/" port)
                               {:decompress-body false})]
     (is (= (slurp (resp :body)) body))
     ;; We should not receive a content-encoding header in the
@@ -43,7 +47,7 @@
 (defn validate-no-gzip-encoding-even-though-gzip-requested
   [body port]
   ;; The client/get function asks for compression by default
-  (let [resp (http-client/get (format "http://localhost:%d/" port))]
+  (let [resp (http-sync/get (format "http://localhost:%d/" port))]
     (is (= (slurp (resp :body)) body))
     ;; We should not receive a content-encoding header in the
     ;; uncompressed case
@@ -243,3 +247,56 @@
             "Unexpected initial capacity for queue")
         (is (= queue-min-size (.getMaxCapacity queue))
             "Unexpected max capacity for queue")))))
+
+(defn get-responses
+  [num-requests port]
+  (doall (for [_ (range num-requests)]
+           (future
+             (http-sync/get
+               (str "http://localhost:"
+                    port
+                    "/hello")
+               {:as :text})))))
+
+(deftest queue-max-size-tests
+  (testing "queue-max-size"
+    (let [response-body  "hello world"
+          app            (fn [_]
+                           (Thread/sleep 5000)
+                           (-> response-body
+                               (rr/response)
+                               (rr/status 200)
+                               (rr/content-type "text/plain")
+                               (rr/charset "UTF-8")))
+          ;; Jetty needs at least num-cpus entries (and likely a bit more) in
+          ;; the queue in order to boot up successfully.  Jetty does some
+          ;; priming of selector threads using the queue independently of
+          ;; any incoming requests, for example.
+          queue-max-size (* (ks/num-cpus) 2)
+          ;; For the fail case, need to generate some number of concurrent
+          ;; requests in excess of the size of the queue in order for the queue
+          ;; to be completely filled and for some requests to start being
+          ;; dropped
+          num-requests   (+ queue-max-size 30)]
+      (testing "of default (infinite) size doesn't lead to any request fails"
+        (with-test-webserver-and-config
+          app port {:shutdown-timeout-seconds 0}
+          (let [responses (get-responses num-requests port)]
+            (doseq [response responses]
+              (is (= 200 (:status @response))
+                  "Unsuccessful response status for one request")
+              (is (= response-body (:body @response))
+                  "Unsuccessful response body for one request")))))
+      (testing "of sufficiently low queue-max-size causes some requests to fail"
+        (with-test-webserver-and-config
+          app port {:queue-max-size queue-max-size
+                    :shutdown-timeout-seconds 0}
+          (let [responses (doall (get-responses num-requests port))]
+            (is (some #(try
+                        @%
+                        false
+                        (catch ExecutionException e
+                          (instance? ConnectionClosedException
+                                     (.. e getCause))))
+                      responses)
+                "Didn't encounter connection close for any requests")))))))


Starting “SOME”

Starting “SOME”

--- test/structural_typing/use/condensed_type_descriptions/f_ALL_variants.clj
+++ test/structural_typing/use/condensed_type_descriptions/f_ALL_variants.clj
@@ -72,10 +72,27 @@
     (type! :X {[:a ONLY] {:b even?}})
     (built-like :X {:a [{:b 2}]}) => {:a [{:b 2}]}
     (check-for-explanations :X {:a [{:b 1}]}) => (just (err:shouldbe [:a ONLY :b] "even?" 1))
-    (check-for-explanations :X {:a [{:b 1}]}) => (just (err:shouldbe [:a ONLY :b] "even?" 1))
     (check-for-explanations :X {:a [3 {:b 1}]}) => (just (err:only [3 {:b 1}]))
     (check-for-explanations :X {:a []}) => (just (err:only []))
     (check-for-explanations :X {:a 3}) => (just (err:notpath [:a ONLY :b] {:a 3}))))

+(future-fact "SOME"
+  (fact "describing the whole path"
+    (type! :X {[SOME] even?})
+    (built-like :X [2]) => [2]
+    (built-like :X [1 2]) => [1 2]
+    (check-for-explanations :X [1]) => (just (err:shouldbe [SOME] "even?" [1]))
+    (check-for-explanations :X []) => (just (err:shouldbe [SOME] "even?" []))
+    (check-for-explanations :X 3) => (just (err:notpath [SOME] 3)))
+
+  (fact "as part of a path"
+    (type! :X {[:a SOME] {:b even?}})
+    (built-like :X {:a [{:b 2}]}) => {:a [{:b 2}]}
+    (built-like :X {:a [{:b 1} {:b 2}]}) => {:a [{:b 1} {:b 2}]}
+    (check-for-explanations :X {:a [{:b 1}]}) => (just (err:shouldbe [:a SOME] "even?" [{:b 1}]))
+    (check-for-explanations :X {:a []}) => (just (err:shouldbe [:a SOME] "even?" []))
+    (check-for-explanations :X {:a 3}) => (just (err:notpath [:a SOME] 3))))
+
+
 (start-over!)


release bigquery 0.2.4

release bigquery 0.2.4

--- bigquery/project.clj
+++ bigquery/project.clj
@@ -1,4 +1,4 @@
-(defproject gclouj/bigquery "0.2.4-SNAPSHOT"
+(defproject gclouj/bigquery "0.2.4"
   :description "Google Cloud BigQuery"
   :url "https://github.com/pingles/gclouj"
   :license {:name "Eclipse Public License"


turns datagram into byte array

turns datagram into byte array

--- exercise3/src/de/haw/vs/networking/datagram.clj
+++ exercise3/src/de/haw/vs/networking/datagram.clj
@@ -43,8 +43,12 @@
      :slot            (nth datagram 25)
      :send-time       (bytes->timestamp (Arrays/copyOfRange datagram 26 34))}))

-(defn message->datagram [message]
+(defn- message->datagram-list [message]
   (concat [(station->byte (:station-class message))]
           (payload->bytes (str (:station-name message) (:payload-content message)))
           [(byte (:slot message))]
           (timestamp->bytes (:send-time message))))
+
+(defn message->datagram [message]
+  (let [datagram-list (message->datagram-list message)]
+    (byte-array (count datagram-list) datagram-list)))


cleanup

cleanup

--- src/clj/com/matthiasnehlsen/inspect/matcher.clj
+++ src/clj/com/matthiasnehlsen/inspect/matcher.clj
@@ -78,17 +78,12 @@
     (swap! stats assoc origin (inc (get @stats origin 0)))
     (doseq [uid (:any @uids)]
       (when (pos? (get-in @client-maps [uid origin] 0))
-        (let [html (puget/pprint-str (:payload msg) {:print-color true
-                                                     :color-markup :html-classes
-                                                     :map-coll-separator :line})
+        (let [html (puget/pprint-str (:payload msg)
+                                     {:print-color true :color-markup :html-classes :map-coll-separator :line})
               hicc-html (hicv/html->hiccup html)
               hicc-spans (rest (first (rest (first hicc-html))))
               hicc-w-linebreaks (map #(if (= % ",\n") [:br] %) hicc-spans)]
-          (prn hicc-w-linebreaks)
-          (puget/cprint msg)
-          (chsk-send! uid [:info/msg (assoc msg
-                                       :payload (with-out-str (pp/pprint (:payload msg)))
-                                       :hiccup hicc-w-linebreaks)]))
+          (chsk-send! uid [:info/msg (assoc msg :payload hicc-w-linebreaks)]))
         (swap! client-maps #(update-in % [uid origin] dec))
         (chsk-send! uid [:info/client-map (get-in @client-maps [uid])])))))


chart for time per book

chart for time per book

--- src/cljs/iwaswhere_web/ui/charts/pomodoros.cljs
+++ src/cljs/iwaswhere_web/ui/charts/pomodoros.cljs
@@ -67,6 +67,51 @@
        ^{:key (str idx)}
        [day-bars v local idx chart-h y-scale put-fn]))])

+;; TODO: either DRY up or rethink
+(defn day-bars-by-book
+  "Renders group with rects for all stories of the particular day."
+  [day-stats local idx chart-h y-scale put-fn]
+  (let [options (subscribe [:options])
+        books (reaction (:books @options))
+        stacked-reducer (fn [acc [k v]]
+                          (let [total (get acc :total 0)]
+                            (-> acc
+                                (assoc-in [:total] (+ total v))
+                                (assoc-in [:items k :v] v)
+                                (assoc-in [:items k :y] total))))]
+    (fn [day-stats local idx chart-h y-scale put-fn]
+      (let [mouse-enter-fn (cc/mouse-enter-fn local day-stats)
+            mouse-leave-fn (cc/mouse-leave-fn local day-stats)
+            books @books
+            time-by-book (sort-by #(str (first %)) (:time-by-book day-stats))
+            stacked (reduce stacked-reducer {} time-by-book)
+            time-by-book (reverse (sort-by #(str (first %)) (:items stacked)))]
+        [:g
+         {:on-mouse-enter mouse-enter-fn
+          :on-mouse-leave mouse-leave-fn}
+         (for [[book {:keys [y v]}] time-by-book]
+           (let [h (* y-scale v)
+                 y (- chart-h (+ h (* y-scale y)))
+                 book-name (or (:book-name (get books book)) "No book")]
+             ^{:key (str book)}
+             [:rect {:on-click (cc/open-day-fn v put-fn)
+                     :fill     (cc/item-color book-name)
+                     :x        (* 30 idx)
+                     :y        y
+                     :width    26
+                     :height   h}]))]))))
+
+(defn bars-by-book
+  "Renders chart with daily recorded times, split up by story."
+  [indexed local chart-h y-scale put-fn]
+  [:g
+   (for [[idx v] indexed]
+     (let [h (* y-scale (:total-time v))
+           mouse-enter-fn (cc/mouse-enter-fn local v)
+           mouse-leave-fn (cc/mouse-leave-fn local v)]
+       ^{:key (str idx)}
+       [day-bars-by-book v local idx chart-h y-scale put-fn]))])
+
 (defn time-by-stories-list
   "Render list of times spent on individual stories, plus the total."
   [day-stats]
@@ -115,6 +160,11 @@
           [:g
            [cc/chart-title "Time tracked"]
            [bars-by-story indexed-20 local chart-h 0.0045 put-fn]]]
+         [:svg
+          {:viewBox (str "0 0 600 " chart-h)}
+          [:g
+           [cc/chart-title "Time tracked"]
+           [bars-by-book indexed-20 local chart-h 0.0045 put-fn]]]
          (if-let [mouse-over (:mouse-over @local)]
            [time-by-stories-list mouse-over]
            [time-by-stories-list (second (last pomodoro-stats))])


goofed the last bit beacuse i changed the date format.

--- src/clojure/com/davidykay/helloclojure/main.clj
+++ src/clojure/com/davidykay/helloclojure/main.clj
@@ -1,17 +1,32 @@
 (ns com.davidykay.helloclojure.main
+  (:require [neko.log :as log])
   (:use [neko.activity :only [defactivity set-content-view!]]
         [neko.threading :only [on-ui]]
         [neko.ui :only [make-ui config]]
-        )
+        [clojure.string :only [join]])
   (:import (java.util Calendar)
+           (android.view View)
            (android.app Activity)
            (android.app DatePickerDialog DatePickerDialog$OnDateSetListener)
            (android.app DialogFragment)))

-(def listing (atom ""))
+(def listing (atom (sorted-map)))

 (declare ^android.widget.LinearLayout mylayout)
 (declare update-ui)
+
+(defn format-events [events]
+  (->> (map (fn [[location event]]
+              (format "%s - %s\n" location event))
+            events)
+       (join "                      ")))
+
+(defn format-listing [lst]
+  (->> (map (fn [[date events]]
+               (format "%s - %s" date (format-events events)))
+             lst)
+       join))
+

 (defn set-elmt [elmt s]
   (on-ui (config (elmt (.getTag mylayout)) :text s)))
@@ -20,10 +35,14 @@
   (str (.getText (elmt (.getTag mylayout)))))

 (defn add-event []
-  (swap! listing str
-     (apply format "%s - %s - %s\n" (map get-elmt [::date ::location ::name])))
-  (update-ui))
-
+  (let [date-key (try
+                   (read-string (get-elmt ::date))
+                   (catch RuntimeException e "Date string is empty!"))]
+    (log/d "add-event. date-key: " date-key)
+    (log/d "add-event. Current val of listing: " @listing)
+    (when (number? date-key)
+      (swap! listing update-in [date-key] (fnil conj []) [(get-elmt ::location) (get-elmt ::name)])
+      (update-ui))))

 (defn date-picker [activity]
   (proxy [DialogFragment DatePickerDialog$OnDateSetListener] []
@@ -35,10 +54,12 @@
         (DatePickerDialog. activity this year month day)))
      (onDateSet [view year month day]
        (set-elmt ::date
-         (format "%02d/%02d/%02d" year (inc month) day)))))
+         (format "%02d%02d%02d" year (inc month) day)))))
+         ;(format "%02d/%02d/%02d" year (inc month) day)))))

 (defn show-picker [activity dp]
   (. dp show (. activity getFragmentManager) "datePicker"))
+

 (defn main-layout [activity]
   [:linear-layout {:orientation :vertical,
@@ -55,15 +76,15 @@
               :on-click (fn [_] (show-picker activity
                                             (date-picker activity)))}]]
    [:button {:text "+ Event",
-             :on-click (fn [_] (add-event))}]
-   [:text-view {:text @listing,
+             :on-click (fn [_](add-event))}]
+   [:text-view {:text (format-listing @listing),
                 :id ::listing}]])

 (defn update-ui []
-  (set-elmt ::listing @listing)
+  (set-elmt ::listing (format-listing @listing))
   (set-elmt ::location "")
-  (set-elmt ::name ""))
-
+  (set-elmt ::name "")
+  (set-elmt ::date ""))

 (defactivity com.davidykay.helloclojure.MainActivity
   :key :main
@@ -73,5 +94,4 @@
     (on-ui
      (set-content-view! this
                         (main-layout this)))
-    (on-ui
-     (set-elmt ::listing @listing))))
+    (on-ui (set-elmt ::listing (format-listing @listing)))))


CMR-2755: Addressed review comments.

CMR-2755: Addressed review comments.

--- search-app/src/cmr/search/services/parameters/legacy_parameters.clj
+++ search-app/src/cmr/search/services/parameters/legacy_parameters.clj
@@ -122,7 +122,7 @@
         attribute-type (psa-pre-validation attributes)
         attr-maps (when (= :legacy-style attribute-type)
                     (if (vector? attributes)
-                      (vector (reduce checked-merge attributes))
+                      [(reduce checked-merge attributes)]
                       (vec (vals attributes))))
         psa (map attr-map->cmr-param attr-maps)]
     (if (seq psa)


fix token decoding in UI, fixes #99

fix token decoding in UI, fixes #99

--- priv/ui/src/cljs/holiday_ping_ui/helpers/token.cljs
+++ priv/ui/src/cljs/holiday_ping_ui/helpers/token.cljs
@@ -1,7 +1,8 @@
 (ns holiday-ping-ui.helpers.token
   (:require
    [clojure.string :as string]
-   [goog.crypt.base64 :as base64]))
+   [goog.crypt.base64 :as base64]
+   [goog.crypt :as crypt]))

 (defn decode
@@ -10,7 +11,8 @@
     (-> token
         (string/split #"\.")
         second
-        (base64/decodeString true)
+        base64/decodeStringToByteArray
+        crypt/utf8ByteArrayToString
         parse-json
         (js->clj :keywordize-keys true))))


test IObj

test IObj

--- src/main/clojure/clojure/tools/reader/reader_types.clj
+++ src/main/clojure/clojure/tools/reader/reader_types.clj
@@ -291,7 +291,7 @@
         new-frame (assoc-in @frame [:offset] (.length buffer))]
     (with-bindings {frame new-frame}
       (let [ret (f)]
-        (if (instance? clojure.lang.IMeta ret)
+        (if (instance? clojure.lang.IObj ret)
           (merge-meta ret {:source (peek-source-log frame)})
           ret)))))


fixed lein arity

fixed lein arity

--- main/src/dda/pallet/dda_managed_ide/infra/clojure.clj
+++ main/src/dda/pallet/dda_managed_ide/infra/clojure.clj
@@ -106,4 +106,4 @@
 (s/defn configure-user
   [facility config]
   (when (contains? config :clojure)
-    (configure-user-leiningen (-> config :clojure))))
+    (configure-user-leiningen facility (-> config :clojure))))


fix inspect blowing up on misbehaving types

datascript/DB pretends to be a record but (keys db) breaks.
Inspect runs into this since (map? db) is true and it tries to
sort the keys for display purposes which fails with in interal
exception since they (seq db) isn't a seq of MapEntry instances.

Don't know if this should be a considered a bug in Datascript but
it only surfaced because inspect calls (keys db) which is user
is unlikely to do. Since this throws the inspect just adds a
try/catch (which it should have had anyways) and treat the type
as unsupported instead.

fixes #858

--- src/main/shadow/remote/runtime/obj_support.cljc
+++ src/main/shadow/remote/runtime/obj_support.cljc
@@ -102,7 +102,7 @@
      (error-format ex)))

 (defn exception? [x]
-  #?(:clj  (instance? java.lang.Throwable x)
+  #?(:clj (instance? java.lang.Throwable x)
      :cljs (instance? js/Error x)))

 (defn attempt-to-sort [desc coll]
@@ -263,74 +263,78 @@
     ))

 (defn inspect-basic [{:keys [data] :as desc} obj opts]
-  (cond
-    (nil? data)
-    (assoc-in desc [:summary :data-type] :nil)
-
-    (string? data)
-    (-> desc
-        (update :summary merge {:data-type :string
-                                :length (count data)})
-        ;; FIXME: substring support?
-        (assoc-in [:handlers :get-value] (fn [msg] data)))
-
-    (boolean? data)
-    (-> desc
-        (assoc-in [:summary :data-type] :boolean)
-        (assoc-in [:handlers :get-value] (fn [msg] data)))
-
-    (number? data)
-    (-> desc
-        (assoc-in [:summary :data-type] :number)
-        (assoc-in [:handlers :get-value] (fn [msg] data)))
-
-    (keyword? data)
-    (-> desc
-        (assoc-in [:summary :data-type] :keyword)
-        (assoc-in [:handlers :get-value] (fn [msg] data)))
-
-    (symbol? data)
-    (-> desc
-        (assoc-in [:summary :data-type] :symbol)
-        (assoc-in [:handlers :get-value] (fn [msg] data)))
-
-    (map? data)
-    (-> desc
-        (update :summary merge {:data-type :map
-                                :entries (count data)})
-        (attempt-to-sort (keys data))
-        (browseable-kv))
-
-    (vector? data)
-    (-> desc
-        (update :summary merge {:data-type :vec
-                                :entries (count data)})
-        (browseable-vec))
-
-    (set? data)
-    (-> desc
-        (update :summary merge {:data-type :set
-                                :entries (count data)})
-        (attempt-to-sort data)
-        (browseable-seq))
-
-    (list? data)
-    (-> desc
-        (update :summary merge {:data-type :list
-                                :entries (count data)})
-        (assoc :view-order (vec data))
-        (browseable-seq))
-
-    ;; lazy seqs
-    (seq? data)
-    (-> desc
-        (update :summary merge {:data-type :lazy-seq})
-        (pageable-seq))
-
-    ;; FIXME: records?
-
-    :else
-    (assoc-in desc [:summary :data-type] :unsupported)))
+  (try
+    (cond
+      (nil? data)
+      (assoc-in desc [:summary :data-type] :nil)
+
+      (string? data)
+      (-> desc
+          (update :summary merge {:data-type :string
+                                  :length (count data)})
+          ;; FIXME: substring support?
+          (assoc-in [:handlers :get-value] (fn [msg] data)))
+
+      (boolean? data)
+      (-> desc
+          (assoc-in [:summary :data-type] :boolean)
+          (assoc-in [:handlers :get-value] (fn [msg] data)))
+
+      (number? data)
+      (-> desc
+          (assoc-in [:summary :data-type] :number)
+          (assoc-in [:handlers :get-value] (fn [msg] data)))
+
+      (keyword? data)
+      (-> desc
+          (assoc-in [:summary :data-type] :keyword)
+          (assoc-in [:handlers :get-value] (fn [msg] data)))
+
+      (symbol? data)
+      (-> desc
+          (assoc-in [:summary :data-type] :symbol)
+          (assoc-in [:handlers :get-value] (fn [msg] data)))
+
+      (map? data)
+      (-> desc
+          (update :summary merge {:data-type :map
+                                  :entries (count data)})
+          (attempt-to-sort (keys data))
+          (browseable-kv))
+
+      (vector? data)
+      (-> desc
+          (update :summary merge {:data-type :vec
+                                  :entries (count data)})
+          (browseable-vec))
+
+      (set? data)
+      (-> desc
+          (update :summary merge {:data-type :set
+                                  :entries (count data)})
+          (attempt-to-sort data)
+          (browseable-seq))
+
+      (list? data)
+      (-> desc
+          (update :summary merge {:data-type :list
+                                  :entries (count data)})
+          (assoc :view-order (vec data))
+          (browseable-seq))
+
+      ;; lazy seqs
+      (seq? data)
+      (-> desc
+          (update :summary merge {:data-type :lazy-seq})
+          (pageable-seq))
+
+      ;; FIXME: records?
+
+      :else
+      (assoc-in desc [:summary :data-type] :unsupported))
+
+    (catch #?(:cljs :default :clj Exception) e
+      (assoc-in desc [:summary :data-type] :unsupported))))

 (defn inspect-type-info [desc obj opts]
   (assoc-in desc [:summary :obj-type] (obj-type-string obj)))


(maint) Remove legacy-service dependency on Master and CA for PE

Without this patch the legacy-routes-service specifies a dependency on
the master-service and the ca-service.  This is a problem because the
master-service is not implemented in Puppet Enterprise, instead the
pe-master-service is implemented.  This patch addresses the problem by
removing the dependency on the master service which will allow the
legacy-service to operate in PE.

The dependency is no longer necessary because the catch-all 404 handler
has been removed from the master-service which allows either service to
handle request before handing them to the other service.

--- src/clj/puppetlabs/services/legacy_routes/legacy_routes_service.clj
+++ src/clj/puppetlabs/services/legacy_routes/legacy_routes_service.clj
@@ -13,9 +13,7 @@
 (tk/defservice legacy-routes-service
   [[:WebroutingService add-ring-handler get-route]
    [:RequestHandlerService handle-request]
-   [:PuppetServerConfigService get-config]
-   [:MasterService]
-   [:CaService]]
+   [:PuppetServerConfigService get-config]]
   (init
     [this context]
     (let [path (get-route this)


added to a large degree imperative version of the conversion code

- in the hope to speed up things, but a test revealed no difference,
just more complicated code
- gonna remove the imperative code in the next commit

--- convert-climate-data/src/convert/netcdf.clj
+++ convert-climate-data/src/convert/netcdf.clj
@@ -19,7 +19,7 @@
            ["DURSUN_ts_" :dursun "DURSUN" :s]
            ["RELHUM_2M_ts_" :relhum_2m "RELHUM_2M" :%]
            ["T_2M_ts_" :t_2m "T_2M" :K]
-           ["TD_2M_ts_" :td_2m "TD_2M" :K]                      ; dew point temp = Taupunkt
+           #_["TD_2M_ts_" :td_2m "TD_2M" :K]                      ; dew point temp = Taupunkt
            ["TOT_PREC_ts_" :tot_prec "TOT_PREC" :kg_m-2]           ; total precipition
            ["U_10M_ts_" :u_10m "U_10M" :m_s-1]                  ; wind u component 10m
            ["V_10M_ts_" :v_10m "V_10M" :m_s-1]                  ; wind v component 10m
@@ -28,7 +28,7 @@
           :let [dataset (nd/open-dataset (str path "/" filename-start year ".nc"))]]
     (swap! opened-datasets assoc-in [year sym] dataset)
     (swap! variables assoc-in [year sym] (.findVariable dataset var-name))
-    #_(println "opened dataset: " (str path "/" filename-start year ".nc")))
+    (println "opened dataset: " (str path "/" filename-start year ".nc")))
   (println "opened all datasets from year " from-year " to year " to-year))

 (defn close-datasets []
@@ -63,100 +63,248 @@
                 days-in-year (if leap-year? 366 365)
                 sym-to-var (get @variables year)

-                to-part-seq-3 (fn [arr]
-                                (partition 24 (for [i (range 0 (.getSize arr))]
-                                                (.get arr i 0 0))))
-
-                to-part-seq-4 (fn [arr]
-                                (partition 24 (for [i (range 0 (.getSize arr))]
-                                                (.get arr i 0 0 0))))
-
-                sum #(reduce + 0 %)
-                avg #(/ (sum %) 24)
-
-                ;get all data for a single year (hourly values)
-                [tmins* tavgs* tmaxs*] (-> sym-to-var
-                                        :t_2m
-                                        (.read,,, (str ":,0," lat-i "," lon-i))
-                                        to-part-seq-4
-                                        ((juxt (partial map (partial apply min))
-                                               (partial map avg)
-                                               (partial map (partial apply max))
-                                               ) ,,,))
-                tmins (map #(round (- % 273.15) :digits 1) tmins*)
-                tavgs (map #(round (- % 273.15) :digits 1) tavgs*)
-                tmaxs (map #(round (- % 273.15) :digits 1) tmaxs*)
-                ;_ (println "tavgs: " tavgs)
-
-                dir-rad (-> sym-to-var
-                            :aswdir_s
-                            (.read,,, (str ":," lat-i "," lon-i))
-                            to-part-seq-3
-                            (#(map sum %),,,))
-                dif-rad (-> sym-to-var
-                            :aswdifd_s
-                            (.read,,, (str ":," lat-i "," lon-i))
-                            to-part-seq-3
-                            (#(map sum %),,,))
-                globrads* (map + dir-rad dif-rad)
-                ;convert Wh*m-2 to MJ*m-2 via 1Wh = 3600J and 1MJ = 1.000.000J
-                ;the Netcdf just tells about W*m-2 as Unit, but this is the
-                ;radiation collected within 1 hour
-                globrads (map #(round (* 3.6 0.001 %) :digits 2) globrads*)
-                ;_ (println "globrads: " globrads)
-
+                  to-part-seq-3 (fn [arr]
+                                  (partition 24 (for [i (range 0 (.getSize arr))]
+                                                  (.get arr i 0 0))))
+
+                  to-part-seq-4 (fn [arr]
+                                  (partition 24 (for [i (range 0 (.getSize arr))]
+                                                  (.get arr i 0 0 0))))
+
+                  sum #(reduce + 0 %)
+                  avg #(/ (sum %) 24)
+
+                ;#_(
+                    ;get all data for a single year (hourly values)
+                  [tmins* tavgs* tmaxs*] (-> sym-to-var
+                                             :t_2m
+                                             (.read,,, (str ":,0," lat-i "," lon-i))
+                                             to-part-seq-4
+                                             ((juxt (partial map (partial apply min))
+                                                    (partial map avg)
+                                                    (partial map (partial apply max))
+                                                    ) ,,,))
+                  tmins (map #(round (- % 273.15) :digits 1) tmins*)
+                  tavgs (map #(round (- % 273.15) :digits 1) tavgs*)
+                  tmaxs (map #(round (- % 273.15) :digits 1) tmaxs*)
+                  ;_ (println "tavgs: " tavgs)
+                  ;)
+
+                #_([tmins tavgs tmaxs] (let [arr (-> sym-to-var
+                                                  :t_2m
+                                                  (.read,,, (str ":,0," lat-i "," lon-i)))
+                                          size (.getSize arr)]
+                                      (loop [tmins []
+                                             tavgs []
+                                             tmaxs []
+                                             i 0]
+                                        (if (< i size)
+                                          (let [[tmin tavg tmax] (loop [tmin 99999
+                                                                        tsum 0
+                                                                        tmax -9999
+                                                                        i24 i]
+                                                                   (let [t (- (.get arr i24 0 0 0) 273.15)
+                                                                         tmin* (min tmin t)
+                                                                         tsum* (+ tsum t)
+                                                                         tmax* (max t tmax)]
+                                                                     (if (= (mod (inc i24) 24) 0)
+                                                                       [(round tmin* :digits 1)
+                                                                        (round (/ tsum* 24) :digits 1)
+                                                                        (round tmax* :digits 1)]
+                                                                       (recur tmin* tsum* tmax* (inc i24)))))]
+                                            (recur (conj tmins tmin)
+                                                   (conj tavgs tavg)
+                                                   (conj tmaxs tmax)
+                                                   (+ i 24)))
+                                          [tmins tavgs tmaxs])))
+                ;_ (println "tavgs: " tavgs #_(interleave tavgs tavgs**))
+)
+                ;#_(
+                  dir-rad (-> sym-to-var
+                              :aswdir_s
+                              (.read,,, (str ":," lat-i "," lon-i))
+                              to-part-seq-3
+                              (#(map sum %),,,)
+                              doall)
+                  dif-rad (-> sym-to-var
+                              :aswdifd_s
+                              (.read,,, (str ":," lat-i "," lon-i))
+                              to-part-seq-3
+                              (#(map sum %),,,)
+                              doall)
+                  globrads* (map + dir-rad dif-rad)
+                  ;convert Wh*m-2 to MJ*m-2 via 1Wh = 3600J and 1MJ = 1.000.000J
+                  ;the Netcdf just tells about W*m-2 as Unit, but this is the
+                  ;radiation collected within 1 hour
+                  globrads (->> globrads*
+                                  (map #(round (* 3.6 0.001 %) :digits 2) ,,,))
+                  ;_ (println "globrads: " globrads)
+                  ;)
+
+                #_(globrads (let [dir-arr (-> sym-to-var
+                                          :aswdir_s
+                                          (.read,,, (str ":," lat-i "," lon-i)))
+                              dif-arr (-> sym-to-var
+                                          :aswdifd_s
+                                          (.read,,, (str ":," lat-i "," lon-i)))
+                              size (.getSize dir-arr)]
+                          (loop [globrads []
+                                 i 0]
+                            (if (< i size)
+                              (let [globrad (loop [globrad-sum 0
+                                                   i24 i]
+                                              (let [dir (.get dir-arr i24 0 0)
+                                                    dif (.get dif-arr i24 0 0)
+                                                    globrad-sum* (+ globrad-sum dir dif)]
+                                                (if (= (mod (inc i24) 24) 0)
+                                                  (round (* 3.6 0.001 globrad-sum*) :digits 2)
+                                                  (recur globrad-sum* (inc i24)))))]
+                                (recur (conj globrads globrad)
+                                       (+ i 24)))
+                              globrads)))
+                ;_ (println "globrads: " globrads #_(interleave globrads globrads**))
+)
                 #_sunhours #_(-> sym-to-var
                              :dursun
                              (.read,,, (str ":," lat-i "," lon-i))
                              to-part-seq-3
                              (#(map (fn [vs] (/ (sum vs) 3600.)) %),,,))

-                relhums (-> sym-to-var
-                           :relhum_2m
-                           (.read,,, (str ":,0," lat-i "," lon-i))
-                           to-part-seq-4
-                           (#(map (fn [rhs] (round (avg rhs) :digits 1)) %),,,))
-
-                precips (-> sym-to-var
-                           :tot_prec
-                           (.read,,, (str ":," lat-i "," lon-i))
-                           to-part-seq-3
-                           (#(map (fn [ps] (round (sum ps) :digits 1)) %),,,))
-                ;_ (println "precips: " precips)
-
-                u-wind-arr (-> sym-to-var :u_10m (.read,,, (str ":,0," lat-i "," lon-i)))
-                v-wind-arr (-> sym-to-var :v_10m (.read,,, (str ":,0," lat-i "," lon-i)))
+                ;#_(
+                  relhums (-> sym-to-var
+                               :relhum_2m
+                               (.read,,, (str ":,0," lat-i "," lon-i))
+                               to-part-seq-4
+                               (#(map (fn [rhs] (round (avg rhs) :digits 1)) %),,,))
+                  ;)
+
+                #_(relhums (let [arr (-> sym-to-var
+                                          :relhum_2m
+                                          (.read,,, (str ":,0," lat-i "," lon-i)))
+                              size (.getSize arr)]
+                           (loop [relhums []
+                                  i 0]
+                             (if (< i size)
+                               (let [avg-relhum (loop [relhum-sum 0
+                                                       i24 i]
+                                                  (let [relhum (.get arr i24 0 0 0)
+                                                        relhum-sum* (+ relhum-sum relhum)]
+                                                    (if (= (mod (inc i24) 24) 0)
+                                                      (round (/ relhum-sum* 24) :digits 1)
+                                                      (recur relhum-sum* (inc i24)))))]
+                                 (recur (conj relhums avg-relhum)
+                                        (+ i 24)))
+                               relhums)))
+                ;_ (println "relhums: " relhums #_(interleave relhums relhums*))
+)
+                ;#_(
+                  precips (-> sym-to-var
+                               :tot_prec
+                               (.read,,, (str ":," lat-i "," lon-i))
+                               to-part-seq-3
+                               (#(map (fn [ps] (round (sum ps) :digits 1)) %),,,))
+                  ;_ (println "precips: " precips*)
+                ;)
+
+                #_(precips (let [arr (-> sym-to-var
+                                      :tot_prec
+                                      (.read,,, (str ":," lat-i "," lon-i)))
+                              size (.getSize arr)]
+                          (loop [precips []
+                                 i 0]
+                            (if (< i size)
+                              (let [precip-sum (loop [precip-sum 0
+                                                      i24 i]
+                                                 (let [precip (.get arr i24 0 0)
+                                                       precip-sum* (+ precip-sum precip)
+                                                       ]
+                                                   (if (= (mod (inc i24) 24) 0)
+                                                     (round precip-sum* :digits 1)
+                                                     (recur precip-sum* (inc i24)))))]
+                                (recur (conj precips precip-sum)
+                                       (+ i 24)))
+                              precips)))
+                ;_ (println "precips: " precips #_(interleave precips precips*))
+)
+                ;#_(
+                u-wind-arr (-> sym-to-var :u_10m (.read ,,, (str ":,0," lat-i "," lon-i)))
+                v-wind-arr (-> sym-to-var :v_10m (.read ,,, (str ":,0," lat-i "," lon-i)))
                 winds (->> (for [i (range 0 (.getSize u-wind-arr))]
-                            [(.get u-wind-arr i 0 0 0)
-                             (.get v-wind-arr i 0 0 0)])
-                          (partition 24,,,)
+                             [(.get u-wind-arr i 0 0 0)
+                              (.get v-wind-arr i 0 0 0)])
+                           (partition 24,,,)
                            (map (fn [uvs] (round (/ (reduce (fn [acc [u v]]
                                                               (+ acc (Math/sqrt (+ (* u u) (* v v)))))
                                                             0 uvs)
                                                     24)
                                                  :digits 1)) ,,,))
-
                 ;_ (println "winds: " winds)
-
-                [days months years dates] ((juxt (partial map first)
-                                                 (partial map second)
-                                                 (partial map #(nth % 2))
-                                                 (partial map #(nth % 3)))
-                                            (for [diy (range 1 (inc days-in-year))]
-                                              (let [date (ctc/plus (ctc/date-time year) (ctc/days (dec diy)))]
-                                                [(ctc/day date)
-                                                 (ctc/month date)
-                                                 year
-                                                 (ctf/unparse (ctf/formatter "yyyy-MM-dd") date)])))
+                ;)
+
+                #_(winds (let [u-wind-arr (-> sym-to-var
+                                           :u_10m
+                                           (.read,,, (str ":,0," lat-i "," lon-i)))
+                            v-wind-arr (-> sym-to-var
+                                           :v_10m
+                                           (.read,,, (str ":,0," lat-i "," lon-i)))
+                            size (.getSize u-wind-arr)]
+                           (loop [winds []
+                                  i 0]
+                             (if (< i size)
+                               (let [wind (loop [wind-sum 0
+                                                 i24 i]
+                                            (let [u (.get u-wind-arr i24 0 0 0)
+                                                  v (.get v-wind-arr i24 0 0 0)
+                                                  wind-sum* (+ wind-sum (Math/sqrt (+ (* u u) (* v v))))]
+                                              (if (= (mod (inc i24) 24) 0)
+                                                (round (/ wind-sum* 24) :digits 1)
+                                                (recur wind-sum* (inc i24)))))]
+                                 (recur (conj winds wind)
+                                        (+ i 24)))
+                               winds)))
+                ;_ (println "winds: " (interleave winds winds*))
+)
+
+                ;#_(
+                [days
+                 months
+                 years
+                 dates] ((juxt (partial map first)
+                                (partial map second)
+                                (partial map #(nth % 2))
+                                (partial map #(nth % 3)))
+                                           (doall (for [diy (range 1 (inc days-in-year))]
+                                                    (let [date (ctc/plus (ctc/date-time year) (ctc/days (dec diy)))]
+                                                      [(ctc/day date)
+                                                       (ctc/month date)
+                                                       year
+                                                       (ctf/unparse (ctf/formatter "yyyy-MM-dd") date)]))))

                 ;_ (println "days: " days)
                 ;_ (println "dates: " dates)
-
+                ;    )
+
+                #_([days months years dates] (loop [days []
+                                                 months []
+                                                 years []
+                                                 dates []
+                                                 diy 1]
+                                            (if (< diy (inc days-in-year))
+                                              (let [date (ctc/plus (ctc/date-time year) (ctc/days (dec diy)))]
+                                                (recur (conj days (ctc/day date))
+                                                       (conj months (ctc/month date))
+                                                       (conj years year)
+                                                       (conj dates (ctf/unparse (ctf/formatter "yyyy-MM-dd") date))
+                                                       (inc diy)))
+                                              [days months years dates]))
+
+                ;_ (println "days: " days #_(interleave days days*))
+                ;_ (println "dates: " dates #_(interleave dates dates*))
+)
                 row-strs (map (fn [& vs] (map str vs))
-                              days months years dates tmins tavgs tmaxs precips globrads relhums winds)
-                ]
+                              days months years dates tmins tavgs tmaxs precips globrads relhums winds)]
             (doseq [row-str row-strs]
-              ;(println "row-str: " row-str)
+              #_(println "row-str: " row-str)
               (.write w (csv/write-csv [row-str])))))))))

 (defn run-climate-file-conversion [& {:strs [read-path write-path from-year to-year
@@ -187,14 +335,14 @@
        "from-year" "1994"
        "to-year" "2012")

-
-
-
-
-
-
-
-
-
-
-
+;java -jar target\uberjar\convert-climate-data-1.0-standalone.jar read-path z:/DWD write-path d:/DWD-out from-year 1994 to-year 1996
+
+
+
+
+
+
+
+
+
+


Add dynamic bindings to info reported by 'expect'

--- modules/lazytest/src/main/clojure/lazytest/expect.clj
+++ modules/lazytest/src/main/clojure/lazytest/expect.clj
@@ -40,6 +40,7 @@
 			     '~(meta expr)
 			     {:form '~expr
 			      :locals ~(local-bindings &env)
+			      :bindings (get-thread-bindings)
 			      :evaluated (list* f# args#)
 			      :result result#
 			      :file ~*file*
@@ -53,6 +54,7 @@
 			     '~(meta expr)
 			     {:form '~expr
 			      :locals ~(local-bindings &env)
+			      :bindings (get-thread-bindings)
 			      :result result#
 			      :file ~*file*
 			      :ns '~(ns-name *ns*)}


Return only segments from hl7

Return only segments from hl7

--- adapter-hl7v2/src/adapter_hl7v2/core.clj
+++ adapter-hl7v2/src/adapter_hl7v2/core.clj
@@ -37,7 +37,11 @@
   ;; TODO handle remote urls
   (def u (string->url url))
   (def hl7file (string/join "/" (:path u)))
-  (hl7parser/parse (slurp hl7file)))
+  ;; :id :fields
+  (try (def segments (get (hl7parser/parse (slurp hl7file)) :segments))
+       (info segments)
+
+  (catch Exception e (error e))))

 (defn build-select "Build a SELECT FROM HL7v2" [url tables query]
   (println url))