(PDB-5216) query-eng: rename options to context in a few places

Match some of our previous naming changes to use context for broader
information as with the service context, e.g. the database,
node-purge-ttl, etc.

--- src/puppetlabs/puppetdb/query_eng.clj
+++ src/puppetlabs/puppetdb/query_eng.clj
@@ -187,7 +187,7 @@
   (->> (or (System/getenv "PDB_USE_DEPRECATED_QUERY_STREAMING_METHOD") "yes")
        (re-matches #"yes|true|1") seq not))

-(def query-options-schema
+(def query-context-schema
   {:scf-read-db s/Any
    :url-prefix String
    :node-purge-ttl Period
@@ -205,7 +205,7 @@
   ([version :- s/Keyword
     query
     options
-    context :- query-options-schema
+    context :- query-context-schema
     row-fn]
    (let [{:keys [scf-read-db url-prefix warn-experimental pretty-print log-queries]
           :or {warn-experimental true
@@ -360,13 +360,13 @@
      :stream stream}))

 (defn preferred-produce-streaming-body
-  [version query-map options]
+  [version query-map context]
   (let [{:keys [scf-read-db url-prefix warn-experimental pretty-print log-queries]
          :or {warn-experimental true
               pretty-print false
-              log-queries false}} options
+              log-queries false}} context
         log-id (when log-queries (str (java.util.UUID/randomUUID)))
-        query-config (select-keys options [:node-purge-ttl :add-agent-report-filter])
+        query-config (select-keys context [:node-purge-ttl :add-agent-report-filter])
         {:keys [query remaining-query entity query-options]}
         (user-query->engine-query version query-map query-config warn-experimental)]

@@ -402,13 +402,13 @@
 (def munge-fn-hook identity)

 (defn- deprecated-produce-streaming-body
-  [version query-map options]
+  [version query-map context]
   (let [{:keys [scf-read-db url-prefix warn-experimental pretty-print log-queries]
          :or {warn-experimental true
               pretty-print false
-              log-queries false}} options
+              log-queries false}} context
         log-id (when log-queries (str (java.util.UUID/randomUUID)))
-        query-config (select-keys options [:node-purge-ttl :add-agent-report-filter])
+        query-config (select-keys context [:node-purge-ttl :add-agent-report-filter])
         {:keys [query remaining-query entity query-options]}
         (user-query->engine-query version query-map query-config warn-experimental)]

@@ -471,10 +471,10 @@
    If the query can't be parsed, a 400 is returned."
   [version :- s/Keyword
    query-map
-   options :- query-options-schema]
+   context :- query-context-schema]
   (if use-preferred-streaming-method?
-    (preferred-produce-streaming-body version query-map options)
-    (deprecated-produce-streaming-body version query-map options)))
+    (preferred-produce-streaming-body version query-map context)
+    (deprecated-produce-streaming-body version query-map context)))

 (pls/defn-validated object-exists? :- s/Bool
   "Returns true if an object exists."


use vector syntax over (vec '())

use vector syntax over (vec '())


start work on blinking

start work on blinking

--- dada-swt/src/main/clojure/org/dada/swt/nattable.clj
+++ dada-swt/src/main/clojure/org/dada/swt/nattable.clj
@@ -7,8 +7,9 @@
   [org.eclipse.swt.widgets Display Shell]
   [ca.odell.glazedlists GlazedLists SortedList]
   [net.sourceforge.nattable NatTable]
+  [net.sourceforge.nattable.blink BlinkLayer]
   [net.sourceforge.nattable.config ConfigRegistry DefaultNatTableStyleConfiguration]
-  [net.sourceforge.nattable.data ListDataProvider IColumnPropertyAccessor]
+  [net.sourceforge.nattable.data ListDataProvider IColumnPropertyAccessor IRowIdAccessor]
   [net.sourceforge.nattable.extension.glazedlists GlazedListsEventLayer GlazedListsSortModel]
   [net.sourceforge.nattable.grid.data DefaultColumnHeaderDataProvider DefaultCornerDataProvider DefaultRowHeaderDataProvider]
   [net.sourceforge.nattable.grid.layer ColumnHeaderLayer CornerLayer DefaultColumnHeaderDataLayer DefaultRowHeaderDataLayer GridLayer RowHeaderLayer]
@@ -29,8 +30,12 @@

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

+;; Basic Table
 ;; see http://nattable.org/drupal/docs/basicgrid
+;; Sorted Table
 ;; see http://nattable.svn.sourceforge.net/viewvc/nattable/trunk/nattable/net.sourceforge.nattable.examples/src/net/sourceforge/nattable/examples/demo/SortableGridExample.java?revision=3912&view=markup
+;; Blinking Table
+;; http://nattable.svn.sourceforge.net/viewvc/nattable/trunk/nattable/net.sourceforge.nattable.examples/src/net/sourceforge/nattable/examples/demo/BlinkingGridExample.java?revision=3912&view=markup

 ;;--------------------------------------------------------------------------------
 ;; Plugging data
@@ -66,13 +71,21 @@
 ;;--------------------------------------------------------------------------------
 ;; Setting up the body region

+(def config-registry (ConfigRegistry.))
+
 (def body-data-layer (DataLayer. body-data-provider))

 (def glazed-lists-event-layer (GlazedListsEventLayer. body-data-layer event-list))

-(def body-layer-stack (DefaultBodyLayerStack. glazed-lists-event-layer))
+(def blink-layer
+     (BlinkLayer.
+      glazed-lists-event-layer
+      body-data-provider
+      (proxy [IRowIdAccessor][](#^Serializable getRowId [#^Collection row] (first row)))
+      column-property-accessor
+      config-registry))

-(def config-registry (ConfigRegistry.))
+(def body-layer-stack (DefaultBodyLayerStack. blink-layer))

 ;;--------------------------------------------------------------------------------
 ;; Setting up the column header region


RS | Use korma's defdb method for managing postgres connection pool for tests to hopefully prevent connections running out

--- integration/objective8/integration_helpers.clj
+++ integration/objective8/integration_helpers.clj
@@ -2,6 +2,7 @@
   (:require [net.cgrand.enlive-html :as html]
             [midje.sweet :as midje]
             [korma.core :as korma]
+            [korma.db :as kormadb]
             [peridot.core :as p]
             [cheshire.core :as json]
             [objective8.core :as core]
@@ -9,7 +10,7 @@
             [objective8.storage.database :as db]
             [midje.sweet :as midje]))

-(defn db-connection [] (db/connect! db/postgres-spec))
+(defn db-connection [] (kormadb/defdb testdb db/postgres-spec))

 (defn truncate-tables []
   (korma/delete m/bearer-token)


Fix bug where string-editor was initialized with every render causing focus problems

--- src/reabledit/components.cljs
+++ src/reabledit/components.cljs
@@ -91,6 +91,8 @@
                             (disable-edit!))}
                [:span value]])]]))})))

+(defonce default-editor (string-editor))
+
 ;;
 ;; Dependencies for the main component
 ;;
