test hook for service restart

test hook for service restart

--- src/main/cawala/api/read.clj
+++ src/main/cawala/api/read.clj
@@ -6,7 +6,7 @@
                      :person/relation :friend}
                  2  {:db/id 2 :person/name "Sally" :person/age 22
                      :person/relation :friend}
-                 3  {:db/id 3 :person/name "Allie" :person/age 53
+                 3  {:db/id 3 :person/name "Allie" :person/age 52
                      :person/relation :enemy}
                  4  {:db/id 4 :person/name "Zoe" :person/age 32
                      :person/relation :friend}


Fix ring-swagger example

Fix ring-swagger example

--- examples/ring-swagger/src/example/server.clj
+++ examples/ring-swagger/src/example/server.clj
@@ -61,7 +61,7 @@
                             {:status 200
                              :body {:total (+ x y)}})}}]]]

-      {:reitit.middleware/transform dev/print-context-diffs
+      {:reitit.middleware/transform dev/print-request-diffs
        :data {:coercion reitit.coercion.spec/coercion
               :muuntaja m/instance
               :middleware [;; query-params & form-params


Comment in nongenerative tests

Comment in nongenerative tests

--- test/active/clojure/record_test.cljc
+++ test/active/clojure/record_test.cljc
@@ -285,25 +285,26 @@
 ;; Note: Clojure / Java introduced new error handling features with Clojure version 1.10.0.
 ;; Therefore we're using `(.getMessage (.getCause e))` now instead of only `(getMessage e)`.
 #?(:clj (defmacro throws-exception?
-          [form]
+          [form msg]
           (try
             (eval form)
             (catch Exception e
               (or (clojure.string/includes?
                    (str e)
-                   "This record type definition already exists with different arguments.")
+                   msg)
                   (clojure.string/includes?
                    (.getMessage (.getCause e))
-                   "This record type definition already exists with different arguments."))))))
-
-#_(deftest nongenerative-record-test
+                   msg))))))
+
+(deftest nongenerative-record-test
    ;; Other implementation should throw an error
   (is (throws-exception?
-        (define-record-type NonGenerativeRecord
-          {:nongenerative "NonGenerativeRecord"}
-          (make-non-generative-record)
-          non-generative-record?
-          [])))
+       (define-record-type NonGenerativeRecord
+         {:nongenerative "NonGenerativeRecord"}
+         (make-non-generative-record)
+         non-generative-record?
+         [])
+       "This record type definition already exists with different arguments."))
    ;; The exact same definition should not throw an exception
    (is (nil? (define-record-type NonGenerativeRecord
                {:nongenerative "NonGenerativeRecord"}
@@ -317,7 +318,8 @@
           {:nongenerative "NonGROtherNS"}
           (make-ngrons field)
           ngrons?
-          [field ngrons-field]))))
+          [field ngrons-field])
+        "This record type definition already exists with different arguments.")))

 ;;; Test automatic generation of nongenerative id
 (define-record-type NonGenerativeRecordAuto


Remove bad whitespace

Remove bad whitespace

--- test/adventofclojure/day_01_test.clj
+++ test/adventofclojure/day_01_test.clj
@@ -3,12 +3,12 @@
             [adventofclojure.day-01 :refer :all]))

 (deftest move-test
-  (is (=  {:dir :n, :n 1, :s 0, :e 0, :w 0} (move starting-state "X1"))))
+  (is (= {:dir :n, :n 1, :s 0, :e 0, :w 0} (move starting-state "X1"))))

 (deftest turn-test
-  (is (=  {:dir :n, :n 0, :s 0, :e 0, :w 0} (turn starting-state "X0")))
-  (is (=  {:dir :w, :n 0, :s 0, :e 0, :w 0} (turn starting-state "L0")))
-  (is (=  {:dir :e, :n 0, :s 0, :e 0, :w 0} (turn starting-state "R0"))))
+  (is (= {:dir :n, :n 0, :s 0, :e 0, :w 0} (turn starting-state "X0")))
+  (is (= {:dir :w, :n 0, :s 0, :e 0, :w 0} (turn starting-state "L0")))
+  (is (= {:dir :e, :n 0, :s 0, :e 0, :w 0} (turn starting-state "R0"))))

 (deftest add-crumb-test
   (is (= {:dir :n, :n 1, :s 0, :e 1, :w 0, :crumbs '({:x 1, :y 1} {:x 0, :y 0})}


Second test for starts-with function

Second test for starts-with function

--- test/clouseau/test_utils.clj
+++ test/clouseau/test_utils.clj
@@ -309,6 +309,15 @@
             true  (startsWith "Hello world!" "H")
             true  (startsWith "Hello world!" ""))))

+(deftest test-starts-with-2
+    "Check the function clouseau.utils/starts-with."
+    (testing "the function clouseau.utils/starts-with."
+        (are [x y] (= x y)
+            false (startsWith "" "hello")
+            false (startsWith "" "Hello")
+            false (startsWith "" "H")
+            true  (startsWith "" ""))))
+
 (deftest test-starts-with-NPE
     "Check the function clouseau.utils/starts-with."
     (testing "the function clouseau.utils/starts-with."


Formatting

Formatting

--- src/hundred_pushups/events.cljs
+++ src/hundred_pushups/events.cljs
@@ -29,11 +29,7 @@
 (defn boot-flow []
   {:first-dispatch [:boot/load-db]
    :rules
-   [
-    {:when :seen? :events [:boot/db-init.ok] :halt? true}
-    ]
-   }
-  )
+   [{:when :seen? :events [:boot/db-init.ok] :halt? true}]})

 ;; -- Handlers --------------------------------------------------------------


Removes unused event handler

Removes unused event handler

--- src/hundred_pushups/events.cljs
+++ src/hundred_pushups/events.cljs
@@ -6,10 +6,7 @@
     [hundred-pushups.db :as db :refer [default-db]]
     [re-frame.core :refer [reg-event-db after reg-event-fx dispatch reg-fx]]
     [cljs.core.async :as async]
-    )
-  ;; TODO - delete?
-  (:require-macros [cljs.core.async.macros :refer [go]])
-  )
+    ))

 ;; -- Interceptors ------------------------------------------------------------
 ;;
@@ -42,13 +39,6 @@

 ;; TODO - improve naming scheme
 (def local-storage-db-key :db)
-
-;; TODO - remove
-(reg-event-db
- :initialize-db
- validate-spec
- (fn [_ _]
-   default-db))

 (reg-event-fx
  :boot/init


cleanup scanner

cleanup scanner

--- src/hackerrank/security/Security_Bijective_Functions.clj
+++ src/hackerrank/security/Security_Bijective_Functions.clj
@@ -4,12 +4,9 @@
   (:use [clojure.string :only (split join trim)]))

+(def input "3\n1 2 3")

-(with-in-str "1"
-;;   (def scan (Scanner. System/in))
-  (def scan (Scanner. *in*))
-
-  (println (. scan nextInt)))
-
-;; (with-in-str "1"
-;;   (println (read-line)))
+(with-in-str input
+  (let [scan (Scanner. *in*)
+        n (. scan nextInt)]
+    (println n)))


Internal API change for invalidate!

Internal API change for invalidate!

