Read handler check now uses JavaScript truth

--- src/longshi/fressian/byte_stream.cljs
+++ src/longshi/fressian/byte_stream.cljs
@@ -190,7 +190,7 @@

      If no handler is found a tagged object is returned"
     (let [rh (or (get handlers tag) (get standard-handlers tag))]
-      (if rh
+      (if-not (nil? rh)
         (rh bis tag fields)
         (let [values (make-array fields)]
           (do


added D3 include to page

added D3 include to page

--- src/main/clj/emotions_demo/webapp.clj
+++ src/main/clj/emotions_demo/webapp.clj
@@ -47,6 +47,7 @@
       (include-css "/css/demo.css")
       (include-js "//fb.me/react-0.8.0.js") ; only required in dev build
       (include-js "/out/goog/base.js") ; only required in dev build
+      (include-js "/jslib/d3/d3.min.js")
       (include-js "/js/demo.js")
       (javascript-tag "goog.require('emotions_demo.client');") ; only required in dev build
       ]))


use :ns nREPL key on all sent messages – ensures the evaluation namespace matches what's in the UI at send-time

--- ccw.core/src/ccw/repl/view_helpers.clj
+++ ccw.core/src/ccw/repl/view_helpers.clj
@@ -3,6 +3,7 @@
     [ccw.repl.cmdhistory :as history])
   (:use (clojure.contrib def core))
   (:import ccw.CCWPlugin
+    ccw.repl.REPLView
     org.eclipse.ui.PlatformUI
     org.eclipse.swt.SWT
     (org.eclipse.swt.custom StyledText StyleRange)))