@@ -122,7 +124,7 @@
       :on-click #(move-to-cell!)
       :on-double-click #(enable-edit!)}
      (if edited?
-       [(or (:editor column) (string-editor))
+       [(or (:editor column) default-editor)
         (get-in @state [:edit :updated])
         (:key column)
         #(swap! state assoc-in [:edit :updated] %)


Add :checked-arrays docs

Add :checked-arrays docs

Closes #574

--- sidecar/src/figwheel_sidecar/schemas/cljs_options.clj
+++ sidecar/src/figwheel_sidecar/schemas/cljs_options.clj
@@ -617,10 +617,18 @@
   :language-in :es6
   :rewrite-polyfills true")

-;; TODO waiting on docs
 (def-key ::checked-arrays (s/or :keyval #{:warn :error}
                                 :false   false?
-                                :nil    nil?))
+                                :nil    nil?)
+  "If set to :warn or :error, checks inferred types and runtime values passed
+to aget and aset. Inferred type mismatches will result in the
+:invalid-array-access warning being triggered. Logs when incorrect values
+are passed if set to :warn, throws if set to :error. May be set to a
+false-y value to disable this feature.
+
+This setting does not apply if :optimizations is set to :advanced.
+
+  :checked-arrays :warn")

 ;; ** ClojureScript Compiler Warnings


fix typo in documentation

fix typo in documentation

--- src/babel/espanol/morphology.cljc
+++ src/babel/espanol/morphology.cljc
@@ -293,7 +293,7 @@
      expr)))

 (defn stem-per-passato-prossimo [infinitive]
-  "_infinitive_ should be a string (italian verb infinitive form)"
+  "_infinitive_ should be a string (verb infinitive form)"
   (string/replace infinitive #"^(.*)([aei])(re)$" (fn [[_ prefix vowel suffix]] (str prefix))))

 (defn passato-prossimo [infinitive]


Add tests for IDeref to maybe.

Add tests for IDeref to maybe.

--- spec/cats/monad/maybe_spec.cljx
+++ spec/cats/monad/maybe_spec.cljx
@@ -22,6 +22,10 @@
   (s/it "get-value function"
     (s/should= (p/get-value (maybe/just 1)) 1)
     (s/should= (p/get-value (maybe/nothing)) nil))
+
+  (s/it "Test IDeref"
+    (s/should= nil @(maybe/nothing))
+    (s/should= 1 @(maybe/just 1)))

   (s/it "Test predicates"
     (let [m1 (maybe/just 1)]


Add endpoint that returns all templates as transit

--- src/clj/clj_templates/handler.clj
+++ src/clj/clj_templates/handler.clj
@@ -1,18 +1,33 @@
 (ns clj-templates.handler
   (:require [compojure.core :refer [GET routes]]
             [compojure.route :refer [resources]]
-            [ring.util.response :refer [resource-response]]
+            [ring.util.response :refer [resource-response response]]
             [ring.logger.timbre :refer [wrap-with-logger]]
             [ring.middleware.defaults :refer [site-defaults wrap-defaults]]
             [ring.util.http-response :refer [content-type ok]]
-            [integrant.core :as ig]))
+            [clj-templates.db.db :as db]
+            [integrant.core :as ig]
+            [cognitect.transit :as transit])
+  (:import (java.io ByteArrayOutputStream)))
+
+(defn transit-json [v]
+  (let [out (ByteArrayOutputStream. 4096)
+        _ (-> out
+              (transit/writer :json)
+              (transit/write v))
+        res (.toString out)]
+    (.reset out)
+    res))

 (defn home-page []
-  (content-type (resource-response "index.html" {:root "public"}) "text/html; charset=utf-8"))
+  (-> (resource-response "index.html" {:root "public"})
+      (content-type "text/html; charset=utf-8")))

-;; TODO: Get from db
 (defn templates [db]
-  "Templates")
+  (let [all-templates {:templates (db/all-templates db)}
+        transit-templates (transit-json all-templates)]
+    (-> (response transit-templates)
+        (content-type "application/transit+json"))))

 (defn app-routes [db]
   (routes


link attachments in list

link attachments in list

--- src/clj_money/web/attachments.clj
+++ src/clj_money/web/attachments.clj
@@ -19,7 +19,9 @@
 (defn- attachment-row
   [attachment]
   [:tr
-   [:td (:caption attachment)]
+   [:td
+    [:a {:href (format "/images/%s" (:image-id attachment))}
+     (:caption attachment)]]
    [:td "&nbsp"]])

 (defn index


Make rats easier to kill

Make rats easier to kill

--- src/cljc/robinson/monstergen.cljc
+++ src/cljc/robinson/monstergen.cljc
@@ -130,8 +130,8 @@
   ;;        |               |  |  |                |                |    | | |     |     |    toughness
   ;;        |               |  |  |                |                |    | | |     |     |    | body-parts                                  attacks                       temperament             movement policy                        range-threshold
   ;;        |               |  |  |                |                |    | | |     |     |    | |                                           |                             |                       |                                       | status
-  (Monster. :rat            1  90 "rat"            "rats"           nil  6 0 0.9   0.2   2    1 #{:face :head :neck :body :leg :tail}       #{:bite :claw}                :hostile                :follow-player-in-range-or-random       8 #{:hostile})
-  (Monster. :gecko          1 110 "gecko"          "geckos"         nil  9 0 0.9   0.2   2    1 #{:head :face :body :tail :leg}             #{:bite}                      :hostile-after-sound    :follow-player-in-range-or-random       4 #{:hostile})
+  (Monster. :rat            1  90 "rat"            "rats"           nil  4 0 0.9   0.2   2    1 #{:face :head :neck :body :leg :tail}       #{:bite :claw}                :hostile                :follow-player-in-range-or-random       8 #{:hostile})
+  (Monster. :gecko          1 130 "gecko"          "geckos"         nil  9 0 0.9   0.2   2    1 #{:head :face :body :tail :leg}             #{:bite}                      :hostile-after-sound    :follow-player-in-range-or-random       4 #{:hostile})
   (Monster. :bird           1 130 "bird"           "birds"          nil  7 0 2.1   1     3    2 #{:head :body :tail :leg :beak :wing}       #{:bite :claw}                :retreat-after-sound    :random                                 8 #{:docile})
   (Monster. :mosquito       2 180 "mosquito"       "mosquitoes"     nil  5 0 1.4   0.01  3    2 #{:head :body :leg :wing}                   #{:bite}                      :hostile-after-attacked :follow-player-in-range-or-random       3 #{:hostile})
   (Monster. :spider         2 120 "spider"         "spiders"        nil  6 0 0.9   0.1   3    2 #{:face :leg :abdomen}                      #{:bite-venom}                :retreat-after-attacked :follow-player-in-range-or-random       5 #{:docile})


redirect to firecloud.terra.bio not app.terra.bio (#1528)

--- src/cljs/main/broadfcui/main.cljs
+++ src/cljs/main/broadfcui/main.cljs
@@ -209,7 +209,7 @@
       (let [{:keys [terra-redirect make-props]} props
             url-snippet (terra-redirect (make-props))
             query-marker (if (string/includes? url-snippet "?") "&" "?")
-            redir (str (config/terra-url) "/#" url-snippet query-marker "fcredir=1")]
+            redir (str (config/firecloud-terra-url) "/#" url-snippet query-marker "fcredir=1")]
         (js-invoke (aget js/window "location") "replace" redir)))})

 (react/defc- App


Add alias for ctr mode.

Add alias for ctr mode.

--- src/clojure/buddy/core/crypto.clj
+++ src/clojure/buddy/core/crypto.clj
@@ -16,6 +16,7 @@
   *supported-modes* {:ecb #(identity %)
                      :cbc #(CBCBlockCipher. %)
                      :ctr #(SICBlockCipher. %)
+                     :sic #(SICBlockCipher. %)
                      :ofb #(OFBBlockCipher. %1 (* 8 (.getBlockSize %1)))})

 (def ^{:doc "Supported block ciphers."


allow reserved Javascript words to be used as build ids

--- sidecar/src/figwheel_sidecar/build_middleware/injection.clj
+++ sidecar/src/figwheel_sidecar/build_middleware/injection.clj
@@ -19,7 +19,7 @@

 (defn figwheel-connect-ns-parts [{:keys [id]}]
   (cond-> ["figwheel" "connect"]
-    (and id (name-like? id)) (conj (name id))))
+    (and id (name-like? id)) (conj (str "build-" (name id)))))

 (defn underscore [cljs-path-name]
   (string/replace cljs-path-name "-" "_"))


Strip off prefixes like refs/heads/ from branch and tag names

--- src/web/components/state_chooser.cljs
+++ src/web/components/state_chooser.cljs
@@ -1,5 +1,6 @@
 (ns web.components.state-chooser
-  (:require [om.next :as om :refer-macros [defui]]
+  (:require [clojure.string :as str]
+            [om.next :as om :refer-macros [defui]]
             [om.dom :as dom]))

 (defui StateChooserItem
@@ -17,7 +18,9 @@
           :branch "b "
           :tag "t "
           " ")
-        name))))
+        (str/replace name
+                     #"refs/heads/|refs/remotes/|refs/tags/"
+                     "")))))

 (def state-chooser-item (om/factory StateChooserItem {:keyfn :id}))


Review comment: prefer dissoc and update to destructuring.

--- src/common/datomish/transact.cljc
+++ src/common/datomish/transact.cljc
@@ -474,7 +474,8 @@

   First, resolve :upserts-e against the database.  Some [a v] -> e will upsert; some will not.
   Some :upserts-e evolve to become actual :upserts (they upserted!); any other :upserts-e evolve to
-  become :allocations-e (they did not upsert, and will not upsert this transaction).
+  become :allocations-e (they did not upsert, and will not upsert this transaction).  All :upserts-e
+  will evolve out of the :upserts-e generation: each one upserts or does not.

   Using the newly upserted id-literals, some :upserts-ev evolve to become :resolved;
   some :upserts-ev evolve to become :upserts-e; and some :upserts-ev remain :upserts-ev.
@@ -490,20 +491,19 @@

   As a future optimization, :upserts do not need to be inserted; they upserted, so they already
   exist in the DB.  (We still need to verify uniqueness and ensure no overlapping can occur.)
-  Similary, :allocations-* do not need to be checked for existence, so they can be written to the DB
+  Similarly, :allocations-* do not need to be checked for existence, so they can be written to the DB
   faster."
   (go-pair
-    (let [{:keys [upserted resolved upserts-ev upserts-e allocations-ev allocations-e allocations-v entities]} evolution]
-      (if-not upserts-e
+    (let [upserts-e (seq (:upserts-e evolution))
+          id->e     (and upserts-e
+                         (<? (<resolve-upserts-e db upserts-e)))]
+      (if-not id->e
         ;; No more progress to be made.  Any upserts-ev must just be allocations.
-        {:allocations-ev (concat upserts-ev allocations-ev)
-         :allocations-e allocations-e
-         :allocations-v allocations-v
-         :upserted upserted
-         :resolved resolved
-         :entities entities}
+        (update
+          (dissoc evolution :upserts-ev :upserts-e)
+          :allocations-ev concat (:upserts-ev evolution))
         ;; Progress can be made.  Try to evolve further.
-        (let [id->e (<? (<resolve-upserts-e db upserts-e))]
+        (let [{:keys [upserted resolved upserts-ev allocations-ev allocations-e allocations-v entities]} evolution]
           (merge-with
             concat
             {:tempids  id->e ;; TODO: ensure we handle conflicting upserts across generations correctly here.


Bring back one more test

Bring back one more test

--- test/clojure/clojurewerkz/cassaforte/cql_test.clj
+++ test/clojure/clojurewerkz/cassaforte/cql_test.clj
@@ -435,21 +435,25 @@
                 (map :episode_id)
                 set)))))

-;; (deftest test-insert-with-consistency-level
-;;   (let [r {:name "Alex" :city "Munich" :age (int 19)}]
-;;     (client/execute s
-;;                     "INSERT INTO users (name, city, age) VALUES ('Alex', 'Munich', 19);"
-;;                     :consistency-level (cp/consistency-level :quorum))
-;;     (is (= r (get-one s :users)))
-;;     (truncate s :users)))
-
-;; (deftest test-insert-with-forced-prepared-statements
-;;   (comment
-;;     (let [r {:name "Alex" :city "Munich" :age (int 19)}]
-;;       (client/forcing-prepared-statements
-;;        (insert s :users r))
-;;       (is (= r (get-one s :users)))
-;;       (truncate s :users))))
+(deftest test-insert-with-consistency-level
+  (let [r {:name "Alex" :city "Munich" :age (int 19)}]
+    (client/execute *session*
+                    "INSERT INTO users (name, city, age) VALUES ('Alex', 'Munich', 19);"
+                    :consistency-level (cp/consistency-level :quorum))
+    (is (= r (first (select *session* :users (limit 1)))))
+    (truncate *session* :users)))
+
+(deftest test-insert-with-forced-prepared-statements
+  (let [r        {:name "Alex" :city "Munich" :age (int 19)}
+        prepared (client/prepare *session*
+                  (new-query-api/insert :users
+                                        {:name new-query-api/?
+                                         :city new-query-api/?
+                                         :age  new-query-api/?}))]
+    (client/execute *session*
+                    (client/bind prepared
+                                 {:name "Alex" :city "Munich" :age (int 19)}))
+    (is (= r (first (select *session* :users (limit 1)))))))

 ;; (deftest test-insert-without-prepared-statements
 ;;   (comment


Fix indexes tests

Fix indexes tests

--- test/com/wsscode/pathom/connect/indexes_test.cljc
+++ test/com/wsscode/pathom/connect/indexes_test.cljc
@@ -48,11 +48,8 @@

   (is (= (query->ast->io [{:a {:b [:b]
                                :c [:c]}}])
-         {:a {:b {}}})))
-
-(comment
-  (eql/query->ast [{:a {:b [:b]
-                        :c [:c]}}]))
+         {:a {:b {}
+              :c {}}})))

 (deftest test-sub-select-io
   (is (= (pci/sub-select-io {} {})
@@ -119,9 +116,6 @@
          [{:a1 [:b1 {:b2 [{:c3 [:d2]}]}]}])))

 (deftest normalize-io-test
-  (is (= (pci/normalize-io [])
-         {}))
-
   (is (= (pci/normalize-io [:a])
          {:a {}}))


Bugfix

Bugfix

--- src/clj_simple_chart/bp/diagrams/coal_per_capita_sel.clj
+++ src/clj_simple_chart/bp/diagrams/coal_per_capita_sel.clj
@@ -161,7 +161,7 @@
      (axis/render-axis y)
      (axis/render-axis x)
     [:g {:transform (translate-y (+ (:height (meta header)) available-height))} footer]
-    ]])
+    ]]])

 (defn render-self []
   (render "./img/bp-svg/coal-per-capita-sel.svg" "./img/bp-png/coal-per-capita-sel.png" (diagram)))


fixup-stream

fixup-stream

Without a content-type appears to cause httpkit to return :body set to org.httpkit.BytesInputStream
So, convert this to a string to make things work downstream

--- src/ads_txt_crawler/httpkit.clj
+++ src/ads_txt_crawler/httpkit.clj
@@ -12,6 +12,11 @@

 (def client (http/make-client {:ssl-configurer sni-configure}))

+(defn fixup-stream [m]
+  (if (instance? org.httpkit.BytesInputStream (:body m))
+    (let [body (slurp (:body m))]
+      (assoc m :body body))
+    m))

 ;; This produces the following error if called directly with http://elpais.com/ads.txt
 ;; When it redirects to https://elpais.com/ads.txt the following error happens


Prepare for "update"

Prepare for "update"

--- src/clojure/clojurewerkz/cassaforte/new_query_api.clj
+++ src/clojure/clojurewerkz/cassaforte/new_query_api.clj
@@ -267,7 +267,6 @@
          (sort-by #(get order (first %)))
          ;; (map second)
          (reduce (fn [builder [statement-name statement-args]]
-                   (println statement-name)
                    ((get renderers statement-name) builder statement-args))
                  (QueryBuilder/select))
          (.toString)
@@ -295,19 +294,20 @@
   [m]
   [:using m])

+(def ^:private with-values
+  {:timestamp #(QueryBuilder/timestamp %)
+   :ttl       #(QueryBuilder/ttl %)})
 (let [order       {:values        1
                    :value         1
                    :values-vector 1
                    :values-seq    1
                    :using         2
                    :if-not-exists 3}
-      with-values {:timestamp #(QueryBuilder/timestamp %)
-                   :ttl       #(QueryBuilder/ttl %)}
       renderers
       {:value         (fn value-query [query-builder [key value]]
                         (.value query-builder (name key) value))
        :if-not-exists (fn value-query [query-builder _]
-                        (.value query-builder (name key) value))
+                        (.ifNotExists query-builder))
        :values-vector (fn values-query [query-builder m]
                         (.values query-builder (into-array (map name (keys m))) (object-array (vals m))))
        :values-seq    (fn order-by-query [query-builder [key-seq value-seq]]


Implement first approximation of batch statements

--- src/clojure/clojurewerkz/cassaforte/new_query_api.clj
+++ src/clojure/clojurewerkz/cassaforte/new_query_api.clj
@@ -9,6 +9,14 @@
   (:require [clojurewerkz.cassaforte.aliases :as alias]
             clojurewerkz.cassaforte.query.query-builder
             clojurewerkz.cassaforte.query.types))
+
+(def ^:dynamic *batch* false)
+
+(defn maybe-stringify
+  [statement]
+  (if *batch*
+    statement
+    (.toString statement)))

 (alias/alias-ns 'clojurewerkz.cassaforte.query.query-builder)
 (alias/alias-ns 'clojurewerkz.cassaforte.query.types)
@@ -205,7 +213,7 @@
          (reduce (fn [builder [statement-name statement-args]]
                    ((get renderers statement-name) builder statement-args))
                  (QueryBuilder/select))
-         (.toString)
+         (maybe-stringify)
          )))

 ;;
@@ -259,7 +267,7 @@
          (reduce (fn [builder [statement-name statement-args]]
                    ((get renderers statement-name) builder statement-args))
                  (QueryBuilder/insertInto (name table-name)))
-         (.toString))))
+         (maybe-stringify))))

 ;;
 ;; Update Query