--- test/derive/simple_test.cljs
+++ test/derive/simple_test.cljs
@@ -50,7 +50,7 @@
   (let [c (d/default-cache)]
     (d/add-value! c [1 2] :result {:store #{1 4 8}})
     (is (= (first (d/get-value c [1 2])) :result))
-    (is (= (d/invalidate! c :store #{4}) #{[1 2]}))))
+    (is (= (d/invalidate! c :store #{4}) [[1 2]]))))

 (deftest simple-store
   (let [store (store/create)


hide play again when ther are no notes

hide play again when ther are no notes

--- src/cljs/daveconservatoire/site/ui/exercises.cljs
+++ src/cljs/daveconservatoire/site/ui/exercises.cljs
@@ -139,7 +139,7 @@
   Object
   (render [this]
     (let [{:keys [::options ::ex-answer ::ex-total-questions
-                  ::streak-count] :as props} (om/props this)
+                  ::streak-count ::notes] :as props} (om/props this)
           [opt-type _] (s/conform ::options options)
           check-answer #(do
                          (om/transact! this `[(dcex/check-answer)
@@ -171,9 +171,10 @@
                             (dom/div #js {:id "problem-type-or-description"}
                               (dom/div #js {:className "problem"}
                                 (om/children this)
-                                (dom/a #js {:className "btn_primary"
-                                            :onClick   #(play-sound this)}
-                                  "Play Again"))))
+                                (if (seq notes)
+                                  (dom/a #js {:className "btn_primary"
+                                              :onClick   #(play-sound this)}
+                                    "Play Again")))))
                           (dom/div #js {:id "hintsarea"}))
                         (dom/div #js {:id "answer_area_wrap"}
                           (dom/div #js {:id "answer_area"}


Cleanup tests

Cleanup tests

--- test/expound/alpha_test.cljc
+++ test/expound/alpha_test.cljc
@@ -1434,10 +1434,6 @@
                   (throw e))))))))))

 ;; Using conformers for transformation should not crash by default, or at least give useful error message.
-;; Examples from:
-
-;;
-
 (defn numberify [s]
   (cond
     (number? s) s
@@ -1478,8 +1474,6 @@
    (s/conformer seq)
    ; re-use previous sequence spec
    :conformers-test/string-AB-seq))
-
-(comment)

 (deftest conformers-test
   ;; Example from http://cjohansen.no/a-unified-specification/


Use rand-nth instead of first and shuffle in robot-name/generate-name

--- exercises/robot-name/src/example.clj
+++ exercises/robot-name/src/example.clj
@@ -2,7 +2,7 @@

 (def ^:private letters (map char (range 65 91)))
 (defn- generate-name []
-  (format "%s%03d" (apply str (repeatedly 2 #(first (shuffle letters))))
+  (format "%s%03d" (apply str (repeatedly 2 #(rand-nth letters)))
           (rand-int 1000)))

 (defn robot []


NPE check for the function substring

NPE check for the function substring

--- test/hurvinek/utils_test.clj
+++ test/hurvinek/utils_test.clj
@@ -139,6 +139,10 @@
     "Check the function hurvinek.utils/third."
     (testing "the function hurvinek.utils/third."
         (are [x y] (= x y)
+            nil (third [])
+            nil (third '())
+            nil (third [1])
+            nil (third '(1))
             nil (third [1 2])
             nil (third '(1 2)))))

@@ -184,6 +188,13 @@
             "" (substring "Hello world!" 1 1)
             "" (substring "Hello world!" 2 2)
             "" (substring "Hello world!" 10 10))))
+
+(deftest test-substring-NPE
+    "Check the function hurvinek.utils/substring."
+    (testing "the function hurvinek.utils/substring."
+        (is (thrown? NullPointerException (substring nil 0 0)))
+        (is (thrown? NullPointerException (substring "" nil 0)))
+        (is (thrown? NullPointerException (substring "" 0 nil)))))

 (deftest test-contains-1
     "Check the function hurvinek.utils/contains."


queue: use volatile! instead of our own implem.

--- src/io/cyanite/engine/queue.clj
+++ src/io/cyanite/engine/queue.clj
@@ -22,31 +22,11 @@
   (consume! [this f])
   (add! [this e]))

-(defprotocol WrapperEvent
-  (get-data  [_])
-  (set-data! [this v]))
-
 (defn make-event-factory
   [ctor]
   (reify EventFactory
     (newInstance [this]
       (ctor))))
-
-;; For sakes of prototyping, we are using the mutable
-;; wrapper. This is not very idiomatic to ring buffer,
-;; so it's better to use mutable bags of primitives.
-;; If the approach with RB proves itself, we will migrate
-;; the code to use it.
-(deftype Event [^{:volatile-mutable true} x]
-  WrapperEvent
-  (get-data [_]
-    x)
-  (set-data! [this v]
-    (set! x v)))
-
-(defn wrapper-event-factory
-  []
-  (make-event-factory (fn [] (Event. nil))))

 (defn threadpool
   [sz]
@@ -66,7 +46,7 @@
   [f]
   (reify EventHandler
     (onEvent [this event sequence eob]
-      (f (get-data event)))))
+      (f @event))))

 (defrecord DisruptorQueue [disruptor translator]
   QueueEngine
@@ -81,9 +61,10 @@
 (defn make-queue
   [defaults]
   (let [capacity (or (:queue-capacity defaults) default-capacity)
-        pool     (threadpool (or (:pool-size defaults) default-poolsize))]
-    (DisruptorQueue. (disruptor (wrapper-event-factory) capacity pool)
-                     (make-translator (fn [e v] (set-data! e v))))))
+        pool     (threadpool (or (:pool-size defaults) default-poolsize))
+        factory  (make-event-factory #(volatile! nil))]
+    (DisruptorQueue. (disruptor factory capacity pool)
+                     (make-translator vreset!))))

 (defrecord BlockingMemoryQueue [ingestq writeq defaults]
   component/Lifecycle


stop calling card-init on cards installed facedown

--- src/clj/game/core.clj
+++ src/clj/game/core.clj
@@ -1427,9 +1427,11 @@
                (let [c (if host-card
                          (host state side host-card card)
                          (move state side card [:rig (if facedown :facedown (to-keyword type))]))
-                     installed-card (card-init state side (assoc c :installed true) (not facedown))]
+                     installed-card (if facedown
+                                      (update! state side (assoc c :installed true))
+                                      (card-init state side (assoc c :installed true) true))]
                  (if facedown
-                   (system-msg state side "installs a card facedown" )
+                   (system-msg state side "installs a card facedown")
                  (if custom-message
                    (system-msg state side custom-message)
                    (system-msg state side (str (build-spend-msg cost-str "install") title


Use google metadata server (#1514)

Use google metadata server (#1514)

--- scheduler/src/cook/kubernetes/compute_cluster.clj
+++ scheduler/src/cook/kubernetes/compute_cluster.clj
@@ -435,6 +435,19 @@
         (catch Exception ex
           (log/error ex "Error refreshing bearer token"))))))

+(defn- set-credentials
+  "Set credentials for api client"
+  [api-client credentials bearer-token-refresh-seconds]
+  (let [scoped-credentials (.createScoped credentials ["https://www.googleapis.com/auth/cloud-platform"
+                                                       "https://www.googleapis.com/auth/userinfo.email"])
+        bearer-token (get-bearer-token scoped-credentials)]
+    (.scheduleAtFixedRate bearer-token-executor
+                          (make-bearer-token-refresh-task api-client scoped-credentials)
+                          bearer-token-refresh-seconds
+                          bearer-token-refresh-seconds
+                          TimeUnit/SECONDS)
+    (.setApiKey api-client bearer-token)))
+
 (defn make-api-client
   "Builds an ApiClient from the given configuration parameters:
     - If config-file is specified, initializes the api file from the file at config-file
@@ -458,19 +471,12 @@
     (when (some? ssl-cert-path)
       (.setSslCaCert api-client
                      (FileInputStream. (File. ssl-cert-path))))
-    (when google-credentials
+    (if google-credentials
       (with-open [file-stream (FileInputStream. (File. google-credentials))]
-        (let [credentials (GoogleCredentials/fromStream file-stream)
-              scoped-credentials (.createScoped credentials ["https://www.googleapis.com/auth/cloud-platform"
-                                                             "https://www.googleapis.com/auth/userinfo.email"])
-              bearer-token (get-bearer-token scoped-credentials)]
-          (.scheduleAtFixedRate bearer-token-executor
-                                (make-bearer-token-refresh-task api-client scoped-credentials)
-                                bearer-token-refresh-seconds
-                                bearer-token-refresh-seconds
-                                TimeUnit/SECONDS)
-          (.setApiKey api-client bearer-token))))
-
+        (let [credentials (GoogleCredentials/fromStream file-stream)]
+          (set-credentials api-client credentials bearer-token-refresh-seconds)))
+      (let [credentials (GoogleCredentials/getApplicationDefault)]
+        (set-credentials api-client credentials bearer-token-refresh-seconds)))
     api-client))

 (defn guard-invalid-synthetic-pods-config


more error checking for macros

more error checking for macros

--- src/insn/clojure.clj
+++ src/insn/clojure.clj
@@ -66,7 +66,8 @@
         [decls args] (if (seq? (first args))
                        (split-with seq? args)
                        [(list args) nil])
-        [post] (util/optional map? args)]
+        [post more] (util/optional map? args)]
+    (assert (nil? more) (str "trailing defn data: " (pr-str (first more))))
     `(do
        (def ~fname (fn ~fname ~@decls))
        (doto #'~fname
@@ -77,5 +78,5 @@
 (defmacro defn-
   "Bytecode version of `clojure.core/defn-`. See `defn`."
   [fname & args]
-  (assert (symbol? fname) fname)
+  (assert (symbol? fname) (str "invalid defn- name: " (pr-str fname)))
   (list* `defn (vary-meta fname assoc :private true) args))


Connection doesn't need to require data ns.

--- src/merkle_db/connection.clj
+++ src/merkle_db/connection.clj
@@ -9,7 +9,6 @@
       [node :as node]
       [ref :as ref])
     (merkle-db
-      [data :as data]
       [db :as db])))


don't use separate column for model settings

--- server-cached/src/patavi/server/server_cached.clj
+++ server-cached/src/patavi/server/server_cached.clj
@@ -46,7 +46,7 @@
 (defn println* [x] (println x) x)

 (defn handle-with-cache [id req]
-  (let [call (jdbc/query db-url ["select id, method, linearModel, problem, result from pataviTask where id = ?" (Integer. id)])]
+  (let [call (jdbc/query db-url ["select id, method, problem, result from pataviTask where id = ?" (Integer. id)])]
     (if (empty? call)
         { :status 404 :body "No such task" }
         (handle-service-with-cache req (first call)))))


order more sensibly

order more sensibly

--- src/metabase/api/meta/db.clj
+++ src/metabase/api/meta/db.clj
@@ -44,12 +44,11 @@
 (defendpoint POST "/validate" [:as {{:keys [host port]} :body}]
   {host Required
    port Required}
-  (let [response-invalid (fn [m] {:status 400 :body {:valid false :message m}})]
+  ((let [response-invalid (fn [m] {:status 400 :body {:valid false :message m}})]
     (cond
-      (not (u/host-port-up? host port))
-        (cond (not (u/host-up? host)) (response-invalid "Host not reachable")
-              :else (response-invalid "Invalid port"))
-      :else {:valid true})))
+      (u/host-port-up? host port) {:valid true}
+      (u/host-up? host)           (response-invalid "Invalid port")
+      :else                       "Host not reachable"))))

 (defendpoint GET "/:id" [id]
   (->404 (sel :one Database :id id)


DM + RS | #000 | Remove unused dependency from twitter workflow

--- src/objective8/front_end/workflows/twitter.clj
+++ src/objective8/front_end/workflows/twitter.clj
@@ -2,7 +2,6 @@
     (:require [clojure.tools.logging :as log]
               [oauth.client :as oauth]
               [ring.util.response :as response]
-              [ring.util.request :as request]
               [bidi.ring :refer [make-handler]]
               [objective8.front-end.views :as views]
               [objective8.utils :as utils]


bump figwheel

bump figwheel

--- src/leiningen/new/aemette/project.clj
+++ src/leiningen/new/aemette/project.clj
@@ -9,7 +9,7 @@
                  [secretary "1.2.3"]]

   :plugins [[lein-cljsbuild "1.1.1"]
-            [lein-figwheel "0.5.0-1"]]
+            [lein-figwheel "0.5.0-2"]]

   :source-paths ["src"]
   :clean-targets ^{:protect false} [[:cljsbuild :builds 0 :compiler :output-dir]


Moved Clojurescript dependency to :profiles :dev :dependencies.

Based on Phil Hagelberg's advice in:
http://librelist.com/browser//leiningen/2014/9/7/clarifications-about-scope-in-dependencies/#32fcd639eb09c94545bec6a56c200167

--- src/leiningen/new/reagent/project.clj
+++ src/leiningen/new/reagent/project.clj
@@ -12,7 +12,6 @@
                  [reagent "0.5.0"]
                  [reagent-forms "0.5.0"]
                  [reagent-utils "0.1.4"]
-                 [org.clojure/clojurescript "0.0-3211" :scope "provided"]
                  [ring "1.3.2"]
                  [ring/ring-defaults "0.1.4"]
                  [prone "0.8.1"]
@@ -50,7 +49,8 @@
   :profiles {:dev {:repl-options {:init-ns {{project-ns}}.repl
                                   :nrepl-middleware [cemerick.piggieback/wrap-cljs-repl{{{nrepl-middleware}}}]}

-                   :dependencies [[ring-mock "0.1.5"]
+                   :dependencies [[org.clojure/clojurescript "0.0-3211"]
+                                  [ring-mock "0.1.5"]
                                   [ring/ring-devel "1.3.2"]
                                   [weasel "0.6.0"]
                                   [leiningen-core "2.5.1"]


spelling corrected.

spelling corrected.

--- src/dda/pallet/crate/servertest/fact/file.clj
+++ src/dda/pallet/crate/servertest/fact/file.clj
@@ -24,7 +24,8 @@

 (def FileFactConfig {:file-paths [s/Str]})

-(def FileFactResult {s/Keyword {:size-in-bytes s/Num
+(def FileFactResult {s/Keyword {:exist s/Bool
+                                :size-in-bytes s/Num
                                 :user s/Str
                                 :group s/Str
                                 :mod s/Str
@@ -42,7 +43,7 @@
      (drop-while #(not (re-matches #"\s*(tcp|udp).*" %))
        (clojure.string/split netstat-resource #"\n"))))

-(s/defn collect-netstat-fact
+(s/defn collect-file-fact
   "Defines the netstat resource.
    This is automatically done serverstate crate is used.
    See also: https://unix.stackexchange.com/questions/128985/why-not-parse-ls, http://man7.org/linux/man-pages/man1/find.1.html"


Add reconciler action to store local component state

--- frontend/src/cruncher/utils/lib.cljs
+++ frontend/src/cruncher/utils/lib.cljs
@@ -1,6 +1,6 @@
 (ns cruncher.utils.lib
   (:require [om.next :as om :refer-macros [defui]]
-            [goog.dom :as gdom]
+            [cljs.core.async :refer [chan close!]]
             [cruncher.data.pokemon :as pokemon]))

 (defonce app-state
@@ -91,6 +91,10 @@
                                  :to_delete (:to_delete status)
                                  :deleted   (:deleted status)})))})

+(defmethod mutate 'status/niantic
+  [{:keys [state]} _ {:keys [status]}]
+  {:action (fn [] (swap! state update-in [:connected?] (fn [] status)))})
+
 (defmethod mutate 'toggle/progress
   [{:keys [state]} _ {:keys [status]}]
   {:action (fn [] (swap! state update-in [:progress-running?] (fn [] status)))})
@@ -243,6 +247,16 @@
   (when (string? str)
     (= "true" str)))

+
+;;;; Threading
+(defn timeout
+  "Set timeout for the current thread."
+  [ms]
+  (let [c (chan)]
+    (js/setTimeout (fn [] (close! c)) ms)
+    c))
+
+
 ;;;; Helpers
 (defn pokemon-evolution
   [pokemon]


Namespace the specs appropriately

Namespace the specs appropriately

--- fulcro-todo/src/main/app/schema.cljs
+++ fulcro-todo/src/main/app/schema.cljs
@@ -2,22 +2,22 @@
   (:require [cljs.spec.alpha :as spec]
             [clojure.string :as str]))

-(spec/def ::added-at int?)
+(spec/def :db/id int?)

-(spec/def ::text (spec/and string?
-                           (complement str/blank?)))
+(spec/def :item/added-at int?)

-(spec/def ::checked? boolean?)
+(spec/def :item/text (spec/and string?
+                               (complement str/blank?)))

-(spec/def ::item (spec/keys :req-un [::added-at
-                                     ::text
-                                     ::checked?]))
+(spec/def :item/checked? boolean?)
+
+(spec/def :item/by-id (spec/keys :req [:db/id :item/added-at :item/text :item/checked?]))

 (spec/def ::items-by-added-at (spec/and map?
                                         (spec/map-of ::added-at ::item)))

-(spec/def ::item-list (spec/coll-of ::added-at))
+(spec/def :item-list (spec/coll-of ::added-at))

-(spec/def ::input-value string?)
+(spec/def :item-adder/input-value string?)

-(spec/def ::sort-by-desc-added-at? boolean?)
+(spec/def :sort-by-desc-added-at? boolean?)


Return 204 on DELETE

Return 204 on DELETE

--- src/kixi/hecuba/api/devices.clj
+++ src/kixi/hecuba/api/devices.clj
@@ -150,6 +150,13 @@
         util/camelify
         json/encode)))

+(defn resource-respond-with-entity [ctx]
+  (let [request (:request ctx)
+        method  (:request-method request)]
+    (case method
+      :delete false
+      :else true)))
+
 (defresource index [{:keys [commander querier]} handlers]
   :allowed-methods #{:get :post}
   :available-media-types #{"text/html" "application/json"}
@@ -167,7 +174,7 @@
   :authorized? (authorized? querier :device)
   :exists? (partial resource-exists? querier)
   :delete-enacted? (partial resource-delete-enacted? commander)
-  :respond-with-entity? (constantly true) ;; the only way to return 200 ok
+  :respond-with-entity? (partial resource-respond-with-entity)
   :new? (constantly false)
   :can-put-to-missing? (constantly false)
   :put! (partial resource-put! querier commander)


search: minor stuff

search: minor stuff

--- search/test/org/mobileink/migae/search_test.clj
+++ search/test/org/mobileink/migae/search_test.clj
@@ -65,7 +65,6 @@
              "some test text max 1 MB"))
       (is (= (.getText (.getOnlyField theDoc "textfld2"))
              "some more test text")))))
-      ;; (log/debug "doc 1: " theDoc))))

 (deftest ^:doc search-doc-2
   (testing "search doc 2"


perf tweaks

perf tweaks

--- src/clj/clojure/spec.clj
+++ src/clj/clojure/spec.clj
@@ -118,23 +118,33 @@
           (throw (Exception. (str "Unable to resolve spec: " spec-or-k))))))

 (defprotocol Specize
-  (specize* [_]))
+  (specize* [_] [_ form]))

 (extend-protocol Specize
   clojure.lang.Keyword
-  (specize* [k] (specize* (reg-resolve! k)))
+  (specize* ([k] (specize* (reg-resolve! k)))
+            ([k _] (specize* (reg-resolve! k))))

   clojure.lang.Symbol
-  (specize* [s] (specize* (reg-resolve! s)))
+  (specize* ([s] (specize* (reg-resolve! s)))
+            ([s _] (specize* (reg-resolve! s))))

   clojure.spec.Spec
-  (specize* [s] s)
+  (specize* ([s] s)
+            ([s _] s))

   Object
-  (specize* [o] (spec-impl ::unknown o nil nil)))
-
-(defn- specize [s]
-  (specize* s))
+  (specize* ([o] (spec-impl ::unknown o nil nil))
+            ([o form] (spec-impl form o nil nil))))
+
+(defn- specize
+  ([s] (specize* s))
+  ([s form] (specize* s form)))
+
+(defn invalid?
+  "tests the validity of a conform return value"
+  [ret]
+  (identical? ::invalid ret))

 (defn conform
   "Given a spec and a value, returns :clojure.spec/invalid if value does not match spec,
@@ -426,26 +436,28 @@
         req-keys (into req-keys (map unk req-un-specs))
         opt-keys (into (vec opt) (map unk opt-un))
         opt-specs (into (vec opt) opt-un)
+        gx (gensym)
         parse-req (fn [rk f]
                     (map (fn [x]
                            (if (keyword? x)
-                             `#(contains? % ~(f x))
-                             (let [gx (gensym)]
-                               `(fn* [~gx]
-                                     ~(walk/postwalk
-                                       (fn [y] (if (keyword? y) `(contains? ~gx ~(f y)) y))
-                                       x)))))
+                             `(contains? ~gx ~(f x))
+                             (walk/postwalk
+                               (fn [y] (if (keyword? y) `(contains? ~gx ~(f y)) y))
+                               x)))
                          rk))
-        pred-exprs [`map?]
+        pred-exprs [`(map? ~gx)]
         pred-exprs (into pred-exprs (parse-req req identity))
         pred-exprs (into pred-exprs (parse-req req-un unk))
+        keys-pred `(fn* [~gx] (c/and ~@pred-exprs))
+        pred-exprs (mapv (fn [e] `(fn* [~gx] ~e)) pred-exprs)
         pred-forms (walk/postwalk res pred-exprs)]
-   ;; `(map-spec-impl ~req-keys '~req ~opt '~pred-forms ~pred-exprs ~gen)
+    ;; `(map-spec-impl ~req-keys '~req ~opt '~pred-forms ~pred-exprs ~gen)
     `(map-spec-impl {:req '~req :opt '~opt :req-un '~req-un :opt-un '~opt-un
                      :req-keys '~req-keys :req-specs '~req-specs
                      :opt-keys '~opt-keys :opt-specs '~opt-specs
                      :pred-forms '~pred-forms
                      :pred-exprs ~pred-exprs
+                     :keys-pred ~keys-pred
                      :gfn ~gen})))

 (defmacro or
@@ -651,7 +663,7 @@
   [v args]
   (let [fn-spec (get-spec v)]
     (when-let [arg-spec (:args fn-spec)]
-      (when (= ::invalid (conform arg-spec args))
+      (when (invalid? (conform arg-spec args))
         (let [ed (assoc (explain-data* arg-spec [:args]
                                        (if-let [name (spec-name arg-spec)] [name] []) [] args)
                    ::args args)]
@@ -720,9 +732,18 @@
 (defn valid?
   "Helper function that returns true when x is valid for spec."
   ([spec x]
-     (not= ::invalid (dt spec x ::unknown)))
+     (let [spec (specize spec)]
+       (not (invalid? (conform* spec x)))))
   ([spec x form]
-     (not= ::invalid (dt spec x form))))
+     (let [spec (specize spec form)]
+       (not (invalid? (conform* spec x))))))
+
+(defn- pvalid?
+  "internal helper function that returns true when x is valid for spec."
+  ([pred x]
+     (not (invalid? (dt pred x ::unknown))))
+  ([pred x form]
+     (not (invalid? (dt pred x form)))))

 (defn- explain-1 [form pred path via in v]
   ;;(prn {:form form :pred pred :path path :in in :v v})
@@ -733,36 +754,35 @@

 (defn ^:skip-wiki map-spec-impl
   "Do not call this directly, use 'spec' with a map argument"
-  [{:keys [req-un opt-un pred-exprs opt-keys req-specs req req-keys opt-specs pred-forms opt gfn]
+  [{:keys [req-un opt-un keys-pred pred-exprs opt-keys req-specs req req-keys opt-specs pred-forms opt gfn]
     :as argm}]
-  (let [keys-pred (apply every-pred pred-exprs)
-        k->s (zipmap (concat req-keys opt-keys) (concat req-specs opt-specs))
-        keys->specs #(c/or (k->s %) %)
+  (let [k->s (zipmap (concat req-keys opt-keys) (concat req-specs opt-specs))
+        keys->specnames #(c/or (k->s %) %)
         id (java.util.UUID/randomUUID)]
     (reify
      Spec
      (conform* [_ m]
                (if (keys-pred m)
                  (let [reg (registry)]
-                   (loop [ret m, [k & ks :as keys] (c/keys m)]
+                   (loop [ret m, [[k v] & ks :as keys] m]
                      (if keys
-                       (if (contains? reg (keys->specs k))
-                         (let [v (get m k)
-                               cv (conform (keys->specs k) v)]
-                           (if (= cv ::invalid)
-                             ::invalid
-                             (recur (if (identical? cv v) ret (assoc ret k cv))
-                                    ks)))
-                         (recur ret ks))
+                       (let [sname (keys->specnames k)]
+                         (if-let [s (get reg sname)]
+                           (let [cv (conform s v)]
+                             (if (invalid? cv)
+                               ::invalid
+                               (recur (if (identical? cv v) ret (assoc ret k cv))
+                                      ks)))
+                           (recur ret ks)))
                        ret)))
                  ::invalid))
      (unform* [_ m]
               (let [reg (registry)]
                 (loop [ret m, [k & ks :as keys] (c/keys m)]
                   (if keys
-                    (if (contains? reg (keys->specs k))
+                    (if (contains? reg (keys->specnames k))
                       (let [cv (get m k)
-                            v (unform (keys->specs k) cv)]
+                            v (unform (keys->specnames k) cv)]
                         (recur (if (identical? cv v) ret (assoc ret k v))
                                ks))
                       (recur ret ks))
@@ -780,9 +800,9 @@
                              #(identity {:path path :pred % :val x :via via :in in})
                              probs))
                           (map (fn [[k v]]
-                                 (when-not (c/or (not (contains? reg (keys->specs k)))
-                                                 (valid? (keys->specs k) v k))
-                                   (explain-1 (keys->specs k) (keys->specs k) (conj path k) via (conj in k) v)))
+                                 (when-not (c/or (not (contains? reg (keys->specnames k)))
+                                                 (pvalid? (keys->specnames k) v k))
+                                   (explain-1 (keys->specnames k) (keys->specnames k) (conj path k) via (conj in k) v)))
                                (seq x))))))
      (gen* [_ overrides path rmap]
            (if gfn
@@ -825,16 +845,17 @@
       :else
       (reify
        Spec
-       (conform* [_ x] (if cpred?
-                         (pred x)
-                         (if (pred x) x ::invalid)))
+       (conform* [_ x] (let [ret (pred x)]
+                         (if cpred?
+                           ret
+                           (if ret x ::invalid))))
        (unform* [_ x] (if cpred?
                         (if unc
                           (unc x)
                           (throw (IllegalStateException. "no unform fn for conformer")))
                         x))
        (explain* [_ path via in x]
-                 (when (= ::invalid (dt pred x form cpred?))
+                 (when (invalid? (dt pred x form cpred?))
                    [{:path path :pred (abbrev form) :val x :via via :in in}]))
        (gen* [_ _ _ _] (if gfn
                          (gfn)
@@ -881,7 +902,7 @@
                                     #(tag % k)
                                     (gensub p overrides (conj path k) rmap (list 'method form k))))))))
                       gs (->> (methods @mmvar)
-                              (remove (fn [[k]] (= k ::invalid)))
+                              (remove (fn [[k]] (invalid? k)))
                               (map gen)
                               (remove nil?))]
                   (when (every? identity gs)
@@ -893,56 +914,59 @@
   "Do not call this directly, use 'tuple'"
   ([forms preds] (tuple-impl forms preds nil))
   ([forms preds gfn]
-     (reify
-      Spec
-      (conform* [_ x]
-                (if-not (c/and (vector? x)
-                               (= (count x) (count preds)))
-                  ::invalid
-                  (loop [ret x, i 0]
-                    (if (= i (count x))
-                      ret
-                      (let [v (x i)
-                            cv (dt (preds i) v (forms i))]
-                        (if (= ::invalid cv)
-                          ::invalid
-                          (recur (if (identical? cv v) ret (assoc ret i cv))
-                                 (inc i))))))))
-      (unform* [_ x]
-               (c/assert (c/and (vector? x)
-                              (= (count x) (count preds))))
-               (loop [ret x, i 0]
-                 (if (= i (count x))
-                   ret
-                   (let [cv (x i)
-                         v (unform (preds i) cv)]
-                     (recur (if (identical? cv v) ret (assoc ret i v))
-                            (inc i))))))
-      (explain* [_ path via in x]
-                (cond
-                 (not (vector? x))
-                 [{:path path :pred 'vector? :val x :via via :in in}]
-
-                 (not= (count x) (count preds))
-                 [{:path path :pred `(= (count ~'%) ~(count preds)) :val x :via via :in in}]
-
-                 :else
-                 (apply concat
-                        (map (fn [i form pred]
-                               (let [v (x i)]
-                                 (when-not (valid? pred v)
-                                   (explain-1 form pred (conj path i) via (conj in i) v))))
-                             (range (count preds)) forms preds))))
-      (gen* [_ overrides path rmap]
-            (if gfn
-              (gfn)
-              (let [gen (fn [i p f]
-                          (gensub p overrides (conj path i) rmap f))
-                    gs (map gen (range (count preds)) preds forms)]
-                (when (every? identity gs)
-                  (apply gen/tuple gs)))))
-      (with-gen* [_ gfn] (tuple-impl forms preds gfn))
-      (describe* [_] `(tuple ~@forms)))))
+     (let [specs (delay (mapv specize* preds forms))
+           cnt (count preds)]
+       (reify
+        Spec
+        (conform* [_ x]
+                  (let [specs @specs]
+                    (if-not (c/and (vector? x)
+                                   (= (count x) cnt))
+                      ::invalid
+                      (loop [ret x, i 0]
+                        (if (= i cnt)
+                          ret
+                          (let [v (x i)
+                                cv (conform* (specs i) v)]
+                            (if (invalid? cv)
+                              ::invalid
+                              (recur (if (identical? cv v) ret (assoc ret i cv))
+                                     (inc i)))))))))
+        (unform* [_ x]
+                 (c/assert (c/and (vector? x)
+                                  (= (count x) (count preds))))
+                 (loop [ret x, i 0]
+                   (if (= i (count x))
+                     ret
+                     (let [cv (x i)
+                           v (unform (preds i) cv)]
+                       (recur (if (identical? cv v) ret (assoc ret i v))
+                              (inc i))))))
+        (explain* [_ path via in x]
+                  (cond
+                   (not (vector? x))
+                   [{:path path :pred 'vector? :val x :via via :in in}]
+
+                   (not= (count x) (count preds))
+                   [{:path path :pred `(= (count ~'%) ~(count preds)) :val x :via via :in in}]
+
+                   :else
+                   (apply concat
+                          (map (fn [i form pred]
+                                 (let [v (x i)]
+                                   (when-not (pvalid? pred v)
+                                     (explain-1 form pred (conj path i) via (conj in i) v))))
+                               (range (count preds)) forms preds))))
+        (gen* [_ overrides path rmap]
+              (if gfn
+                (gfn)
+                (let [gen (fn [i p f]
+                            (gensub p overrides (conj path i) rmap f))
+                      gs (map gen (range (count preds)) preds forms)]
+                  (when (every? identity gs)
+                    (apply gen/tuple gs)))))
+        (with-gen* [_ gfn] (tuple-impl forms preds gfn))
+        (describe* [_] `(tuple ~@forms))))))

 (defn- tagged-ret [tag ret]
   (clojure.lang.MapEntry. tag ret))
@@ -952,25 +976,25 @@
   [keys forms preds gfn]
   (let [id (java.util.UUID/randomUUID)
         kps (zipmap keys preds)
-        specs (delay (mapv specize preds))
+        specs (delay (mapv specize preds forms))
         cform (case (count preds)
                     2 (fn [x]
                         (let [specs @specs
                               ret (conform* (specs 0) x)]
-                          (if (= ::invalid ret)
+                          (if (invalid? ret)
                             (let [ret (conform* (specs 1) x)]
-                              (if (= ::invalid ret)
+                              (if (invalid? ret)
                                 ::invalid
                                 (tagged-ret (keys 1) ret)))
                             (tagged-ret (keys 0) ret))))
                     3 (fn [x]
                         (let [specs @specs
                               ret (conform* (specs 0) x)]
-                          (if (= ::invalid ret)
+                          (if (invalid? ret)
                             (let [ret (conform* (specs 1) x)]
-                              (if (= ::invalid ret)
+                              (if (invalid? ret)
                                 (let [ret (conform* (specs 2) x)]
-                                  (if (= ::invalid ret)
+                                  (if (invalid? ret)
                                     ::invalid
                                     (tagged-ret (keys 2) ret)))
                                 (tagged-ret (keys 1) ret)))
@@ -981,7 +1005,7 @@
                           (if (< i (count specs))
                             (let [spec (specs i)]
                               (let [ret (conform* spec x)]
-                                (if (= ::invalid ret)
+                                (if (invalid? ret)
                                   (recur (inc i))
                                   (tagged-ret (keys i) ret))))
                             ::invalid)))))]
@@ -990,10 +1014,10 @@
      (conform* [_ x] (cform x))
      (unform* [_ [k x]] (unform (kps k) x))
      (explain* [this path via in x]
-               (when-not (valid? this x)
+               (when-not (pvalid? this x)
                  (apply concat
                         (map (fn [k form pred]
-                               (when-not (valid? pred x)
+                               (when-not (pvalid? pred x)
                                  (explain-1 form pred (conj path k) via in x)))
                              keys forms preds))))
      (gen* [_ overrides path rmap]
@@ -1016,7 +1040,7 @@
          [form & forms] forms]
     (if pred
       (let [nret (dt pred ret form)]
-        (if (= ::invalid nret)
+        (if (invalid? nret)
           ::invalid
           ;;propagate conformed values
           (recur nret preds forms)))
@@ -1029,29 +1053,29 @@
          [pred & preds] preds]
     (when pred
       (let [nret (dt pred ret form)]
-        (if (not= ::invalid nret)
-          (recur nret forms preds)
-          (explain-1 form pred path via in ret))))))
+        (if (invalid? nret)
+          (explain-1 form pred path via in ret)
+          (recur nret forms preds))))))

 (defn ^:skip-wiki and-spec-impl
   "Do not call this directly, use 'and'"
   [forms preds gfn]
-  (let [specs (delay (mapv specize preds))
+  (let [specs (delay (mapv specize preds forms))
         cform
         (case (count preds)
               2 (fn [x]
                   (let [specs @specs
                         ret (conform* (specs 0) x)]
-                    (if (= ::invalid ret)
+                    (if (invalid? ret)
                       ::invalid
                       (conform* (specs 1) ret))))
               3 (fn [x]
                   (let [specs @specs
                         ret (conform* (specs 0) x)]
-                    (if (= ::invalid ret)
+                    (if (invalid? ret)
                       ::invalid
                       (let [ret (conform* (specs 1) ret)]
-                        (if (= ::invalid ret)
+                        (if (invalid? ret)
                           ::invalid
                           (conform* (specs 2) ret))))))
               (fn [x]
@@ -1059,7 +1083,7 @@
                   (loop [ret x i 0]
                     (if (< i (count specs))
                       (let [nret (conform* (specs i) ret)]
-                        (if (= ::invalid nret)
+                        (if (invalid? nret)
                           ::invalid
                           ;;propagate conformed values
                           (recur nret (inc i))))
@@ -1079,7 +1103,7 @@
   (reify
    Spec
    (conform* [_ x] (let [ms (map #(dt %1 x %2) preds forms)]
-                     (if (some #{::invalid} ms)
+                     (if (some invalid? ms)
                        ::invalid
                        (apply c/merge ms))))
    (unform* [_ x] (apply c/merge (map #(unform % x) (reverse preds))))
@@ -1102,7 +1126,7 @@
   (let [pred (c/or kfn coll?)
         kform (c/or kform `coll?)]
     (cond
-     (not (valid? pred x))
+     (not (pvalid? pred x))
      (explain-1 kform pred path via in x)

      (c/and distinct (not (empty? x)) (not (apply distinct? x)))
@@ -1127,7 +1151,7 @@
                :as opts}
     gfn]
      (let [conform-into gen-into
-           check? #(valid? pred %)
+           check? #(pvalid? pred %)
            kfn (c/or kfn (fn [i v] i))
            addcv (fn [ret i v cv] (conj ret cv))
            cfns (fn [x]
@@ -1166,7 +1190,7 @@
                      (loop [ret (init x), i 0, [v & vs :as vseq] (seq x)]
                        (if vseq
                          (let [cv (dt pred v nil)]
-                           (if (= ::invalid cv)
+                           (if (invalid? cv)
                              ::invalid
                              (recur (add ret i v cv) (inc i) vs)))
                          (complete ret))))
@@ -1326,7 +1350,7 @@
           ::amp (c/and (accept-nil? p1)
                        (c/or (noret? p1 (preturn p1))
                              (let [ret (-> (preturn p1) (and-preds ps (next forms)))]
-                               (not= ret ::invalid))))
+                               (not (invalid? ret)))))
           ::rep (c/or (identical? p1 p2) (accept-nil? p1))
           ::pcat (every? accept-nil? ps)
           ::alt (c/some accept-nil? ps))))