@@ -75,8 +76,8 @@
       (.replaceAll "\\n|\\r" " "))))

 (defn eval-expression
-  [repl-view log-component {:keys [send]} requests-atom expr]
-  (let [response-fn (send expr)
+  [^REPLView repl-view log-component {:keys [send]} requests-atom expr]
+  (let [response-fn (send expr :ns (.getCurrentNamespace repl-view))
         key [(System/currentTimeMillis) expr]]
     (swap! requests-atom assoc key response-fn)
     (future (try


More WIP

More WIP

--- src/re_frame_async_flow_fx/core.cljs
+++ src/re_frame_async_flow_fx/core.cljs
@@ -4,14 +4,14 @@

 (defn startable-tasks
-  "Return a list of tasks that have not been started and their
-   when fn answers true given its events and those seen."
-  [rules seen-events started-tasks]
+  "Given a set of 'now-seen-events' and a set of already started tasks
+  return the list of tasks which should now be started."
+  [rules now-seen-events started-tasks]
   (->> (remove (comp started-tasks :id) rules)
        (filterv (fn [task]
                   (condp = (:when task)
-                    :seen-all-of  (empty? (set/difference (:events task)  seen-events))
-                    :seen-any-of  (seq (set/intersection seen-events (:events task))))))))
+                    :seen-all-of  (empty? (set/difference (:events task)  now-seen-events))
+                    :seen-any-of  (seq (set/intersection now-seen-events (:events task))))))))

 (defn make-flow-event-handler
@@ -22,7 +22,7 @@

         ;;  rules'  XXX make all :dispatch a list PLUS make :done   [id :done]   then use rules' below
-        ;;
+        ;;
         ]

     ;; return an event handler which will manage the flow
@@ -34,6 +34,7 @@
     (fn flow-event-hander
       [{:keys [db]} event-v]
         (condp = event-v
+
               ;; Setup the flow coordinator:
               ;;  1. Initialise the state  (seen-events and started-tasks)
               ;;  2. dispatch the first event, to kick start
@@ -54,9 +55,9 @@
                        :event-forwarder {:unregister id}})

               ;;
-              ;; An new event has been forwarded to this handler. What does it mean?
-              ;;  1. work out if this new event means we need to dispatch another
-              ;;  2. remember the new state
+              ;; A new event has been forwarded to this handler. What does it mean?
+              ;;  1. does this new event mean we need to dispatch another
+              ;;  2. remember that this new event has happened
               (let [[event-id forwarded-event] event-v
                     _   (assert (= id event-id))
                     _   (assert (vector? forwarded-event))


Calculate patterns beforehand

Calculate patterns beforehand

--- src/github_changelog/conventional.clj
+++ src/github_changelog/conventional.clj
@@ -15,19 +15,23 @@
 (def header-pattern #"^(\w*)(?:\((.*)\))?\: (.*)$")

 (defn collect-issues [pull pattern link-fn]
-  (->> (re-seq (fixes-pattern pattern) (str (:body pull)))
+  (->> (re-seq pattern (str (:body pull)))
        (map second)
        (map #(vector % (link-fn %)))))

+(def jira-pattern (fixes-pattern "\\[?([A-Z]+-\\d+)\\]?"))
+
 (defn jira-issues [{:keys [jira]} pull]
   (let [base (str jira "/browse/")]
-    (collect-issues pull "\\[?([A-Z]+-\\d+)\\]?" (partial str base))))
+    (collect-issues pull jira-pattern (partial str base))))
+
+(def github-pattern (fixes-pattern "(#\\d+)"))

 (defn- parse-int [x] (Integer. (re-find #"[0-9]+" x)))

 (defn github-issues [_ pull]
   (let [base (str (get-in pull [:base :repo :html_url]) "/issues/")]
-    (collect-issues pull "(#\\d+)" #(str base (parse-int %)))))
+    (collect-issues pull github-pattern #(str base (parse-int %)))))

 (defn parse-issues [config pull]
   (apply concat ((juxt jira-issues github-issues) config pull)))


Display loading panel when place selected

--- src-cljs/acfe/core.cljs
+++ src-cljs/acfe/core.cljs
@@ -77,6 +77,7 @@

 (defn on-place-click
   [e]
+  (panel/create-loading-panel)
   (this-as
    this
    (GET (str "/api/place.html?id=" (.-id this))


Default to :distributed instead of :invalidated and ixnay CHM default

--- modules/cache/src/main/clojure/immutant/cache/core.clj
+++ modules/cache/src/main/clojure/immutant/cache/core.clj
@@ -69,10 +69,12 @@
       (.start))))

 (defn clustered-cache
-  [name & {:keys [mode sync] :or {mode :invalidated sync true}}]
-  (if (.isRunning clustered-manager name)
-    (reconfigure name (cache-mode mode sync))
-    (configure name (cache-mode mode sync))))
+  "Defaults to :distributed, with :sync=true"
+  [name & {:keys [mode sync] :or {sync true}}]
+  (let [mode (or mode :distributed)]
+    (if (.isRunning clustered-manager name)
+      (reconfigure name (cache-mode mode sync))
+      (configure name (cache-mode mode sync)))))

 (try-defn reqs local-cache
   ([]
@@ -85,14 +87,12 @@
   ([name] (raw-cache name nil))
   ([name mode]
      (cond
-      clustered-manager (clustered-cache name :mode (or mode :invalidated))
+      clustered-manager (clustered-cache name :mode mode)
       local-manager (do
                       (if (and mode (not= mode :local))
                         (log/warn "Invalid mode," mode ", falling back to local"))
                       (local-cache name))
-      :else (do
-              (log/warn "Infinispan not available; falling back to ConcurrentHashMap")
-              (java.util.concurrent.ConcurrentHashMap.)))))
+      :else (log/error "Infinispan not found on the classpath"))))

 (defn lifespan-params [{:keys [ttl idle units] :or {ttl -1 idle -1 units :seconds}}]


delaney.clj: (read-symbols) removes comment lines

--- clojure/org/gavrog/clojure/delaney.clj
+++ clojure/org/gavrog/clojure/delaney.clj
@@ -639,7 +639,9 @@
 ;; === Reading a sequence of symbols from a file (very naive method for now)

 (defn read-symbols [filename]
-     (->> (-> filename slurp (.split "<")) (drop 1) (map dsymbol)))
+     (->> (-> filename slurp (.replaceAll "#.*\\n" "") (.split "<"))
+       (drop 1)
+       (map dsymbol)))

 ;; === Tests


delaney.clj: some more refactoring in the print method.

--- clojure/org/gavrog/clojure/delaney.clj
+++ clojure/org/gavrog/clojure/delaney.clj
@@ -207,9 +207,8 @@
                             (orbit-reps ds [i (inc i)])))
         ops-str (s/join "," (map #(s/join " " (images %)) (indices ds)))
         ms-str (s/join "," (map #(s/join " " (m-vals %)) (range (.dim ds))))
-        dims-str (if (= 2 (.dim ds))
-                   (str (.size ds))
-                   (str (.size ds) " " (.dim ds)))
+        [size dim] [(.size ds) (.dim ds)]
+        dims-str (s/join " " (if (= 2 dim) [size] [size dim]))
         code (str "<1.1:" dims-str ":" ops-str ":" ms-str ">")]
     (if *print-readably*
       (print-simple (str "(dsymbol \"" code "\")") w)
@@ -241,8 +240,7 @@
 (defn- with-m-vals [ds spins]
   (reduce (fn [ds i]
             (let [j (inc i)]
-              (reduce (fn [ds [D m]]
-                        (spin ds i j D (/ m (r ds i j D))))
+              (reduce (fn [ds [D m]] (spin ds i j D (/ m (r ds i j D))))
                       ds
                       (filter (fn [[D m]] (> m 0))
                               (zipmap (orbit-reps ds [i j]) (nth spins i))))))


fix js-obj calls keys

fix js-obj calls keys

While working on another project here I just realized using keywords as keys on `js-obj` makes then generate keys like `":className"` instead of `"className"`. So, before this commit the `:classNames` are not being correctly applied.

--- src/untangled/client/data_fetch.cljs
+++ src/untangled/client/data_fetch.cljs
@@ -301,9 +301,9 @@
   (def ui-thing2 (om/factory Thing2))
   ```"
   [data-render props & {:keys [ready-render loading-render failed-render not-present-render]
-                        :or   {loading-render (fn [_] (dom/div (js-obj :className "lazy-loading-load") "Loading..."))
-                               ready-render   (fn [_] (dom/div (js-obj :className "lazy-loading-ready") "Queued"))
-                               failed-render  (fn [_] (dom/div (js-obj :className "lazy-loading-failed") "Loading error!"))}}]
+                        :or   {loading-render (fn [_] (dom/div (js-obj "className" "lazy-loading-load") "Loading..."))
+                               ready-render   (fn [_] (dom/div (js-obj "className" "lazy-loading-ready") "Queued"))
+                               failed-render  (fn [_] (dom/div (js-obj "className" "lazy-loading-failed") "Loading error!"))}}]

   (let [state (:ui/fetch-state props)]
     (cond


Add graceful shutdown of the metric store

--- src/whisper2cyanite/metric_store.clj
+++ src/whisper2cyanite/metric_store.clj
@@ -1,7 +1,7 @@
 (ns whisper2cyanite.metric-store
   (:require [qbits.alia :as alia]
             [qbits.alia.policy.load-balancing :as alia_lbp]
-            [clojure.core.async :refer [chan <! take! >!!]]
+            [clojure.core.async :as async]
             [whisper2cyanite.utils :as utils])
   (:import [com.datastax.driver.core
             BatchStatement
@@ -35,20 +35,23 @@

 (defn- get-channel
   "Get store channel."
-  [session statement chan_size batch_size]
-  (let [ch (chan chan_size)
+  [session statement chan_size batch_size data-stored?]
+  (let [ch (async/chan chan_size)
         ch-p (utils/partition-or-time batch_size ch batch_size 5)]
-    (utils/go-forever
-     (let [values (<! ch-p)]
-       (try
-         (take!
-          (alia/execute-chan session (batch statement values)
-                             {:consistency :any})
-          (fn [rows-or-e]
-            (if (instance? Throwable rows-or-e)
-              (println rows-or-e "Cassandra error"))))
-         (catch Exception e
-           (println e "Store processing exception")))))
+    (utils/go-while (not @data-stored?)
+                    (let [values (async/<! ch-p)]
+                      (if values
+                        (try
+                          (async/take!
+                           (alia/execute-chan session (batch statement values)
+                                              {:consistency :any})
+                           (fn [rows-or-e]
+                             (if (instance? Throwable rows-or-e)
+                               (println rows-or-e "Cassandra error"))))
+                          (catch Exception e
+                            (println e "Store processing exception")))
+                        (when (not @data-stored?)
+                          (swap! data-stored? (fn [_] true))))))
     ch))

 (defn cassandra-metric-store
@@ -60,11 +63,15 @@
         insert! (get-cassandra-query session)
         chan_size (:cassandra-channel-size options default-cassandra-channel-size)
         batch_size (:cassandra-batch-size options default-cassandra-batch-size)
-        channel (get-channel session insert! chan_size batch_size)]
+        data-stored? (atom false)
+        channel (get-channel session insert! chan_size batch_size data-stored?)]
     (reify
       MetricStore
       (insert [this tenant rollup period path time value ttl]
-        (>!! channel [(int ttl) [(double value)] (str tenant) (int rollup)
-                      (int period) (str path) (long time)]))
+        (async/>!! channel [(int ttl) [(double value)] (str tenant) (int rollup)
+                            (int period) (str path) (long time)]))
       (shutdown [this]
+        (async/close! channel)
+        (while (not @data-stored?)
+          (Thread/sleep 100))
         (.close session)))))


[#1787] Remove metadata.type

[#1787] Remove metadata.type

--- backend/src/akvo/lumen/lib/aggregation/bubble.clj
+++ backend/src/akvo/lumen/lib/aggregation/bubble.clj
@@ -51,6 +51,5 @@
                  "label" (:title column-size)
                  "data" (mapv (fn [[size-value label]] {"value" size-value}) sql-response)
                  "metadata"  {"type" (:type column-size)}}]
-      "common" {"metadata" {"type" nil
-                            "sampled" (= (count sql-response) max-points)}
+      "common" {"metadata" {"sampled" (= (count sql-response) max-points)}
                 "data" (mapv (fn [[size-value label]] {"label" label}) sql-response)}})))


[compute/nn/train] Tiny docstring improvement. (#17)

--- compute/src/think/compute/nn/train.clj
+++ compute/src/think/compute/nn/train.clj
@@ -134,10 +134,9 @@
         optimiser (opt/setup-optimiser optimiser backend (layers/parameter-count net))]
     {:network net :optimiser optimiser :loss-fn loss-fns :batching-system batching-system}))

-
 (defn train
-  "Epoch train filter takes an epoch-index and a train config and produces
-a new train config after perhaps printing output or some other side effecty thing."
+  "Epoch train filter takes an epoch-index and a train config and produces a new
+  train config; providing an opportunity for side effects (e.g., printing)."
   [net optimiser dataset input-labels output-labels-and-loss epoch-count
    & {:keys [epoch-train-filter]
       :or {epoch-train-filter println-report-epoch}}]


add simplified attributes

add simplified attributes

--- src/clj/clj_money/api/transactions.clj
+++ src/clj/clj_money/api/transactions.clj
@@ -36,7 +36,10 @@
    :entity-id
    :transaction-date
    :memo
-   :items])
+   :items
+   :debit-account-id
+   :credit-account-id
+   :quantity])

 (defn create
   [{params :params}]


Pass parent title through to child section & render. Fixes #73.

--- src/clj/clojuredocs/pages/quickref.clj
+++ src/clj/clojuredocs/pages/quickref.clj
@@ -12,11 +12,16 @@
       (str/replace #"[^a-z0-9]" "-")
       (str/replace #"-+" "-")))

-(defn $group [{:keys [title syms]}]
+(defn $group [{:keys [title syms]} parent-title]
   [:div.group
    [:div.quickref-header.clearfix
     [:h4 title]
-    [:h4.header-reference "Simple Values > Numbers"]]
+    [:h4.header-reference
+     (when parent-title
+       parent-title)
+     (when parent-title
+       " > ")
+     title]]
    [:dl.dl-horizontal
     (mapcat #(vector
                [:div.dl-row
@@ -30,18 +35,18 @@
                   "1 ex."]]])
       syms)]])

-(defn $category [{:keys [title groups]}]
+(defn $category [{:keys [title groups]} parent-title]
   [:div.category
    [:div.category-header.clearfix
     [:h3 {:id (title->id title)} title]
-    [:h3.header-reference "Simple Values"]]
-   (map $group groups)])
+    [:h3.header-reference parent-title]]
+   (map #($group % title) groups)])

 (defn $sphere [{:keys [title categories]}]
   [:div.sphere
    [:div.sphere-header
     [:h2 {:id (title->id title)} title]]
-   (map $category categories)])
+   (map #($category % title) categories)])

 (defn $toc-category [{:keys [title]}]
   [:li [:a {:href (str "#" (title->id title))


removed dead code

removed dead code

--- src/cljc/flocking/behaviors/rules.cljc
+++ src/cljc/flocking/behaviors/rules.cljc
@@ -43,23 +43,10 @@
 (defmethod steer :cohere [_ behavior boid flock] (cohere behavior boid flock))
 (defmethod steer :default [_ _ _ _] [0 0])

-;(defn steer [behavior-key behavior boid flock]
-;  (case behavior-key
-;    :wander (wander behavior boid flock)
-;    :separate (separate behavior boid flock)
-;    :align (align behavior boid flock)
-;    :cohere (cohere behavior boid flock)
-;    [0 0]))
-
 ;Multimethod for updates to behaviors
 (defmulti update-behavior (fn[behavior-name _ _ _] behavior-name))
 (defmethod update-behavior :wander [_ behavior _ _] (update-wander behavior))
 (defmethod update-behavior :default [_ behavior _ _] behavior)
-
-;(defn update-behavior [behavior-key behavior boid flock]
-;  (case behavior-key
-;    :wander (update-wander behavior)
-;    behavior))

 ;Methods to iterate over updates
 (defn behaviors-calc[f behaviors boid world-state]


Removing parameters file that was renamed.

--- src/cmr/search/services/parameters.clj
+++ src/cmr/search/services/parameters.clj
@@ -1,232 +0,0 @@
-(ns cmr.search.services.parameters
-  "Contains functions for parsing and converting query parameters to query conditions"
-  (:require [clojure.string :as s]
-            [cmr.common.services.errors :as errors]
-            [cmr.search.models.query :as qm]
-            [cmr.search.data.query-to-elastic :as q2e]
-            [cmr.common.date-time-parser :as dt-parser]
-            [cmr.common.util :as u]
-            [cmr.search.services.parameters.legacy-parameters :as lp]))
-
-(def nrt-aliases
-  ["near_real_time","nrt", "NRT", "near real time","near-real time","near-real-time","near real-time"])
-
-(def concept-param->type
-  "A mapping of param names to query condition types based on concept-type"
-  {:collection {:entry-title :string
-                :entry-id :string
-                :provider :string
-                :short-name :string
-                :version :string
-                :updated-since :updated-since
-                :processing-level-id :string
-                :collection-data-type :collection-data-type
-                :temporal :temporal
-                :concept-id :string
-                :platform :string
-                :instrument :string
-                :sensor :string
-                :project :string
-                :archive-center :string
-                :spatial-keyword :string
-                :two-d-coordinate-system-name :string
-                :science-keywords :science-keywords
-                :downloadable :boolean
-                :polygon :polygon
-                :bounding-box :bounding-box}
-   :granule {:granule-ur :string
-             :collection-concept-id :string
-             :producer-granule-id :string
-             :day-night :string
-             :readable-granule-name :readable-granule-name
-             :provider :collection-query
-             :entry-title :collection-query
-             :attribute :attribute
-             :short-name :collection-query
-             :orbit-number :orbit-number
-             :equator-crossing-longitude :equator-crossing-longitude
-             :equator-crossing-date :equator-crossing-date
-             :version :collection-query
-             :updated-since :updated-since
-             :temporal :temporal
-             :platform :inheritance
-             :instrument :inheritance
-             :sensor :inheritance
-             :project :string
-             :cloud-cover :num-range
-             :concept-id :string
-             :exclude :exclude
-             :downloadable :boolean
-             :polygon :polygon
-             :bounding-box :bounding-box}})
-
-(def always-case-sensitive
-  "A set of parameters that will always be case sensitive"
-  #{:concept-id :collection-concept-id})
-
-(defn case-sensitive-field?
-  "Return true if the given field is a case-sensitive field"
-  [field options]
-  (or (always-case-sensitive field)
-      (= "false" (get-in options [field :ignore-case]))))
-
-(defn pattern-field?
-  "Returns true if the field is a pattern"
-  [field options]
-  (= "true" (get-in options [field :pattern])))
-
-(defn group-operation
-  "Returns the group operation (:and or :or) for the given field."
-  ([field options]
-   (group-operation field options :or))
-  ([field options default]
-   (cond
-     (= "true" (get-in options [field :and])) :and
-     (= "true" (get-in options [field :or])) :or
-     :else default)))
-
-(defn- param-name->type
-  "Returns the query condition type based on the given concept-type and param-name."
-  [concept-type param-name]
-  (get-in concept-param->type [concept-type param-name]))
-
-(defmulti parameter->condition
-  "Converts a parameter into a condition"
-  (fn [concept-type param value options]
-    (param-name->type concept-type param)))
-
-(defmethod parameter->condition :string
-  [concept-type param value options]
-  (let [case-sensitive (case-sensitive-field? param options)
-        pattern (pattern-field? param options)
-        group-operation (group-operation param options)]
-    (if (sequential? value)
-      (qm/string-conditions param value case-sensitive pattern group-operation)
-      (qm/string-condition param value case-sensitive pattern))))
-
-;; Construct an inheritance query condition for granules.
-;; This will find granules which either have explicitly specified a value
-;; or have not specified any value for the field and inherit it from their parent collection.
-(defmethod parameter->condition :inheritance
-  [concept-type param value options]
-  (let [field-condition (parameter->condition :collection param value options)]
-    (qm/or-conds
-      [field-condition
-       (qm/and-conds
-         [(qm/->CollectionQueryCondition field-condition)
-          (qm/map->MissingCondition {:field (q2e/query-field->elastic-field param concept-type)})])])))
-
-;; or-conds --> "not (CondA and CondB)" == "(not CondA) or (not CondB)"
-(defmethod parameter->condition :exclude
-  [concept-type param value options]
-  (qm/or-conds
-    (map (fn [[exclude-param exclude-val]]
-           (qm/map->NegatedCondition
-             {:condition (parameter->condition concept-type exclude-param exclude-val options)}))
-         value)))
-
-(defmethod parameter->condition :updated-since
-  [concept-type param value options]
-  (qm/map->DateRangeCondition
-    {:field param
-     :start-date (dt-parser/parse-datetime
-                   (if (sequential? value) (first value) value))
-     :end-date nil}))
-
-(defmethod parameter->condition :boolean
-  [concept-type param value options]
-  (cond
-    (or (= "true" value) (= "false" value))
-    (qm/map->BooleanCondition {:field param
-                               :value (= "true" value)})
-
-    (= "unset" (s/lower-case value))
-    (qm/map->MatchAllCondition {})
-
-    :else
-    (errors/internal-error! (format "Boolean condition for %s has invalid value of [%s]" param value))))
-
-
-(defmethod parameter->condition :readable-granule-name
-  [concept-type param value options]
-  (if (sequential? value)
-    (if (= "true" (get-in options [param :and]))
-      (qm/and-conds
-        (map #(parameter->condition concept-type param % options) value))
-      (qm/or-conds
-        (map #(parameter->condition concept-type param % options) value)))
-    (let [case-sensitive (case-sensitive-field? :readable-granule-name options)
-          pattern (pattern-field? :readable-granule-name options)]
-    (qm/or-conds
-      [(qm/string-condition :granule-ur value case-sensitive pattern)
-       (qm/string-condition :producer-granule-id value case-sensitive pattern)]))))
-
-(defmethod parameter->condition :collection-data-type
-  [concept-type param value options]
-  (if (sequential? value)
-    (if (= "true" (get-in options [param :and]))
-      (qm/and-conds
-        (map #(parameter->condition concept-type param % options) value))
-      (qm/or-conds
-        (map #(parameter->condition concept-type param % options) value)))
-    (let [value (if (some #{value} nrt-aliases) "NEAR_REAL_TIME" value)
-          case-sensitive (case-sensitive-field? :collection-data-type options)
-          pattern (pattern-field? :collection-data-type options)]
-      (if (or (= "SCIENCE_QUALITY" value)
-              (and (= "SCIENCE_QUALITY" (s/upper-case value))
-                   (not= "false" (get-in options [:collection-data-type :ignore-case]))))
-        ; SCIENCE_QUALITY collection-data-type should match concepts with SCIENCE_QUALITY
-        ; or the ones missing collection-data-type field
-        (qm/or-conds
-          [(qm/string-condition :collection-data-type value case-sensitive pattern)
-           (qm/map->MissingCondition {:field :collection-data-type})])
-        (qm/string-condition :collection-data-type value case-sensitive pattern)))))
-
-(defmethod parameter->condition :num-range
-  [concept-type param value options]
-  (qm/numeric-range-str->condition param value))
-
-(defn parse-sort-key
-  "Parses the sort key param and returns a sequence of maps with fields and order.
-  Returns nil if no sort key was specified."
-  [sort-key]
-  (when sort-key
-    (if (sequential? sort-key)
-      (mapcat parse-sort-key sort-key)
-      (let [[_ dir-char field] (re-find #"([\-+])?(.*)" sort-key)
-            direction (case dir-char
-                        "-" :desc
-                        "+" :asc
-                        :asc)
-            field (keyword field)]
-        [{:order direction
-          :field (or (lp/param-aliases field)
-                     field)}]))))
-
-(defn parameters->query
-  "Converts parameters into a query model."
-  [concept-type params]
-  (let [options (u/map-keys->kebab-case (get params :options {}))
-        page-size (Integer. (get params :page-size qm/default-page-size))
-        page-num (Integer. (get params :page-num qm/default-page-num))
-        sort-keys (parse-sort-key (:sort-key params))
-        result-format (get params :result-format (qm/default-result-format concept-type))
-        params (dissoc params :options :page-size :page-num :sort-key :result-format)]
-    (if (empty? params)
-      ;; matches everything
-      (qm/query {:concept-type concept-type
-                 :page-size page-size
-                 :page-num page-num
-                 :sort-keys sort-keys
-                 :result-format result-format})
-      ;; Convert params into conditions
-      (let [conditions (map (fn [[param value]]
-                              (parameter->condition concept-type param value options))
-                            params)]
-        (qm/query {:concept-type concept-type
-                   :page-size page-size
-                   :page-num page-num
-                   :condition (qm/and-conds conditions)
-                   :sort-keys sort-keys
-                   :result-format result-format})))))
-


saving state

saving state

--- cljs-server/snowflake_server/core.cljs
+++ cljs-server/snowflake_server/core.cljs
@@ -108,9 +108,9 @@
     (deref classes)))

 (defn- load-project-configs! []
-  (doseq [p (keys @projects)]
-    (let [project-config (read-project-config p)]
-      (swap! projects assoc p project-config))))
+  (doseq [path (keys @projects)]
+    (let [project-config (read-project-config path)]
+      (swap! projects update-in [path] merge project-config))))

 (defn- load-projects-file! []
   (let [projects-vector (jsonfile->clj projects-file)
@@ -122,6 +122,17 @@

 (load-projects-file!)
 (load-project-configs!)
+
+(defn- load-classes! [p]
+  (let [project-path (:path p)
+        css-glob-patterns (get-in p [:css-files :include])
+        first-pattern (first css-glob-patterns)
+        glob-options (js-obj "cwd" project-path)
+        ;; css-files (.sync glob (first css-glob-patterns) (js-obj "root" project-path))]
+        files (.sync glob first-pattern glob-options)]
+    (js-log files)))
+
+(load-classes! (first (vals @projects)))

 ;;------------------------------------------------------------------------------
 ;; Server Initialization


delaney.clj: added a deftype for symbols.

--- clojure/org/gavrog/clojure/delaney.clj
+++ clojure/org/gavrog/clojure/delaney.clj
@@ -2,18 +2,27 @@
   (:use (org.gavrog.clojure [util :only [empty-queue pop-while]]))
   (:import (org.gavrog.joss.dsyms.basic DelaneySymbol)))

-(defprotocol D-symbol
+(defprotocol IDSymbol
   (elements [_])
   (indices [_])
   (s [_ i D])
   (v [_ i j D]))

 (extend-type DelaneySymbol
-  D-symbol
+  IDSymbol
   (elements [ds] (iterator-seq (.elements ds)))
   (indices [ds] (iterator-seq (.indices ds)))
   (s [ds i D] (when (.definesOp ds i D) (.op ds i D)))
   (v [ds i j D] (when (.definesV ds i j D) (.v ds i j D))))
+
+(deftype DSymbol [idcs elms s v]
+  IDSymbol
+  (elements [_] elms)
+  (indices [_] idcs)
+  (s [_ i D] (get s [i, D]))
+  (v [_ i j D]
+     (cond)))
+

 ;; General D-symbol functions


cleanup

cleanup

--- ccw.core/src/ccw/debug/serverrepl.clj
+++ ccw.core/src/ccw/debug/serverrepl.clj
@@ -108,13 +108,9 @@
         [:children
          (apply vector (sort-by :name (map #(var-info (second %)) (ns-interns n))))]))))

-(def ns-info-cache (atom nil))
-
 (defn namespaces-info []
-  (let [info
-        {:name "namespaces" :type "namespaces"
-         :children (apply vector (sort-by :name (map ns-info (all-ns))))}]
-    (reset! ns-info-cache info) info))
+  {:name "namespaces" :type "namespaces"
+   :children (apply vector (sort-by :name (map ns-info (all-ns))))})

 ; The following function (splitted-match) taken from vimClojure with the permission of the author.
 ; Please look for vimClojure license for more detail


add combine-solvers

add combine-solvers

--- src/app/symbol_solver/type_solver.clj
+++ src/app/symbol_solver/type_solver.clj
@@ -48,3 +48,10 @@
       (if (simple-name? name-to-solve)
         (solve-system-class (str "java.lang." name-to-solve))
         nil))))
+
+(defn combine-solvers
+  [solver-1 solver-2]
+  (fn [name-to-solve]
+    (let [res1 (solver-1 name-to-solve)
+          res2 (when solver-2 (solver-2 name-to-solve))]
+      (or res1 res2))))


More precalculation

More precalculation

--- src/onyx/messaging/protocol_netty.clj
+++ src/onyx/messaging/protocol_netty.clj
@@ -37,6 +37,7 @@
 (def ^:const acks-base-length (int 4))
 ; id uuid, completion-id uuid, ack-val long
 (def ^:const ack-base-length (int 40))
+(def ^:const acks-header-length (int (+ acks-base-length type-header-length)))

 ; message length without nippy segments
 ; id (uuid), acker-id (uuid), completion-id (uuid), ack-val (long)
@@ -68,11 +69,10 @@
   (take-uuid buf))

 (defn build-acks-msg-buf [acks]
-  (let [^ByteBuf buf (byte-buffer (+ acks-base-length
-                                     type-header-length
-                                     (* (count acks) ack-base-length)))]
+  (let [cnt (int (count acks))
+        ^ByteBuf buf (byte-buffer (+ acks-header-length (* cnt ack-base-length)))]
     (.writeByte buf ack-type-id)
-    (.writeInt buf (int (count acks)))
+    (.writeInt buf cnt)
     (doseq [ack acks]
       (write-uuid buf (:id ack))
       (write-uuid buf (:completion-id ack))


No need to return `:exists? true` when resource exists

--- src/asciinema/endpoint/asciicasts.clj
+++ src/asciinema/endpoint/asciicasts.clj
@@ -60,8 +60,7 @@
                  :query {(s/optional-key :dl) s/Bool}}
     :properties (fn [ctx]
                   (if-let [asciicast (adb/get-asciicast-by-token db (-> ctx :parameters :path :token))]
-                    {:exists? true
-                     ::asciicast asciicast}
+                    {::asciicast asciicast}
                     {:exists? false}))
     :response (fn [ctx]
                 (let [asciicast (-> ctx :properties ::asciicast)
@@ -85,8 +84,7 @@
                                        time (assoc :snapshot-at time)
                                        theme (assoc :theme theme)
                                        scale (assoc :scale (Integer/parseInt scale)))]
-                      {:exists? true
-                       :version (asciicast/png-version asciicast png-params)
+                      {:version (asciicast/png-version asciicast png-params)
                        ::asciicast asciicast
                        ::png-params png-params})
                     {:exists? false}))


use true instead of filename for source maps

--- src/leiningen/new/reagent/project.clj
+++ src/leiningen/new/reagent/project.clj
@@ -61,7 +61,7 @@
                                     :rules :cljs}]}
                    {{/cljx-build?}}
                    :cljsbuild {:builds {:app {:source-paths ["env/dev/cljs"]
-                                              :compiler {:source-map "resources/public/js/out.js.map"}}}}}
+                                              :compiler {:source-map true}}}}}

              :uberjar {:hooks [{{cljx-uberjar-hook}}leiningen.cljsbuild minify-assets.plugin/hooks]
                        :env {:production true}


Change to microsecond resolution in receiver

--- src-clj/tamarack/explorer_api.clj
+++ src-clj/tamarack/explorer_api.clj
@@ -4,6 +4,8 @@
             [tamarack.model :as model]
             [clj-time.format :as time-format]
             [clj-time.coerce :as time-coerce]))
+
+(def USEC->MSEC (/ 1 1000))

 (defn str->uuid [s]
   (java.util.UUID/fromString s))
@@ -20,10 +22,11 @@
   (edn-response (model/application-info app-id)))

 (def chart-map
-  {:ms-per-req (fn [{tot :requests time :total_time}] (if (zero? tot) nil (float (/ time tot))))
+  {:ms-per-req (fn [{tot :requests time :total_time}]
+                 (if (zero? tot) nil (float (* (/ time tot) USEC->MSEC))))
    :reqs-per-min :requests
    :errs-per-req (fn [{tot :requests errs :errors}] (if (zero? tot) nil (float (/ errs tot))))
-   :total-time :total_time})
+   :total-time #(-> % :total_time (* USEC->MSEC))})

 (defn application-chart [app-id chart-type from to]
   (let [data (model/request-data-by-minute app-id from to)


A few fixes in the subs screen for panel opening/closing

--- src/day8/re_frame/trace/view/subs.cljs
+++ src/day8/re_frame/trace/view/subs.cljs
@@ -23,11 +23,11 @@

 ;; TODO: START ========== LOCAL DATA - REPLACE WITH SUBS AND EVENTS

-(def *pods (r/atom [{:type :destroyed :layer "3" :path [:todo/blah]      :open? true :diff? true}
-                    {:type :created   :layer "3" :path [:todo/completed] :open? true :diff? true}
-                    {:type :re-run    :layer "3" :path [:todo/completed] :open? true :diff? true}
-                    {:type :re-run    :layer "2" :path [:todo/blah]      :open? true :diff? true}
-                    {:type :not-run   :layer "3" :path [:todo/blah]      :open? true :diff? true}]
+(def *pods (r/atom [{:id (gensym) :type :destroyed :layer "3" :path [:todo/blah]      :open? true :diff? true}
+                    {:id (gensym) :type :created   :layer "3" :path [:todo/completed] :open? true :diff? true}
+                    {:id (gensym) :type :re-run    :layer "3" :path [:todo/completed] :open? true :diff? true}
+                    {:id (gensym) :type :re-run    :layer "2" :path [:todo/blah]      :open? true :diff? true}
+                    {:id (gensym) :type :not-run   :layer "3" :path [:todo/blah]      :open? true :diff? true}]
                    #_[]))

 (defn update-pod-field
@@ -35,7 +35,7 @@
   (let [f (fn [pod]
             (if (= id (:id pod))
               (do
-                ;(println "Updated" field "in" (:id pod) "from" (get pod field) "to" new-val)
+                (println "Updated" field "in" (:id pod) "from" (get pod field) "to" new-val)
                 (assoc pod field new-val))
               pod))]
     (reset! *pods (mapv f @*pods))))
@@ -122,9 +122,7 @@
                :class  "noselect"
                :style  {:cursor "pointer"}
                :attr   {:title    (str (if open? "Close" "Open") " the pod bay doors, HAL")
-                        :on-click (rc/handler-fn
-                                    (swap! open? not)
-                                    (println "Clicked [arrow]"))}
+                        :on-click (rc/handler-fn (update-pod-field id :open? (not open?)))}
                :child  [rc/box
                         :margin "auto"
                         :child  [:span.arrow (if open? "▼" "▶")]]]


add write times w/o caching

add write times w/o caching

--- bench/transit/bench.cljs
+++ bench/transit/bench.cljs
@@ -8,9 +8,9 @@
 (def json (. fs (readFileSync "../transit/seattle-data0.tjs" "utf8")))
 (def r (t/reader :json))
 (def w (t/writer :json))
+(def w-nc (t/writer :json {:cache false}))

 (println "100 iters, transit read seattle data")
-(println (.read r json))
 (time
   (dotimes [_ 100]
     (.read r json)))
@@ -26,14 +26,16 @@
     (dotimes [_ 100]
       (.write w seattle))))

+(println "100 iters, transit write seattle data no-cache")
+(let [seattle (.read r json)]
+  (time
+    (dotimes [_ 100]
+      (.write w-nc seattle))))
+
+(println (.write w-nc [:foo :foo]))
+
 (println "100 iters, JSON.stringify seattle data")
 (let [seattle (.parse js/JSON json)]
   (time
     (dotimes [_ 100]
       (.stringify js/JSON seattle))))
-
-(println "10 iters, cljs.reader/read-string seattle data")
-(def edn (pr-str (.read r json)))
-(time
-  (dotimes [_ 10]
-    (r/read-string edn)))


remove println

remove println

--- bench/transit/bench.cljs
+++ bench/transit/bench.cljs
@@ -32,8 +32,6 @@
     (dotimes [_ 100]
       (.write w-nc seattle))))

-(println (.write w-nc [:foo :foo]))
-
 (println "100 iters, JSON.stringify seattle data")
 (let [seattle (.parse js/JSON json)]
   (time


simpler strucuture validation

simpler strucuture validation

--- src/celestial/persistency/actions.clj
+++ src/celestial/persistency/actions.clj
@@ -1,25 +1,27 @@
 (ns celestial.persistency.actions
   "Actions persistency"
   (:require
+    [slingshot.slingshot :refer  [throw+]]
     [subs.core :as subs :refer (validate!)]
+    [clojure.core.strint :refer (<<)]
     [puny.core :refer (entity)]))

 (entity action :indices [operates-on])

-(defn find-action-for [action-key type]
+(defn find-action-for [name type]
   (let [ids (get-action-index :operates-on type)
         actions (map #(-> % Long/parseLong  get-action) ids)]
-    (first (filter #(-> % :actions action-key nil? not) actions))))
+    (first (filter #(= (-> % :name) name) actions))))

 (defn cap? [m] (contains? m :capistrano))

-(def cap-nested {:capistrano {:args #{:required :Vector}}})
+(def cap {:args #{:required :Vector}})

 (def action-base-validation
-  {:src #{:required :String} :operates-on #{:required :String :type-exists}})
+  {:src #{:required :String} :operates-on #{:required :String :type-exists}
+   :name #{:required :String}})

-(defn validate-action [{:keys [actions] :as action}]
-  (doseq [[k {:keys [capistrano] :as m}] actions]
-    (when capistrano (validate! m cap-nested :error ::invalid-action)))
-  (validate! action action-base-validation :error ::invalid-nested-action ))
+(defn validate-action [{:keys [capistrano] :as action}]
+  (when capistrano (validate! capistrano cap :error ::invalid-cap-action))
+  (validate! action action-base-validation :error ::invalid-action ))


add assertion

add assertion

--- src/clj/morpheus/models/edge/core.clj
+++ src/clj/morpheus/models/edge/core.clj
@@ -46,6 +46,8 @@
                                     edge-schema-id v2-e-field)
           v1-list-cell-row-id (eb/extract-cell-list-id v1-cell v1-e-field edge-schema-id)
           v2-list-cell-row-id (eb/extract-cell-list-id v2-cell v2-e-field edge-schema-id)]
+      (assert v1-list-cell-row-id)
+      (assert v2-list-cell-row-id)
       (neb/update-cell* v1-list-cell-row-id 'morpheus.models.edge.base/conj-into-list-cell v1-remote)
       (neb/update-cell* v2-list-cell-row-id 'morpheus.models.edge.base/conj-into-list-cell v2-remote)
       (merge edge-cell-vertex-fields


Refactor make-component function

Refactor make-component function

--- core/src/cljc/hellhound/component.cljc
+++ core/src/cljc/hellhound/component.cljc
@@ -84,20 +84,24 @@
 (defn make-component
   "A helper function to create a component map with the given details.

-  Returns a component map with the given, `start-fn`, `stop-fn` and
-  the optional `f` and `dependencies` collection. The function `f` get
-  executed everytime a value is available on the component's input stream."
-  {:added      1.0
-   :public-api true}
-  ([start-fn stop-fn]
-   (make-component start-fn stop-fn nil []))
-  ([start-fn stop-fn f]
-   (make-component start-fn stop-fn f []))
-  ([start-fn stop-fn f dependencies]
-   {::start-fn start-fn
-    ::stop-fn stop-fn
-    ::depends-on dependencies
-    ::fn f}))
+  Returns a component map with the given `componenet-description-map` that
+  is going to be merged with the default values of a componenet. The default
+  values are:
+
+  {:hellhound.component/start-fn (fn [x _] x)
+   :hellhound.component/stop-fn  identity
+   :hellhound.component/depends-on []
+   :hellhound.component/fn identity}
+
+  For more information on components checkout the :hellhoun.component/component
+  spec."
+  [componenet-description-map]
+  (merge
+   {::start-fn default-start-fn
+    ::stop-fn default-stop-fn
+    ::depends-on []
+    ::fn identity}
+   componenet-description-map))

 (defn make-transformer


added get for stage

added get for stage

--- src/hivewing_core/hive_data_stages.clj
+++ src/hivewing_core/hive_data_stages.clj
@@ -371,6 +371,13 @@
     (jdbc/query sql-db ["SELECT * FROM hive_data_processing_stages WHERE hive_uuid = ?" (ensure-uuid hive-uuid)])
     (catch clojure.lang.ExceptionInfo e false)))

+(defn hive-data-stages-get
+  [hive-uuid stage-uuid]
+
+  (try
+    (first (jdbc/query sql-db ["SELECT * FROM hive_data_processing_stages WHERE hive_uuid = ? AND uuid = ? LIMIT 1" (ensure-uuid hive-uuid) (ensure-uuid stage-uuid)]))
+    (catch clojure.lang.ExceptionInfo e false)))
+
 (defn hive-data-stages-create
   [hive-uuid stage-type & params-arr]
   (let [params (apply hash-map params-arr)


s/pret-stem/preterito-stem/

s/pret-stem/preterito-stem/

--- src/babel/espanol/morphology/verbs.clj
+++ src/babel/espanol/morphology/verbs.clj
@@ -503,17 +503,17 @@
         ;; default stem: will be used except under certain conditions, as described in next check.
         stem (string/replace infinitive #"[iae]r$" "")

-        stem (if (get-in word [:pret-stem])
+        stem (if (get-in word [:preterito-stem])
                (cond  (and usted ;; if we in usted mode, and person is 2nd.
                            (= :2nd (get-in word [:agr :person])))
-                      (get-in word [:pret-stem])
+                      (get-in word [:preterito-stem])

                       (and ustedes  ;; if we in ustedes mode, and person is 2nd.
                            (= :2nd (get-in word [:agr :person])))
-                      (get-in word [:pret-stem])
+                      (get-in word [:preterito-stem])

                       (= :3rd (get-in word [:agr :person]))
-                      (get-in word [:pret-stem])
+                      (get-in word [:preterito-stem])
                       true
                       stem)
                stem)


avoid closing over atom in subscription

avoid closing over atom in subscription

--- src/braid/ui/views/pages/recent.cljs
+++ src/braid/ui/views/pages/recent.cljs
@@ -5,7 +5,7 @@
 (defn recent-page-view
   []
   (let [group-id (subscribe [:open-group-id])
-        threads (subscribe [:get-threads-for-group @group-id])
+        threads (subscribe [:get-threads-for-group] [group-id])
         user-id (subscribe [:user-id])]
     (fn []
       (let [sorted-threads


Set unfurl_media to true when posting via Slack

--- src/yetibot/core/adapters/slack.clj
+++ src/yetibot/core/adapters/slack.clj
@@ -45,7 +45,7 @@

 (defn send-msg [msg]
   (slack-chat/post-message (slack-config) *target* msg
-                           {:as_user "true"}))
+                           {:unfurl_media "true" :as_user "true"}))

 (defn send-paste [msg]
   (send-msg msg))


Whitespace fixes in project.clj

Whitespace fixes in project.clj

I'd rather have the code of Chestnut be ugly, than the code that
Chestnut generate be ugly.

--- src/leiningen/new/chestnut/project.clj
+++ src/leiningen/new/chestnut/project.clj
@@ -35,8 +35,7 @@
                                         :preamble      ["react/react.min.js"]
                                         :externs       ["react/externs/react.js"]
                                         :optimizations :none
-                                        :pretty-print  true}}
-                        {{#spec?}}
+                                        :pretty-print  true}}{{#spec?}}
                         :dev {:source-paths ["src/cljs"  "spec/cljs"]
                               :compiler {:output-to     "resources/public/js/app_spec.js"
                                          :output-dir    "resources/public/js/spec"
@@ -45,21 +44,14 @@
                                          :externs       ["react/externs/react.js"]
                                          :optimizations :whitespace
                                          :pretty-print  false}
-                               :notify-command ["phantomjs"  "bin/speclj" "resources/public/js/app_spec.js"]}
-                        {{/spec?}}}
-              {{#spec?}}
-              :test-commands {"test" ["phantomjs" "bin/speclj" "resources/public/js/app_spec.js"]}
-              {{/spec?}}}
-  {{#less?}}
+                               :notify-command ["phantomjs"  "bin/speclj" "resources/public/js/app_spec.js"]}{{/spec?}}}{{#spec?}}
+              :test-commands {"test" ["phantomjs" "bin/speclj" "resources/public/js/app_spec.js"]}{{/spec?}}}{{#less?}}
   :less {:source-paths ["src/less"]
          :target-path "resources/public/css"}
-  {{/less?}}
-
-  {{#sass?}}
+  {{/less?}}{{#sass?}}
   :sassc [{:src "src/scss/style.scss"
            :output-to "resources/public/css/style.css"}]
-  :auto {"sassc"  {:file-pattern  #"\.(scss)$"}}
-  {{/sass?}}
+  :auto {"sassc"  {:file-pattern  #"\.(scss)$"}}{{/sass?}}

   :profiles {:dev {:repl-options {:init-ns {{project-ns}}.server
                                   :nrepl-middleware [cemerick.piggieback/wrap-cljs-repl{{{nrepl-middleware}}}]}
@@ -72,24 +64,18 @@

                    :env {:is-dev true}

-                   :cljsbuild {:builds {:app {:source-paths ["env/dev/cljs"]}}}
+                   :cljsbuild {:builds {:app {:source-paths ["env/dev/cljs"]}}}{{#spec?}}

-                   {{#spec?}}
-                   :dependencies [[speclj "3.1.0"]]
-                   {{/spec?}}
+                   :dependencies [[speclj "3.1.0"]]{{/spec?}}{{#cljx-hook?}}

-                   {{#cljx-hook?}}
-                   :hooks [cljx.hooks]
-                   {{/cljx-hook?}}
-                   {{#cljx-build?}}
+                   :hooks [cljx.hooks]{{/cljx-hook?}}{{#cljx-build?}}
+
                    :cljx {:builds [{:source-paths ["src/cljx"]
                                     :output-path "target/generated/clj"
                                     :rules :clj}
                                    {:source-paths ["src/cljx"]
                                     :output-path "target/generated/cljs"
-                                    :rules :cljs}]}
-                   {{/cljx-build?}}
-                   :cljsbuild {:builds {:app {:source-paths ["env/dev/cljs"]}}}}
+                                    :rules :cljs}]}{{/cljx-build?}}}

              :uberjar {:hooks [{{cljx-uberjar-hook}}leiningen.cljsbuild{{less-hook}}{{sass-hook}}]
                        :env {:production true}


Fixed whitespace

Fixed whitespace

--- src/leiningen/new/figwheel/project.clj
+++ src/leiningen/new/figwheel/project.clj
@@ -18,23 +18,23 @@
   :source-paths ["src"]

   :cljsbuild {
-              :builds [{:id "dev"
-                        :source-paths ["src"]
-                        :compiler {:output-to "resources/public/js/compiled/{{sanitized}}.js"
-                                   :output-dir "resources/public/js/compiled/out"
-                                   :optimizations :none
-                                   :source-map true
-                                   :source-map-timestamp true
-                                   :cache-analysis true }}
-                       {:id "min"
-                        :source-paths ["src"]
-                        :compiler {:output-to "resources/public/{{sanitized}}.min.js"
+    :builds [{:id "dev"
+              :source-paths ["src"]
+              :compiler {:output-to "resources/public/js/compiled/{{sanitized}}.js"
+                         :output-dir "resources/public/js/compiled/out"
+                         :optimizations :none
+                         :source-map true
+                         :source-map-timestamp true
+                         :cache-analysis true }}
+             {:id "min"
+              :source-paths ["src"]
+              :compiler {:output-to "resources/public/{{sanitized}}.min.js"
                                    :optimizations :advanced
                                    :pretty-print false}}]}

   :figwheel {
              :http-server-root "public" ;; default and assumes "resources"
-             :server-port 3449          ;; default
+             :server-port 3449 ;; default
              :css-dirs ["resources/public/css"] ;; watch and update CSS

              ;; Server Ring Handler (optional)


transfer-possible predicate broken out.

transfer-possible predicate broken out.

--- src/clj/elephantdb/common/domain.clj
+++ src/clj/elephantdb/common/domain.clj
@@ -274,13 +274,18 @@
                (shard-set domain))
     (.succeedVersion local-store version)))

+(defn transfer-possible?
+  [domain version]
+  (and (not (has-version? domain version))
+       (-> (:remote-store domain)
+           (has-version? version))))
+
 ;; TODO: Do we have the right semantics here for loading?
 (defn update-domain!
   [{:keys [remote-store] :as domain} rw-lock
    & {:keys [throttle version]
       :or {version (.mostRecentVersion remote-store)}}]
-  (when (and (not (has-version? domain version))
-             (has-version? (:remote-store domain) version))
+  (when (transfer-possible? domain version)
     (status/to-loading domain)
     (transfer-version! domain version :throttle throttle)
     (load-version! version rw-lock)


working on the evergreen problem of making generation faster

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -21,11 +21,21 @@
 (def ^:const shufflefn
   (fn [x]
     ;; deterministic generation:
-;;    x
-    ;; nondeterministic generation
-    (lazy-seq (shuffle x))
-
-    ))
+    (cond
+      false
+      (take 1 x)
+
+      false
+      (shuffle (take 10 x))
+
+      false
+      (if (not (empty? x))
+        (cons (rand-nth x) x)
+        x)
+
+      true
+      ;; nondeterministic generation
+      (lazy-seq (shuffle x)))))

 (declare add-comp-to-bolts)
 (declare add-comps-to-bolt)
@@ -160,25 +170,28 @@
       (do (log/trace (str "no compiled bolts found for: " search-for-key))
           (lazy-seq (lightning-bolts model spec 0 depth))))))

+;; a 'lightning bolts' is a dag that
+;; has among paths, paths like [:head :head :head] and
+;; pictorially look like:
+;;
+;;
+;;   H        H    H
+;;    \      /      \
+;;     H    H        H        ...
+;;    /      \        \
+;;   H        ..       ..
+;;    \
+;;     ..
+;;
+;; Each bolt has has a head child.
+;; Each head child may be a leaf or
+;; otherwise has a child with the same two
+;; possibilities: either it's a leaf or itself
+;; a bolt, up to the maximum depth.
 (defn lightning-bolts
   "Return every possible bolt for the given model and spec. Start at the given depth and
    keep generating until the given max-depth is reached."
   [model spec depth max-depth & [use-candidate-parents]]
-  ;; 'lightning bolts' look like:
-  ;;
-  ;;
-  ;;   H        H    H
-  ;;    \      /      \
-  ;;     H    H        H        ...
-  ;;    /      \        \
-  ;;   H        ..       ..
-  ;;    \
-  ;;     ..
-  ;;
-  ;; Each bolt is a tree with only one child per parent: the head child.
-  ;; Each head child may be a leaf or
-  ;; otherwise has a child with the same two options (leaf or a head child),
-  ;; up to the maximum depth.
   (log/debug (str "lightning-bolts: depth="
                   depth "; spec=" (dag_unify.core/strip-refs spec)))
   (if (and (< depth max-depth)
@@ -188,25 +201,7 @@
               (let [filtered
                     (->>
                      (:grammar model)
-                     (map (fn [rule]
-                            (let [result (unify rule spec)]
-                              (cond (= :fail result)
-                                    (log/debug (str "rule:" (:rule rule)
-                                                    " => "
-                                                    "FAIL between:"
-                                                    (:rule rule)
-                                                    " and: "
-                                                    (strip-refs spec)
-                                                    "; fail path:"
-                                                    (dag_unify.core/fail-path
-                                                     rule
-                                                     spec)))
-                                    true
-                                    (log/debug (str "rule:" (:rule rule)
-                                                    " OK for spec:"
-                                                    (dag_unify.core/strip-refs
-                                                     spec))))
-                              result)))
+                     (map #(unify % spec))
                      (filter #(not (= :fail %)))
                      (shufflefn))]
                 (if (empty? filtered)
@@ -229,13 +224,14 @@
                        (assoc-in candidate-parent [:head] head))))
            (lightning-bolts model spec depth max-depth (rest candidate-parents))))
         []))
-    (let [lexemes
-          (shufflefn (get-lexemes model spec))]
+    (let [lexemes (shufflefn (get-lexemes model spec))]
       (if (empty? lexemes)
         (log/debug (str "lightning-bolts: no lexemes at depth: " depth
                         " for spec: " (dag_unify.core/strip-refs spec)))
-        (log/debug (str "lightning-bolts: one or more lexemes at depth: " depth
-                        " for spec: " (dag_unify.core/strip-refs spec))))
+        (log/debug (str "lightning-bolts at depth: " depth
+                        " first lexeme:" "'"
+                        ((:morph model) (first lexemes))
+                        "'")))
       lexemes)))

 (defn add-comps-to-bolt
@@ -319,14 +315,18 @@
                 (not (= :verb (get-in % [:synsem :cat])))))
    (map
     (fn [lexeme]
-      (do
+      (let [result (unify lexeme spec)]
         (log/debug (str "get-lexemes: testing lexeme: "
-                        (dag_unify.core/strip-refs lexeme)))
-        (let [result (unify lexeme spec)]
-          (if (= result :fail)
-            (log/debug (str "fail-path:"
-                            (dag_unify.core/fail-path lexeme spec))))
-          result))))
+                        "'" ((:morph model) lexeme) "'"
+                        (str " "
+                             (if (= result :fail)
+                               (let [fail-path
+                                     (dag_unify.core/fail-path lexeme spec)]
+                                 {:fail-path (:fail-path fail-path)
+                                  :lexeme (:val1 fail-path)
+                                  :spec (:val2 fail-path)})
+                               "ok."))))
+        result)))
    (filter #(not (= :fail %)))))

 (defn show-spec [spec]


remove depth check

remove depth check

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -105,8 +105,7 @@
 (defn comp-paths-to-bolts-map
   "return a map between the set of all complements in the given _bolt_,and the lazy sequence of bolts for that spec."
   [bolt model depth max-depth]
-  (if (and (not (nil? bolt))
-           (< depth max-depth))
+  (if (and (not (nil? bolt)))
     (let [comp-paths (find-comp-paths bolt)]
       (if (not (empty? comp-paths))
         (let [debug (log/trace (str "comp-paths-to-bolts-map: start: "


(defn add-comps) should return a lazy-seq

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -125,21 +125,22 @@
   "given a bolt, return the lazy sequence of all bolts derived from this bolt after adding,
    at each supplied path in comp-paths, the bolts for that path."
   [bolt model comp-paths bolts-at-paths depth max-depth & [top-bolt path-from-top]]
-  (let [top-bolt (or top-bolt bolt)]
-    (if (empty? comp-paths)
-      [bolt] ;; done: we've added all the comps to the bolt, so just return the bolt as a singleton vector.
-      ;; else, more comp-paths to go.
-      (flatten
-       (mapfn #(add-comps % model
-                          (rest comp-paths)
-                          (rest bolts-at-paths)
-                          depth max-depth top-bolt path-from-top)
-              (let [path (first comp-paths)
-                    bolts-at (first bolts-at-paths)]
+  (lazy-seq
+   (let [top-bolt (or top-bolt bolt)]
+     (if (empty? comp-paths)
+       [bolt] ;; done: we've added all the comps to the bolt, so just return the bolt as a singleton vector.
+       ;; else, more comp-paths to go.
+       (flatten
+        (mapfn #(add-comps % model
+                           (rest comp-paths)
+                           (rest bolts-at-paths)
+                           depth max-depth top-bolt path-from-top)
+               (let [path (first comp-paths)
+                     bolts-at (first bolts-at-paths)]
                 (flatten
                  (mapfn #(let [bolt (assoc-in bolt path %)]
                            (add-bolt-at top-bolt bolt path % model depth max-depth))
-                  bolts-at))))))))
+                        bolts-at)))))))))

 (defn add-bolt-at [top-bolt bolt path bolt-at model depth max-depth]
   (lazy-seq


+(declare find-comp-paths)

+(declare find-comp-paths)

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -91,8 +91,10 @@
        (lightning-bolts language-model spec 0 total-depth :max-total-depth max-total-depth)
        (add-all-comps language-model total-depth false max-total-depth spec)))))

+(declare find-comp-paths)
+
 (defn comp-paths-for-comp-bolts [bolt model depth max-depth]
-  (let [comp-paths (babel.generate/find-comp-paths bolt)]
+  (let [comp-paths (find-comp-paths bolt)]
     (zipmap
      comp-paths
      (map #(lightning-bolts


~(defn add-to-bolt-at-path): rewrite for clarity

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -181,14 +181,16 @@
      (comp-paths (- depth 1)))))

 (defn add-to-bolt-at-path
-  "find all complements for bolt at given path, and create a partial tree: bolt + complement => partial tree"
+  "generate all complements for bolt at given path, and create a partial tree: bolt + complement => partial tree"
   [bolt path model]
-  (map #(let [partial-tree
-              (dag_unify.core/assoc-in! (dag_unify.core/copy bolt) path %)]
-          (if (:default-fn model)
-            ((:default-fn model) partial-tree)
-            partial-tree))
-       (gen (get-in bolt path) model 0)))
+  (->>
+   (gen (get-in bolt path) model 0) ;; generate all complements for _bolt_ at _path_.
+   (map #(let [partial-tree
+               (dag_unify.core/assoc-in! (dag_unify.core/copy bolt) path %)] ;; add the complement to the bolt at _path_.
+           ;; apply model's :default-fn, if any.
+           (if (:default-fn model)
+             ((:default-fn model) partial-tree)
+             partial-tree)))))

 (defn get-lexemes [model spec]
   "Get lexemes matching the spec. Use a model's index if available, where the index is a function that we call with _spec_ to get a set of indices. otherwise use the model's entire lexeme."


use default field value in absence of explicit projections

--- pigpen-cascading/src/main/clojure/pigpen/cascading.clj
+++ pigpen-cascading/src/main/clojure/pigpen/cascading.clj
@@ -93,7 +93,7 @@
         udf (first (map :udf code-defs))
         fields (if field-projections
                  (cfields (map #(cascading-field (:alias %)) field-projections))
-                 Fields/UNKNOWN)
+                 (cfields ["value"]))
         cogroup-opts (get-in flowdef [:cogroup-opts pipe])]
     (if-not (nil? cogroup-opts)
       (let [buffer (case (:group-type cogroup-opts)


cleanup

cleanup

--- test/babel/test/es.clj
+++ test/babel/test/es.clj
@@ -9,7 +9,6 @@
             [clojure.test :refer :all]
             [clojure.tools.logging :as log]
             [dag-unify.core :refer [get-in]]))
-

 (deftest generate-conditional
   (let [result (engine/generate {:synsem {:subcat '()


Add license header to file

Add license header to file

--- src/clj/com/climate/claypoole/lazy.clj
+++ src/clj/com/climate/claypoole/lazy.clj
@@ -1,3 +1,16 @@
+;; The Climate Corporation licenses this file to you under under the Apache
+;; License, Version 2.0 (the "License"); you may not use this file except in
+;; compliance with the License.  You may obtain a copy of the License at
+;;
+;;   http://www.apache.org/licenses/LICENSE-2.0
+;;
+;; See the NOTICE file distributed with this work for additional information
+;; regarding copyright ownership.  Unless required by applicable law or agreed
+;; to in writing, software distributed under the License is distributed on an
+;; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+;; or implied.  See the License for the specific language governing permissions
+;; and limitations under the License.
+
 (ns com.climate.claypoole.lazy
   (:refer-clojure :exclude [future future-call pcalls pmap pvalues])
   (:require [com.climate.claypoole :as cp]


Additional functions for testing

Additional functions for testing

--- src/clj/funstructor/funstruct_base.clj
+++ src/clj/funstructor/funstruct_base.clj
@@ -7,7 +7,10 @@
    "(= (+ 2 2) 5)"

    :identity
-   "(defn [x] x)"
+   "(defn id [x] x)"
+
+   :multiply-by-x
+   "(defn mult [a b] (* a b))"

    :abs
    "(defn abs [x] (if (pos? x) x (- x)))"


New tests: test-get-prod-test-job-suffix1/2

--- test/emender_jenkins/config_test.clj
+++ test/emender_jenkins/config_test.clj
@@ -426,6 +426,23 @@
             (get-stage-test-jobs-suffix {:configuration nil}) nil
             (get-stage-test-jobs-suffix nil) nil)))

+(deftest test-get-prod-test-jobs-suffix-1
+    "Check the behaviour of function emender-jenkins.config/get-prod-test-jobs-suffix."
+    (testing "the behaviour of function emender-jenkins.config/get-prod-test-jobs-suffix."
+        (are [x y] (= x y)
+            (get-prod-test-jobs-suffix {:configuration {:jobs {:prod-test-jobs-suffix nil}}})   nil
+            (get-prod-test-jobs-suffix {:configuration {:jobs {:prod-test-jobs-suffix false}}}) false
+            (get-prod-test-jobs-suffix {:configuration {:jobs {:prod-test-jobs-suffix true}}})  true
+            (get-prod-test-jobs-suffix {:configuration {:jobs {:prod-test-jobs-suffix "xyzzy"}}}) "xyzzy")))
+
+(deftest test-get-prod-test-jobs-suffix-2
+    "Check the behaviour of function emender-jenkins.config/get-prod-test-jobs-suffix."
+    (testing "the behaviour of function emender-jenkins.config/get-prod-test-jobs-suffix."
+        (are [x y] (= x y)
+            (get-prod-test-jobs-suffix {:configuration {:jobs nil}}) nil
+            (get-prod-test-jobs-suffix {:configuration nil}) nil
+            (get-prod-test-jobs-suffix nil) nil)))
+
 (deftest test-override-options-by-cli-1
     "Check the behaviour of function emender-jenkins.config/override-options-by-cli."
     (testing "the behaviour of function emender-jenkins.config/override-options-by-cli."


format currency values

format currency values

--- src/cljs/clj_money/views/accounts.cljs
+++ src/cljs/clj_money/views/accounts.cljs
@@ -1,8 +1,7 @@
 (ns clj-money.views.accounts
   (:require [reagent.core :as r]
             [reagent-forms.core :refer [bind-fields]]
-            ; TODO Figure out why this isn't loading correctly
-            #_[reagent.format :refer [currency-format]]
+            [reagent.format :refer [currency-format]]
             [secretary.core :as secretary :include-macros true]
             [cljs-time.format :as f]
             [clj-money.api.commodities :as commodities]
@@ -209,7 +208,7 @@
   [:tr
    [:td.text-right (f/unparse-local (f/formatter "M/d/yyyy") (:transaction-date item))]
    [:td (:description item)]
-   [:td.text-right #_(currency-format (:value item))]])
+   [:td.text-right (currency-format (:value item))]])

 (defn- items-table
   [items]


Make public interface easier to understand

--- src/cljs/cljs-physics-engine/core.cljs
+++ src/cljs/cljs-physics-engine/core.cljs
@@ -109,8 +109,8 @@
         (not (= (count ps) (count (into #{} (map :id ps))))) "All particles must have unique :id keys"
         :else nil))

-(defn step-forward [env connections t ps]
-  (let [error (validate env ps)]
+(defn step-forward [env connections time-step particles]
+  (let [error (validate env particles)]
     (if (not (nil? error))
       {:error error}
-      {:particles (into [] (map (partial update-particle env t ps) ps))})))
+      {:particles (into [] (map (partial update-particle env time-step particles) particles))})))


Make the site components contain a button

--- src/cljs/comic_reader/pages/sites.cljs
+++ src/cljs/comic_reader/pages/sites.cljs
@@ -4,7 +4,14 @@
             [secretary.core :refer [dispatch!]]))

 (defn manga-site [site-data]
-  ^{:key (:id site-data)} [:li (:name site-data)])
+  ^{:key (:id site-data)}
+  [:li
+   [:input {:type "button"
+            :value (:name site-data)
+            :on-click #(.log js/console
+                        (str "You clicked the "
+                             (:id site-data)
+                             " button!"))}]])

 (defn site-list [sites]
   [:div


Use less defs, missing fact call

Use less defs, missing fact call

--- test/onyx/log/leave_cluster_test.clj
+++ test/onyx/log/leave_cluster_test.clj
@@ -4,17 +4,12 @@
             [onyx.system]
             [midje.sweet :refer :all]))

-(def entry (create-log-entry :leave-cluster {:id :c}))
-
-(def f (partial extensions/apply-log-entry entry))
-
-(def rep-diff (partial extensions/replica-diff entry))
-
-(def rep-reactions (partial extensions/reactions entry))
-
-(def old-replica {:pairs {:a :b :b :c :c :a} :peers [:a :b :c]})
-
-(let [new-replica (f old-replica)
+(let [entry (create-log-entry :leave-cluster {:id :c})
+      f (partial extensions/apply-log-entry entry)
+      rep-diff (partial extensions/replica-diff entry)
+      rep-reactions (partial extensions/reactions entry)
+      old-replica {:pairs {:a :b :b :c :c :a} :peers [:a :b :c]}
+      new-replica (f old-replica)
       diff (rep-diff old-replica new-replica)]
   (fact (get-in new-replica [:pairs :a]) => :b)
   (fact (get-in new-replica [:pairs :b]) => :a)
@@ -22,82 +17,65 @@
   (fact diff => {:died :c :updated-watch {:observer :b :subject :a}})
   (fact (rep-reactions old-replica new-replica diff {:id :a}) => nil))

-(def entry (create-log-entry :leave-cluster {:id :b}))
-
-(def f (partial extensions/apply-log-entry entry))
-
-(def rep-diff (partial extensions/replica-diff entry))
-
-(def rep-reactions (partial extensions/reactions entry))
-
-(def old-replica {:pairs {:a :b :b :a} :peers [:a :b]})
-
-(let [new-replica (f old-replica)
+(let [entry (create-log-entry :leave-cluster {:id :b})
+      f (partial extensions/apply-log-entry entry)
+      rep-diff (partial extensions/replica-diff entry)
+      rep-reactions (partial extensions/reactions entry)
+      old-replica {:pairs {:a :b :b :a} :peers [:a :b]}
+      new-replica (f old-replica)
       diff (rep-diff old-replica new-replica)]
   (fact (get-in new-replica [:pairs :a]) => nil)
   (fact (get-in new-replica [:pairs :b]) => nil)
   (fact diff => {:died :b :updated-watch {:observer :a :subject :a}})
   (fact (rep-reactions old-replica new-replica diff {:id :a}) => nil))

-(def entry (create-log-entry :leave-cluster {:id :d}))
-
-(def f (partial extensions/apply-log-entry entry))
-
-(def rep-diff (partial extensions/replica-diff entry))
-
-(def rep-reactions (partial extensions/reactions entry))
-
-(def old-replica {:job-scheduler :onyx.job-scheduler/round-robin
-                  :pairs {:a :b :b :c :c :d :d :a}
-                  :peers [:a :b :c :d]
-                  :jobs [:j1 :j2]
-                  :task-schedulers {:j1 :onyx.task-scheduler/round-robin
-                                    :j2 :onyx.task-scheduler/round-robin}
-                  :tasks {:j1 [:t1] :j2 [:t2]}
-                  :allocations {:j1 {:t1 [:a :b]}
-                                :j2 {:t2 [:c :d]}}})
-
-(let [new-replica (f old-replica)
+(let [entry (create-log-entry :leave-cluster {:id :d})
+      f (partial extensions/apply-log-entry entry)
+      rep-diff (partial extensions/replica-diff entry)
+      rep-reactions (partial extensions/reactions entry)
+      old-replica {:job-scheduler :onyx.job-scheduler/round-robin
+                   :pairs {:a :b :b :c :c :d :d :a}
+                   :peers [:a :b :c :d]
+                   :jobs [:j1 :j2]
+                   :task-schedulers {:j1 :onyx.task-scheduler/round-robin
+                                     :j2 :onyx.task-scheduler/round-robin}
+                   :tasks {:j1 [:t1] :j2 [:t2]}
+                   :allocations {:j1 {:t1 [:a :b]}
+                                 :j2 {:t2 [:c :d]}}}
+      new-replica (f old-replica)
       diff (rep-diff old-replica new-replica)]
-  (:allocations (f old-replica)) => {:j1 {:t1 [:a :b]} :j2 {:t2 [:c]}}
+  (fact (:allocations (f old-replica)) => {:j1 {:t1 [:a :b]} :j2 {:t2 [:c]}})
   (fact (rep-reactions old-replica new-replica diff {:id :a}) => nil)
   (fact (rep-reactions old-replica new-replica diff {:id :b}) => nil)
   (fact (rep-reactions old-replica new-replica diff {:id :c}) => nil))

-(def entry (create-log-entry :leave-cluster {:id :c}))
-
-(def f (partial extensions/apply-log-entry entry))
-
-(def rep-diff (partial extensions/replica-diff entry))
-
-(def rep-reactions (partial extensions/reactions entry))
-
-(def old-replica {:job-scheduler :onyx.job-scheduler/round-robin
-                  :pairs {:a :b :b :c :c :a}
-                  :peers [:a :b :c]
-                  :jobs [:j1 :j2]
-                  :task-schedulers {:j1 :onyx.task-scheduler/round-robin
-                                    :j2 :onyx.task-scheduler/round-robin}
-                  :tasks {:j1 [:t1] :j2 [:t2]}
-                  :allocations {:j1 {:t1 [:a :b]} :j2 {:t2 [:c]}}})
-
-(let [new-replica (f old-replica)
+(let [entry (create-log-entry :leave-cluster {:id :c})
+      f (partial extensions/apply-log-entry entry)
+      rep-diff (partial extensions/replica-diff entry)
+      rep-reactions (partial extensions/reactions entry)
+      old-replica {:job-scheduler :onyx.job-scheduler/round-robin
+                   :pairs {:a :b :b :c :c :a}
+                   :peers [:a :b :c]
+                   :jobs [:j1 :j2]
+                   :task-schedulers {:j1 :onyx.task-scheduler/round-robin
+                                     :j2 :onyx.task-scheduler/round-robin}
+                   :tasks {:j1 [:t1] :j2 [:t2]}
+                   :allocations {:j1 {:t1 [:a :b]} :j2 {:t2 [:c]}}}
+      new-replica (f old-replica)
       diff (rep-diff old-replica new-replica)]
-  (:allocations (f old-replica)) => {:j1 {:t1 [:a :b]} :j2 {:t2 []}}
+  (fact (:allocations (f old-replica)) => {:j1 {:t1 [:a :b]} :j2 {:t2 []}})
   (fact (rep-reactions old-replica new-replica diff {:id :a}) => nil)
   (fact (rep-reactions old-replica new-replica diff {:id :b})
-        => [{:fn :volunteer-for-task :args {:id :b}}]))
+        => [{:fn :volunteer-for-task :args {:id :b}}])

-(def old-replica {:job-scheduler :onyx.job-scheduler/round-robin
-                  :pairs {:a :b :b :c :c :a}
-                  :peers [:a :b :c]
-                  :jobs [:j1 :j2]
-                  :task-schedulers {:j1 :onyx.task-scheduler/round-robin
-                                    :j2 :onyx.task-scheduler/round-robin}
-                  :tasks {:j1 [:t1] :j2 [:t2]}
-                  :allocations {:j1 {:t1 [:a :b]} :j2 {:t2 [:c]}}
-                  :sealing-tasks {:t2 :c}})
-
-(let [new-replica (f old-replica)]
-  (:sealing-tasks new-replica) => {})
-
+  (let [old-replica2 {:job-scheduler :onyx.job-scheduler/round-robin
+                      :pairs {:a :b :b :c :c :a}
+                      :peers [:a :b :c]
+                      :jobs [:j1 :j2]
+                      :task-schedulers {:j1 :onyx.task-scheduler/round-robin
+                                        :j2 :onyx.task-scheduler/round-robin}
+                      :tasks {:j1 [:t1] :j2 [:t2]}
+                      :allocations {:j1 {:t1 [:a :b]} :j2 {:t2 [:c]}}
+                      :sealing-tasks {:t2 :c}}
+        new-replica2 (f old-replica2)]
+    (fact (:sealing-tasks new-replica2) => {})))


Fix tests when operating w/o an endpoint

--- test/taoensso/faraday/tests/main.clj
+++ test/taoensso/faraday/tests/main.clj
@@ -125,32 +125,32 @@
 ;; (expect (interaction (println Long))      (println 5))

 ;;; Test AWSCredentialProvider
-(let [i0 {:id 0 :name "foo"}
-      i1 {:id 1 :name "bar"}
-      i2 {:id 2 :name "baz"}
-      creds    (BasicAWSCredentials. (:access-key *client-opts*)
-                                     (:secret-key *client-opts*))
-      provider (StaticCredentialsProvider. creds)
-      endpoint (:endpoint *client-opts*)]
+(when-let [endpoint (:endpoint *client-opts*)]
+  (let [i0 {:id 0 :name "foo"}
+        i1 {:id 1 :name "bar"}
+        i2 {:id 2 :name "baz"}
+        creds    (BasicAWSCredentials. (:access-key *client-opts*)
+                   (:secret-key *client-opts*))
+        provider (StaticCredentialsProvider. creds)]

-  (binding [*client-opts* {:provider provider
-                           :endpoint endpoint}]
+    (binding [*client-opts* {:provider provider
+                             :endpoint endpoint}]

-    (expect ; Batch put
-      [i0 i1 nil]
-      (do
-        (far/batch-write-item *client-opts*
-          {ttable {:delete [{:id 0} {:id 1} {:id 2}]}})
-        ;;
-        (far/batch-write-item *client-opts* {ttable {:put [i0 i1]}})
-        [(far/get-item *client-opts* ttable {:id  0})
-         (far/get-item *client-opts* ttable {:id  1})
-         (far/get-item *client-opts* ttable {:id -1})]))))
+      (expect ; Batch put
+        [i0 i1 nil]
+        (do
+          (far/batch-write-item *client-opts*
+            {ttable {:delete [{:id 0} {:id 1} {:id 2}]}})
+          ;;
+          (far/batch-write-item *client-opts* {ttable {:put [i0 i1]}})
+          [(far/get-item *client-opts* ttable {:id  0})
+           (far/get-item *client-opts* ttable {:id  1})
+           (far/get-item *client-opts* ttable {:id -1})])))))

 ;;; Test `list-tables` lazy sequence
 ;; Creates a _large_ number of tables so only run locally
-(let [endpoint (:endpoint *client-opts*)]
-  (when (and endpoint (.contains ^String endpoint "localhost"))
+(when-let [endpoint (:endpoint *client-opts*)]
+  (when (.contains ^String endpoint "localhost")
     (expect
       (let [;; Generate > 100 tables to exceed the batch size limit:
             tables (map #(keyword (str "test_" %)) (range 102))]


✅ Test that all commands wrap UUIDs in (foreign-key/references)

Why:
- Will detect if new commands are added where the foreign key check is
  missing
- Does not recurse into schemas, but only checks the top-level values

--- test/territory_bro/commands_test.clj
+++ test/territory_bro/commands_test.clj
@@ -48,7 +48,15 @@

     (testing "unknown command type"
       ;; TODO: produce a helpful error message
-      (is (s/check commands/Command unknown-command)))))
+      (is (s/check commands/Command unknown-command)))
+
+    (testing "all UUIDs are foreign-key checked"
+      (doseq [[type schema] commands/command-schemas]
+        (doseq [[key val] schema]
+          ;; there should not be a schema where the value is a plain UUID
+          ;; instead of a (foreign-key/references :stuff UUID)
+          (is (not= UUID val)
+              (str "command " type " key " (pr-str key) " is missing a (foreign-key/references) check")))))))

 (deftest validate-command-test
   (binding [foreign-key/*reference-checkers* testutil/dummy-reference-checkers]


Use 'case' with integers instead of 'cond'

This may yield a slight performance improvement, but it is barely
measurable.

--- src/main/clojure/clojure/data/json.clj
+++ src/main/clojure/clojure/data/json.clj
@@ -23,49 +23,67 @@

 ;;; JSON READER

-(defmacro ^{:private true} codepoint [c]
+(defmacro ^:private codepoint [c]
   (int c))

 (declare read-json-reader)
+
+(defn- codepoint-clause [[test result]]
+  (cond (list? test)
+          [(map int test) result]
+        (= test :whitespace)
+          ['(9 10 13 32) result]
+        (= test :simple-ascii)
+          [(remove #{(codepoint \") (codepoint \\) (codepoint \/)}
+                   (range 32 127))
+           result]
+        :else
+          [(int test) result]))
+
+(defmacro ^:private codepoint-case [e & clauses]
+   `(case ~e
+      ~@(mapcat codepoint-clause (partition 2 clauses))
+      ~@(when (odd? (count clauses))
+          [(last clauses)])))

 (defn- read-json-array [^PushbackReader stream keywordize?]
   ;; Expects to be called with the head of the stream AFTER the
   ;; opening bracket.
   (loop [c (.read stream), result (transient [])]
     (when (neg? c) (throw (EOFException. "JSON error (end-of-file inside array)")))
-    (cond
-     (Character/isWhitespace c) (recur (.read stream) result)
-     (= c (codepoint \,)) (recur (.read stream) result)
-     (= c (codepoint \])) (persistent! result)
-     :else (do (.unread stream c)
-               (let [element (read-json-reader stream keywordize? true nil)]
-                 (recur (.read stream) (conj! result element)))))))
+    (codepoint-case c
+      :whitespace (recur (.read stream) result)
+      \, (recur (.read stream) result)
+      \] (persistent! result)
+      (do (.unread stream c)
+          (let [element (read-json-reader stream keywordize? true nil)]
+            (recur (.read stream) (conj! result element)))))))

 (defn- read-json-object [^PushbackReader stream keywordize?]
   ;; Expects to be called with the head of the stream AFTER the
   ;; opening bracket.
   (loop [c (.read stream), key nil, result (transient {})]
     (when (neg? c) (throw (EOFException. "JSON error (end-of-file inside array)")))
-    (cond
-     (Character/isWhitespace c) (recur (.read stream) key result)
-
-     (= c (codepoint \,)) (recur (.read stream) nil result)
-
-     (= c (codepoint \:)) (recur (.read stream) key result)
-
-     (= c (codepoint \})) (if (nil? key)
-                            (persistent! result)
-                            (throw (Exception. "JSON error (key missing value in object)")))
-
-     :else (do (.unread stream c)
-               (let [element (read-json-reader stream keywordize? true nil)]
-                 (if (nil? key)
-                   (if (string? element)
-                     (recur (.read stream) element result)
-                     (throw (Exception. "JSON error (non-string key in object)")))
-                   (recur (.read stream) nil
-                          (assoc! result (if keywordize? (keyword key) key)
-                                  element))))))))
+    (codepoint-case c
+     :whitespace (recur (.read stream) key result)
+
+     \, (recur (.read stream) nil result)
+
+     \: (recur (.read stream) key result)
+
+     \} (if (nil? key)
+           (persistent! result)
+           (throw (Exception. "JSON error (key missing value in object)")))
+
+     (do (.unread stream c)
+         (let [element (read-json-reader stream keywordize? true nil)]
+           (if (nil? key)
+             (if (string? element)
+               (recur (.read stream) element result)
+               (throw (Exception. "JSON error (non-string key in object)")))
+             (recur (.read stream) nil
+                    (assoc! result (if keywordize? (keyword key) key)
+                            element))))))))

 (defn- read-json-hex-character [^PushbackReader stream]
   ;; Expects to be called with the head of the stream AFTER the
@@ -83,14 +101,14 @@
   ;; Expects to be called with the head of the stream AFTER the
   ;; initial backslash.
   (let [c (.read stream)]
-    (cond
-     (#{(codepoint \") (codepoint \\) (codepoint \/)} c) (char c)
-     (= c (codepoint \b)) \backspace
-     (= c (codepoint \f)) \formfeed
-     (= c (codepoint \n)) \newline
-     (= c (codepoint \r)) \return
-     (= c (codepoint \t)) \tab
-     (= c (codepoint \u)) (read-json-hex-character stream))))
+    (codepoint-case c
+      (\" \\ \/) (char c)
+      \b \backspace
+      \f \formfeed
+      \n \newline
+      \r \return
+      \t \tab
+      \u (read-json-hex-character stream))))

 (defn- read-json-quoted-string [^PushbackReader stream]
   ;; Expects to be called with the head of the stream AFTER the
@@ -98,12 +116,12 @@
   (let [buffer (StringBuilder.)]
     (loop [c (.read stream)]
       (when (neg? c) (throw (EOFException. "JSON error (end-of-file inside array)")))
-      (cond
-       (= c (codepoint \")) (str buffer)
-       (= c (codepoint \\)) (do (.append buffer (read-json-escaped-character stream))
-                                (recur (.read stream)))
-       :else (do (.append buffer (char c))
-                 (recur (.read stream)))))))
+      (codepoint-case c
+          \" (str buffer)
+          \\ (do (.append buffer (read-json-escaped-character stream))
+                 (recur (.read stream)))
+          (do (.append buffer (char c))
+              (recur (.read stream)))))))

 (defn- read-json-reader
   ([^PushbackReader stream keywordize? eof-error? eof-value]
@@ -112,50 +130,49 @@
 	 (if eof-error?
 	   (throw (EOFException. "JSON error (end-of-file)"))
 	   eof-value)
-	 (cond
-          ;; Ignore whitespace
-          (Character/isWhitespace c) (recur (.read stream))
-
-          ;; Read numbers, true, and false with Clojure reader
-          (#{(codepoint \-) (codepoint \0) (codepoint \1) (codepoint \2) (codepoint \3) (codepoint \4) (codepoint \5) (codepoint \6) (codepoint \7) (codepoint \8) (codepoint \9)} c)
-          (do (.unread stream c)
-              (read stream true nil))
-
-          ;; Read strings
-          (= c (codepoint \")) (read-json-quoted-string stream)
-
-          ;; Read null as nil
-          (= c (codepoint \n)) (let [ull [(char (.read stream))
-                                          (char (.read stream))
-                                          (char (.read stream))]]
-                                 (if (= ull [\u \l \l])
-                                   nil
-                                   (throw (Exception. (str "JSON error (expected null): " c ull)))))
-
-          ;; Read true
-          (= c (codepoint \t)) (let [rue [(.read stream)
-                                          (.read stream)
-                                          (.read stream)]]
-                                 (if (= rue [(codepoint \r) (codepoint \u) (codepoint \e)])
-                                   true
-                                   (throw (Exception. (str "JSON error (expected true): " c rue)))))
-
-          ;; Read false
-          (= c (codepoint \f)) (let [alse [(.read stream)
-                                           (.read stream)
-                                           (.read stream)
-                                           (.read stream)]]
-                                 (if (= alse [(codepoint \a) (codepoint \l) (codepoint \s) (codepoint \e)])
-                                   false
-                                   (throw (Exception. (str "JSON error (expected false): " c alse)))))
-
-          ;; Read JSON objects
-          (= c (codepoint \{)) (read-json-object stream keywordize?)
-
-          ;; Read JSON arrays
-          (= c (codepoint \[)) (read-json-array stream keywordize?)
-
-          :else (throw (Exception. (str "JSON error (unexpected character): " (char c)))))))))
+	 (codepoint-case c
+           :whitespace (recur (.read stream))
+
+           ;; Read numbers with Clojure reader
+           (\- \0 \1 \2 \3 \4 \5 \6 \7 \8 \9)
+           (do (.unread stream c)
+               (read stream true nil))
+
+           ;; Read strings
+           \" (read-json-quoted-string stream)
+
+           ;; Read null as nil
+           \n (let [ull [(.read stream)
+                         (.read stream)
+                         (.read stream)]]
+                (if (= ull [(codepoint \u) (codepoint \l) (codepoint \l)])
+                  nil
+                  (throw (Exception. (str "JSON error (expected null): " c ull)))))
+
+           ;; Read true
+           \t (let [rue [(.read stream)
+                         (.read stream)
+                         (.read stream)]]
+                (if (= rue [(codepoint \r) (codepoint \u) (codepoint \e)])
+                  true
+                  (throw (Exception. (str "JSON error (expected true): " c rue)))))
+
+           ;; Read false
+           \f (let [alse [(.read stream)
+                          (.read stream)
+                          (.read stream)
+                          (.read stream)]]
+                (if (= alse [(codepoint \a) (codepoint \l) (codepoint \s) (codepoint \e)])
+                  false
+                  (throw (Exception. (str "JSON error (expected false): " c alse)))))
+
+           ;; Read JSON objects
+           \{ (read-json-object stream keywordize?)
+
+           ;; Read JSON arrays
+           \[ (read-json-array stream keywordize?)
+
+           (throw (Exception. (str "JSON error (unexpected character): " (char c)))))))))

 (defprotocol Read-JSON-From
   (read-json-from [input keywordize? eof-error? eof-value]
@@ -203,24 +220,24 @@
     (.append sb \")
     (dotimes [i (count s)]
       (let [cp (int (.charAt s i))]
-        (cond
-         ;; Handle printable JSON escapes before ASCII
-         (= cp 34) (.append sb "\\\"")
-         (= cp 92) (.append sb "\\\\")
-         (= cp 47) (.append sb "\\/")
-         ;; Print simple ASCII characters
-         (< 31 cp 127) (.append sb (.charAt s i))
-         ;; Handle non-printable JSON escapes
-         (= cp 8) (.append sb "\\b")
-         (= cp 12) (.append sb "\\f")
-         (= cp 10) (.append sb "\\n")
-         (= cp 13) (.append sb "\\r")
-         (= cp 9) (.append sb "\\t")
-	 ;; Any other character is Unicode
-         :else (if escape-unicode?
-		 ;; Hexadecimal-escaped
-		 (.append sb (format "\\u%04x" cp))
-		 (.appendCodePoint sb cp)))))
+        (codepoint-case cp
+          ;; Handle printable JSON escapes before ASCII
+          \" (.append sb "\\\"")
+          \\ (.append sb "\\\\")
+          \/ (.append sb "\\/")
+          ;; Print simple ASCII characters
+          :simple-ascii (.append sb (.charAt s i))
+          ;; Handle JSON escapes
+          \backspace (.append sb "\\b")
+          \formfeed  (.append sb "\\f")
+          \newline   (.append sb "\\n")
+          \return    (.append sb "\\r")
+          \tab       (.append sb "\\t")
+          ;; Any other character is Unicode
+          (if escape-unicode?
+            ;; Hexadecimal-escaped
+            (.append sb (format "\\u%04x" cp))
+            (.appendCodePoint sb cp)))))
     (.append sb \")
     (.print out (str sb))))


pull dec to top of read-quoted-string

pull dec to top of read-quoted-string

--- src/main/clojure/clojure/data/json.clj
+++ src/main/clojure/clojure/data/json.clj
@@ -95,7 +95,8 @@
   ;; Expects to be called with the head of the stream AFTER the
   ;; opening quotation mark.
   (let [buffer ^chars (char-array 64)
-        read (.read stream buffer 0 64)]
+        read (.read stream buffer 0 64)
+        end-index (unchecked-dec-int read)]
     (when (neg? read)
       (throw (EOFException. "JSON error (end-of-file inside string)")))
     (loop [i (int 0)]
@@ -109,7 +110,7 @@
                    len (unchecked-subtract-int read off)]
                (.unread stream buffer off len)
                (slow-read-string stream (String. buffer 0 i)))
-          (if (= i (dec read))
+          (if (= i end-index)
             (do (.unread stream c)
                 (slow-read-string stream (String. buffer 0 i)))
             (recur (unchecked-inc-int i))))))))