@@ -316,7 +324,7 @@
          (reduce (fn [builder [statement-name statement-args]]
                    ((get renderers statement-name) builder statement-args))
                  (QueryBuilder/update (name table-name)))
-         (.toString))))
+         (maybe-stringify))))

 ;;
 ;; Delete Query
@@ -391,7 +399,7 @@
                    (println statement-name)
                    ((get renderers statement-name) builder statement-args))
                  (QueryBuilder/delete))
-         (.toString))))
+         (maybe-stringify))))

 ;;
 ;; Truncate
@@ -403,6 +411,14 @@
   ([table-name keyspace]
      (.toString (QueryBuilder/truncate (name keyspace) (name table-name)))))

+(defmacro batch
+  [statements]
+  `(binding [*batch* true]
+     (let [builder# (QueryBuilder/batch (into-array ~statements))]
+       (.toString builder#)
+       )
+    )
+  )
 ;; Batch batch(RegularStatement... statements)
 ;; Batch unloggedBatch(RegularStatement... statements)
 ;; Truncate truncate(String table)


Extract eq

Extract eq

--- src/clojure/clojurewerkz/cassaforte/new_query_api.clj
+++ src/clojure/clojurewerkz/cassaforte/new_query_api.clj
@@ -47,10 +47,11 @@
   [s]
   (QueryBuilder/quote (name s)))

-(let [eq  (fn [^String column ^Object value]
-            (QueryBuilder/eq column value))
-
-      in  (fn [^String column values]
+(defn eq-
+  [^String column ^Object value]
+  (QueryBuilder/eq column value))
+
+(let [in  (fn [^String column values]
             (QueryBuilder/in column values))

       lt  (fn [^String column ^Object value]
@@ -67,8 +68,8 @@

   (def ^:private query-type-map
     {:in in
-     :=  eq
-     =   eq
+     :=  eq-
+     =   eq-
      :>  gt
      >   gt
      :>= gte


fix last commit

fix last commit

--- src-cljs/cljsbuild_ui/exec.cljs
+++ src-cljs/cljsbuild_ui/exec.cljs
@@ -104,7 +104,7 @@
 ;; Helper
 ;;------------------------------------------------------------------------------

-(def on-windows? (.test js/process.platform #"^win"))
+(def on-windows? (.test #"^win" js/process.platform))

 (defn- project-file->cwd [f]
   (replace f #"project\.clj$" ""))


Display property code under properties table.

--- src-cljs/kixi/hecuba/model.cljs
+++ src-cljs/kixi/hecuba/model.cljs
@@ -48,7 +48,8 @@
                                                     :header   {:cols {:addressStreetTwo {:label "Address" :href "href"}
                                                                       :addressCounty    {:label "County"}
                                                                       :addressCountry   {:label "Country"}
-                                                                      :addressRegion    {:label "Region"}}
+                                                                      :addressRegion    {:label "Region"}
+                                                                      :propertyCode     {:label "Property Code"}}
                                                                :sort [:addressStreetTwo]}
                                                     :data     []
                                                     :selected nil


141 initial commit

141 initial commit

--- stuf/src/sandbox/4clojure.clj
+++ stuf/src/sandbox/4clojure.clj
@@ -1235,3 +1235,6 @@
     (if (= (update sets) sets)
       sets
       (min-set (update sets)))))
+;;141
+(defn [trump]
+  (fn [game] (map identity game)))


Add tests for assert-original-mime-type.

--- test/vignette/util/thumbnail_test.clj
+++ test/vignette/util/thumbnail_test.clj
@@ -91,3 +91,8 @@
 (facts :route-map->thumb-args
        (route-map->thumb-args beach-map) => (contains ["--height" "100" "--width" "100"
                                                       "--mode" "thumbnail"] :in-any-order))
+
+(facts :assert-original-mime-type
+  (assert-original-mime-type "" {}) => nil
+  (assert-original-mime-type "file.jpg" {}) => nil
+  (assert-original-mime-type "file.ogv" {}) => (throws ExceptionInfo))


including reflexive verbs from 'small' language-model, as expected

--- src/babel/italiano/grammar.cljc
+++ src/babel/italiano/grammar.cljc
@@ -597,7 +597,9 @@

                                   (or (and
                                        (= (get-in % [:synsem :cat]) :verb)
-                                       (= (get-in % [:synsem :sem :obj] :unspec) :unspec)) ;; exclude transitive verbs.
+
+                                       (or (= (get-in % [:synsem :sem :obj] :unspec) :unspec) ;; exclude transitive verbs..
+                                           (= (get-in % [:synsem :sem :reflexive] false) true))) ;; ..unless they are reflexive.

                                       (and (= (get-in % [:synsem :propernoun]) true)
                                            (= (get-in % [:synsem :sem :city] false) false)) ;; exclude cities from the small grammar.


add locally-defined lexicon here since I'm using it a lot

--- src/babel/italiano/lexicon.cljc
+++ src/babel/italiano/lexicon.cljc
@@ -53,8 +53,6 @@

 (declare edn2lexicon)

-(def lexicon (edn2lexicon (clojure.java.io/resource "babel/italiano/lexicon.edn")))
-
 ;; TODO: promote to babel.lexiconfn
 ;; also consider renaming babel.lexiconfn to babel.lexicon.
 (defn apply-unify-key [lexicon]
@@ -225,3 +223,5 @@

      ;; TODO: consider doing encyclopedia constraints
      ))
+
+(def lexicon (edn2lexicon (clojure.java.io/resource "babel/italiano/lexicon.edn")))


Change ncstrips progression semantics, make clear effect order.

--- src/edu/berkeley/ai/angelic/ncstrips_descriptions.clj
+++ src/edu/berkeley/ai/angelic/ncstrips_descriptions.clj
@@ -266,6 +266,37 @@
 ;Note that right now, pos-del + add --> add, del + pos-add --> pos-add, del + pos-del --> del.
 ; Right now, undefined if certain + uncertain effects combined (except delete + pos-add).
 ; TODO: enforce constraints?
+
+
+; Current algorithm:
+ ; Apply preconditions
+ ; Apply deletes
+ ; Determine applicable possible-effects
+ ; Apply adds
+ ; Apply possible-effects.
+
+; Current matrix:
+;    d  a pd pa
+;--------------
+;d | d  a  d pb
+;a |    a  I  I
+;pd|      pd pb
+;pa|         pa
+
+; New algorithm:
+ ; Apply preconditions
+ ; Apply deletes
+ ; Apply adds
+ ; Apply possible effects
+;    d  a pd pa
+;--------------
+;d | d  a  d pb
+;a |    a pb  a
+;pd|      pd pb
+;pa|         pa
+
+
+
 (defn- progress-effect-clause [effect clause combiner]
 ;  (println "Progress " effect clause)
   (let [pos-pre (util/safe-get effect :pos-preconditions)
@@ -277,21 +308,18 @@
 ;	(println more-pos-pre more-neg-pre)
 	(when (and (every? clause more-pos-pre)
 		   (every? #(not (= :true (clause %))) more-neg-pre))
-;	  (println "go")
 	  (let [all-pos-pre   (concat more-pos-pre pos-pre)
 		all-neg-pre   (concat more-neg-pre neg-pre)
-		clause        (into (reduce dissoc clause all-neg-pre) (map #(vector % :true) all-pos-pre))
+		after-pre        (into (reduce dissoc clause all-neg-pre) (map #(vector % :true) all-pos-pre))
 		[adds dels]   (apply map concat [(util/safe-get effect :adds) (util/safe-get effect :deletes)]
 				     (map #(% pred-maps) (util/safe-get effect :effect-fns)))
+	       	after-eff     (into (reduce dissoc after-pre dels) (map #(vector % :true) adds))
 		[padds pdels] (apply map concat [(util/safe-get effect :possible-adds) (util/safe-get effect :possible-deletes)]
 				      (map #(% pred-maps) (util/safe-get effect :possible-effect-fns)))
-		after-dels    (reduce dissoc clause dels)
- 		unks          (concat (filter #(not= :true (after-dels %)) padds)
-				      (filter #(= :true (after-dels %))    pdels))]
-	   [(into after-dels
-	      (concat (map #(vector % :true) adds)
-		      (map #(vector % :unknown) unks)))
-	     (- ((util/safe-get effect :cost-fn) pred-maps combiner))]))))))
+ 		unks          (concat (filter #(nil?    (after-eff %)) padds)
+				      (filter #(= :true (after-eff %)) pdels))]
+	   [(into after-eff (map #(vector % :unknown) unks))
+	    (- ((util/safe-get effect :cost-fn) pred-maps combiner))]))))))

 (defn- progress-ncstrips [val desc combiner]
 ;  (println "proggy " val combiner)


I want a fan because it's so hot.

I want a fan because it's so hot.

--- src/clj/freestuffly/scraper.clj
+++ src/clj/freestuffly/scraper.clj
@@ -6,7 +6,7 @@
   (:require [hickory.select :as s]))

 (def ^:private interesting-keywords
-  #"(?i)paint|playstation|camp|emulsion|lamp|ladder|roller|xbox|mac|fish|marine|kitchen|new|unused|ergodox|cherry|programming|roller|suitcase")
+  #"(?i)paint|playstation|camp|emulsion|lamp|ladder|roller|xbox|mac|fish|marine|kitchen|new|unused|ergodox|cherry|programming|roller|suitcase|fan")

 (def ^:private freecycle-group "southwark-freecycle")
 (def ^:private freecycle-results-per-page 100)


fix typo in Progenitor

fix typo in Progenitor

--- src/clj/game/cards-programs.clj
+++ src/clj/game/cards-programs.clj
@@ -406,9 +406,9 @@
    {:abilities [{:label "Install a virus program on Progenitor"
                  :cost [:click 1] :req (req (empty? (:hosted card)))
                  :prompt "Choose a Virus program to install on Progenitor"
-                 :choices :choices {:req #(and (= (:type %) "Program")
-                                               (has? % :subtype "Virus")
-                                               (= (:zone %) [:hand]))}
+                 :choices {:req #(and (= (:type %) "Program")
+                                      (has? % :subtype "Virus")
+                                      (= (:zone %) [:hand]))}
                  :msg (msg "host " (:title target))
                  :effect (effect (gain :memory (:memoryunits target))
                                  (runner-install target {:host-card card}))}


Updates comments in `core-abilities`

Updates comments in `core-abilities`

--- src/clj/game/core-abilities.clj
+++ src/clj/game/core-abilities.clj
@@ -4,9 +4,9 @@
          can-trigger? do-choices do-ability
          psi-game resolve-psi resolve-trace show-select)

-; Functions for implementing card abilities and prompts
-
-; Abilities
+;;;; Functions for implementing card abilities and prompts
+
+;;; Abilities
 (defn resolve-ability
   "Resolves an ability defined by the given ability map. Checks :req functions; shows prompts, psi games,
   traces, etc. as needed; charges costs; invokes :effect functions. All card effects and most engine effects
@@ -61,32 +61,32 @@
   :optional -- shows a 'Yes/No' prompt to let the user decide whether to resolve the ability.
   :end-turn -- if the ability is resolved, then this ability map will be resolved at the end of the turn."

-  ; perhaps the most important function in the game logic
+  ;; perhaps the most important function in the game logic
   [state side ability card targets]
   (when ability
-    ; Is this an optional ability?
+    ;; Is this an optional ability?
     (check-optional state side ability card targets)
-    ; Is this a psi game?
+    ;; Is this a psi game?
     (check-psi state side ability card targets)
-    ; Is this a trace?
+    ;; Is this a trace?
     (check-trace state side ability card targets)
-    ; Ensure this ability can be triggered more than once per turn,
-    ; or has not been yet been triggered this turn.
+    ;; Ensure this ability can be triggered more than once per turn,
+    ;; or has not been yet been triggered this turn.
     (when (can-trigger? state side ability card targets)
       (if (:choices ability)
-        ; It's a prompt!
+        ;; It's a prompt!
         (do-choices state side ability card targets)
-        ; Not a prompt. Trigger the ability.
+        ;; Not a prompt. Trigger the ability.
         (do-ability state side ability card targets)))))

-; Checking functions for resolve-ability
+;;; Checking functions for resolve-ability
 (defn- check-req
   "Check if the requirement is fulfilled, or no requirement present"
   [state side card targets ability]
   (if-let [req (:req ability)]
     (req state side card targets)
-    ; return true if no requirement present
+    ;; return true if no requirement present
     true))

 (defn- check-optional
@@ -126,14 +126,14 @@
         ab (dissoc ability :choices)
         args {:priority priority :cancel-effect cancel-effect}]
    (if (map? choices)
-     ; Two types of choices use maps: select prompts, and :number prompts.
+     ;; Two types of choices use maps: select prompts, and :number prompts.
      (if (:req choices)
-       ; a select prompt
+       ;; a select prompt
        (show-select state s card ability {:priority priority})
-       ; a :number prompt
+       ;; a :number prompt
        (let [n ((:number choices) state side card targets)]
          (prompt! state s card prompt {:number n} ab args)))
-     ; Not a map; either :credit, :counter, or a vector of cards or strings.
+     ;; Not a map; either :credit, :counter, or a vector of cards or strings.
      (let [cs (if-not (fn? choices)
                 choices ; :credit or :counter
                 (let [cards (choices state side card targets)] ; a vector of cards or strings
@@ -146,28 +146,28 @@
   "Perform the ability, checking all costs can be paid etc."
   [state side {:keys [cost counter-cost advance-counter-cost] :as ability}
    {:keys [counter advance-counter] :as card} targets]
-  ; Ensure counter costs can be paid
+  ;; Ensure counter costs can be paid
   (when (and (or (not counter-cost)
                  (<= counter-cost (or counter 0)))
              (or (not advance-counter-cost)
                  (<= advance-counter-cost (or advance-counter 0))))
-    ; Ensure that any costs can be paid.
+    ;; Ensure that any costs can be paid.
     (when-let [cost-str (apply pay (concat [state side card] cost))]
       (let [c (-> card
                   (update-in [:advance-counter] #(- (or % 0) (or advance-counter-cost 0)))
                   (update-in [:counter] #(- (or % 0) (or counter-cost 0))))]
-        ; Remove any counters.
+        ;; Remove any counters.
         (when (or counter-cost advance-counter-cost)
           (update! state side c)
           (when (has? card :type "Agenda")
             (trigger-event state side :agenda-counter-spent card)))
-        ; Print the message.
+        ;; Print the message.
         (print-msg state side ability card targets cost-str)
-        ; Trigger the effect.
+        ;; Trigger the effect.
         (do-effect state side ability c targets)
-        ; Record the :end-turn effect.
+        ;; Record the :end-turn effect.
         (register-end-turn state side ability card targets))
-      ; Record the ability has been triggered if it is restricted to happening once..
+      ;; Record the ability has been triggered if it is restricted to happening once..
       (register-once state ability card))))

 (defn- print-msg
@@ -198,7 +198,7 @@
   (when once (swap! state assoc-in [once (or once-key cid)] true)))

-; Optional Ability
+;;; Optional Ability
 (defn optional-ability
   "Shows a 'Yes/No' prompt and resolves the given ability if Yes is chosen."
   [state side card msg ability targets]
@@ -209,7 +209,7 @@
                                                       (resolve-ability state side no-ability card targets))))))

-; Prompts
+;;; Prompts
 (defn prompt!
   "Shows a prompt with the given message and choices. The given ability will be resolved
   when the user resolves the prompt. Cards should generally not call this function directly; they
@@ -248,8 +248,8 @@
   As with prompt!, the preferred method for showing a select prompt is through resolve-ability."
   ([state side card ability] (show-select state side card ability nil))
   ([state side card ability {:keys [priority] :as args}]
-   ; if :max is a function, call it and assoc its return value as the new :max number of cards
-   ; that can be selected.
+   ;; if :max is a function, call it and assoc its return value as the new :max number of cards
+   ;; that can be selected.
    (let [ability (update-in ability [:choices :max] #(if (fn? %) (% state side card nil) %))]
      (swap! state update-in [side :selected]
             #(conj (vec %) {:ability (dissoc ability :choices) :req (get-in ability [:choices :req])
@@ -293,7 +293,7 @@
   (when (= :waiting (-> @state side :prompt first :prompt-type))
     (swap! state update-in [side :prompt] rest)))

-; Psi games
+;;; Psi games
 (defn psi-game
   "Starts a psi game by showing the psi prompt to both players. psi is a map containing
   :equal and :not-equal abilities which will be triggered in resolve-psi accordingly."
@@ -324,7 +324,7 @@
         state side (str (clojure.string/capitalize (name opponent)) " to choose psi game credits")))))

-; Traces
+;;; Traces
 (defn init-trace
   "Shows a trace prompt to the runner, after the corp has already spent credits to boost."
   [state side card {:keys [base] :as ability} boost]


tests for Grimoire and Plascrete

tests for Grimoire and Plascrete

--- src/clj/test/cards-hardware.clj
+++ src/clj/test/cards-hardware.clj
@@ -71,7 +71,39 @@
         (is (= 5 (:current-strength (refresh ram))) "Dinosaurus giving +2 strength to Battering Ram")
         (core/move state :runner (find-card "Battering Ram" (:hosted (refresh dino))) :discard) ; trash Battering Ram
         (is (= 4 (:memory (get-runner))) "Battering Ram 2 MU not added to available MU")))))
-
+
+(deftest grimoire
+  "Grimoire - Gain 2 MU, add a free virus counter to installed virus programs"
+  (do-game
+    (new-game (default-corp)
+              (default-runner [(qty "Grimoire" 1) (qty "Imp" 1)]))
+    (take-credits state :corp)
+    (play-from-hand state :runner "Grimoire")
+    (is (= 6 (:memory (get-runner))) "Gained 2 MU")
+    (play-from-hand state :runner "Imp")
+    (let [imp (get-in @state [:runner :rig :program 0])]
+      (is (= 3 (:counter (refresh imp))) "Imp received an extra virus counter on install"))))
+
+(deftest plascrete
+  "Plascrete Carapace - Prevent meat damage"
+  (do-game
+    (new-game (default-corp [(qty "Scorched Earth" 1)])
+              (default-runner [(qty "Plascrete Carapace" 1) (qty "Sure Gamble" 1)]))
+    (take-credits state :corp)
+    (play-from-hand state :runner "Plascrete Carapace")
+    (let [plas (get-in @state [:runner :rig :hardware 0])]
+      (is (= 4 (:counter (refresh plas))) "4 counters on install")
+      (take-credits state :runner)
+      (core/gain state :runner :tag 1)
+      (play-from-hand state :corp "Scorched Earth")
+      (card-ability state :runner plas 0)
+      (card-ability state :runner plas 0)
+      (card-ability state :runner plas 0)
+      (card-ability state :runner plas 0)
+      (prompt-choice :runner "Done")
+      (is (= 1 (count (:hand (get-runner)))) "All meat damage prevented")
+      (is (empty? (get-in @state [:runner :rig :hardware])) "Plascrete depleted and trashed"))))
+
 (deftest turntable-swap
   "Turntable - Swap a stolen agenda for a scored agenda"
   (do-game


cljs-nusmods.main - Port over code for `(Clear All)` link

This completes our port of the Module Finder page over to ClojureScript.
Time to move on to the next phase of our project.

Signed-off-by: Pang Yan Han <22594c345857f664c61cd411f607c4d40a9d4af9@gmail.com>

--- src/cljs/cljs_nusmods/main.cljs
+++ src/cljs/cljs_nusmods/main.cljs
@@ -1,6 +1,6 @@
 (ns ^{:doc "main entry point for the cljs-nusmods project"}
   cljs-nusmods.main
-  (:use [jayq.core :only [$ one]])
+  (:use [jayq.core :only [$ hide is one prevent show]])
   (:require [cljs-nusmods.module-array-repr     :as module-array-repr]
             [cljs-nusmods.aux-module-array-repr :as aux-module-array-repr]
             [cljs-nusmods.time                  :as time-helper]))
@@ -192,6 +192,68 @@
                       "initSelection" (fn [])
                       "query"         (select2-query-fn modulesArray)))))

+(defn- init-dom-clear-modules
+  "Code for `(Clear Modules)` button on top of the `Select Modules for
+   Timetable` input box"
+  []
+  (let [$searchModules       ($ :#search_modules)
+        $noneSelectedDiv     ($ :#search-modules-none-selected-div)
+        $someSelectedDiv     ($ :#search-modules-selected-div)
+        $someSelectedDivText ($ :#search-modules-nr-selected)]
+    (hide $someSelectedDiv)
+    (.change
+      $searchModules
+      (fn [evt]
+        (cond
+          ; some module has just been added
+          (aget evt "added")
+          (do
+            (if (is $noneSelectedDiv ":visible")
+                (hide $noneSelectedDiv))
+            ; Add the new module to the `MODULES_SELECTED` global
+            (aset (aget js/window "MODULES_SELECTED")
+                  (aget (aget evt "added") "id")
+                  true)
+            (if (is $someSelectedDiv ":visible")
+                (.text $someSelectedDivText
+                       (str "Selected "
+                            (.-length (goog.object.getKeys
+                                        (aget js/window "MODULES_SELECTED")))
+                            " Modules"))
+                ; 0 modules -> 1 module
+                (do (.text $someSelectedDivText "Selected 1 Module")
+                    (show $someSelectedDiv))))
+
+          ; some module was removed
+          (aget evt "removed")
+          (do
+            (js-delete (aget js/window "MODULES_SELECTED")
+                       (aget (aget evt "removed") "id"))
+            (let [nrModulesSelected
+                  (.-length (goog.object.getKeys
+                              (aget js/window "MODULES_SELECTED")))]
+              (cond
+                (<= nrModulesSelected 0)
+                (do (hide $someSelectedDiv)
+                    (show $noneSelectedDiv))
+
+                (= nrModulesSelected 1)
+                (.text $someSelectedDivText "Selected 1 Module")
+
+                :else
+                (.text $someSelectedDivText
+                       (str "Selected " nrModulesSelected " Modules"))))))))
+
+    (.click ($ :#search-modules-clear-all-modules)
+            (fn [evt]
+              (prevent evt)
+              (if (js/confirm
+                     "Are you sure you want to clear all selected modules?")
+                  (do (aset js/window "MODULES_SELECTED" (js-obj))
+                      (.select2 $searchModules "val" "")
+                      (hide $someSelectedDiv)
+                      (show $noneSelectedDiv)))))))
+
 ; Main entry point of the program
 (defn ^:export init []
   ; Globals
@@ -226,7 +288,8 @@
                                    "moduleType" (js-obj "valueType" "item"))
                     "items"      itemsArray))
           (.configureFromDOM myExhibit)
-          (init-select2-input-box modulesArray))))
+          (init-select2-input-box modulesArray)
+          (init-dom-clear-modules))))

     ; Retrieve Exhibit 3.0 Library
     (getScript "js/vendor/exhibit3-all.min.js" (fn []))))


Add google history integration

Add google history integration

--- src/cljs/comic_reader/main.cljs
+++ src/cljs/comic_reader/main.cljs
@@ -9,7 +9,9 @@
              :refer [comic-viewer]]
             [reagent.core :as reagent :refer [atom]]
             [secretary.core :as secretary
-             :include-macros true :refer [defroute]]))
+             :include-macros true :refer [defroute]]
+            [goog.events :as events]
+            [goog.history.EventType :as EventType]))

 (enable-console-print!)

@@ -35,6 +37,14 @@
            ;; the client to focus on
            :build-id "dev"})

+(defn hook-browser-navigation! []
+  (doto (History.)
+    (events/listen
+        EventType/NAVIGATE
+        (fn [event]
+          (secretary/dispatch! (.-token event))))
+    (.setEnabled true)))
+
 (defroute "/" []
   (session/put! :current-page site-list))


Construct a lock and show it

Construct a lock and show it

--- src/cljs_lock_example/core.cljs
+++ src/cljs_lock_example/core.cljs
@@ -1,5 +1,6 @@
 (ns cljs-lock-example.core
-  (:require [clojure.browser.repl :as repl]))
+  (:require [clojure.browser.repl :as repl]
+            cljsjs.auth0-lock))

 ;; (defonce conn
 ;;   (repl/connect "http://localhost:9000/repl"))
@@ -7,3 +8,8 @@
 (enable-console-print!)

 (println "Hello world!")
+
+(def cid "yKJO1ckwuY1X8gPEhTRfhJXyObfiLxih")
+(def domain "mdocs.auth0.com")
+(def lock (js/Auth0Lock. cid domain))
+(.show lock)


Ensure CORS conformity on artifact endpoints

--- src/clojars/routes/artifact.clj
+++ src/clojars/routes/artifact.clj
@@ -45,10 +45,12 @@
   (cond
     (= file-format "json") (-> (response/response (view/make-latest-version-json db group-id artifact-id))
                                (response/header "Cache-Control" "no-cache")
-                               (response/content-type "application/json; charset=UTF-8"))
+                               (response/content-type "application/json; charset=UTF-8")
+                               (response/header "Access-Control-Allow-Origin" "*"))
     (= file-format "svg") (-> (response/response (view/make-latest-version-svg db group-id artifact-id))
                               (response/header "Cache-Control" "no-cache")
-                              (response/content-type "image/svg+xml")))))
+                              (response/content-type "image/svg+xml")
+                              (response/header "Access-Control-Allow-Origin" "*")))))

 (defn routes [db reporter stats]
   (compojure/routes


New function for removing all child nodes.

--- src/clojure/clj_chess/game.cljc
+++ src/clojure/clj_chess/game.cljc
@@ -141,6 +141,12 @@
   [zipper key value]
   (zip/edit zipper assoc-in [key] value))

+(defn- zip-remove-children
+  "Takes a game tree zipper and returns a zipper for a modified game tree
+  where all the child nodes at the current location are removed."
+  [zipper]
+  (zip/edit zipper #(dissoc % :children)))
+

 (defn add-move
   "Takes a game, a move function (a function that, given a board and
@@ -255,6 +261,17 @@
                 :current-node (if (= (zip/up z) (zip/prev z))
                                 (zip/node zr)
                                 (zip/node (zip/up zr))))))
+
+
+(defn remove-children
+  "Removes all child nodes of a node (by default, the current node), and
+  returns a modified game with the current node set to the node whose
+  children we just removed."
+  [game & {:keys [node-id] :or {node-id (-> game :current-node :node-id)}}]
+  (assoc game
+    :root-node (-> (game-zip game node-id) zip-remove-children zip/root)
+    :current-node node-id))
+

 (defn goto-node-matching
   "Returns a game equal to the input game, except that :current-node is set to


Add explanatory comment

Add explanatory comment

--- src/main/clojure/clojure/test/check/clojure_test.cljc
+++ src/main/clojure/clojure/test/check/clojure_test.cljc
@@ -163,6 +163,9 @@
   report shrunk results. Defaults to true."
   true)

+;; This check accomodates a number of tools that rebind ct/report
+;; to be a regular function instead of a multimethod, and may do
+;; so before this code is loaded (see TCHECK-125)
 (if-not (instance? #?(:clj clojure.lang.MultiFn :cljs MultiFn) ct/report)
   (binding [*out* *err*]
     (println "clojure.test/report is not a multimethod, some reporting functions have been disabled."))


2017 Day 1 Part 2 solved.

2017 Day 1 Part 2 solved.

--- 2017/day1/src/day1/core.clj
+++ 2017/day1/src/day1/core.clj
@@ -7,13 +7,12 @@
   (partition (count colls) (apply interleave colls)))

 (defn matchsum
-  "Finds the sum of all digits that match the next digit in a string.
-  (It \"wraps\" around, so that the last digit must match the first to be added)"
-  [x]
+  "Finds the sum of all digits that match the digit distance away, wrapping around."
+  [x distance]
   (->> x
        seq
        (map (fn [^Character c] (Character/digit c 10)))
-       ((fn [y] (zip y (next (cycle y)))))
+       ((fn [y] (zip y (nthnext (cycle y) distance))))
        (map (fn [v] (if (= (first v) (second v)) (first v) 0)))
        ;; Add things that do the logic here
        (reduce +)))
@@ -22,4 +21,6 @@
   "Lets you run matchsum from the command line."
   [& args]
   (let [file (if args (first args) "input")]
-    (println (matchsum (clojure.string/trim (slurp file))))))
+    (let [contents (clojure.string/trim (slurp file))]
+      (println (matchsum contents 1))
+      (println (matchsum contents (/ (count contents) 2))))))


Add additional tests for range deftype

Add additional tests for range deftype

--- test/cljs/cljs/core_test.cljs
+++ test/cljs/cljs/core_test.cljs
@@ -683,16 +683,15 @@
   (assert (zero? (count (methods bar))))

   ;; Range
-  (assert (= (range 0 30 3) (list 0 3 6 9 12 15 18 21 24 27)))
-  (assert (= (count (range 0 30 3)) 10))
-  (assert (= (count (range 0 -30 -3)) 10))
-
-  ;; Negative Ranges
+  (assert (= (range 0 10 3) (list 0 3 6 9)))
+  (assert (= (count (range 0 10 3)) 4))
+  (assert (= (range 0 -10 -3) (list 0 -3 -6 -9)))
+  (assert (= (count (range 0 -10 -3)) 4))
+  (assert (= (range -10 10 3) (list -10 -7 -4 -1 2 5 8)))
+  (assert (= (count (range -10 10 3)) 7))
+  (assert (= (range 0 1 1) (list 0)))
   (assert (= (range 0 -3 -1) (list 0 -1 -2)))
   (assert (= (range 3 0 -1) (list 3 2 1)))
-  (assert (= (range 0 1 1) (list 0)))
-
-  ;; Empty Ranges
   (assert (= (range 0 10 -1) (list)))
   (assert (= (range 0 1 0) (list)))
   (assert (= (range 10 0 1) (list)))
@@ -701,11 +700,6 @@
   (assert (= (count (range 0 1 0)) 0))
   (assert (= (count (range 10 0 1)) 0))
   (assert (= (count (range 0 0 0)) 0))
-  (assert (= (reduce + (range 0 10 -1)) 0))
-  (assert (= (reduce + (range 0 1 0)) 0))
-  (assert (= (reduce + (range 0 0 0)) 0))
-
-  ;; Infinite Repeating Range Sequences
   (assert (= (take 3 (range 1 0 0)) (list 1 1 1)))
   (assert (= (take 3 (range 3 1 0)) (list 3 3 3)))


better solution to paired async tests

better solution to paired async tests

--- test/deferst/system_test.cljc
+++ test/deferst/system_test.cljc
@@ -337,7 +337,8 @@
            (fn [_] (is (= @destructor-vals x-dvals))
              (done))))))))

-(deftest composed-builders-creation
+(defn composed-builders-fixtures
+  []
   (let [destructor-vals (atom [])
         ff (fn [v] [v (fn [] (swap! destructor-vals conj v))])
         sb-obj-specs [[:a ff {:a-arg [:foo]}]
@@ -350,33 +351,48 @@
         sb (s/system-builder sb-obj-specs)
         sb2 (s/system-builder sb sb2-obj-specs)
         sys (s/start-system! sb2 {:foo 10})
-        sysmap (s/system-map sys)]
-
-    (testing "items are created"
-      #?(:clj
-         (is (= @sysmap x-sysmap))
-
-         :cljs
-         (t/async
-          done
-          (p/then
-           sysmap
-           (fn [v] (is (= v x-sysmap))
-             (done))))))))
-
-(deftest composed-builders-destruction
-  (let [destructor-vals (atom [])
-        ff (fn [v] [v (fn [] (swap! destructor-vals conj v))])
-
-        sb (s/system-builder [[:a ff {:a-arg [:foo]}]
-                              [:b identity {:b-arg [:a :a-arg]}]])
-        sb2 (s/system-builder sb [[:c ff {:c-a [:a :a-arg]
-                                          :c-b [:b :b-arg]}]])
-        sys (s/start-system! sb2 {:foo 10})
+        sysmap (s/system-map sys)
         stop-sys (s/stop-system! sys)

         x-sysmap {:foo 10 :a {:a-arg 10} :b {:b-arg 10} :c {:c-a 10 :c-b 10}}
         x-dvals [{:c-a 10 :c-b 10} {:a-arg 10}]]
+    {:destructor-vals destructor-vals
+     :sb2 sb2
+     :sys sys
+     :sysmap sysmap
+     :stop-sys stop-sys
+     :x-sysmap x-sysmap
+     :x-dvals x-dvals}))
+
+(deftest composed-builders-creation
+  (let [{destructor-vals :destructor-vals
+         sb2 :sb2
+         sys :sys
+         sysmap :sysmap
+         stop-sys :stop-sys
+         x-sysmap :x-sysmap
+         x-dvals :x-dvals} (composed-builders-fixtures)]
+
+    (testing "items are created"
+      #?(:clj
+         (is (= @sysmap x-sysmap))
+
+         :cljs
+         (t/async
+          done
+          (p/then
+           sysmap
+           (fn [v] (is (= v x-sysmap))
+             (done))))))))
+
+(deftest composed-builders-destruction
+  (let [{destructor-vals :destructor-vals
+         sb2 :sb2
+         sys :sys
+         sysmap :sysmap
+         stop-sys :stop-sys
+         x-sysmap :x-sysmap
+         x-dvals :x-dvals} (composed-builders-fixtures)]

     (testing "items were destroyed"
       #?(:clj


Add failing highlight search test.

Add failing highlight search test.

--- test/haystack/search_test.clj
+++ test/haystack/search_test.clj
@@ -57,3 +57,11 @@
  (in-top 2 199152 2542450)
  )

+
+;; This is a failing test as it highlights the whole manufacturer part number.
+;; It is commented out because we don't yet have the "highlighted" test.
+;; (test-search highlight-check
+;;              {:search "allied molded"}
+;;              (highlighted :manufacturer-part-number "Alli")
+;;              )
+


Formatting

Formatting

--- src/layzee/use_cases/lazy_web.clj
+++ src/layzee/use_cases/lazy_web.clj
@@ -8,8 +8,8 @@
      #(nil? (:retweeted_status %1)))

 (defn- result[search-fn conversation-fn log-fn how-many]
-  (let [result (timing/time #(apply search-fn [{:count how-many :filter no-retweets}]) #(log-fn "It took <%sms> to search"       (:duration %)))]
-    (let [results-with-replies (timing/time #(doall (pmap (partial conversation-fn) result))   #(log-fn "It took <%sms> to find replies to <%s> tweets" (:duration %) (count result)))]
+  (let [result (timing/time #(apply search-fn [{:count how-many :filter no-retweets}])       #(log-fn "It took <%sms> to search"                      (:duration %)))]
+    (let [results-with-replies (timing/time #(doall (pmap (partial conversation-fn) result)) #(log-fn "It took <%sms> to find replies to <%s> tweets" (:duration %) (count result)))]
       {
        :timestamp (t/now)
        :result results-with-replies})))


ignore ':uneval' forms when upgrading. (fixes #28)

--- src/leiningen/ancient/upgrade.clj
+++ src/leiningen/ancient/upgrade.clj
@@ -49,7 +49,10 @@
    at a given position right of the current one."
   [zloc p]
   (cond (not zloc) nil
-        (integer? p) (nth (iterate z/right zloc) p)
+        (integer? p) (nth
+                       (->> (iterate z/right zloc)
+                            (remove #(= (z/tag %) :uneval)))
+                       p)
         (keyword? p) (when-let [floc (z/find-value zloc p)]
                        (when-let [floc (z/right floc)]
                          (z/down floc)))


CMR-5016: Clean up require block.

CMR-5016: Clean up require block.

--- system-int-test/test/cmr/system_int_test/header_test.clj
+++ system-int-test/test/cmr/system_int_test/header_test.clj
@@ -1,14 +1,15 @@
 (ns cmr.system-int-test.header_test
   "Tests for headers in ingest and search responses"
-  (:require [clojure.test :refer :all]
-            [clj-http.client :as client]
-            [clojure.string :as string]
-            [cmr.system-int-test.utils.ingest-util :as ingest]
-            [cmr.system-int-test.utils.search-util :as search]
-            [cmr.system-int-test.utils.index-util :as index]
-            [cmr.system-int-test.data2.collection :as dc]
-            [cmr.system-int-test.utils.url-helper :as url]
-            [cmr.common-app.api.routes :as routes]))
+  (:require
+   [clj-http.client :as client]
+   [clojure.string :as string]
+   [clojure.test :refer :all]
+   [cmr.common-app.api.routes :as routes]
+   [cmr.system-int-test.data2.collection :as dc]
+   [cmr.system-int-test.utils.index-util :as index]
+   [cmr.system-int-test.utils.ingest-util :as ingest]
+   [cmr.system-int-test.utils.search-util :as search]
+   [cmr.system-int-test.utils.url-helper :as url]))

 (use-fixtures :each (ingest/reset-fixture {"provguid1" "PROV1"}))


point to an existing artifact on clojars

--- examples/guesthouse/project.clj
+++ examples/guesthouse/project.clj
@@ -4,7 +4,7 @@
   :license {:name "Eclipse Public License"
             :url "http://www.eclipse.org/legal/epl-v10.html"}
   :dependencies [[prismatic/plumbing "0.2.1"]
-                 [prismatic/fnhouse "0.1.0-SNAPSHOT"]
+                 [prismatic/fnhouse "0.1.0"]
                  [org.clojure/clojure "1.5.1"]
                  [clj-http "0.9.0"]
                  [ring/ring-core "1.0.0-RC1"]


Fixed tests for the new list interactor

Fixed tests for the new list interactor

--- test/clj/squad_share/test/interactors/list_all_links.clj
+++ test/clj/squad_share/test/interactors/list_all_links.clj
@@ -3,14 +3,19 @@
             [clojure.core.async :refer [go <!!]]
             [postgres.async :as pg]
             [squad-share.config :as config]
+            [squad-share.test.test-utils :as test-utils]
             [squad-share.interactors.list-all-links :as list-all-links]))

+(use-fixtures :each test-utils/cleanup)
+
 (deftest list-all-links
-  ((<!! (pg/insert! config/db {:table "squadshare.links"} {:title (str (java.util.UUID/randomUUID)), :description "Description", :url "http://test"}))
-   (let [ context {}
+   (let [
+          _ (<!! (pg/insert! config/db {:table "squadshare.links"} {:title (str (java.util.UUID/randomUUID)), :description "Description", :url "http://test"}))
+          _ (<!! (pg/insert! config/db {:table "squadshare.links"} {:title (str (java.util.UUID/randomUUID)), :description "Description", :url "http://test"}))
+          context {}
           result (list-all-links/run! context)]
-        (prn result)
-
     (testing "the link is retreived by the interactor"
-      (let [result (<!! (pg/execute! config/db ["select count(title) from squadshare.links"]))]
-        (= result 1))))))
+      (let [result (<!! (pg/execute! config/db ["select * from squadshare.links"]))]
+        ( is (= (count (-> result
+                           :rows
+                           )) 2 ))))))


added devenir

added devenir

--- src/babel/francais/lexicon.cljc
+++ src/babel/francais/lexicon.cljc
@@ -197,6 +197,24 @@

    "désirer" {:synsem {:cat :verb
                        :sem {:pred :desire}}}
+
+   "devenir"
+   (let [common
+         {:synsem {:essere true
+                   :cat :verb}
+          :français {:future-stem "deviendr"
+                     :drop-e true
+                     :past-participle "devenu"
+                     :imperfect-stem "deven"
+                     :present {:1sing "devienss"
+                               :2sing "deviens"
+                               :3sing "devient"
+                               :1plur "devenons"
+                               :2plur "devenez"
+                               :3plur "deviennent"}}}]
+     (unify common {:synsem {:sem {:pred :become
+                                   :subj {:human true}}}}))
+

    "dire"
    (let [shared-part-of-dire


added rester

added rester

--- src/babel/francais/lexicon.cljc
+++ src/babel/francais/lexicon.cljc
@@ -63,9 +63,9 @@
                          :past-participle "appris"
                          :sem {:pred :learn}}}

-   "arriver" {:synsem {:cat :verb
+   "rester" {:synsem {:cat :verb
                        :essere true
-                       :sem {:pred :arrive}}}
+                       :sem {:pred :remain}}}

    "assurer" [{:synsem {:cat :verb
                         :sem {:pred :assure}}}


more cleanup

more cleanup

--- src/babel/italiano/grammar.cljc
+++ src/babel/italiano/grammar.cljc
@@ -423,13 +423,12 @@
                                      :cat :verb}})
                    (unify h21a
                           root-is-comp-root
-                          {:rule "vp-aux-phrasal-complement-passato"
+                          {:rule "vp-aux-phrasal-complement"
                            :head {:phrasal false
                                   :synsem {:aux true}}
                            :comp {:phrasal true}
                            :synsem {:aux true
-                                    :sem {:tense :past
-                                          :aspect :simple}
+                                    :sem {:tense :past}
                                     :cat :verb}})
                    (unify h21a
                           root-is-comp
@@ -660,11 +659,9 @@
                      (= (:rule %) "s-imperfect-nonphrasal")
                      (= (:rule %) "s-aux")
                      (= (:rule %) "vp-32")
-                     (= (:rule %) "vp-aux-nonphrasal-complement-passato")
-                     (= (:rule %) "vp-aux-phrasal-complement-passato")
+                     (= (:rule %) "vp-aux-phrasal-complement")
                      (= (:rule %) "vp-aux-22")
                      (= (:rule %) "vp-aux-nonphrasal-complement")
-                     (= (:rule %) "vp-aux-phrasal-complement-trapassato")
                      (= (:rule %) "vp-present")
                      (= (:rule %) "vp-pronoun-nonphrasal")
                      (= (:rule %) "vp-pronoun-phrasal")


fix intransitivization rule

fix intransitivization rule

--- src/babel/italiano/lexicon.cljc
+++ src/babel/italiano/lexicon.cljc
@@ -222,7 +222,11 @@

       (verb-pred-defaults encyc/verbs)

-      (new-entries ;; remove the second argument and semantic object to make verbs intransitive.
+      (new-entries
+       ;; remove the second argument and semantic object to make verbs intransitive,
+       ;; if it is {:cat :verb} and {:allow-intransitive true}, etc.
+
+       ;; if condition:
        {:allow-intransitivize true
         :synsem {:cat :verb
                  :aux false
@@ -230,23 +234,15 @@
                        :reflexive false}
                  :subcat {:2 {:cat :noun}
                           :3 []}}}
-       ;; this is the 'modify-with' function that
-       ;; (new-entries) will apply to each lexeme.
+       ;; then condition:
        (fn [lexeme]
-         (do
-           (if (= :fail lexeme)
-             (throw (babel.exception/exception (str "input to (fn [lexeme]) was :fail."))))
-           (log/info (str "modify-with input: "
-                          (dag_unify.core/strip-refs lexeme)))
-           (let [result
-                 (dissoc-paths lexeme [[:synsem :sem :obj]
-                                       [:synsem :subcat :2]])]
-             (log/info (str "intransitivize lexeme: "
-                            (dag_unify.core/strip-refs lexeme)))
-             (log/info (str "intransitivize pre-result: "
-                            (dag_unify.core/strip-refs result)))
-             result))))
-
+         (unify (dissoc-paths lexeme [[:synsem :sem :obj]
+                                      [:synsem :subcat :2]
+                                      [:synsem :subcat :3]])
+                {:applied {:intransitivize true}
+                 :synsem {:subcat {:2 []
+                                   :3 []}
+                          :sem {:obj :unspec}}})))

       (default ;; reflexive defaults to false..
        {:synsem {:cat :verb


Fixed the simple example

Fixed the simple example

--- examples/simple/src/simple.cljs
+++ examples/simple/src/simple.cljs
@@ -5,7 +5,7 @@

 (def customer (atom {:type :private}))

-(defmulti render-details (comp :type deref))
+(defmulti render-details (comp rum/react (fn [customer] (rum/cursor customer :type))))

 (defmethod render-details :private
   [customer]
@@ -39,7 +39,7 @@
             customer [:city]
             :placeholder "Enter city name")))

-(rum/defc customer-form-view < rum/cursored rum/cursored-watch
+(rum/defc customer-form-view < rum/reactive
   [customer]
   (f/form
     (f/group-title {:class "group-title-main"} "Customer info")


CMR-3552: Addressed the PR comments.

CMR-3552: Addressed the PR comments.

--- ingest-app/src/cmr/ingest/services/humanizer_alias_cache.clj
+++ ingest-app/src/cmr/ingest/services/humanizer_alias_cache.clj
@@ -22,7 +22,7 @@
   "Returns the alias map like
    {\"platform\" {\"TERRA\" [\"AM-1\" \"am-1\" \"AM 1\"] \"OTHERPLATFORMS\" [\"otheraliases\"]}
     \"tiling_system_name\" {\"TILE\" [\"tile_1\" \"tile_2\"] \"OTHERTILES\" [\"otheraliases\"]}
-    \"instrument\" {\"INSTRUMENT\" [\"instr1\" \"instr2\"] \"OTHERTILES\" [\"otheraliases\"]}}"
+    \"instrument\" {\"INSTRUMENT\" [\"instr1\" \"instr2\"] \"OTHERINSTRUMENTS\" [\"otheraliases\"]}}"
   [humanizer]
   (into {}
         (for [[k1 v1]
@@ -81,8 +81,7 @@
   (let [subelements (get element subelement-key)
         subelement-aliases (get-field-aliases
                              subelements subelement-name-key subelement-alias-map)]
-    (-> element
-        (update subelement-key concat subelement-aliases))))
+    (update element subelement-key concat subelement-aliases)))

 (defn update-collection-with-platform-aliases
   "Returns the collection with humanizer platform aliases added.
@@ -138,13 +137,9 @@
                          :short-name)
         instr-alias-map (get humanizer-alias-map "instrument")
         plats (get collection plat-key)
-        updated-plats (for [plat plats
-                            :let [updated-plat
-                                  (update-element-with-subelement-aliases
-                                    plat instr-key instr-name-key instr-alias-map)]]
-                        updated-plat)]
+        updated-plats (map #(update-element-with-subelement-aliases
+                              % instr-key instr-name-key instr-alias-map) plats)]
     (-> collection
-        (dissoc plat-key)
         (assoc plat-key updated-plats))))

 (defn update-collection-with-aliases


Keep the sleep so the CI build can actually finish.

--- integration-tests/src/test/clojure/immutant/integs/basic.clj
+++ integration-tests/src/test/clojure/immutant/integs/basic.clj
@@ -30,12 +30,14 @@

 (deftest simple "it should work"
   (println "simple:" (java.sql.Timestamp. (.getTime (java.util.Date.))))
+  (Thread/sleep 5000)
   (let [result (client/get "http://localhost:8080/basic-ring")]
     ;(println "RESPONSE" result)
     (is (.startsWith (result :body) "Hello from Immutant!"))))

 (deftest app-should-have-its-config
   (println "ashic:" (java.sql.Timestamp. (.getTime (java.util.Date.))))
+  (Thread/sleep 5000)
   (let [result (client/get "http://localhost:8080/basic-ring")]
     ;(println "RESPONSE" result)
     (is (.contains (result :body) ":ham :biscuit"))))


oops, missed on -M place

oops, missed on -M place

--- src/main/shadow/cljs/npm/cli.cljs
+++ src/main/shadow/cljs/npm/cli.cljs
@@ -423,7 +423,7 @@
           deps
           ["clojure"
            (-> (get-clojure-args project-root config opts)
-               (conj "-m"))]
+               (conj "-M" "-m"))]

           lein
           ["lein"


s/debug/trace/

s/debug/trace/

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -118,7 +118,7 @@
                  (log/debug (str "lightning-bolts: " (get-in parent [:rule])
                                  " : (optimizeme) size of subset of candidate heads: "
                                  (count subset) " with spec: " (strip-refs spec)))
-                 (log/debug (str "lightning-bolts: " (get-in parent [:rule])
+                 (log/trace (str "lightning-bolts: " (get-in parent [:rule])
                                  " : head lexeme candidates: "
                                  (string/join ","
                                               (map #((:morph language-model) %)
@@ -127,7 +127,7 @@
                  (let [result (over/overh parent (lazy-shuffle subset))]
                    (log/debug (str "lightning-bolts: (optimizeme) surviving candidate heads: " (count result)))

-                   (log/debug (str "lightning-bolts: surviving results: "
+                   (log/trace (str "lightning-bolts: surviving results: "
                                    (string/join ","
                                                 (map #((:morph language-model) %)
                                                      result))))
@@ -212,7 +212,7 @@
                     (:lexicon language-model))
         from-bolt bolt ;; so we can show what (add-complement-to-bolt) did to the input bolt, for logging.
         spec (strip-refs (get-in bolt path))
-        debug (log/info (str "spec to find complement lexemes: " spec))
+        debug (log/debug (str "spec to find complement lexemes: " spec))
         complement-candidate-lexemes
         (if (not (= true (get-in bolt (concat path [:phrasal]))))
           (if-let [index-fn
@@ -220,7 +220,7 @@
             (index-fn spec)
             (flatten (vals lexicon))))
         debug
-        (log/debug (str "lexical-complements (pre-over):"
+        (log/trace (str "lexical-complements (pre-over):"
                         (string/join ","
                                      (map #((:morph language-model) %)
                                           complement-candidate-lexemes))))
@@ -231,7 +231,7 @@
                                        (and (not-fail? (unify (get-in lexeme [:synsem] :top)
                                                               bolt-child-synsem))))
                                      complement-candidate-lexemes))]
-    (log/debug (str "lexical-complements (post-over):"
+    (log/trace (str "lexical-complements (post-over):"
                     (string/join ","
                                  (map #((:morph language-model) %)
                                       lexical-complements))))


use pmap rather than map in one place

use pmap rather than map in one place

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -140,7 +140,7 @@
                  (flatten
                   (mapfn
                    (fn [bolt-at]
-                    (add-bolt-at top-bolt bolt path bolt-at model depth max-depth))
+                     (add-bolt-at top-bolt bolt path bolt-at model depth max-depth))
                    bolts-at)))))))))

 (defn add-bolt-at [top-bolt bolt path bolt-at model depth max-depth]
@@ -151,8 +151,8 @@
                bolt
                (assoc-in bolt path bolt-at))]
             (let [comp-paths (find-comp-paths bolt-at)
-                  comp-bolts (mapfn #(comp-path-to-bolts bolt-at % model (+ 1 depth) max-depth)
-                                    comp-paths)]
+                  comp-bolts (pmap #(comp-path-to-bolts bolt-at % model (+ 1 depth) max-depth)
+                                   comp-paths)]
               (when (not (some empty? comp-bolts))
                 (mapfn #(if (= bolt bolt-at)
                           %
@@ -438,7 +438,7 @@
                  path)]
       (if (not (empty? path))
         (concat
-         [(vec (concat path [:comp]))]
+         (concat path [:comp])
          (find-comp-paths bolt (rest path)))
         [[:comp]]))))


add more params

add more params

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -92,7 +92,7 @@
                                (rest comp-paths)
                                (rest bolts-at-paths)
                                depth max-depth top-bolt truncate? take-n)
-                   ((fn [comp-paths bolts-at-paths]
+                   ((fn [comp-paths bolts-at-paths bolt top-bolt]
                       (let [path (first comp-paths)
                             bolts-at (first bolts-at-paths)]
                         (flatten
@@ -104,7 +104,7 @@
                                             (if truncate? (truncate with-added-complement [path] model)
                                                 with-added-complement))))))
                                 bolts-at))))
-                    comp-paths bolts-at-paths)))))))))
+                    comp-paths bolts-at-paths bolt top-bolt)))))))))

 (defn add-bolt-at [top-bolt bolt path bolt-at model depth max-depth truncate? & [take-n]]
   (mapfn #(do-defaults % model)


s/debug/trace/

s/debug/trace/

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -189,7 +189,7 @@
   (log/trace (str "add-all-comps: bolt count: " (count bolts)))
   (lazy-mapcat
    (fn [bolt]
-     (log/debug (str "adding all comps to bolt: " (show-bolt bolt language-model)))
+     (log/trace (str "adding all comps to bolt: " (show-bolt bolt language-model)))
      (add-all-comps-with-paths [bolt] language-model total-depth
                                (find-comp-paths-in (bolt-depth bolt))
                                truncate-children max-total-depth


small optimizations to (defn candidate-parents)

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -358,7 +358,7 @@
 (defn candidate-parents [rules spec]
   "find subset of _rules_ for which each member unifies successfully with _spec_"
   (log/trace (str "candidate-parents: spec: " (strip-refs spec)))
-  (filter #(not (fail? %))
+  (filter #(not (= :fail %))
           (mapfn (fn [rule]
                    (log/trace (str "candidate-parents: rule: " (:rule rule)))
                    (if (and (not (fail? (unifyc (get-in rule [:synsem :cat] :top)
@@ -372,16 +372,9 @@
                      (let [result
                            (unifyc spec rule)]
                        (if (fail? result)
-                         (do
-                           (log/trace (str " rule: " (:rule rule) " failed (2)"))
-                           :fail)
-                         (do
-                           (log/trace (str " rule: " (:rule rule) " did not fail."))
-                           (log/info (str "returning parent with synsem: " (strip-refs (get-in result [:synsem]))))
-                           result)))
-                     (do
-                       (log/trace (str " rule: " (:rule rule) " failed (1)"))
-                       :fail)))
+                         :fail
+                         result))
+                     :fail))
                  rules)))

 (defn lazy-shuffle [seq]


remove apparently unneeded lazy-seq

remove apparently unneeded lazy-seq

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -129,19 +129,18 @@
     (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.
-      (lazy-seq
-       (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
-                   (fn [bolt-at]
-                     (add-bolt-at top-bolt bolt path bolt-at model depth max-depth))
-                   bolts-at)))))))))
+      (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
+                  (fn [bolt-at]
+                    (add-bolt-at top-bolt bolt path bolt-at model depth max-depth))
+                  bolts-at))))))))

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


using map-indexed to iterate over the columns

--- backend/src/akvo/lumen/lib/aggregation/scatter.clj
+++ backend/src/akvo/lumen/lib/aggregation/scatter.clj
@@ -6,14 +6,15 @@
             [clojure.java.jdbc :as jdbc]
             [clojure.tools.logging :as log]))

-(defn- serie-data [sql-data index]
-  (vec (map-indexed  #(hash-map :value (nth %2 index)) sql-data)))
+(defn- serie-data [tag sql-data index]
+  (mapv #(array-map tag (nth % index)) sql-data))

 (defn serie [sql-data column index]
-  {:key      (:title column)
-   :label    (:title column)
-   :data (serie-data sql-data index)
-   :metadata {:type (:type column)}})
+  (when (:title column)
+    {:key (:title column)
+     :label (:title column)
+     :data (serie-data :value sql-data index)
+     :metadata {:type (:type column)}}))

 (defn query
   [tenant-conn {:keys [columns table-name]} query]
@@ -61,12 +62,10 @@
         sql-text (if column-bucket sql-text-with-aggregation sql-text-without-aggregation)
         sql-response (run-query tenant-conn sql-text)]
     (lib/ok
-     {:series (conj [(serie sql-response column-x 0)
-                     (serie sql-response column-y 1)]
-                    (when (:title column-size)
-                      (serie sql-response column-size 2))
-                    (when (:title column-category)
-                      (serie sql-response column-size 3)))
-      :common {:metadata {:type    (:type column-label)
-                          :sampled (= (count sql-response) max-points)}
-               :data     (serie-data sql-response 4)}})))
+      {:series (map-indexed
+                 (fn [idx column]
+                   (serie sql-response column idx))
+                 [column-x column-y column-size column-category])
+       :common {:metadata {:type (:type column-label)
+                           :sampled (= (count sql-response) max-points)}
+                :data (serie-data :label sql-response 4)}})))


Use atoms for state

Use atoms for state

--- clojure/robot-name/robot.clj
+++ clojure/robot-name/robot.clj
@@ -1,6 +1,5 @@
 (def name-chars  "ABCDEFGHIJKLMNOPQRSTUVWXYZW")
 (def name-digits "0123456789")
-(def names {})

 (defn- random-chars [count collection]
   (repeatedly count #(rand-nth collection)))
@@ -12,12 +11,10 @@

 (defn robot []
   (let [name (new-name)]
-    (def names (assoc names name name))
-    {:id name}))
+    {:id (atom name)}))

 (defn robot-name [robot]
-  (names (robot :id)))
+  @(robot :id))

 (defn reset-name [robot]
-  (def names (update-in names [(robot :id)] new-name))
-  robot)+  (swap! (robot :id) new-name))


add more exceptions for imperfect: "dicevo" -> "dire"


comments and whitespace

comments and whitespace

--- src/babel/italiano/morphology/verbs.cljc
+++ src/babel/italiano/morphology/verbs.cljc
@@ -107,7 +107,7 @@
    [{:agr {:synsem {:subcat {:1 {:agr {:number :sing
                                        :person :1st}}}}}
      :p [
-         #"(.*)erò"     "$1are"
+         #"(.*)erò"     "$1are"  ;; parlerò -> parlare
          #"(.*)cherò"   "$1care" ;; cercherò -> cercare
          #"(.*)chò"     "$1care" ;; carichò -> caricare
          #"(.*)erò"     "$1arsi"
@@ -143,7 +143,7 @@
          #"(.*)ai"       "$1e" ;; farai -> fare
          #"(.*)erai"     "$1are"
          #"(.*)erai"     "$1arsi"
-         #"(.*)cherai"    "$1care" ;; cercherai -> cercare
+         #"(.*)cherai"   "$1care" ;; cercherai -> cercare
          #"(.*)drai"     "$1dare"
          #"(.*)erai"     "$1ersi"
          #"(.*)errai"    "$1enere" ;; otterrai -> ottenere


Made induce-context to not recompute parts of the old context

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

--- src/conexp/contrib/dl/languages/EL_gfp_exploration.clj
+++ src/conexp/contrib/dl/languages/EL_gfp_exploration.clj
@@ -27,12 +27,22 @@
 (defn- induced-context
   "Returns context induced by the set of concept descriptions and the
   given model."
-  [descriptions model]
-  (let [objects    (model-base-set model),
-	attributes descriptions,
-	incidence  (set-of [g m] [m attributes,
-				  g (interpret model m)])]
-    (make-context objects attributes incidence)))
+  ([descriptions model]
+     (induced-context descriptions model (make-context #{} #{} #{})))
+  ([descriptions model old-context]
+     (let [new-objects    (difference (model-base-set model)
+                                      (objects old-context)),
+           new-attributes (difference (set descriptions)
+                                      (attributes old-context)),
+           new-incidence  (union (set-of [x y] [y new-attributes,
+                                                x (interpret model y)])
+                                 (if (empty? new-objects)
+                                   (incidence old-context)
+                                   (set-of [x y] [y (attributes old-context),
+                                                  x (interpret model y)])))]
+       (make-context (union (objects old-context) new-objects)
+                     (union (attributes old-context) new-attributes)
+                     new-incidence))))

 (defn- obviously-true?
   "Returns true iff the given subsumption is obviously true."
@@ -88,9 +98,9 @@
 				    model
 				    (recur (extend-model-by-contradiction model susu))))),
 		   next-M_k   (apply add-concepts! M_k (for [r (role-names language)]
-							 (dl-expression language
-									(exists r (model-closure next-model all-P_k))))),
-		   next-K     (induced-context (seq-on next-M_k) next-model),
+                                                         (dl-expression language
+                                                                        (exists r (model-closure next-model all-P_k))))),
+		   next-K     (induced-context (seq-on next-M_k) next-model K),
 		   next-Pi_k  (conj Pi_k P_k),

 		   implications (set-of impl [P_l next-Pi_k


remove support for subjunctive for now

remove support for subjunctive for now

--- src/babel/italiano/morphology/verbs.cljc
+++ src/babel/italiano/morphology/verbs.cljc
@@ -88,8 +88,7 @@
         patterns-gerund
         patterns-imperfetto
         patterns-passato
-        patterns-present
-        patterns-subjunctive)))
+        patterns-present)))

 (defn regular-conditional [word]
   (let [unifying-patterns


Remove vestigial constant

Remove vestigial constant

--- src/onyx/state/log/bookkeeper.clj
+++ src/onyx/state/log/bookkeeper.clj
@@ -232,9 +232,6 @@
             state')))
       state)))

-
-(def chunk-size 2)
-
 (defn playback-ledger [state ^LedgerHandle lh last-confirmed {:keys [onyx.core/peer-opts] :as event}]
   (let [chunk-size (arg-or-default :onyx.bookkeeper/read-batch-size peer-opts)]
     (if-not (neg? last-confirmed)


fleshed out boolean, integer, string coercions in onyx-java.utility.interop

--- src/onyx_java/utility/interop.clj
+++ src/onyx_java/utility/interop.clj
@@ -16,10 +16,12 @@
   :name onyx-java.IPipeline
   :methods [[writeBatch [clojure.lang.IPersistentMap] clojure.lang.IPersistentMap]])

+(defn boolean_string [y] (if (= (type y) java.lang.String) (read-string y) y))
+
 (def casts
-  {:boolean (fn [x] x)
-   :integer (fn [x] x)
-   :string (fn [x] x)
+  {:boolean (fn [x] (boolean (boolean_string x)))
+   :integer (fn [x] (Integer/parseInt (re-find #"\A-?\d+" x)))
+   :string (fn [x] (str x))
    :any (fn [x] x)
    :keyword (fn [x] (keyword x))
    :vector (fn [x] (vec x))})
@@ -30,6 +32,8 @@
      (fn [m* k v]
        (let [k* (keyword k)
              type (get-in model [section* :model k* :type])
+             choices (get-in model [section* :model k* :choices])
+             required (not (get-in model [section* :model k* :optional?]))
              v* ((get casts type identity) v)]
          (assoc m* k* v*)))
      {}


Make Eastwood happy. Thanks Eastwood!

Make Eastwood happy. Thanks Eastwood!

--- src/open_company/api/sections.clj
+++ src/open_company/api/sections.clj
@@ -61,7 +61,7 @@
   :exists? (by-method {
                        :get (fn [_] (get-section conn company-slug section-name as-of))
                        :put (fn [_] (and (nil? as-of) (get-section conn company-slug section-name as-of)))
-                       :patch (fn [_] (and (get-section conn company-slug section-name as-of)))
+                       :patch (fn [_] (get-section conn company-slug section-name as-of))
                        :delete (fn [_] (and (nil? as-of) (get-section conn company-slug section-name as-of)))})

   :known-content-type? (fn [ctx] (common/known-content-type? ctx section-rep/media-type))


First time echo works.

First time echo works.

--- src/cbfg/world-net.cljs
+++ src/cbfg/world-net.cljs
@@ -16,7 +16,7 @@
             (println "server is recv'ing")
             (let [msg (atake server-conn-loop server-recv-ch)]
               (println "server echoing" msg)
-              (aput server-conn-loop server-send-ch msg)
+              (aput server-conn-loop server-send-ch [msg])
               (recur (inc num-requests)))))

 (defn server-accept-loop [actx accept-ch]
@@ -45,7 +45,9 @@
                        cmd-rq ((get cmd-handlers (:op cmd)) cmd)]
                    (render-client-hist (swap! client-hist
                                               #(assoc % ts [cmd nil])))
-                   (aput client-loop client-send-ch cmd-rq)
+                   (println "client sending" cmd-rq)
+                   (aput client-loop client-send-ch [cmd-rq])
+                   (println "client sending done" cmd-rq)
                    (recur (inc num-requests) num-responses)))
                (= ch client-recv-ch)
                (when v


remove TODOs

remove TODOs

--- src/clj/backtype/storm/daemon/common.clj
+++ src/clj/backtype/storm/daemon/common.clj
@@ -226,8 +226,6 @@
     (add-acker! (storm-conf TOPOLOGY-ACKERS) ret)
     (add-system-streams! ret)
     (add-transaction-streams! storm-conf ret)
-    ;; TODO: need to set up streams/inputs for transactional spout
-    ;; TODO: need to set up streams/inputs for transactional bolts
     (validate-structure! ret)
     ret
     ))


slight refactoring

slight refactoring

--- src/clj/backtype/storm/daemon/nimbus.clj
+++ src/clj/backtype/storm/daemon/nimbus.clj
@@ -787,8 +787,7 @@
               task-info (storm-task-info storm-cluster-state storm-id)
               base (.storm-base storm-cluster-state storm-id nil)
               assignment (.assignment-info storm-cluster-state storm-id nil)
-              no-assigned-tasks? (empty? (:task->node+port assignment))
-              task-summaries (if no-assigned-tasks?
+              task-summaries (if (empty? (:task->node+port assignment))
                                []
                                (dofor [[task component] task-info]
                                     (let [[node port] (get-in assignment [:task->node+port task])


launch the worker heartbeat thread immediately so that slow loading tasks don't cause the worker to timeout

--- src/clj/backtype/storm/daemon/worker.clj
+++ src/clj/backtype/storm/daemon/worker.clj
@@ -328,12 +328,20 @@
         ;; heartbeat immediately to nimbus so that it knows that the worker has been started
         _ (do-executor-heartbeats worker)

+
+        executors (atom nil)
+        ;; launch heartbeat threads immediately so that slow-loading tasks don't cause the worker to timeout
+        ;; to the supervisor
+        _ (schedule-recurring (:heartbeat-timer worker) 0 (conf WORKER-HEARTBEAT-FREQUENCY-SECS) heartbeat-fn)
+        _ (schedule-recurring (:executor-heartbeat-timer worker) 0 (conf TASK-HEARTBEAT-FREQUENCY-SECS) #(do-executor-heartbeats worker :executors @executors))
+
+
         refresh-connections (mk-refresh-connections worker)

         _ (refresh-connections nil)
         _ (refresh-storm-active worker nil)

-        executors (dofor [e (:executors worker)] (executor/mk-executor worker e))
+        _ (reset! executors (dofor [e (:executors worker)] (executor/mk-executor worker e)))
         receive-thread-shutdown (launch-receive-thread worker)

         transfer-tuples (mk-transfer-tuples-handler worker)
@@ -350,7 +358,7 @@
                     (log-message "Shut down receive thread")
                     (log-message "Terminating zmq context")
                     (log-message "Shutting down executors")
-                    (doseq [executor executors] (.shutdown executor))
+                    (doseq [executor @executors] (.shutdown executor))
                     (log-message "Shut down executors")

                     ;;this is fine because the only time this is shared is when it's a local context,
@@ -395,8 +403,6 @@

     (schedule-recurring (:refresh-connections-timer worker) 0 (conf TASK-REFRESH-POLL-SECS) refresh-connections)
     (schedule-recurring (:refresh-active-timer worker) 0 (conf TASK-REFRESH-POLL-SECS) (partial refresh-storm-active worker))
-    (schedule-recurring (:heartbeat-timer worker) 0 (conf WORKER-HEARTBEAT-FREQUENCY-SECS) heartbeat-fn)
-    (schedule-recurring (:executor-heartbeat-timer worker) 0 (conf TASK-HEARTBEAT-FREQUENCY-SECS) #(do-executor-heartbeats worker :executors executors))

     (log-message "Worker has topology config " (:storm-conf worker))
     (log-message "Worker " worker-id " for storm " storm-id " on " supervisor-id ":" port " has finished loading")


adjusted valid modis.

adjusted valid modis.

--- src/clj/forma/hadoop/jobs/preprocess.clj
+++ src/clj/forma/hadoop/jobs/preprocess.clj
@@ -6,7 +6,6 @@
                                 globbed-wholefile-tap)])
   (:require [forma.source.hdf :as h]
             [forma.source.rain :as r]
-            [forma.source.modis :as m]
             [forma.static :as s])
   (:gen-class))

@@ -33,9 +32,12 @@
         (r/rain-chunks m-res ll-res chunk-size tile-seq source))))

 ;; TEMPORARY stuff for the big run :-*
+;;
+;; TODO: move to hadoop.io
+
 (defn tiles->globstring
   [& tiles]
-  {:pre [(m/valid-modis? tiles)]}
+  {:pre [(valid-modis? tiles)]}
   (let [hv-seq (interpose "," (for [[th tv] tiles]
                                 (format "h%02dv%02d" th tv)))]
     (format "*{%s}*" (apply str hv-seq))))
@@ -48,7 +50,6 @@

    hadoop jar forma-standalone.jar modisdata/MOD13A3/ reddoutput/ [8 6] [10 12]"
   [input-path output-path & tiles]
-  {:pre [(m/valid-modis? tiles)]}
   (let [tileseq (map read-string tiles)
         tilestring (str input-path (apply tiles->globstring tileseq))]
     (modis-chunker s/forma-subsets s/chunk-size
@@ -58,7 +59,6 @@
 (defn rain-main
   "TODO: Example usage."
   [input-path output-path & tiles]
-  {:pre [(m/valid-modis? tiles)]}
   (rain-chunker "1000" 0.5 s/chunk-size (map read-string tiles)
                 (s3-path input-path)
                 (s3-path output-path)))


Oopps..

Oopps..

--- src/clj/mokkameister/resources/slack.clj
+++ src/clj/mokkameister/resources/slack.clj
@@ -70,7 +70,7 @@
     (pusher/push! "coffee" "coffee" now-msg)
     (slack/notify (str now-msg " - " mokkameister-link) :channel channel)
     (slack/delayed-notify time-ms later-msg :channel channel)
-    (if (= total-count 999)
+    (when (= total-count 999)
       (slack/delayed-notify (+ time-ms 1000) "http://gph.is/2cTHbu3" :channel channel)
       (slack/delayed-notify (+ time-ms 1500) "Dette var brygg nr 1000! :tada::confetti_ball::coffee:" :channel channel))))


cleanup

cleanup

--- src/clj/rksm/cloxp_cljs/ns/internals.clj
+++ src/clj/rksm/cloxp_cljs/ns/internals.clj
@@ -67,12 +67,14 @@

 (defn source-for-symbol
   [sym & [file]]
-  ; FIXME ensure namespace info
+
+  ; ensure we have analyzed data for ns of sym
   (let [ns-name (symbol (namespace sym))]
-    (if-not (some-> (ensure-default-cljs-env)
-              :compiler-env deref
-              :cljs.analyzer/namespaces (get ns-name))
-      (namespace-info ns-name file)))
+    (if-not (get-in
+             @(:compiler-env (ensure-default-cljs-env))
+             [:cljs.analyzer/namespaces ns-name])
+      (ensure-ns-analyzed! ns-name)))
+
   (if-let [file-data (some-> (analyzed-data-of-def sym file)
                        (select-keys [:column :line :file]))]
     (let [def-file (:file file-data)


alter tile functionality

alter tile functionality

--- src/cljs/infinitelives/pixi/tilemap.cljs
+++ src/cljs/infinitelives/pixi/tilemap.cljs
@@ -43,7 +43,28 @@
          :particle true
          opts))

-(defn alter-tile! [sprite-set coord tile-set texture-key]
+
+(defn alter-tile! [layer sprite-set coord tile-set texture-key]
+  (assert (sprite-set coord) (str "Trying to alter position " coord " where no tile is placed is forbidden"))
   (set!
    (.-texture (sprite-set coord))
-   (-> tile-set :texture-map texture-key)))
+   (-> tile-set :texture-map texture-key))
+  sprite-set)
+
+(defn add-tile! [layer sprite-set coord tile-set texture-key]
+  (assert (not (sprite-set coord)) (str "Can only add a new tile to an empty position. Coord " coord " already has tile " (sprite-set coord)))
+  (let [tile-width 16
+        tile-height 16
+        [col row] coord
+        new-sprite (s/make-sprite (-> tile-set :texture-map texture-key)
+                                  :x (* tile-width col) :y (* tile-height row)
+                                  :xhandle 0 :yhandle 0)]
+    (.addChild layer new-sprite)
+    (assoc sprite-set coord new-sprite)))
+
+(defn change-tile! [layer sprite-set coord tile-set texture-key]
+  (if (sprite-set coord)
+    (alter-tile! layer sprite-set coord tile-set texture-key)
+    (add-tile! layer sprite-set coord tile-set texture-key)
+)
+)


Add sum message to sum the two counters

Add sum message to sum the two counters

--- src/cljs/pushpopchestnutreless/core.cljs
+++ src/cljs/pushpopchestnutreless/core.cljs
@@ -26,6 +26,9 @@
 (defmethod step :dec2 [state m]
   (update state :count2 dec))

+(defmethod step :sum [state m]
+  (pp/pprint (+ (:count state) (:count2 state)))
+  state)

 ; VIEW HELPERS

@@ -59,7 +62,10 @@
     {:on-change (on-change :change-text)
      :value (:text state)}]
    [counter (:count state) :inc :dec]
-   [counter (:count2 state) :inc2 :dec2]])
+   [counter (:count2 state) :inc2 :dec2]
+   [:button
+    {:on-click (on-click :sum)}
+    "sum"]])

 (defn app []


only calculate the failure array once

only calculate the failure array once

--- src/cljs/strmatch/logic/kmp_matcher.cljs
+++ src/cljs/strmatch/logic/kmp_matcher.cljs
@@ -37,13 +37,12 @@
      :colors (color-array padding length-of-match)}))

 (defn match
-  ([needle haystack] (vec (reverse (match needle haystack 0 nil 0))))
-  ([needle haystack index result prev-fail]
-   (let [fail (failure-array needle)
-         discrep (discrepancy-index needle haystack index)
-         jump (- discrep (fail discrep))
+  ([needle haystack] (vec (reverse (match needle haystack (failure-array needle) 0 nil 0))))
+  ([needle haystack fail-array index result prev-fail]
+   (let [discrep (discrepancy-index needle haystack index)
+         jump (- discrep (fail-array discrep))
          next-entry (entry-for index discrep needle prev-fail)
          next-result (cons next-entry result)]
      (if (and discrep (<= index (count haystack)))
-       (recur needle haystack (+ index jump) next-result (fail discrep))
+       (recur needle haystack fail-array (+ index jump) next-result (fail-array discrep))
        next-result))))


Add read-body handler helper.

Add read-body handler helper.

--- src/clojure/catacumba/handlers/parse.clj
+++ src/clojure/catacumba/handlers/parse.clj
@@ -67,6 +67,18 @@
   (let [reader (transit/reader (.getInputStream body) :msgpack)]
     (transit/read reader)))

+;; --- Handlers
+
+(defn read-body
+  "A handler that just reads the body from request and puts
+  it on the context under `:body` key."
+  [{:keys [method] :as context}]
+  (if (= method :get)
+    (ctx/delegate {:body nil})
+    (->> (ctx/get-body! context)
+         (p/map (fn [^TypedData body]
+                  (ctx/delegate {:body body}))))))
+
 (defn body-params
   "A route chain that parses the body into
   a clojure friendly data structure.