@@ -1389,11 +1413,11 @@
       (case op
             ::accept nil
             nil (let [ret (dt p x p)]
-                  (when-not (= ::invalid ret) (accept ret)))
+                  (when-not (invalid? ret) (accept ret)))
             ::amp (when-let [p1 (deriv p1 x)]
                     (if (= ::accept (::op p1))
                       (let [ret (-> (preturn p1) (and-preds ps (next forms)))]
-                        (when-not (= ret ::invalid)
+                        (when-not (invalid? ret)
                           (accept ret)))
                       (amp-impl p1 ps forms)))
             ::pcat (alt2 (pcat* {:ps (cons (deriv p0 x) pr), :ks ks, :forms forms, :ret ret})
@@ -1579,12 +1603,12 @@
 (defn- call-valid?
   [f specs args]
   (let [cargs (conform (:args specs) args)]
-    (when-not (= cargs ::invalid)
+    (when-not (invalid? cargs)
       (let [ret (apply f args)
             cret (conform (:ret specs) ret)]
-        (c/and (not= cret ::invalid)
+        (c/and (not (invalid? cret))
                (if (:fn specs)
-                 (valid? (:fn specs) {:args cargs :ret cret})
+                 (pvalid? (:fn specs) {:args cargs :ret cret})
                  true))))))

 (defn- validate-fn
@@ -1622,7 +1646,7 @@
                          [{:path path :pred '(apply fn) :val args :reason (.getMessage ^Throwable ret) :via via :in in}]

                          (let [cret (dt retspec ret rform)]
-                           (if (= ::invalid cret)
+                           (if (invalid? cret)
                              (explain-1 rform retspec (conj path :ret) via in ret)
                              (when fnspec
                                (let [cargs (conform argspec args)]
@@ -1632,7 +1656,7 @@
              (gfn)
              (gen/return
               (fn [& args]
-                (c/assert (valid? argspec args) (with-out-str (explain argspec args)))
+                (c/assert (pvalid? argspec args) (with-out-str (explain argspec args)))
                 (gen/generate (gen retspec overrides))))))
      (with-gen* [_ gfn] (fspec-impl argspec aform retspec rform fnspec fform gfn))
      (describe* [_] `(fspec :args ~aform :ret ~rform :fn ~fform)))))
@@ -1667,7 +1691,7 @@
     (reify
      Spec
      (conform* [_ x] (let [ret (conform* spec x)]
-                       (if (= ::invalid ret)
+                       (if (invalid? ret)
                          ::invalid
                          x)))
      (unform* [_ x] (unform* spec x))


fix repl host selection in browser

fix repl host selection in browser

--- src/main/shadow/cljs/devtools/client/env.cljs
+++ src/main/shadow/cljs/devtools/client/env.cljs
@@ -35,7 +35,10 @@
 (goog-define ignore-warnings false)

 (defn get-repl-host []
-  (if (and use-document-host js/goog.global.document (seq js/goog.global.document.hostname))
+  (if (and use-document-host
+           js/goog.global.document
+           js/goog.global.document.location
+           (seq js/goog.global.document.location.hostname))
     js/document.location.hostname
     repl-host))


index: add title

index: add title

--- src/clj/type/handler.clj
+++ src/clj/type/handler.clj
@@ -12,6 +12,7 @@
 (def loading-page
   (html5
    [:head
+    [:title "Type Letter"]
     [:meta {:charset "utf-8"}]
     [:meta {:name "viewport"
             :content "width=device-width, initial-scale=1"}]


Realias data namespace in maps.cljs

Realias data namespace in maps.cljs

--- src/cljs/gtfve/maps.cljs
+++ src/cljs/gtfve/maps.cljs
@@ -7,7 +7,7 @@
             [goog.events :as events]
             [goog.history.EventType :as EventType]
             [cljsjs.react :as react]
-            [gtfve.data :as data])
+            [gtfve.data :as d])
   (:import goog.History))

 (defonce Maps google.maps)


Raise partition size

Raise partition size

--- src/laskuri/core.clj
+++ src/laskuri/core.clj
@@ -10,7 +10,9 @@
   (:import [org.apache.spark.api.java JavaSparkContext StorageLevels])
   (:gen-class main true))

-(def repartition-amount 100)
+; Five years of logs is 700 GB. Max partition size is 2GB.
+; 1000 gives ~700 MB partition size.
+(def repartition-amount 1000)

 (defn get-parsed-lines [ctx location redact?]
   "Get a new input stream of parsed lines."
@@ -191,7 +193,10 @@
           parsed-lines-ok (f/filter parsed-lines (f/fn [[date doi domain status]] (not= 0 (.length status))))

           ; Repartition. The input is/may be gzip files, in which case they'll be in one big partition each.
-          parsed-rebalanced (f/repartition parsed-lines-ok repartition-amount)
+          ; This can be nil for no repartition.
+          parsed-rebalanced (if repartition-amount
+            (f/repartition parsed-lines-ok repartition-amount)
+            parsed-lines-ok)

           parsed-cached (f/persist parsed-rebalanced StorageLevels/DISK_ONLY)]


script interpreter comes next

script interpreter comes next

--- src/latte/script.clj
+++ src/latte/script.clj
@@ -56,4 +56,3 @@
           :have-name name}]
     [:ok (dissoc def-env name) ctx]))

-


Adding save function

Adding save function

--- src/levycurve/ui.clj
+++ src/levycurve/ui.clj
@@ -14,7 +14,7 @@
    :extends javax.swing.JFrame
    )
   (:import
-   (javax.swing JButton JTextField JLabel JOptionPane)
+   (javax.swing JButton JTextField JLabel JOptionPane JFileChooser)
    (java.io File)
    (javax.imageio ImageIO)
    (javax.swing.event DocumentListener)
@@ -141,7 +141,14 @@
     )
   )
 (defn -save [ui]
-  (ImageIO/write (.getState ui :img) "png" (File. "Fractal.png"))
+  (let
+      [fc (JFileChooser.)
+       ret (.showSaveDialog fc ui)
+       ]
+    (if (= ret JFileChooser/APPROVE_OPTION)
+      (ImageIO/write (.getState ui :img) "png" (.getSelectedFile fc))
+      )
+    )
   )
 (defn -reset [this & clearpath]
   (let [
@@ -151,6 +158,7 @@
     (.flush img)
     (.setColor graphics Color/black)
     (.fillRect graphics 0 0 (.getWidth img) (.getHeight img))
+    (.setColor graphics Color/red)
     (.repaint this)
     )
   (if clearpath


Server logs when starting

Server logs when starting

--- src/madouc/core.clj
+++ src/madouc/core.clj
@@ -1,8 +1,11 @@
 (ns madouc.core
   (:require [immutant.web :as server]
-            [madouc.handlers :as app])
+            [madouc.handlers :as app]
+            [environ.core :refer [env]]
+            [taoensso.timbre :as timbre])
   (:gen-class))

 (defn -main
   [& args]
+  (timbre/info "Starting server...")
   (server/run app/entrypoint))


Add a dtbook template for periodicals

Add a dtbook template for periodicals

--- src/mdr2/dtbook.clj
+++ src/mdr2/dtbook.clj
@@ -21,7 +21,8 @@
     :blurb "Klappentexte"
     :contributors "Mitwirkende"
     :enclosures "Hörbuchbeilagen"
-    :end "Ende des Buches"}
+    :end "Ende des Buches"
+    :title_creator_fmt "%s von %s"}
    :en
    {:about "About this DAISY book"
     :bib "Bibliographic information"
@@ -29,7 +30,8 @@
     :blurb "Blurbs"
     :contributors "Contributors"
     :enclosures "Talking book enclosures"
-    :end "End of book"}})
+    :end "End of book"
+    :title_creator_fmt "%s by %s"}})

 (def ^:private doctype
   (str
@@ -49,12 +51,22 @@

 (defn default-book
   "Return an default book sexp"
+  [title creator language]
+  (let [t (partial translate language)]
+    [:book
+     [:frontmatter
+      [:doctitle (format (t :title_creator_fmt) title creator)]
+      [:docauthor creator]]
+     [:bodymatter
+      [:level1 [:h1] [:p]]]]))
+
+(defn periodical
+  "Return an default periodical sexp"
   [title creator]
   [:book
    [:frontmatter
     [:doctitle title]
-    [:docauthor creator]
-    [:level1 [:p]]]
+    [:docauthor creator]]
    [:bodymatter
     [:level1 [:h1] [:p]]]])

@@ -97,7 +109,7 @@
            source_date source_edition source_publisher source_rights source_title
            multimedia_type multimedia_content narrator produced_date
            revision revision_date revision_description
-           total_time audio_format
+           total_time audio_format production_type
            library_number]}] ; only books imported from the libray have this
   [:dtbook {:xmlns "http://www.daisy.org/z3986/2005/dtbook/"
             :version "2005-3" :xml:lang language}
@@ -130,9 +142,10 @@
     [:meta {:name "dtb:revisionDescription" :content revision_description}]
     [:meta {:name "dtb:totalTime" :content total_time}]
     [:meta {:name "dtb:audioFormat" :content audio_format}]]
-   (if library_number
-     (commercial-audiobook title creator language)
-     (default-book title creator))])
+   (cond
+     library_number (commercial-audiobook title creator language)
+     (= production_type "periodical") (periodical title creator)
+     :else (default-book title creator language))])

 (defn dtbook
   "Create a minimal DTBook XML template according to [the spec](http://www.daisy.org/z3986/2005/Z3986-2005.html) for a given `production`"


fix service agent flag mapping

fix service agent flag mapping

--- src/clj/swarmpit/docker/engine/mapper/inbound.clj
+++ src/clj/swarmpit/docker/engine/mapper/inbound.clj
@@ -313,7 +313,8 @@

 (defn ->service-agent
   [service-labels]
-  (some? (agent-label service-labels)))
+  (when (contains? service-labels agent-label)
+    true))

 (defn ->service-healthcheck
   [service-healthcheck]


with 3-dimensional data, error rate reduced to 0.3%

--- src/mljalfa/knn.clj
+++ src/mljalfa/knn.clj
@@ -14,20 +14,17 @@
                       (map int))
         fweights (->> (stat/sample-normal n :mean 46 :sd 4)
                       (map int))
+        fhairs (->> (stat/sample-normal n :mean 30 :sd 4)
+                    (map int))
         mheights (->> (stat/sample-normal n :mean 165 :sd 6)
                       (map int))
         mweights (->> (stat/sample-normal n :mean 63 :sd 6)
-                      (map int))]
-    (concat (->> (map vector (shuffle mheights) (shuffle mweights))
+                      (map int))
+        mhairs (->> (stat/sample-normal n :mean 15 :sd 3))]
+    (concat (->> (map vector (shuffle mheights) (shuffle mweights) (shuffle mhairs))
                  (map #(hash-map :class :male :datum %)))
-            (->> (map vector (shuffle fheights) (shuffle fweights))
+            (->> (map vector (shuffle fheights) (shuffle fweights) (shuffle fhairs))
                  (map #(hash-map :class :female :datum %))))))
-
-(def training-data
-  (gen-people 100))
-
-(def real-data
-  (gen-people 1000))

 (defn classify
   "Classify one data xi"
@@ -45,10 +42,10 @@

 (defn classify-all
   "Classify all data"
-  [real-data train-data k]
-  (let [result (map #(classify % train-data k) real-data)
+  [reals-data train-data k]
+  (let [result (map #(classify % train-data k) reals-data)
         success (count (filter #(= (:class %) (:result %)) result))
-        error (- (count real-data) success)]
+        error (- (count reals-data) success)]
     {:data result
      :summary {:success success :error error}} ))


cleaned up a bit

cleaned up a bit

--- src/moomoo/core.cljs
+++ src/moomoo/core.cljs
@@ -8,13 +8,10 @@
 (def http (nodejs/require "http"))
 (def socketio (nodejs/require "socket.io"))

-(defn disconnect [socket]
-  (.log js/console "A user has disconnected!"))
-
 (defn connection [socket]
   (.log js/console "A user has connected!")
   (.on socket "disconnect"
-    (complement disconnect))
+    #(.log js/console "A user has disconnected!"))
   (.on socket "set_username"
     (fn [room username]
       (.log js/console username))))


fix exit condition

fix exit condition

--- src/neuseg/train.clj
+++ src/neuseg/train.clj
@@ -6,7 +6,7 @@
         train-data (fann/load-train-data "data/trains/train")
         test-data  (fann/load-train-data "data/trains/tests")]
     (println "training...")
-    (fann/train nn train-data 100 1 0.001)
+    (fann/train nn train-data 1000 1 0.001)
     (println "testing...")
     (println "error = " (fann/testnn nn test-data))
     (fann/save nn "data/models/tagging.nn")))


Making the redhat/centos/scientific be el

--- src/omnibus/core.clj
+++ src/omnibus/core.clj
@@ -178,7 +178,7 @@
       (build-makeself project-name ((projects project-name) :version) ((projects project-name) :iteration) os-and-machine)
       (if (or (= (os-and-machine :platform) "debian") (= (os-and-machine :platform) "ubuntu"))
         (build-deb project-name ((projects project-name) :version) ((projects project-name) :iteration) os-and-machine))
-      (if (or (= (os-and-machine :platform) "redhat") (= (os-and-machine :platform) "centos") (= (os-and-machine :platform) "fedora"))
+      (if (or (= (os-and-machine :platform) "el") (= (os-and-machine :platform) "fedora"))
         (build-rpm project-name ((projects project-name) :version) ((projects project-name) :iteration) os-and-machine)))))

 (defn -main


more analytics

more analytics

--- src/pc/analytics.clj
+++ src/pc/analytics.clj
@@ -33,10 +33,14 @@
                                                  :team/plan
                                                  :plan/trial-end
                                                  clj-time.coerce/from-date
-                                                 (clj-time.format/unparse (clj-time.format/formatters :date-time-no-ms)))}}))
+                                                 (clj-time.format/unparse (clj-time.format/formatters :date-time-no-ms)))}})
+  (mixpanel/track "Created team" (:cust/uuid (:team/creator team))
+                  :subdomain (:team/subdomain team)))

 (defn track-create-plan [team]
-  (mixpanel/engage (:cust/uuid (:team/creator team)) {:$set {:created_plan true}}))
+  (mixpanel/engage (:cust/uuid (:team/creator team)) {:$set {:created_plan true}})
+  (mixpanel/track "Created plan" (:cust/uuid (:team/creator team))
+                  :subdomain (:team/subdomain team)))

 (defn track-login [cust]
   (mixpanel/track "Login" (:cust/uuid cust)))


Fix whitespace

Fix whitespace

--- src/foreclojure/ring.clj
+++ src/foreclojure/ring.clj
@@ -52,4 +52,4 @@
 (defn wrap-404 [handler]
   (fn [request]
     (or (handler request)
-        (route/not-found "Page not found"))))+        (route/not-found "Page not found"))))


Better comment

Better comment

--- src/re_frame/db.cljs
+++ src/re_frame/db.cljs
@@ -5,6 +5,7 @@
 ;; -- Application State  --------------------------------------------------------------------------
 ;;
 ;; Should not be accessed directly by application code
-;; Access is mediated via handlers and subscriptions
+;; Read access goes through subscriptions.
+;; Updates via event handlers.
 (def  app-db (reagent/atom {}))


vec states for watchers

vec states for watchers

--- src/mount/core.cljc
+++ src/mount/core.cljc
@@ -312,7 +312,8 @@

   (add-watcher [_ ks state]
     (doseq [k ks]
-      (swap! watchers update k #(conj % state))))
+      (swap! watchers update k (fn [v]
+                                 (-> (conj v state) vec)))))

   (on-change [_ ks]
     (doseq [k ks]


Convert ls-output to use SHA3

Convert ls-output to use SHA3

Signed-off-by: Gregory Haskins <640d9fe47775e6723f0355b7315e38f7d98d3539@gmail.com>

--- src/obcc/dar/ls.clj
+++ src/obcc/dar/ls.clj
@@ -20,7 +20,7 @@
             [doric.core :as doric]
             [obcc.dar.read :as dar]
             [obcc.config.util :as config.util]
-            [pandect.algo.sha256 :refer :all]))
+            [pandect.algo.sha3-512 :refer :all]))

 (defn platform-version [config]
   (str (config.util/findfirst config [:platform :name]) " version " (config.util/findfirst config [:platform :version])))
@@ -30,9 +30,9 @@
         entries (:entries payload)]

     (println (doric/table [{:name :size} {:name :sha1 :title "SHA1"} {:name :path}] entries))
-    (println "Platform:          " (platform-version config))
-    (println "Digital Signature:  none")
-    (println "Raw Data Size:     " (->> entries (map :size) (reduce +)) "bytes")
-    (println "Archive Size:      " (.length file) "bytes")
-    (println "Compression Alg:   " (get-in payload [:compression :description]))
-    (println "Chaincode SHA-256: " (sha256 file))))
+    (println "Platform:           " (platform-version config))
+    (println "Digital Signature:   none")
+    (println "Raw Data Size:      " (->> entries (map :size) (reduce +)) "bytes")
+    (println "Archive Size:       " (.length file) "bytes")
+    (println "Compression Alg:    " (get-in payload [:compression :description]))
+    (println "Chaincode SHA3:     " (sha3-512 file))))


Remove circular dep.

Remove circular dep.

--- src/onyx/system.clj
+++ src/onyx/system.clj
@@ -27,7 +27,7 @@
 (defn onyx-coordinator
   [{:keys [datomic-uri hornetq-host hornetq-port zk-addr onyx-id revoke-delay]}]
   (map->OnyxCoordinator
-   {:log (component/using (datomic datomic-uri (log-schema)) [:log])
+   {:log (component/using (datomic datomic-uri (log-schema)) [])
     :sync (component/using (zookeeper zk-addr onyx-id) [:log])
     :queue (component/using (hornetq hornetq-host hornetq-port) [:log])
     :coordinator (component/using (coordinator revoke-delay)


Remove intermediate functions.

Remove intermediate functions.

--- src/onyx/system.clj
+++ src/onyx/system.clj
@@ -100,12 +100,6 @@
     (rethrow-component
      #(component/stop-system this peer-group-components))))

-(defn messenger-ctor [{:keys [config] :as peer-group}]
-  (am/aeron peer-group))
-
-(defn messaging-peer-group-ctor [config]
-  (am/aeron-peer-group config))
-
 (defn onyx-development-env
   ([peer-config]
      (onyx-development-env peer-config {:monitoring :no-op}))
@@ -170,7 +164,7 @@
       {:monitoring (extensions/monitoring-agent monitoring-config)
        :log (component/using (zookeeper config) [:monitoring])
        :acking-daemon (component/using (acking-daemon config) [:monitoring :log])
-       :messenger (component/using (messenger-ctor peer-group) [:monitoring :acking-daemon])
+       :messenger (component/using (am/aeron peer-group) [:monitoring :acking-daemon])
        :virtual-peer (component/using (virtual-peer config onyx-task) [:monitoring :log :acking-daemon :messenger])})))

 (defn onyx-peer-group
@@ -178,4 +172,4 @@
   (map->OnyxPeerGroup
    {:config config
     :logging-config (logging-config/logging-configuration config)
-    :messaging-group (component/using (messaging-peer-group-ctor config) [:logging-config])}))
+    :messaging-group (component/using (am/aeron-peer-group config) [:logging-config])}))


Add 'eventstore' tag so that dynamic lookup works.

--- src/photon/muon.clj
+++ src/photon/muon.clj
@@ -53,7 +53,7 @@
                     (:amqp.url conf/config))))
   ([server-name db url]
    (log/info "Connecting to" url)
-   (let [m (mcs/muon url server-name ["photon" "helios"])
+   (let [m (mcs/muon url server-name ["photon" "eventstore"])
          ms (->PhotonMicroservice m (streams/new-async-stream m db))]
      (mcs/start-server! ms)
      ms)))


add q17

add q17

--- src/puzzule/q17.clj
+++ src/puzzule/q17.clj
@@ -1 +1,7 @@
 (ns puzzule.q17)
+
+(def fib-seq
+     (lazy-cat [1 1] (map + (rest fib-seq) fib-seq)))
+
+
+(last (take 32 fib-seq))


WIP: can we make validation-seq work in parallel

--- src/themis/core.clj
+++ src/themis/core.clj
@@ -1,5 +1,6 @@
 (ns themis.core
-  (require [themis.protocols :as protocols]
+  (require [clojure.core.reducers :as r]
+           [themis.protocols :as protocols]
            [themis.extended-protos :as e-protos]
            [themis.rules :as rules]))

@@ -63,8 +64,10 @@
   (let [[coordinates validations] validation-vec]
     (partition-all 2
       (mapcat (fn [[validation-fn opt-map]]
-                (raw-validation t coordinates validation-fn (merge {::coordinates coordinates} opt-map)))
+                (raw-validation t coordinates validation-fn (assoc opt-map ::coordinates coordinates)))
               validations))))
+
+(def ^:dynamic *mapper-fn* mapcat)

 (defn validation-seq
   "Create a lazy sequence of validating a given data structure
@@ -73,7 +76,9 @@
   [t rule-set]
   (let [normalized-rules (rules/normalize rule-set)]
     (when (rules/balanced? normalized-rules)
-      (mapcat #(validate-vec t %) normalized-rules))))
+      (*mapper-fn* #(validate-vec t %) normalized-rules))))
+
+(def ^:dynamic *validation-seq-fn* validation-seq)

 (defn validation
   "Validate a data structure, `t`,
@@ -85,12 +90,25 @@
   ([t rule-set]
    ;; TODO: This can definitely be done better
    (apply merge-with #(flatten (concat [%1] [%2]))
-          (mapcat (fn [result-seq]
+          (mapcat (fn [result-seq] ;; TODO does this mapcat have to change when we go parallel
                     (map #(apply hash-map %) (partition-all 2 result-seq)))
-                  (validation-seq t rule-set))))
+                  (*validation-seq-fn* t rule-set))))
   ([t rule-set merge-fn]
    (merge-fn (validation-seq t rule-set))))

+(defn pvalidation [t rule-set]
+  (binding [*validation-seq-fn* (fn [t rule-set]
+                                  (let [normalized-rules (rules/normalize rule-set)
+                                        chunks (.availableProcessors (Runtime/getRuntime))
+                                        chunked-rules (partition-all chunks normalized-rules)
+                                        _ (prn chunks)]
+                                    (when (rules/balanced? normalized-rules)
+                                      (r/mapcat deref
+                                                (r/map #(future (r/map
+                                                                  (fn [rule-vec]
+                                                                    (validate-vec t rule-vec)) %))
+                                                       chunked-rules)))))]
+    (validation t rule-set)))

 (comment

@@ -109,20 +127,22 @@
   (require '[themis.predicates :as preds])

   (def paul-rules [[[:name :first] [[presence {:response {:text "First name is not there"}}]
-                                    (fn [t-map data-point opt-map] (and (= data-point "Paul")
+                                    (fn [t-map data-point opt-map](Thread/sleep 1000)(and (= data-point "Paul")
                                                                         {:a 1 :b 2}))]]
                    [[:pets 0] [(from-predicate preds/longer-than? 20 "Too short; Needs to be longer than 20")]]
                    [[:pets 0 0] [[::w-pets {:pet-name-starts ""}]
                                  (from-predicate char?)
-                                 (from-predicate #(= % \w) "The first letter is not `w`")]]
+                                 (from-predicate #(or (Thread/sleep 2000) (= % \w)) "The first letter is not `w`")]]
                    ;[[:*] ['degrandis-pets]] ;This is valid, but we can also just write:
                    [:* 'degrandis-pets]])

   (def normal-paul-rules (rules/normalize paul-rules))
   (type (validation-seq paul paul-rules))
-  (validation paul paul-rules)
+  (time (validation paul paul-rules))
+  (time (pvalidation paul paul-rules))
   (mapcat identity (validation paul paul-rules (partial filter second)))
   (validation paul paul-rules (partial keep second))
+

   (defn unfold-result
     "Unfold the themis results map, expanding coordinates to nested maps,


CMR-6221 fixed whitespace

CMR-6221 fixed whitespace

--- system-int-test/test/cmr/system_int_test/search/autocomplete_collection_facet_search_test.clj
+++ system-int-test/test/cmr/system_int_test/search/autocomplete_collection_facet_search_test.clj
@@ -57,24 +57,24 @@

 (deftest autocomplete-response-test
   (testing "response form test"
-     (let [response (search/get-autocomplete-suggestions "q=foo")
-           body (:body response)
-           data (json/parse-string body true)]
-       (is (contains? data :feed))
-       (is (contains? (:feed data) :entry))))
+   (let [response (search/get-autocomplete-suggestions "q=foo")
+         body (:body response)
+         data (json/parse-string body true)]
+     (is (contains? data :feed))
+     (is (contains? (:feed data) :entry))))

   (testing "returns CMR-Hits header"
-     (let [response (search/get-autocomplete-suggestions "q=foo")
-           headers (:headers response)]
-       (is (:CMR-Hits headers))
-       (is (:CMR-Took headers))))
+   (let [response (search/get-autocomplete-suggestions "q=foo")
+         headers (:headers response)]
+     (is (:CMR-Hits headers))
+     (is (:CMR-Took headers))))

   (testing "entries return in descending score order"
-           (let [response (query->json-response-body "q=bar")
-                 entries (response-body->entries response)
-                 a (first entries)
-                 b (second entries)]
-             (is (> (:score a) (:score b))))))
+   (let [response (query->json-response-body "q=bar")
+         entries (response-body->entries response)
+         a (first entries)
+         b (second entries)]
+     (is (> (:score a) (:score b))))))

 (deftest autocomplete-functionality-test
   (testing "value search"


correctly convert h1-h5 elements containing other things than just text

--- src/watney/core.clj
+++ src/watney/core.clj
@@ -21,42 +21,48 @@
        (map (fn [i] " "))
        (apply str)))

+(defn ^:private convert-content
+  "Return the converted contents of an element."
+  [contents prefix-spaces]
+  )
+
 (defn ^:private convert-entity
   "Returns Markdown when given an Enlive data tree."
   [html-tree prefix-spaces]
-  (str (whitespace-str prefix-spaces)
-       (->> html-tree
-            (map (fn [node]
-                   (case (:tag node)
-                     :h1 (str "# " (first (:content node)))
-                     :h2 (str "## " (first (:content node)))
-                     :h3 (str "### " (first (:content node)))
-                     :h4 (str "#### " (first (:content node)))
-                     :p  (str "\n" (->> (:content node)
-                                        (map (fn [sub-node]
-                                               (if (= (type sub-node) java.lang.String)
-                                                 sub-node
-                                                 (->> (convert-entity (list sub-node) prefix-spaces)))))
-                                        (clojure.string/join "")))
-                     :a  (str "[" (first (:content node)) "](" (:href (:attrs node)) ")")
-                     :img (str "![" (:alt (:attrs node)) "](" (:src (:attrs node)) ")")
+  (let [convert-content #(->> (:content %)
+                              (map (fn [sub-node]
+                                     (if (= (type sub-node) java.lang.String)
+                                       sub-node
+                                       (->> (convert-entity (list sub-node) prefix-spaces)))))
+                              (clojure.string/join ""))]
+    (str (whitespace-str prefix-spaces)
+         (->> html-tree
+              (map (fn [node]
+                     (case (:tag node)
+                       :h1 (str "# " (convert-content node))
+                       :h2 (str "## " (convert-content node))
+                       :h3 (str "### " (convert-content node))
+                       :h4 (str "#### " (convert-content node))
+                       :p  (str "\n" (convert-content node))
+                       :a  (str "[" (first (:content node)) "](" (:href (:attrs node)) ")")
+                       :img (str "![" (:alt (:attrs node)) "](" (:src (:attrs node)) ")")

-                     ;; if any of the children of this :li is a :ul, then return 2 spaces here
-                     :li (if (contains-node? (:content node) :ul)
-                           (str (if (= (type (first (:content node))) java.lang.String)
-                                  (str "*  " (first (:content node)) "\n")
-                                  nil)
-                                (->> (:content node)
-                                     (filter #(= (:tag %) :ul))
-                                     first
-                                     :content
-                                     (map (fn [entity]
-                                            (convert-entity (list entity) (+ prefix-spaces 2))))
-                                     (str/join "\n")))
-                           (str "*  " (first (:content node))))
-                     (convert-entity (:content node) 0))))
-            (remove empty?)
-            (str/join "\n"))))
+                       ;; if any of the children of this :li is a :ul, then return 2 spaces here
+                       :li (if (contains-node? (:content node) :ul)
+                             (str (if (= (type (first (:content node))) java.lang.String)
+                                    (str "*  " (first (:content node)) "\n")
+                                    nil)
+                                  (->> (:content node)
+                                       (filter #(= (:tag %) :ul))
+                                       first
+                                       :content
+                                       (map (fn [entity]
+                                              (convert-entity (list entity) (+ prefix-spaces 2))))
+                                       (str/join "\n")))
+                             (str "*  " (first (:content node))))
+                       (convert-entity (:content node) 0))))
+              (remove empty?)
+              (str/join "\n")))))

 (defn convert
   "Convert the HTML string given into Markdown"


Comments.

Comments.

--- src/oc/storage/lib/inbox.clj
+++ src/oc/storage/lib/inbox.clj
@@ -34,6 +34,7 @@
               {:last-activity-at (-> (r/table relation-table-name)
                                      (r/get-all [(r/get-field post-row :uuid)] {:index :resource-uuid})
                                      (r/filter (r/fn [interaction-row]
+                                      ;; Filter out reactions and comments from the current user
                                       (r/and
                                        (r/ge (r/get-field interaction-row "body") "")
                                        (r/ne (r/get-field (r/get-field interaction-row "author") "user-id") user-id))))
@@ -49,6 +50,7 @@
             (r/filter query (r/fn [post-row]
               (r/and ;; All records in boards the user has no access
                      (r/contains allowed-boards (r/get-field post-row :board-uuid))
+                     ;; Leave in only posts whose last activity is within a certain amount of time
                      (r/gt (r/get-field post-row :last-activity-at) minimum-date-timestamp)
                      ;; All records with follow true
                      (r/get-field (r/get-field (r/get-field post-row :user-visibility) user-id) :follow)


remove with db

remove with db

--- tutorial/building_queries.clj
+++ tutorial/building_queries.clj
@@ -8,19 +8,26 @@

 (require '[datomic.client.api :as d])

-(def client (d/client {:server-type :dev-local :system "datomic-samples"}))
-(def conn (d/connect client {:db-name "social-news"}))
-(def db (d/with-db conn))
+(def client (d/client {:server-type :dev-local :system "day-of-datomic-cloud"}))
+(d/create-database client {:db-name "building-queries"})
+(def conn (d/connect client {:db-name "building-queries"}))
+
+(d/transact conn {:tx-data [{:db/ident :user/firstName
+                             :db/valueType :db.type/string
+                             :db/cardinality :db.cardinality/one}
+                            {:db/ident :user/lastName
+                             :db/valueType :db.type/string
+                             :db/cardinality :db.cardinality/one}]})

 ;; some St*rts
-(def db (:db-after (d/with db {:tx-data [{:user/firstName "Stewart"
-                                          :user/lastName "Brand"}
-                                         {:user/firstName "John"
-                                          :user/lastName "Stewart"}
-                                         {:user/firstName "Stuart"
-                                          :user/lastName "Smalley"}
-                                         {:user/firstName "Stuart"
-                                          :user/lastName "Halloway"}]})))
+(d/transact conn {:tx-data [{:user/firstName "Stewart"
+                             :user/lastName "Brand"}
+                            {:user/firstName "John"
+                             :user/lastName "Stewart"}
+                            {:user/firstName "Stuart"
+                             :user/lastName "Smalley"}
+                            {:user/firstName "Stuart"
+                             :user/lastName "Halloway"}]})

 ;; find all the Stewart first names
 (d/q '[:find (pull ?e [*])
@@ -58,5 +65,4 @@
                :in [$ ?fname ?lname]
                :where [[?e :user/firstName ?fname]
                        [?e :user/lastName ?lname]]}
-      :args [db "Stuart" "Smalley"]})
-
+      :args [db "Stuart" "Smalley"]})


Add other note keys

Add other note keys


Allow for old version of command key in midi msg map until we release a new version of midi-clj and update the dependencies.

--- src/overtone/studio/midi.clj
+++ src/overtone/studio/midi.clj
@@ -13,12 +13,14 @@
 (defn midi-event
   "Trigger a global midi event."
   [dev msg ts]
-  (event [:midi (msg :command)] msg)
-  (event [:midi-device (dev :vendor) (dev :name) (dev :description) (msg :command)] msg))
+  (let [command (or (:cmd msg)
+                    (:command msg))]
+    (event [:midi command] msg)
+    (event [:midi-device (dev :vendor) (dev :name) (dev :description) command] msg)))

 (defn- detect-midi-devices
   "Designed to run periodically and update the midi-devices* atom with
-  the latest list of midi sources."
+  the latest list of midi sources and add event handlers to new devices."
   []
   (try
     (let [old-devs     (set (keys @midi-devices*))


Update dependencies to latest versions

Update dependencies to latest versions

--- compojure/hello/project.clj
+++ compojure/hello/project.clj
@@ -1,18 +1,17 @@
 (defproject hello "compojure"
   :description "JSON/Database tests"
-  :url "http://example.com/FIXME"
+  :url "http://localhost:3000/"
   :dependencies [[org.clojure/clojure "1.5.1"]
-                 [compojure "1.1.5"]
+                 [compojure "1.1.6"]
                  [ring/ring-json "0.2.0"]
-                 [korma "0.3.0-RC5"]
+                 [korma "0.3.0-RC6"]
                  [log4j "1.2.15" :exclusions [javax.mail/mail javax.jms/jms com.sun.jdmk/jmxtools com.sun.jmx/jmxri]]
                  [mysql/mysql-connector-java "5.1.6"]
                  [org.clojure/java.jdbc "0.3.0-alpha1"]
                  [c3p0/c3p0 "0.9.1.2"]
-                 [hiccup "1.0.3"]
-                 [enlive "1.1.1"]
+                 [hiccup "1.0.4"]
                  ]
-  :plugins [[lein-ring "0.8.2"]]
+  :plugins [[lein-ring "0.8.10"]]
   :ring {:handler hello.handler/app}
   :profiles
-  {:dev {:dependencies [[ring-mock "0.1.3"]]}})
+  {:dev {:dependencies [[ring-mock "0.1.5"]]}})


[#2472] Adapt/fix extract-multiple caddisfly tx

--- backend/src/akvo/lumen/lib/transformation/multiple_column/caddisfly.clj
+++ backend/src/akvo/lumen/lib/transformation/multiple_column/caddisfly.clj
@@ -34,7 +34,7 @@
   [{:keys [tenant-conn caddisfly] :as deps} table-name current-columns op-spec]
   (jdbc/with-db-transaction [conn tenant-conn]
     (let [{:keys [onError op args]} op-spec
-          selected-column (find-column (walk/keywordize-keys current-columns) (-> args :selectedColumn :columnName))
+          selected-column           (find-column (walk/keywordize-keys current-columns) (-> args :selectedColumn :columnName))

           caddisfly-schema (if-let [multipleId (:multipleId selected-column)]
                              (get-schema caddisfly multipleId)
@@ -44,31 +44,36 @@
                                         {:possible-reason "maybe you don't update the flow dataset!? (via client dashboard ...)"}})))

           new-columns (->> (columns-to-extract (:columns args) selected-column caddisfly-schema (:extractImage args))
-                           (multiple-column/add-name-to-new-columns current-columns))
-
-          _ (log/debug ::apply-operation table-name (:columnName selected-column) onError)
-          _ (log/debug :new-columns new-columns :selected-column selected-column :extractImage (:extractImage args))
+                           (multiple-column/add-name-to-new-columns current-columns))]
+      (if-let [errors (->> (map :title new-columns)
+                           (filter #(engine/column-title-error? % current-columns))
+                           not-empty)]
+        {:success? false
+         :message  (map :message errors)}
+        (let [_ (log/debug ::apply-operation table-name (:columnName selected-column) onError)
+              _ (log/debug :new-columns new-columns :selected-column selected-column :extractImage (:extractImage args))

-          add-db-columns (doseq [c new-columns]
-                           (db.tx.engine/add-column conn {:table-name      table-name
-                                             :column-type     (:type c)
-                                             :new-column-name (:id c)}))
-          update-db-columns (->> (db.transformation/select-rnum-and-column conn {:table-name table-name :column-name (:columnName selected-column)})
-                                 (map
-                                  (fn [m]
-                                    (let [cell-value (multiple-column/multiple-cell-value m (:columnName selected-column))
-                                          cad-results (or (test-results cell-value new-columns)
-                                                          (repeat nil))
-                                          update-vals (->> (map
-                                                            (fn [new-column-name new-column-val]
-                                                              [(keyword new-column-name) new-column-val])
-                                                            (map :id new-columns)
-                                                            cad-results)
-                                                           (reduce #(apply assoc % %2) {}))]
-                                      (log/debug :update-vals update-vals)
-                                      (multiple-column/update-row conn table-name (:rnum m) update-vals "NULL"))))
-                                 doall)]
-      (log/debug :db-txs selected-column add-db-columns update-db-columns)
-      {:success?      true
-       :execution-log [(format "Extract caddisfly column %s" (:columnName selected-column))]
-       :columns       (into current-columns (vec new-columns))})))
+              add-db-columns    (doseq [c new-columns]
+                                  (db.tx.engine/add-column conn {:table-name      table-name
+                                                                 :column-type     (:type c)
+                                                                 :new-column-name (:id c)}))
+              update-db-columns (->> (db.transformation/select-rnum-and-column conn {:table-name table-name :column-name (:columnName selected-column)})
+                                     (map
+                                      (fn [m]
+                                        (let [cell-value  (multiple-column/multiple-cell-value m (:columnName selected-column))
+                                              cad-results (or (test-results cell-value new-columns)
+                                                              (repeat nil))
+                                              update-vals (->> (map
+                                                                (fn [new-column-name new-column-val]
+                                                                  [(keyword new-column-name) new-column-val])
+                                                                (map :id new-columns)
+                                                                cad-results)
+                                                               (reduce #(apply assoc % %2) {}))]
+                                          (log/debug :update-vals update-vals)
+                                          (multiple-column/update-row conn table-name (:rnum m) update-vals "NULL"))))
+                                     doall)
+              ]
+         (log/debug :db-txs selected-column add-db-columns update-db-columns)
+         {:success?      true
+          :execution-log [(format "Extract caddisfly column %s" (:columnName selected-column))]
+          :columns       (into current-columns (vec new-columns))})))))


Add aim cue for afterglow-max example patcher.

--- src/afterglow/examples.clj
+++ src/afterglow/examples.clj
@@ -680,7 +680,7 @@
     (ct/set-cue! (:cue-grid *show*) 0 8
                  (cues/cue :torrent-dir (fn [var-map]
                                           (move/direction-effect
-                                           "Direction"
+                                           "Pan/Tilt"
                                            (params/build-pan-tilt-param :pan (:pan var-map 0.0)
                                                                          :tilt (:tilt var-map 0.0)
                                                                          :degrees true)
@@ -689,6 +689,20 @@
                                         :min -180.0 :max 180.0 :start 0.0 :centered true :resolution 0.5}
                                        {:key "tilt" :name "Tilt"
                                         :min -180.0 :max 180.0 :start 0.0 :centered true :resolution 0.5}]))
+    (ct/set-cue! (:cue-grid *show*) 1 8
+                 (cues/cue :torrent-dir (fn [var-map]
+                                          (move/aim-effect
+                                           "Aim"
+                                           (params/build-aim-param :x (:x var-map 0.0)
+                                                                   :y (:y var-map 0.0)
+                                                                   :z (:z var-map 1.0))
+                                           (show/all-fixtures)))
+                           :variables [{:key "x" :name "X"
+                                        :min -20.0 :max 20.0 :start 0.0 :centered true :resolution 0.05}
+                                       {:key "z" :name "Z"
+                                        :min -20.0 :max 20.0 :start 0.0 :centered true :resolution 0.05}
+                                       {:key "y" :name "Y"
+                                        :min 0.0 :max 20.0 :start 0.0 :centered false :resolution 0.05}]))
     ;; Some compound cues
     (ct/set-cue! (:cue-grid *show*) 8 0
                  (cues/cue :star-swirl (fn [_] (cues/compound-cues-effect