TCLI-91 replace some interop

TCLI-91 replace some interop

clojure.string/starts-with? is Clojure 1.8+

--- src/main/clojure/clojure/tools/cli.clj
+++ src/main/clojure/clojure/tools/cli.clj
@@ -82,13 +82,13 @@
   (s/replace k #"^--no-|^--\[no-\]|^--|^-" ""))

 (defn- flag-for [^String v]
-  (not (.startsWith v "--no-")))
+  (not (s/starts-with? v "--no-")))

 (defn- opt? [^String x]
-  (.startsWith x "-"))
+  (s/starts-with? x "-"))

 (defn- flag? [^String x]
-  (.startsWith x "--[no-]"))
+  (s/starts-with? x "--[no-]"))

 (defn- end-of-args? [x]
   (= "--" x))
@@ -141,10 +141,14 @@
 (defn- switches-for
   [switches flag]
   (-> (for [^String s switches]
-        (cond
-         (and flag (flag? s))            [(s/replace s #"\[no-\]" "no-") (s/replace s #"\[no-\]" "")]
-         (and flag (.startsWith s "--")) [(s/replace s #"--" "--no-") s]
-         :default                        [s]))
+        (cond (and flag (flag? s))
+              [(s/replace s #"\[no-\]" "no-") (s/replace s #"\[no-\]" "")]
+
+              (and flag (s/starts-with? s "--"))
+              [(s/replace s #"--" "--no-") s]
+
+              :default
+              [s]))
       flatten))

 (defn- generate-spec


add Function record type

add Function record type

--- src/bract/core/type.clj
+++ src/bract/core/type.clj
@@ -16,6 +16,13 @@
   (iargs [this] "Return the additional arguments to be passed to the function"))

+(defrecord Function [func name args]
+  IFunction
+  (ifunc [this] func)
+  (iname [this] name)
+  (iargs [this] args))
+
+
 (defn function?
   [x]
   (satisfies? IFunction x))


Don't fail on invalid test results retrieved from Go

--- src/buildviz/gosync.clj
+++ src/buildviz/gosync.clj
@@ -227,12 +227,15 @@
   (flush))

 (defn put-to-buildviz [builds]
-  (doseq [{jobName :jobName buildNo :buildNo build :build junit-xml-func :junit-xml-func} builds]
+  (doseq [{job-name :jobName build-no :buildNo build :build junit-xml-func :junit-xml-func} builds]
     (dot)
-    (log/info (format "Syncing %s %s: build" jobName buildNo build))
-    (put-build jobName buildNo  build)
+    (log/info (format "Syncing %s %s: build" job-name build-no build))
+    (put-build job-name build-no  build)
     (when (some? junit-xml-func)
-      (put-junit-xml jobName buildNo (junit-xml-func)))))
+      (try
+        (put-junit-xml job-name build-no (junit-xml-func))
+        (catch Exception e
+          (log/warn (format "Unable to sync testresults for %s %s" job-name build-no)))))))

 ;; run


Refacto - Display the list of functions.

--- src/app/cljs/one/sample/view.cljs
+++ src/app/cljs/one/sample/view.cljs
@@ -163,7 +163,7 @@
                       #(dispatch/fire :ns-clicked {:ns (parent-ns all-ns ns-nav)})))
       (set-styles! prev {:display "none"}))))

-(defn- display-ns "Display namespaces"
+(defn- display-lns "Display namespaces"
   [lns]
   (let [nsn (by-id "ns-nav")]
     (when lns
@@ -179,17 +179,9 @@
                            "click"
                            #(dispatch/fire :ns-clicked {:ns n}))) lns)))))

-(defmethod render-fnx :ns-navigating [{:keys [all-ns ns-nav]}]
-  (let [lns-fns (ls-curr-ns all-ns ns-nav)
-        fns (second lns-fns)
-        fnd (by-id "fn-display")]
-
-    (hide-spinner)
-
-    (previous-ns-block all-ns ns-nav)
-
-    (display-ns (first lns-fns))
-
+(defn- display-fns "Display functions list"
+  [fns]
+  (let [fnd (by-id "fn-display")]
     (when fns
       ;; show the function block
       (set-styles! fnd {:display "block" :color "blue"})
@@ -203,6 +195,13 @@
                            "click"
                            #(dispatch/fire :fn-clicked {:fn f}))) fns)))))

+(defmethod render-fnx :ns-navigating [{:keys [all-ns ns-nav]}]
+  (let [lns-fns (ls-curr-ns all-ns ns-nav)]
+    (hide-spinner)
+    (previous-ns-block all-ns ns-nav)
+    (display-lns (first lns-fns))
+    (display-fns (second lns-fns))))
+
 (dispatch/react-to #{:state-change-fnx} (fn [_ m] (render-fnx m)))

 ;; ------------- fnx -------------


support :log-chan option in watch

support :log-chan option in watch

lets user customize the log output in embedded environments

--- src/main/shadow/cljs/devtools/api.clj
+++ src/main/shadow/cljs/devtools/api.clj
@@ -190,18 +190,21 @@
     :ok))

 (defn watch*
-  [{:keys [build-id] :as build-config} {:keys [verbose sync] :as opts}]
+  [{:keys [build-id] :as build-config}
+   {:keys [verbose sync log-chan log-close?]
+    :or {log-close? true}
+    :as opts}]
   {:pre [(map? build-config)
          (keyword? build-id) ;; not required here but by start-worker
          (map? opts)]}
-  (let [out (util/stdout-dump verbose)
+  (let [out (or log-chan (util/stdout-dump verbose))

         autobuild?
         (and (not (false? (:autobuild opts)))
              (not (false? (get-in build-config [:devtools :autobuild]))))]

     (-> (start-worker build-config opts)
-        (worker/watch out true)
+        (worker/watch out log-close?)
         (cond->
           autobuild?
           (worker/start-autobuild)
@@ -354,6 +357,15 @@
       (build/optimize)
       (build/flush)
       (build-finish build-config)))
+
+(defn release!
+  ([build]
+   (release! build {}))
+  ([build opts]
+   (with-runtime
+     (let [build-config (config/get-build! build)]
+       (release* build-config opts)))
+   :done))

 (defn release
   ([build]


Another little bug, ordering is important here and I'm not that happy with it...

--- desktop/src-common/ds3/main_screen.clj
+++ desktop/src-common/ds3/main_screen.clj
@@ -81,12 +81,12 @@
         (:enemy? entity2) (enemy/handle-collision entity2 entity screen entities)
         (:ship? entity) (ship/handle-collision entity entity2 screen entities)
         (:ship? entity2) (ship/handle-collision entity2 entity screen entities)
+        (:mini? entity) (enemy/handle-mini-collision entity entity2 screen entities)
+        (:mini? entity2) (enemy/handle-mini-collision entity2 entity screen entities)
         (:bullet? entity) (bullet/handle-collision entity entity2 screen entities)
         (:bullet? entity2) (bullet/handle-collision entity2 entity screen entities)
         (:bomb? entity) (bomb/handle-collision entity entity2 screen entities)
         (:bomb? entity2) (bomb/handle-collision entity2 entity screen entities)
-        (:mini? entity) (enemy/handle-mini-collision entity entity2 screen entities)
-        (:mini? entity2) (enemy/handle-mini-collision entity2 entity screen entities)
         )))

   :on-timer


Print summary when generating site

Print summary when generating site

--- resources/leiningen/new/jcf_static/src/jcf/service.clj
+++ resources/leiningen/new/jcf_static/src/jcf/service.clj
@@ -85,6 +85,7 @@
   []
   (let [assets (optimizations/all (get-assets) {})
         pages (get-pages)]
+    (println (format "Generating %s page(s) to %s..." (count pages) target-dir))
     (stasis/empty-directory! target-dir)
     (optimus.export/save-assets assets target-dir)
     (stasis/export-pages pages target-dir {:optimus-assets assets})))