playing around with maintaining multiple indices for one memoryfactstore

--- sample/src/sample/impl/memory.clj
+++ sample/src/sample/impl/memory.clj
@@ -1,5 +1,8 @@
 (ns sample.impl.memory
-  (:require [clj-karabiner.tree :as t]
+  (:require [clojure.set :as s]
+            [clojure.edn :as edn]
+
+            [clj-karabiner.tree :as t]
             [clj-karabiner.tree.bplustree :as bt]

             [sample.factstore :as fs]
@@ -42,23 +45,38 @@

-(let [eavt-idx (atom (bt/b+tree 3))
+#_(let [eavt-idx (atom (bt/b+tree 3))
       aevt-idx (atom (bt/b+tree 3))
       avet-idx (atom (bt/b+tree 3))
       vaet-idx (atom (bt/b+tree 3))
       mfs (-> (memory-factstore (reify ps/Subscriber
                                   (msg-received [this [e a v t :as fact]]
-                                    (println "SUB1" fact)
                                     (swap! eavt-idx #(t/insert % [e a v t] fact))
                                     (swap! aevt-idx #(t/insert % [a e v t] fact))
                                     (swap! avet-idx #(t/insert % [a v e t] fact))
                                     (swap! vaet-idx #(t/insert % [v a e t] fact)))))
-              (fs/assert [:person/otto :email "otto@foo.com" 1]
-                         [:person/otto :firstname "otto" 1]
-                         [:person/otto :lastname "wurst" 1])
-              (fs/assert [:person/hans :email "hans@foo.com" 2]
-                         [:person/hans :firstname "hans" 2]
-                         [:person/hans :lastname "wurst" 2])
-              (fs/assert [:person/otto :firstname "otto fritz" 3])
-              (fs/assert [:person/hans :firstname "hans hugo" 4]))]
-  (t/lookup-range @eavt-idx [:person/otto]))
+              (fs/assert [:person/otto :person/email     "otto@foo.com"  1]
+                         [:person/otto :person/firstname "otto"          1]
+                         [:person/otto :person/lastname  "wurst"         1])
+              (fs/assert [:person/hans :person/email     "hans@foo.com"  2]
+                         [:person/hans :person/firstname "hans"          2]
+                         [:person/hans :person/lastname  "wurst"         2])
+              (fs/assert [:person/otto :person/firstname "otto fritz"    3])
+              (fs/assert [:person/hans :person/firstname "hans hugo"     4])
+              (fs/assert [:address/a   :address/street   "street1"       5]
+                         [:address/a   :address/number   "11a"           5])
+              (fs/assert [:address/b   :address/street   "street1"       6]
+                         [:address/b   :address/number   "22a"           6])
+              (fs/assert [:person/otto :person/address   (pr-str :address/a)  7]
+                         [:person/otto :person/address   (pr-str :address/b)  7])
+              (fs/assert [:person/hans :person/address   (pr-str :address/b)  8])
+              (fs/assert [:address/a   :address/number   "11b"           9])
+              (fs/assert [:address/b   :address/number   "22b"          10]))]
+  (let [addresses-by-street (t/lookup-range @avet-idx [:address/street "street1"])
+        addresses-by-number (t/lookup-range @avet-idx [:address/number "22b"])
+        abs-es (->> addresses-by-street (map first) set)
+        abn-es (->> addresses-by-number (map first) set)
+        ae (-> (s/intersection abs-es abn-es) first)
+        persons-by-address (t/lookup-range @avet-idx [:person/address (pr-str ae)])
+        pe (->> persons-by-address (map first))]
+    pe))


Rename implementation ns reference to `consume`

- Instead of `sut` which was cider's default pick.

--- test/wonko/kafka/consume_test.clj
+++ test/wonko/kafka/consume_test.clj
@@ -1,6 +1,6 @@
 (ns wonko.kafka.consume-test
   (:require [clojure.test :refer :all]
-            [wonko.kafka.consume :as sut]
+            [wonko.kafka.consume :as consume]
             [wonko.test-utils :as tu]
             [wonko-client.core :as client]
             [wonko.test-config :as tc]
@@ -11,12 +11,12 @@

 (deftest consumption-offset
   (testing "after a restart, don't start consuming from the beginning"
-    (sut/init! tc/zookeeper-config)
+    (consume/init! tc/zookeeper-config)

     (let [topic (tu/rand-str "offset-test")
           events (atom [])
           process-fn #(swap! events conj %)
-          thread-pool (sut/start {topic 1} process-fn)]
+          thread-pool (consume/start {topic 1} process-fn)]

       (admin/create-topic topic)
       (client/set-topics! topic topic)
@@ -31,12 +31,12 @@
       (is (= "first-metric" (-> @events first :metric-name)))

       ;; Restart
-      (sut/stop thread-pool)
-      (sut/init! tc/zookeeper-config)
+      (consume/stop thread-pool)
+      (consume/init! tc/zookeeper-config)
       (reset! events [])

       ;; Second Run
-      (let [thread-pool (sut/start {topic 1} process-fn)]
+      (let [thread-pool (consume/start {topic 1} process-fn)]
         (is (client/gauge :second-metric nil 5))

         (tu/wait-for #(= 1 (count @events)) :interval 0.5 :timeout 2)
@@ -45,4 +45,4 @@
         (is (= "gauge" (-> @events first :metric-type)))
         (is (= "second-metric" (-> @events first :metric-name)))

-        (sut/stop thread-pool)))))
+        (consume/stop thread-pool)))))


Revert "upgrades to jetty version 9.4.49.v20220914 (#1664)" (#1680)

This reverts commit b71ffa9df39be1b9056ebd4a208f60678dc9a19c.

--- waiter/project.clj
+++ waiter/project.clj
@@ -45,7 +45,7 @@
                  [io.grpc/grpc-core "1.20.0"
                   :exclusions [com.google.guava/guava]
                   :scope "test"]
-                 [twosigma/jet "0.7.10-20220917_061811-g0d23827"
+                 [twosigma/jet "0.7.10-20220829_161214-g1f873ca"
                   :exclusions [org.mortbay.jetty.alpn/alpn-boot]]
                  [twosigma/clj-http "1.0.2-20180124_201819-gcdf23e5"
                   :exclusions [commons-codec commons-io org.clojure/tools.reader potemkin slingshot]]


update test example plan

update test example plan

--- test-cljs/frontend/test_utils.cljs
+++ test-cljs/frontend/test_utils.cljs
@@ -114,7 +114,9 @@
                                 :type :osx}}}}
         %
         (map % keys)
-        (conj % {:org_name "circleci"})
+        (conj % {:org_name "circleci"
+                 :org {:name "circleci"
+                       :vcs_type "github"}})
         (apply merge %)))

 (def example-piggieback-plan


Cleaning tests.

Cleaning tests.

--- test/active/clojure/match_test.clj
+++ test/active/clojure/match_test.clj
@@ -5,7 +5,7 @@
             [clojure.test :as t]))

 (t/deftest parse-clause-test
-  (t/testing "key exists clause"
+  (t/testing "key exists without binding clause"
     (t/testing "flat"
       (t/is (= (p/make-key-exists-without-binding-clause :k p/the-existence-matcher)
                (p/parse-clause :k)))
@@ -13,13 +13,17 @@
                (p/parse-clause k))))
     (t/testing "list"
       (t/is (= (p/make-key-exists-without-binding-clause :k p/the-existence-matcher)
-               (p/parse-clause (:k))))))
+               (p/parse-clause (:k))))
+      ;; FIXME: is this also a list - it is not a path?
+      (t/is (= (p/make-key-exists-without-binding-clause :k p/the-existence-matcher)
+               (p/parse-clause [:k])))))

   (t/testing "key exists with binding clause"
     (t/is (= (p/make-key-exists-with-binding-clause :k p/the-existence-matcher "Binding")
              (p/parse-clause (:k :as Binding)))))

-  (t/testing "path exists clause"
+  (t/testing "path exists without binding clause"
+    ;; FIXME: the test for flat and list are the same
     (t/testing "flat"
       (t/is (= (p/make-path-exists-without-binding-clause [:k "V"] p/the-existence-matcher)
                (p/parse-clause [:k V]))))
@@ -27,30 +31,29 @@
       (t/is (= (p/make-path-exists-without-binding-clause [:k "V"] p/the-existence-matcher)
                (p/parse-clause [:k V])))))

-  (t/testing "path exists clause with binding"
+  (t/testing "path exists with binding clause"
     (t/is (= (p/make-path-exists-with-binding-clause [:k "V"] p/the-existence-matcher "Binding")
              (p/parse-clause ([:k V] :as Binding)))))

-  (t/testing "key matches clause"
+  (t/testing "key matches without binding clause"
     (t/testing "with regex"
       (let [c (p/parse-clause (:k #"foo"))]
         (t/is (= :k (p/key-matches-without-binding-clause-key c)))
         (t/is (= "foo" (.pattern ^java.util.regex.Pattern (p/regex-matcher-regex (p/key-matches-without-binding-clause-matcher c)))))
-        ;; (t/is (= "k" (p/key-matches-with-binding-clause-binding c)))
         ))
     (t/testing "with any other value"
       (t/is (= (p/make-key-matches-without-binding-clause :k (p/make-constant-matcher "foo"))
                (p/parse-clause (:k "foo"))))))

-  (t/testing "key matches clause with binding"
+  (t/testing "key matches with binding clause"
     (t/is (= (p/make-key-matches-with-binding-clause :k (p/make-constant-matcher "foo") "Binding")
              (p/parse-clause (:k "foo" :as Binding)))))

-  (t/testing "path matches clause"
+  (t/testing "path matches without binding clause"
     (t/is (= (p/make-path-matches-without-binding-clause [:k "bar" "baz"] (p/make-constant-matcher "foo"))
              (p/parse-clause ([:k bar baz] "foo")))))

-  (t/testing "path matches clause with binding"
+  (t/testing "path matches with binding clause"
     (t/is (= (p/make-path-matches-with-binding-clause [:k "bar" "baz"] (p/make-constant-matcher "foo") "Binding")
              (p/parse-clause ([:k bar baz] "foo" :as Binding)))))


testing things

testing things

--- test/clj/fractals/datalog_test.clj
+++ test/clj/fractals/datalog_test.clj
@@ -152,7 +152,7 @@
             {:user/email email
              :user/upVotes stories}))
    (take n (gen/sample email-gen))
-   (take n (repeat  (take 10 (gen/sample (gen/not-empty gen/string-alpha-numeric)))  ))))
+   (take n (repeat  (take 10 (gen/sample (gen/not-empty gen/string-alpha-numeric)))))))

 (deftest datomic-lifecycle-mbrainz-db
@@ -160,63 +160,61 @@
     (alter-var-root #'datomic-social-db component/start)
     (is (= (type (:conn datomic-social-db))
            datomic.peer.LocalConnection))
-    (is (:conn datomic-social-db)))
-  (is (=
-       "Teach Yourself Programming in Ten Years"
-       (:story/title
-        (d/entity
-         (:db-after
-          @(d/transact (:conn datomic-social-db)
-                       [{:story/title "Teach Yourself Programming in Ten Years"
-                         :story/url "http://norvig.com/21-days.html"}
-                        { :story/title "Clojure Rationale"
-                         :story/url "http://clojure.org/rationale"}
-                        {:story/title "Beating the Averages"
-                         :story/url "http://www.paulgraham.com/avg.html"}
-                        { :user/firstName "Stu"
-                         :user/lastName "Halloway"
-                         :user/email "stuarthalloway@datomic.com"}
-                        {:user/firstName "Ed"
-                         :user/lastName "Itor"
-                         :user/email "editor@example.com"}]))
-         [:story/url "http://norvig.com/21-days.html"]))))
-
-  (is (=  (count (d/q '[:find [?e ...]
-                        :where [?e :story/url]]
-                      (d/db (:conn datomic-social-db))))
-          3))
-  (is (= "john"
-         (->> (conj
-               (mapv
-                (fn [story] [:db/add "john"  :user/upVotes story])
-                (d/q '[:find [?e ...]
-                       :where [?e :story/url]]
-                     (d/db (:conn datomic-social-db))))
-
-               {:db/id "john"
-                :user/email "john@example.com"
-                :user/firstName "john"
-                :user/lastName "Doe"})
-              (d/transact (:conn datomic-social-db))
-              deref
-              :db-after
-              ((fn [db]
-                 (d/entity
-                  db
-                  [:user/email "john@example.com"])))
-              :user/firstName)))
-
-  (is (= (:user/firstName (d/entity
-                           (:db-after
-                            @(d/transact
-                              (:conn datomic-social-db)
-                              [{:user/email "john@example.com"
-                                ;; this finds the existing entity
-                                :user/firstName "Johnathan2"}]))
-                           [:user/email "john@example.com"]))
-         "Johnathan2"))
-
-  (is (= 3 (count (:user/upVotes (d/entity (d/db (:conn datomic-social-db))
+    (is (:conn datomic-social-db))
+    (is (= "Teach Yourself Programming in Ten Years"
+           (:story/title
+            (d/entity
+             (:db-after
+              @(d/transact (:conn datomic-social-db)
+                           [{:story/title "Teach Yourself Programming in Ten Years"
+                             :story/url "http://norvig.com/21-days.html"}
+                            { :story/title "Clojure Rationale"
+                             :story/url "http://clojure.org/rationale"}
+                            {:story/title "Beating the Averages"
+                             :story/url "http://www.paulgraham.com/avg.html"}
+                            { :user/firstName "Stu"
+                             :user/lastName "Halloway"
+                             :user/email "stuarthalloway@datomic.com"}
+                            {:user/firstName "Ed"
+                             :user/lastName "Itor"
+                             :user/email "editor@example.com"}]))
+             [:story/url "http://norvig.com/21-days.html"]))))
+
+    (is (=  (count (d/q '[:find [?e ...]
+                          :where [?e :story/url]]
+                        (d/db (:conn datomic-social-db))))
+            3))
+    (is (= "john"
+           (->> (conj
+                 (mapv
+                  (fn [story] [:db/add "john"  :user/upVotes story])
+                  (d/q '[:find [?e ...]
+                         :where [?e :story/url]]
+                       (d/db (:conn datomic-social-db))))
+
+                 {:db/id "john"
+                  :user/email "john@example.com"
+                  :user/firstName "john"
+                  :user/lastName "Doe"})
+                (d/transact (:conn datomic-social-db))
+                deref
+                :db-after
+                ((fn [db]
+                   (d/entity
+                    db
+                    [:user/email "john@example.com"])))
+                :user/firstName)))
+
+    (is (= (:user/firstName (d/entity
+                             (:db-after
+                              @(d/transact
+                                (:conn datomic-social-db)
+                                [{:user/email "john@example.com"
+                                  ;; this finds the existing entity
+                                  :user/firstName "Johnathan2"}]))
+                             [:user/email "john@example.com"]))
+           "Johnathan2"))
+    (is (= 3 (count (:user/upVotes (d/entity (d/db (:conn datomic-social-db))
                                            [:user/email "john@example.com"])))))

   (is (= 2
@@ -255,12 +253,12 @@
                                   (into []))
                              ))
                [:user/email "john@example.com"]))))
-  @(d/transact (:conn datomic-social-db) (gen-users-with-upvotes 10))
+  @(d/transact (:conn datomic-social-db) (gen-users-wilth-upvotes 10))
   (is (= (count (d/q '[:find ?id :where
                        [?id :user/email]]
                      (d/db (:conn datomic-social-db))))
          13))
-  (alter-var-root #'datomic-social-db component/stop))
+  (alter-var-root #'datomic-social-db component/stop)))

 (defrecord Datomic-Mem [uri conn schema]


Ensure Qanal's own threads are non-daemon. Fix #55

Read the Issue/Fix #55 for more details.

--- qanal/src/qanal/kafka.clj
+++ qanal/src/qanal/kafka.clj
@@ -282,7 +282,7 @@
 (defmacro forever-do [name sleep & body]
   `(let [_sleep#   (or ~sleep 1000)
          _name#    ~name]
-     (async/thread
+     (future
        (while true
          (safe-exec (str "" _name# ", will retry in " _sleep# "ms")
            ~@body)


model.connection: should not make new connection from map missing departure place id

--- test/busa_server/model/connection_test.clj
+++ test/busa_server/model/connection_test.clj
@@ -3,7 +3,11 @@
     [midje.sweet :refer :all]
     [busa-server.model.connection :as connection]))

-(def valid-connection-map {:departure-time "00:00" :duration "45min" :arrival-place-id "p1447" :departure-place-id "p1001"})
+(def valid-connection-map {
+  :departure-time "00:00"
+  :duration "45min"
+  :arrival-place-id "p1447"
+  :departure-place-id "p1001"})

 (fact "should make new connection with id from map"
   (connection/new-connection valid-connection-map) => (contains (merge valid-connection-map {:id anything})))
@@ -16,3 +20,6 @@

 (fact "should not make new connection from map missing arrival place id"
   (connection/new-connection (dissoc valid-connection-map :arrival-place-id)) => (throws Exception))
+
+(fact "should not make new connection from map missing departure place id"
+  (connection/new-connection (dissoc valid-connection-map :departure-place-id)) => (throws Exception))


New test: test-format-time-2

New test: test-format-time-2

--- test/clj_calendar/format_datetime_test.clj
+++ test/clj_calendar/format_datetime_test.clj
@@ -81,4 +81,18 @@
               "one month and one year ago"    (format-time- 1 1 "month" "year")
               "one month and 2 years ago"     (format-time- 1 2 "month" "year"))))

+(deftest test-format-time-2
+    "Check the function clj-calandar.format-datetime/format-time-."
+    (testing "the function clj-calandar.format-datetime/format-time-."
+        (are [x y] (= x y)
+              "2 minutes ago"                (format-time- 2 0 "minute" "second")
+              "2 minutes and one second ago" (format-time- 2 1 "minute" "second")
+              "2 minutes and 2 seconds ago"  (format-time- 2 2 "minute" "second")
+              "2 days ago"                   (format-time- 2 0 "day" "hour")
+              "2 days and one hour ago"      (format-time- 2 1 "day" "hour")
+              "2 days and 2 hours ago"       (format-time- 2 2 "day" "hour")
+              "2 months ago"                 (format-time- 2 0 "month" "year")
+              "2 months and one year ago"    (format-time- 2 1 "month" "year")
+              "2 months and 2 years ago"     (format-time- 2 2 "month" "year"))))

+


a little task cleanup :bath:

a little task cleanup :bath:

--- plugins/matross/tasks/command.clj
+++ plugins/matross/tasks/command.clj
@@ -2,30 +2,24 @@
   (:require [matross.docs :refer [defdocs]]
             [matross.tasks.core :refer [deftask task-result]]
             [matross.connections.core :refer [run exit-ok?]]))
-
-(comment
-:command shell command to run
-:shell system shell to use (optional)
-:env map of environment (optional))

 (defn key=val [map-entry]
   (let [[key val] map-entry
         keyname (name key)]
     (str keyname "=" val)))

+(defdocs :command
+  {:description "Run a shell command on a remote machine."
+   :url "https://github.com/matross/matross/blob/master/plugins/matross/tasks/command.clj"
+   :options {:command "command to run"
+             :env "map containing shell environment (optional)"
+             :shell "path to shell to use (optional)"}
+   :defaults {:shell "/bin/sh" :env {}}
+   :examples [{:command "echo $message"
+               :env {:message "hello, world!"}}]})
+
 (deftask :command [conn {:keys [shell command env]
                          :or   {shell "/bin/sh"}}]
   (let [cmd (concat ["/usr/bin/env" "-i"] (map key=val env) [shell "-c" command])
         proc (run conn {:cmd cmd})]
     (task-result (exit-ok? proc) true proc)))
-
-(defdocs :command
-  {:description "Run a shell command on a remote machine."
-   :url "https://github.com/matross/matross/blob/master/plugins/matross/tasks/command.clj"
-   :options
-     {:command "command to run"
-      :env "map containing shell environment (optional)"
-      :shell "path to shell to use (optional)"}
-   :defaults {:shell "/bin/sh" :env {}}
-   :examples [{:command "echo $message"
-               :env {:message "hello, world!"}}]})


formatting

formatting

--- src/babel/parse.cljc
+++ src/babel/parse.cljc
@@ -287,19 +287,18 @@
    by calling the supplied _fo_ function"
   (let [head-first? (get-in tree [:first] :none)
         pred (get-in tree [:synsem :sem :pred])
-        cat (get-in tree [:synsem :cat])]
+        cat (str (get-in tree [:synsem :cat]) "")]
     (cond
       (and (= :none (get-in tree [:head] :none))
            (= :none (get-in tree [:comp] :none))
            (not (= :none (get-in tree [:rule] :none))))
-      (str "[" (get-in tree [:rule]) "/" (get-in tree [:synsem :cat])
-           (when pred
-             " pred(" pred ") ")
+      (str "[" (get-in tree [:rule]) "/" cat
+           pred
            "'" (fo tree) "']")

       (= head-first? :none)
-      (str "'" (fo tree) "'/" (get-in tree [:synsem :cat])
-           (when pred " pred(" (get-in tree [:synsem :sem :pred]) ") "))
+      (str "'" (fo tree) "'/" cat
+           pred)

       (= head-first? :comp)
       (str "[" (get-in tree [:rule]) " "


blind: removed manual consing where possible

--- src/blind/reader.clj
+++ src/blind/reader.clj
@@ -540,7 +540,7 @@
 (defn wrapping-reader
   [sym]
   (fn [rdr _]
-    (cons sym (cons (read rdr true nil true) nil))))
+    (list sym (read rdr true nil true) nil)))

 (defn throwing-reader
   [msg]
@@ -796,7 +796,7 @@
        (let [seq (seq form)]
          (if seq
            (syntax-quote-coll nil seq)
-           (cons 'clojure.core/list nil)))
+           '(clojure.core/list)))
        :else (throw (UnsupportedOperationException. "Unknown Collection type")))

      (or (keyword? form)
@@ -805,7 +805,7 @@
          (string? form))
      form

-     :else (cons 'quote (cons form nil)))
+     :else (list 'quote form))
    (add-meta form)))

 (defn read-syntax-quote


Added (store-file)

Added (store-file)

--- src/clj_git/core.clj
+++ src/clj_git/core.clj
@@ -60,6 +60,13 @@
         bdata (compress-zlib data)]
     (with-open [wrtr (output-stream filepath)]
       (.write wrtr bdata))))
+
+(defn store-file
+  [filepath]
+  (let [text (slurp filepath)
+        hash-text (hash-str text)]
+    (write-blob text)
+    hash-text))

 (defn all-objects []
   (let [object-path (str (git-root) "objects/")


rollback changes

rollback changes

--- src/clj_pg/honey.clj
+++ src/clj_pg/honey.clj
@@ -166,12 +166,12 @@
 (defn create-database [db db-name & [template]]
   (let [sql (str "CREATE DATABASE " (name db-name) (when template (str " TEMPLATE = " template)))]
     (log/info sql)
-    (jdbc/execute! db [sql] {:transaction? false})))
+    (jdbc/execute! db [sql] :transaction? false)))

 (defn drop-database [db db-name]
   (let [sql (str "DROP DATABASE IF EXISTS " (name db-name))]
     (log/info sql)
-    (jdbc/execute! db [sql] {:transaction? false})))
+    (jdbc/execute! db [sql] :transaction? false)))

 (defn create [db {tbl :table :as spec} data]


require express

require express

--- src/cljs/server.cljs
+++ src/cljs/server.cljs
@@ -6,7 +6,8 @@
 (enable-console-print!)

 (def http (nodejs/require "http"))
-; (def express (nodejs/require "express"))
+
+(def express (nodejs/require "express"))

 (defn fetch-some-joke
   "Fetch joke from The Internet Chuck Norris Database"


error wrap everything. Find any sneaky mis-configs

--- src/clojure/core.clj
+++ src/clojure/core.clj
@@ -40,6 +40,18 @@
 (def MFCC_FREQ_BANDS    13)
 (def DEFAULT_BLOCK_SIZE 512)

+(defn raise-errors [result]
+  (when result
+    (cond
+      (= result xtract-success)        true
+      (= result xtract-no-result)      (do ;;(println :no-result)
+                                         true)
+      (= result xtract-bad-argv)       (throw (Exception. "Bad argv error"))
+      (= result xtract-argument-error) (throw (Exception. "Bad arguments error"))
+      (= result xtract-bad-vec-size)   (throw (Exception. "Bad vector size"))
+      (= result xtract-bad-state)      (throw (Exception. "Bad state"))
+      true (throw (Exception. (str "Unknown result type:" result))))))
+
 (defn- double->clojure [vs len]
   (map-indexed
    (fn [idx v] (xtract/double_array_getitem vs idx))
@@ -138,12 +150,9 @@

 (defn extract-fundemental-frequency [wav-data block-size sample-rate]
   (let [r (double-array 1)]
-    (xtract/xtract_wavelet_f0 wav-data block-size (xtract-args sample-rate) r)
-
-;;    (when (> (first r) 0.0) (println :---------------------> (first r)))
-    (first r)
-    )
-)
+    (raise-errors
+     (xtract/xtract_wavelet_f0 wav-data block-size (xtract-args sample-rate) r))
+    (first r)))

 (defn extract-spectrum
   "Extract frequency domain spectrum from time domain signal"
@@ -152,46 +161,46 @@
   ([windowed-data block-size sample-ratio spectrum-type db-component normalised]

    (let [spectrum (c-double block-size)]
-     (xtract/xtract_spectrum windowed-data
-                             block-size (xtract-args sample-ratio
-                                                     spectrum-type
-                                                     db-component
-                                                     normalised)
-                             spectrum)
+     (raise-errors
+      (xtract/xtract_spectrum windowed-data
+                              block-size (xtract-args sample-ratio
+                                                      spectrum-type
+                                                      db-component
+                                                      normalised)
+                              spectrum))
      spectrum)))

 (defn extract-fft-spectrum [wave-data block-size sample-rate full-window]
   (let [windowed (c-double block-size)]
-    (xtract/xtract_windowed wave-data block-size (xtract/doublea_to_voidp full-window) windowed)
-    (xtract/xtract_init_fft block-size xtract-spectrum)
+    (raise-errors
+     (xtract/xtract_windowed wave-data block-size (xtract/doublea_to_voidp full-window) windowed))
+    (raise-errors
+     (xtract/xtract_init_fft block-size xtract-spectrum))
     (let [spectrum (extract-spectrum windowed block-size (/ sample-rate block-size) xtract-spectrum-magnitude)]
-      (xtract/xtract_free_fft)
-      (xtract/delete_double_array windowed)
+      (raise-errors
+       (xtract/xtract_free_fft))
+      (raise-errors
+       (xtract/delete_double_array windowed))
       spectrum)))

 (defn extract-peaks
   "Extract the amplitude and frequency of spectral peaks from a magnitude spectrum"
   [coefficients block-size sample-ratio peak-threshold]
   (let [peaks (c-double block-size)]
-    (xtract/xtract_peak_spectrum coefficients
-                                 (/ block-size 2)
-                                 (xtract-args sample-ratio peak-threshold)
-                                 peaks)
+    (raise-errors
+     (xtract/xtract_peak_spectrum coefficients
+                                  (/ block-size 2)
+                                  (xtract-args sample-ratio peak-threshold)
+                                  peaks))
     peaks))

 (defn extract-rms-amp
   "Extract the RMS amplitude of an input vector"
   [wav-data block-size sample-ratio]
   (let [rms (double-array 1)]
-    (xtract/xtract_rms_amplitude wav-data block-size (xtract-args sample-ratio) rms)
+    (raise-errors
+     (xtract/xtract_rms_amplitude wav-data block-size (xtract-args sample-ratio) rms))
     rms))
-
-(defn raise-errors [result]
-    (cond
-      (= result xtract-success)        true
-      (= result xtract-bad-argv)       (throw (Exception. "Bad argv error"))
-      (= result xtract-argument-error) (throw (Exception. "Bad arguments error"))
-      true (throw (Exception. "Unknown result type"))))

 (defn frequency->cents [f0]
   (if (= 0.0 f0)
@@ -222,13 +231,14 @@
          ;;  _ (xtract/int_array_setitem bark-band-limits 0 0)
          ]

-     (xtract/xtract_init_mfcc half-block-size
-                              (/ SAMPLE_RATE 2)
-                              xtract-equal-gain
-                              MFCC_FREQ_MIN
-                              MFCC_FREQ_MAX
-                              MFCC_FREQ_BANDS
-                              (xtract_mel_filter/.getFilters mel-filters))
+     (raise-errors
+      (xtract/xtract_init_mfcc half-block-size
+                               (/ SAMPLE_RATE 2)
+                               xtract-equal-gain
+                               MFCC_FREQ_MIN
+                               MFCC_FREQ_MAX
+                               MFCC_FREQ_BANDS
+                               (xtract_mel_filter/.getFilters mel-filters)))

      ;;public static int xtract_init_bark(int N, double sr, SWIGTYPE_p_int band_limits) {
@@ -238,14 +248,12 @@
      (let [full-window (xtract/xtract_init_window block-size xtract-hann)
            half-window (xtract/xtract_init_window half-block-size xtract-hann)]

-       (xtract/xtract_init_wavelet_f0_state)
+       (raise-errors
+        (xtract/xtract_init_wavelet_f0_state))

        (let [stats
              (map-indexed
               (fn [idx v]
-
-
-;;                (println v)
                 (let [wav-data (clojure->c-double v)
                       f0       (extract-fundemental-frequency wav-data block-size SAMPLE_RATE)
                       cents    (frequency->cents f0)
@@ -268,23 +276,28 @@
                       loudness              (double-array [0])
                       tonality              (double-array [0])]

-
-
-                  (xtract/xtract_spectral_centroid spectrum block-size (xtract-args 0.0) spectral-centroid)
-                  (xtract/xtract_irregularity_j    spectrum half-block-size nil spectral-irregularity)
+                  (raise-errors
+                   (xtract/xtract_spectral_centroid spectrum block-size (xtract-args 0.0) spectral-centroid))
+                  (raise-errors
+                   (xtract/xtract_irregularity_j    spectrum half-block-size nil spectral-irregularity))

                   (let [spectral-skewness      (double-array [0])
                         spectral-std-deviation (double-array [0])
                         spectral-mean          (double-array [0])
                         spectral-kurtosis      (double-array [0])]

-                    (xtract/xtract_spectral_mean spectrum block-size nil spectral-mean)
-                    (xtract/xtract_variance spectrum block-size (xtract-args (first spectral-mean)) spectral-variance)
-                    (xtract/xtract_spectral_standard_deviation spectrum block-size (xtract-args (first spectral-variance)) spectral-std-deviation)
+                    (raise-errors
+                     (xtract/xtract_spectral_mean spectrum block-size nil spectral-mean))
+                    (raise-errors
+                     (xtract/xtract_variance spectrum block-size (xtract-args (first spectral-mean)) spectral-variance))
+                    (raise-errors
+                     (xtract/xtract_spectral_standard_deviation spectrum block-size (xtract-args (first spectral-variance)) spectral-std-deviation))

                     (let [argv (xtract-args (first spectral-mean) (first spectral-std-deviation))]
-                      (xtract/xtract_spectral_skewness spectrum block-size argv spectral-skewness)
-                      (xtract/xtract_spectral_kurtosis spectrum block-size argv spectral-kurtosis))
+                      (raise-errors
+                       (xtract/xtract_spectral_skewness spectrum block-size argv spectral-skewness))
+                      (raise-errors
+                       (xtract/xtract_spectral_kurtosis spectrum block-size argv spectral-kurtosis)))

                     ;;(xtract/xtract_noisiness     wav-data block-size (xtract-args NUM_HARMONICS ) noiseness)

@@ -373,10 +386,16 @@
   )))

+
+    (let [block-stats (block-stats "test/fixtures/test.wav")]
+;;      (doseq [frame block-stats] (println frame))
+      (println :global (global-stats block-stats))
+      )
+
 (comment
   (dotimes [i 1]
     (let [block-stats (block-stats "test/fixtures/test.wav")]
-      (doseq [frame block-stats] (println frame))
+;;      (doseq [frame block-stats] (println frame))
       (println :global (global-stats block-stats))
       ))


table pointer cursor if clickable item

table pointer cursor if clickable item

--- src/cljs/material/component/list/basic.cljs
+++ src/cljs/material/component/list/basic.cljs
@@ -37,8 +37,11 @@
                  (fn [coll-index coll]
                    (let [render-fn (:render-fn coll)]
                      (cmp/table-cell
-                       {:key       (str "table-row-cell-" index "-" coll-index)
-                        :className "Swarmpit-table-row-cell"}
+                       (merge
+                         {:key       (str "table-row-cell-" index "-" coll-index)
+                          :className "Swarmpit-table-row-cell"}
+                         (when onclick-handler-fn
+                           {:style {:cursor "pointer"}}))
                        (render-fn item index)))))))) items)))

 (rum/defc table < rum/static


getting crazzy up in here

getting crazzy up in here

--- src/cljs/reagent_demo/views/about_page.cljs
+++ src/cljs/reagent_demo/views/about_page.cljs
@@ -6,25 +6,11 @@

 (def ac (new window/AudioContext))

-(defn distortion-curve [amount]
-  (let [k (+ amount 3)
-        pi (.-PI js/Math)
-        n-samples 44100
-        deg (/ pi 180)]
-    (map
-      #(let [x (/ (* 2 %) (- n-samples 1))]
-          (/ (* k x 20 deg)
-          (* (.abs js/Math x) (+ amount pi))))
-      (range 44100))))
-
 (defn play-clip [url position duration rate gain reverse]
   (let [xhr (new window/XMLHttpRequest)
         source (.createBufferSource ac)
         gain-node (.createGain ac)
-        analize-node (.createAnalyser ac)
-        distort-node (.createWaveShaper ac)
-        biquad-node (.createBiquadFilter ac)
-        convolve-node (.createConvolver ac)]
+        biquad-node (.createBiquadFilter ac)]
     (.open xhr "get" url true)
     (set! (.-responseType xhr) "arraybuffer")
     (set! (.-onload xhr) (fn []
@@ -35,22 +21,15 @@
             (js/Array.prototype.reverse.call (.getChannelData buffer 1)))
           ; (.linearRampToValueAtTime (.-gain gain-node) 1 0)
           ; (.linearRampToValueAtTime (.-gain gain-node) 0 5)
-          ; (set! (.-buffer convolve-node) buffer)
+          (set! (.-buffer source) buffer)
           (set! (.-value (.-gain gain-node)) gain)
           (set! (.-value (.-playbackRate source)) rate)
-          (set! (.-buffer source) buffer)
-          (set! (.-type biquad-node) "notch")
-          (set! (.-value (.-frequency biquad-node)) 1000)
-          (set! (.-Q biquad-node) 1)
-          (set! (.-gain biquad-node) 1)
-          (set! (.-curve distort-node) (distortion-curve 400))
-          (set! (.-oversample distort-node) "4x")
-          (.connect source analize-node)
-          (.connect analize-node distort-node)
-          (.connect distort-node biquad-node)
+          ; (set! (.-Q biquad-node) 1)
+          ; (set! (.-gain biquad-node) 1)
+          ; (set! (.-type biquad-node) "notch")
+          ; (set! (.-value (.-frequency biquad-node)) 1000)
+          (.connect source biquad-node)
           (.connect biquad-node gain-node)
-          ; (.connect biquad-node convolve-node)
-          ; (.connect convolve-node gain-node)
           (.connect gain-node (aget ac "destination"))
           (.start source (.-currentTime ac) position)
           (js/setTimeout
@@ -59,16 +38,15 @@
     (.send xhr)))

 (def url "http://static.kevvv.in/sounds/callmemaybe.mp3")
-; (play-clip url 0 100 0.4 true)
-; (play-clip url 0 100 0.25 1 false)
-(play-clip url 3 6 1 1 false)

-; (js/setInterval #(play-clip url 7.1 4 1 1 false) 3000)
+(defn n-loops [times seconds func]
+  (when (< 0 times)
+    (func times)
+    (js/setTimeout
+      #(n-loops (dec times) seconds func)
+      (* 1000 seconds)
+    )
+  )
+)

-; (play-clip url 7.1 0.35)
-; (js/setInterval #(play-clip url 7.1 2 2 false) 2000)
-
-; (js/setInterval #(play-clip url 17.1 2.5) 1350)
-
-; Array.prototype.reverse.call(buffer.getChannelData(0))
-;       Array.prototype.reverse.call(buffer.getChannelData(1))
+(n-loops 15 5 #(play-clip url (- 16 %) 10 % 1 (odd? %)))


(PDB-589) Add indexes to environment foreign keys

--- src/com/puppetlabs/puppetdb/scf/migrate.clj
+++ src/com/puppetlabs/puppetdb/scf/migrate.clj
@@ -630,7 +630,7 @@

             ;;Rename catalogs_transform to catalogs, replace constraints
             "ALTER TABLE catalogs_transform RENAME to catalogs"
-
+
             (when (postgres?)
               "ALTER TABLE catalogs
                ADD CONSTRAINT catalogs_pkey PRIMARY KEY (id)")
@@ -639,7 +639,7 @@
              ADD CONSTRAINT catalog_resources_catalog_id_fkey FOREIGN KEY (catalog_id)
              REFERENCES catalogs (id)
              ON UPDATE NO ACTION ON DELETE CASCADE"
-
+
             "ALTER TABLE catalogs
              ADD CONSTRAINT catalogs_certname_fkey FOREIGN KEY (certname)
              REFERENCES certnames (name)
@@ -678,12 +678,21 @@
    "ALTER TABLE catalogs
     ADD CONSTRAINT catalogs_env_fkey FOREIGN KEY (environment_id)
     REFERENCES environments (id) ON UPDATE NO ACTION ON DELETE CASCADE"
+
+   "CREATE INDEX idx_catalogs_env ON catalogs(environment_id)"
+
    "ALTER TABLE certname_facts_metadata
     ADD CONSTRAINT facts_env_fkey FOREIGN KEY (environment_id)
     REFERENCES environments (id) ON UPDATE NO ACTION ON DELETE CASCADE"
+
+   "CREATE INDEX idx_certname_facts_env ON certname_facts_metadata(environment_id)"
+
    "ALTER TABLE reports
     ADD CONSTRAINT reports_env_fkey FOREIGN KEY (environment_id)
-    REFERENCES environments (id) ON UPDATE NO ACTION ON DELETE CASCADE"))
+    REFERENCES environments (id) ON UPDATE NO ACTION ON DELETE CASCADE"
+
+   "CREATE INDEX idx_reports_env ON reports(environment_id)"
+   ))

 ;; The available migrations, as a map from migration version to migration function.


sync without collision

sync without collision

--- src/desafio/core.clj
+++ src/desafio/core.clj
@@ -169,13 +169,31 @@
     (let [hit (first hits)]
       ;;process hit
       (println hit)
+      (let [res (esd/get esconn index-name index-type (str (:id hit)))]
+        (if (nil? res)
+          (let ;; put new es entry and update cas
+              [timeline (:timeline hit)
+               id (:id hit)
+               str-id (str (:id hit))
+               created (:created_at hit)
+               text (:text hit)]
+            (esd/put esconn index-name index-type str-id {:timeline timeline
+                                                          :text text
+                                                          :created_at (.getTime (java.util.Date.))
+                                                          :sync true})
+            (cql/update casconn "tweet"
+                        {:timeline timeline
+                         :text text
+                         :sync true
+                         :created_at created}
+                        (casq/where {:id id})))
+          (do ;; update entry
+            )))
       (recur esconn casconn (rest hits)))))

 (defn cassandra2elasticsearch [esconn casconn]
   (let [hits (casGetNotSyncTweets casconn)]
     (cas2es esconn casconn hits)))
-
-

 ;;; tests helpers

@@ -185,10 +203,10 @@
   (casDropTableTweet casconn)
   (casCreateTableTweet casconn))

-(defn data10es3cas [esconn casconn]
+(defn data3es2cas [esconn casconn]
   (resetDBs esconn casconn)
-  (esPutRandomTweets esconn 10)
-  (casPutRandomTweets casconn 3))
+  (esPutRandomTweets esconn 3)
+  (casPutRandomTweets casconn 2))

 ;; Enable command-line invocation
 (defn -main [& args]


Point to external docs in code.

Point to external docs in code.

--- src/dmohs/react.cljs
+++ src/dmohs/react.cljs
@@ -2,50 +2,13 @@
   (:require [dmohs.react.core :as core]))

-;;
-;; React ClojureScript Top-Level API. Follows React's Top-Level API:
-;; https://facebook.github.io/react/docs/top-level-api.html
-;;
-
-
 (defn create-class [fn-map]
-  "Creates and returns a React class from the supplied map, similar to React.createClass.
-
-Each function receives a map of values containing the current instance's properties:
-{:this instance
- :props props
- :state state ; state atom
- :refs refs ; refs atom
- :prev-props ; when appropriate
- :next-props ; when appropriate
- ...
-}
-
-Usage:
-(create-class
- {:get-default-props
-  (fn [] {:starting-value 17})
-  :get-initial-state
-  (fn [{:keys [props]}] {:value (props :starting-value)})
-  :render
-  (fn [{:keys [state]}]
-    [:div {:ref \"the-only-div\" :onClick (fn [e] (swap! state update-in [:value] inc))}
-      \"You've clicked me \" (:value @state) \" times!\"])
-  :component-did-mount
-  (fn [{:keys [refs]}]
-    (.focus (.getDOMNode (@refs \"the-only-div\"))))
-
-Note that render can return either an element (via create-element) or a vector which will be
-automatically passed to create-element.
-"
+  "See: https://github.com/dmohs/react-cljs#reactcreateclass"
   (core/create-class fn-map))

 (defn create-element
-  "Creates and returns a new ReactElement of the given type, similar to React.createElement. The
-first argument can also be a keyword (e.g., :div) which is simply converted to a string. The
-argument may also be a vector (e.g., [:div {:style {:color \"blue\"}} \"Stuff\"]) with arguments
-in the same order."
+  "See: https://github.com/dmohs/react-cljs#reactcreateelement"
   ([type-or-vec] (create-element type-or-vec nil))
   ([type-or-vec props & children]
      (apply core/create-element type-or-vec props children)))


Fix dispatch fn for writers

Fix dispatch fn for writers

--- src/grimoire/api.clj
+++ src/grimoire/api.clj
@@ -5,7 +5,8 @@
   different datastores should only need to extend the multimethods in
   this namespace.")

-(def dispatch (comp :mode :datastore))
+(defn dispatch [config & more]
+  (-> config :datastore :mode))

 ;; Interacting with the datastore - reading
 ;;--------------------------------------------------------------------


Remove empty ns

Remove empty ns

--- src/grimoire/lib.clj
+++ src/grimoire/lib.clj
@@ -1,6 +0,0 @@
-(ns grimoire.lib)
-
-(defn foo
-  "I don't do a whole lot."
-  [x]
-  (println x "Hello, World!"))


Replace missing-ids query with an equivalent

--- src/vip/data_processor/validation/v5/id.clj
+++ src/vip/data_processor/validation/v5/id.clj
@@ -29,14 +29,12 @@
 (def validate-no-missing-ids
   (util/build-xml-tree-value-query-validator
    :fatal :id :missing :missing-id
-   "SELECT xtv.path
-    FROM (SELECT DISTINCT subltree(path, 0, 4) || 'id' AS path
-          FROM xml_tree_values WHERE results_id = ?
-          AND nlevel(subltree(path, 0, 4)) = 4) xtv
-    LEFT JOIN (SELECT path FROM xml_tree_values WHERE results_id = ?) xtv2
-    ON xtv.path = xtv2.path
-    WHERE xtv2.path IS NULL"
-   util/two-import-ids))
+   "select distinct subltree(path, 0, 4) || 'id' as path
+    from xml_tree_values
+    where results_id = ?
+      and nlevel(path) > 3
+      and parent_with_id is null"
+   (fn [{:keys [import-id]}] [import-id])))

 (defn validate-ids-with
   [{:keys [import-id] :as ctx} simple-path query]


play-notes: allow notes with no duration in the middle

--- src/mantra/core.cljs
+++ src/mantra/core.cljs
@@ -147,7 +147,7 @@
   (reduce (fn [timeout {:keys [pitch duration volume] :as note-model}]
             (when pitch
               (c/set-timeout! clock #(play-fn osc-model note-model) timeout))
-            (+ timeout duration))
+            (+ timeout (or duration 0)))
           0
           notes))


return model so we can get a look at it

return model so we can get a look at it

--- dada-demo/src/main/clojure/org/dada/demo/client.clj
+++ dada-demo/src/main/clojure/org/dada/demo/client.clj
@@ -96,8 +96,10 @@
     (defn inspect-remote-model [model-name]
       (let [local-model (model model-name (.getMetadata session-manager model-name))]
 	(.registerView session-manager model-name (.decouple view-service-factory local-model))
-	(inspect-model local-model)))
+	(inspect-model local-model)
+	local-model
+	))

-    (inspect-remote-model "Whales")
+    (inspect-remote-model "MetaModel")

-    ))+    ))


implemented set_name

implemented set_name

--- src/moomoo/core.cljs
+++ src/moomoo/core.cljs
@@ -14,16 +14,17 @@
 (defn connection [socket]
   (.log js/console "A user has connected!")
   (.on socket "disconnect"
-    (fn []
-      (disconnect socket))))
+    (complement disconnect))
+  (.on socket "set_username"
+    (fn [room username]
+      (.log js/console username))))

 (defn -main []
   (println "Hello world!")
   (let [app (.createServer http)
         io (.listen socketio app)]
     (.on io "connection"
-      (fn [socket]
-        (connection socket)))
+      (complement connection))
     (.listen app port)))

 (set! *main-cli-fn* -main)


Tentative fix for #339.

Tentative fix for #339.

--- src/onyx/interop.clj
+++ src/onyx/interop.clj
@@ -2,16 +2,15 @@
   (:gen-class :name onyx.interop
               :methods [^:static [write_batch [clojure.lang.IPersistentMap] clojure.lang.IPersistentMap]
                         ^:static [read_batch [clojure.lang.IPersistentMap] clojure.lang.IPersistentMap]])
-  (:require [onyx.peer.function :refer [write-batch read-batch]]
-            [onyx.peer.pipeline-extensions :refer [PipelineInput Pipeline]]))
+  (:require [onyx.peer.pipeline-extensions :refer [PipelineInput Pipeline]]))

 (defn -write_batch
   [event]
-  (write-batch event))
+  ((resolve 'onyx.peer.function/write-batch) event))

 (defn -read_batch
   [event]
-  (read-batch event))
+  ((resolve 'onyx.peer.function/read-batch) event))

 (gen-interface
   :name onyx.IPipelineInput


Continue to add tests for load balancer

Continue to add tests for load balancer

--- test/clojure/patterns_test.clj
+++ test/clojure/patterns_test.clj
@@ -59,11 +59,15 @@
                                                :service2 (fn [] 2)
                                                :service3 (fn [] 3)}
                                               1000)))
-        (is (= 2 @(patterns/submit-action-map load-balancer
-                                              {:service1 (fn [] 1)
-                                               :service2 (fn [] 2)
-                                               :service3 (fn [] 3)}
-                                              1000)))
+        (is (= 2 @(patterns/submit-action load-balancer
+                                          (fn [context] (:result context 10))
+                                          1000)))
+        (is (= 2 @(patterns/perform-action load-balancer
+                                           (fn [context] (:result context 10)))))
+        (is (= 2 @(patterns/perform-action-map load-balancer
+                                               {:service1 (fn [] 1)
+                                                :service2 (fn [] 2)
+                                                :service3 (fn [] 3)})))
         (.countDown latch)))
     (testing "Nil returned if all services reject action"
       (let [latch (CountDownLatch. 1)]
@@ -75,7 +79,15 @@
                                                 :service2 (fn [] 2)
                                                 :service3 (fn [] 3)}
                                                1000)))
-
+        (is (= nil (patterns/submit-action load-balancer
+                                           (fn [context] (:result context 10))
+                                           1000)))
+        (is (= nil (patterns/perform-action-map load-balancer
+                                                {:service1 (fn [] 1)
+                                                 :service2 (fn [] 2)
+                                                 :service3 (fn [] 3)})))
+        (is (= nil (patterns/perform-action load-balancer
+                                            (fn [context] (:result context 10)))))
         (.countDown latch)))))

 (deftest shotgun


add more tests

add more tests

--- test/dreiser/langtool_test.clj
+++ test/dreiser/langtool_test.clj
@@ -24,5 +24,16 @@
       (is (= (count (:suggestedReplacements (first checks))) 9))
       (is (= (:offset (first checks)) 0))
       (is (= (:toPos (first checks)) 4))
-      (is (= (:fromPos (first checks)) 0)))))
+      (is (= (:fromPos (first checks)) 0))))
+  (testing "Find one problem with repetitive the"
+    (let [result (ltool/check "The morning is good. The day is good. The night is good." "BritishEnglish")
+          checks (:checks result)]
+      (is (= (:value result) "The morning is good. The day is good. The night is good."))
+      (is (= (count checks) 1))
+      (is (= (:shortMessage (first checks)) "Three successive sentences begin with the same word."))
+      (is (= (:message (first checks)) "Three successive sentences begin with the same word. Reword the sentence or use a thesaurus to find a synonym."))
+      (is (= (count (:suggestedReplacements (first checks))) 0))
+      (is (= (:offset (first checks)) 38))
+      (is (= (:toPos (first checks)) 41))
+      (is (= (:fromPos (first checks)) 38)))))


Added table sort in reverse #rows order

Added table sort in reverse #rows order

--- src/pg_demo/core.clj
+++ src/pg_demo/core.clj
@@ -14,7 +14,7 @@
   (:import java.util.TimeZone)
   (:gen-class))

-(def large-db true)
+(def large-db false)

 (def ora-spec
   { :classname    "oracle.jdbc.OracleDriver"  ; must be in classpath
@@ -117,7 +117,6 @@

 (def pg-threadpool (cp/threadpool 4))

-; This works, but too hard to control the number of simultaneous processes
 (defn result-set->pg-insert [table-name result-set]
   (jdbc/with-db-connection [pg-conn pg-spec]
     (let [rows-inserted     (atom 0)
@@ -159,9 +158,13 @@
   (println "-----------------------------------------------------------------------------")
   (println "Beginning data transfer...")
   (newline)
-  (let [table-futures-map   (into (sorted-map)
-                              (for [table-name (keys tables/table-name->creation-sql) ]
-                                { table-name (cp/future pg-threadpool (proc-table table-name)) } ))
+  (let [
+    table-names-sorted    (as-> (keys @oracle-table-rows) it      ; table names
+                                (sort-by @oracle-table-rows it)   ; sort by # rows
+                                (reverse it))                     ; descending order
+    table-futures-map     (into (sorted-map)
+                            (for [table-name table-names-sorted]
+                              { table-name (cp/future pg-threadpool (proc-table table-name)) } ))
   ]
     (doseq [it table-futures-map]
       (deref (val it))  ; block until complete


Little tweaks to see about errors in exploration

--- src/player/core.cljs
+++ src/player/core.cljs
@@ -214,12 +214,13 @@
         [playouts _ _ explored seen]
         (reduce
           (fn [[playouts path prev-opts explored seen] [prev cur]]
-            (let [cur-opts (into #{} (map #(option-desc cur % heval/time-unit) (second (roll/next-transitions cur))))
+            (let [cur-opts (into #{} (map #(option-desc cur % heval/time-unit)
+                                          (second (roll/next-transitions cur))))
                   ; _ (println "explore" (get-in cur [:objects :m :state]))
                   next-path (if (some? prev)
                               (conj path prev)
                               path)
-                  removed-opts (filter #(not (contains? explored (assoc % :t (- (:entry-time cur) heval/time-unit))))
+                  removed-opts (filter #(not (contains? explored (assoc % :t (- (:entry-time cur) (:entry-time prev)))))
                                        (sets/difference prev-opts cur-opts))
                   _ (println "removed" removed-opts)
                   [remove-explore-playouts explored seen]
@@ -229,7 +230,7 @@
                             time (max
                                    (+ (:entry-time prev) heval/time-unit)
                                    (min (iv/end (:interval trans))
-                                        (:t opt)))
+                                        (:entry-time cur)))
                             _ (assert (= (get-in prev [:objects (:id opt) :state])
                                          (:state opt))
                                       (str "not="
@@ -237,7 +238,7 @@
                                            (:state opt)
                                            "The state of the object in the previous state should be consistent with the from-state of the option."))
                             succ (roll/follow-transition ha-defs prev trans time)
-                            _ (assert (= (get-in succ [:objects (:id opt) :state])
+                            _ (soft-assert (= (get-in succ [:objects (:id opt) :state])
                                          (:target opt))
                                       (str "not="
                                            (get-in succ [:objects (:id opt) :state])
@@ -249,7 +250,8 @@
                            explored
                            (assoc opt
                              :t
-                             (- time (get-in cur [:objects (:id opt) :entry-time]))))
+                             (- (:entry-time succ)
+                                (get-in prev [:objects (:id opt) :entry-time]))))
                          seen]))
                     [[] explored seen]
                     removed-opts)
@@ -262,17 +264,17 @@
                     (fn [[ps explored seen] opt]
                       (let [trans (option-desc->transition cur opt)
                             time (+ (:entry-time cur) heval/time-unit)
-                            _ (soft-assert (= (get-in cur [:objects (:id opt) :state])
-                                              (:state opt))
-                                           "not="
+                            _ (assert (= (get-in cur [:objects (:id opt) :state])
+                                         (:state opt))
+                                      (str "not="
                                            (get-in cur [:objects (:id opt) :state])
-                                           (:state opt))
+                                           (:state opt)))
                             succ (roll/follow-transition ha-defs cur trans time)
                             _ (soft-assert (= (get-in succ [:objects (:id opt) :state])
-                                              (:target opt))
-                                           "not="
+                                         (:target opt))
+                                      (str "not="
                                            (get-in succ [:objects (:id opt) :state])
-                                           (:target opt))
+                                           (:target opt)))
                             [rolled seen] (roll/inert-playout ha-defs succ explore-roll-limit seen)]
                         ;(println "steps" (count rolled))
                         [(conj ps (concat (conj next-path cur succ) rolled))


Moving the Connection in JdbcKeyValue.

Moving the Connection in JdbcKeyValue.

I'm grouping it above the protocol methods instead of at the top.

--- src/poky/kv/jdbc.clj
+++ src/poky/kv/jdbc.clj
@@ -11,7 +11,6 @@

 (defrecord JdbcKeyValue [conn]
   KeyValue
-  Connection
   (get* [this b k params]
     (get* this b k))
   (get* [this b k]
@@ -33,6 +32,7 @@
   (delete* [this b k]
     (compare-seq-first (jdbc-delete @conn b k) 1))

+  Connection
   (connection [this]
     (get-connection this))
   (close [this]


Moving the parenthesis to the proper place

--- src/posthere/app.clj
+++ src/posthere/app.clj
@@ -18,10 +18,10 @@
   (GET "/:uuid" [uuid] (results-view uuid)) ; Show them the results of their requests

   ; POST requests
-  (POST "/:uuid" [uuid :as request] (capture-request uuid request))) ; Capture their POST request
+  (POST "/:uuid" [uuid :as request] (capture-request uuid request)) ; Capture their POST request

   ; Resource requests
-  (route/resources "/assets/")
+  (route/resources "/assets/"))

 (def app
   (if hot-reload


sort comparator generation working

sort comparator generation working

--- src/prais2/data.cljs
+++ src/prais2/data.cljs
@@ -72,6 +72,7 @@
 (defn compare-all
   "return a sort-by key-fn which operates on all sort-columns"
   [sort-columns]
+  (prn sort-columns)
   (reduce #(compare-merge %1 %2) (constantly 0)  sort-columns)
   )

@@ -81,8 +82,11 @@
   (assoc data :rows (sort (compare-all sort-columns) (:rows data)))
   )

-(r/defc table1 < r/reactive (data-table-on :#table1) [data]
-  (let [headers (:headers data)
+(def sort-columns (atom [[5 true] [1 false]]))
+
+(r/defc table1 < r/reactive #_(data-table-on :#table1) [data]
+  (let [sdata (sort-column data @sort-columns)
+        headers (:headers sdata)
         visible-headers (- (count headers) 1)]
     [:div.row
      [:div.col-md-12
@@ -95,7 +99,7 @@
            ]]

        [:tbody {:key :tbody}
-        (let [rows (:rows data)]
+        (let [rows (:rows sdata)]
           (for [row (range (count rows))]
             (let [row-cells (nth rows row)]
               [:tr {:key row}


whitespace only

whitespace only


create trigger for first fig animation

create trigger for first fig animation

--- frontend/components/landing_b.cljs
+++ frontend/components/landing_b.cljs
@@ -26,6 +26,7 @@
         nav-bkg (om/get-node owner "nav-bkg")
         no-cta (om/get-node owner "no-cta")
         nav-no-bkg (om/get-node owner "nav-no-bkg")
+        first-fig (om/get-node owner "first-fig")
         vh (.-height (goog.style/getSize nav-bkg))
         scroll-callback #(do
                            (om/set-state! owner [:header-logo-visible] (neg? (.-bottom (.getBoundingClientRect logo))))
@@ -33,6 +34,7 @@
                            (om/set-state! owner [:header-bkg-visible] (< (.-bottom (.getBoundingClientRect nav-bkg)) 70))
                            (om/set-state! owner [:header-cta-invisible] (< (.-top (.getBoundingClientRect no-cta)) vh))
                            (om/set-state! owner [:header-bkg-invisible] (< (.-top (.getBoundingClientRect nav-no-bkg)) 70))
+                           (om/set-state! owner [:first-fig-visible] (< (.-top (.getBoundingClientRect first-fig)) vh))
                            (om/set-state! owner [:header-bkg-scroller] (min (js/Math.abs (.-top (.getBoundingClientRect nav-no-bkg)))
                                                                             (js/Math.abs (- 70 (.-bottom (.getBoundingClientRect nav-bkg)))))))]
     (om/set-state! owner [:browser-resize-key]
@@ -51,6 +53,7 @@
        :header-bkg-visible false
        :header-cta-invisible false
        :header-bkg-invisible false
+       :first-fig-visible false
        :scroll-ch (chan (sliding-buffer 1))})
     om/IRenderState
     (render-state [_ state]
@@ -97,13 +100,13 @@
                   "Learn more"
                   (common/ico :chevron-down)]]]
                [:section.home-purpose
-                [:div.home-drawings
+                [:div.home-drawings {:class (when (:first-fig-visible state) ["fig-visible"])}
                  [:div.drawing]
                  [:div.drawing]
                  (om/build drawings/drawing-dashboard app)]
                 [:div.home-articles
                  [:article
-                  [:h1
+                  [:h1 {:ref "first-fig"}
                    "Launches are dead,"
                    [:br]
                    " long live iteration."]


Add an other test case.

Add an other test case.

--- test/suricatta/extend_test.clj
+++ test/suricatta/extend_test.clj
@@ -129,8 +129,11 @@
   (let [q (-> (dsl/insert-into :t1)
               (dsl/insert-values {:data (myjson {:foo 1})}))]

-    (is (= (fmt/get-sql q {:dialect :pgsql :type :indexed})
+    (is (= (fmt/get-sql q)
            "insert into t1 (data) values (?::json)"))
+
+    (is (= (fmt/get-sql q {:dialect :pgsql :type :inlined})
+           "insert into t1 (data) values ('{\"foo\":1}'::json)"))

     (is (= (fmt/get-sql q {:dialect :pgsql :type :inlined})
            "insert into t1 (data) values ('{\"foo\":1}'::json)"))))


Drop all tables only within the test database.

- Do NOT drop by owner, since that might affect tables outside of the
  test database.

--- test/time_tracker/fixtures.clj
+++ test/time_tracker/fixtures.clj
@@ -14,7 +14,9 @@
   (f))

 (defn destroy-db []
-  (jdbc/execute! config/db-spec [(str "DROP OWNED BY " (environ/env :test-db-username))]))
+  (jdbc/with-db-transaction [conn (db/connection)]
+    (jdbc/execute! conn "DROP SCHEMA IF EXISTS public CASCADE;")
+    (jdbc/execute! conn "CREATE SCHEMA IF NOT EXISTS public;")))

 (defn migrate-test-db [f]
   (migrate-db)


Formatting tweak.

Formatting tweak.

--- scripts/extract-ipip-neo-pi-r.clj
+++ scripts/extract-ipip-neo-pi-r.clj
@@ -104,8 +104,7 @@
           #(hash-map :id (inc (+ (count positives) %1))
                      :question %2
                      :reversed? true)
-          negatives)))
-  ))
+          negatives)))))

 (defn get-data [url]
   (let [tables-data (get-tables-data (util/fetch-url url))


added log4j log facade

added log4j log facade

--- core/project.clj
+++ core/project.clj
@@ -8,6 +8,7 @@
   :java-source-paths ["java"]

   :dependencies [[org.clojure/clojure "1.7.0"]
+                 [org.slf4j/slf4j-log4j12 "1.7.12"]
                  [org.apache.samza/samza-api        "0.9.1"]
                  [org.apache.samza/samza-kafka_2.10 "0.9.1"]
                  [samsara/moebius "0.2.0"]


CMR-2884 and CMR-3060: Creating demos.

CMR-2884 and CMR-3060: Creating demos.

--- ingest-app/src/cmr/ingest/validation/validation.clj
+++ ingest-app/src/cmr/ingest/validation/validation.clj
@@ -121,7 +121,7 @@
                               :collection))]
     (if (config/return-umm-json-validation-errors)
       (errors/throw-service-errors :invalid-data err-messages)
-      (warn "UMM-C JSON-Schema Validation Errors: " (pr-str err-messages))))
+      (warn "UMM-C JSON-Schema Validation Errors: " (pr-str (vec err-messages)))))

   (when-let [err-messages (seq (umm-spec-validation/validate-collection
                                 collection
@@ -129,7 +129,7 @@
                                   [(keyword-validations context)])))]
     (if (config/return-umm-spec-validation-errors)
       (errors/throw-service-errors :invalid-data err-messages)
-      (warn "UMM-C UMM Spec Validation Errors: " (pr-str err-messages)))))
+      (warn "UMM-C UMM Spec Validation Errors: " (pr-str (vec err-messages))))))

 (defn validate-granule-umm-spec
   "Validates a UMM granule record using rules defined in UMM Spec with a UMM Spec collection record"
@@ -138,7 +138,7 @@
     (if (config/return-umm-spec-validation-errors)
       (if-errors-throw :invalid-data errors)
       (warn (format "Granule with Granule UR [%s] had the following UMM Spec validation errors: %s"
-                    (:granule-ur granule) (pr-str errors))))))
+                    (:granule-ur granule) (pr-str (vec errors)))))))

 (defn validate-granule-umm
   [context collection granule]


Fix usage with uberjars.

Fix usage with uberjars.

--- src/soy_clj/core.clj
+++ src/soy_clj/core.clj
@@ -31,7 +31,7 @@
   "Returns a compiled set of templates from the given files."
   [files]
   (let [builder (SoyFileSet/builder)]
-    (run! #(.add builder (io/file (io/resource %))) files)
+    (run! #(.add builder (io/resource %) ^String %) files)
     (.setGeneralOptions builder opts)
     (.. builder (build) (compileToTofu))))


Remove redundant code

Remove redundant code

--- lein-template/src/leiningen/new/modular/project.clj
+++ lein-template/src/leiningen/new/modular/project.clj
@@ -17,12 +17,6 @@
    {{#dependencies}}
    {{{.}}}
    {{/dependencies}}
-
-   ;; Temp
-   #_[garden "1.1.5"]
-   #_[cheshire "5.3.1"]
-   #_[liberator "0.11.0"]
-   #_[clj-jwt "0.0.8"]
    ]

   :main {{name}}.main
@@ -32,7 +26,4 @@

   :profiles {:dev {:dependencies [[org.clojure/tools.namespace "0.2.4"]]
                    :source-paths ["dev"
-                                  #_"{{modular-dir}}/modules/menu/src"
-                                  #_"{{modular-dir}}/modules/bootstrap/src"
-                                  #_"{{cylon-dir}}/src"
                                   ]}})


fixed Bach rhythms and added left hand.

fixed Bach rhythms and added left hand.

--- test/examples/mad.clj
+++ test/examples/mad.clj
@@ -110,19 +110,33 @@
 ;
 ; These are the notes for the right hand in bars (I think), but it's tough to
 ; get the timing right.
-(def g-minuet [[D5 D5 D5]
-               [B4 [A4 B4] G4]
-               [A4 D5 C5]
-               [B4 B4 A4] ; the two B4's should be tied together (ie. they should be one note. I don't think it's possible to express that they are one note using the []-dividing notation
-               [D5 [C5 B4] [A4 G4]]
-               [E5 [C5 B4] [A4 G4]]
-               [F4 [E4 D4] F4]
-               [G4]
-               [B4 E5 E5]
-               [C#5 [B4 C5] A4]
-               [D5 E5 F5]
-               [[E5 D5] [C#5 B4] A4]])
+(def g-minuet-right-hand [[D5 D5 D5]
+                         [B4 [A4 B4] G4]
+                         [A4 D5 C5]
+                         [B4 B4 A4] ; the two B4's should be tied together (ie. they should be one note). I don't think it's possible to express that they are one note using the []-dividing notation
+                         [D5 [C5 B4] [A4 G4]]
+                         [E5 [C5 B4] [A4 G4]]
+                         [F4 [E4 D4] F4]
+                         [G4]
+                         [B4 E5 E5]
+                         [C#5 [B4 C5] A4]
+                         [D5 E5 F5]
+                         [[E5 D5] [C#5 B4] A4]])

+(def g-minuet-left-hand [[G3 F#3 D3]
+                        [G3 D3 G2]
+                        [G3 [F#3 E3] [F#3 D3]]
+                        [G3 G2 [D3 C3]]
+                        [B2]
+                        [C3] ; I made up some harmonies here...
+                        [D3] ; ...as the sheet music gif omitted them
+                        [G2]
+                        [G3 G3 E3]
+                        [A3 E3 A2]
+                        [F#3 E3 D3]
+                        [A2 E3 [A3 G3]])
+
+; now make it play both hands at once! I don't know how.
 (comment p (map
      #(assoc % :synth ks1-demo)
      (pattern g-minuet 10)))


add background-sh that may come in handy later

--- user.clj
+++ user.clj
@@ -2,6 +2,7 @@
   (:require clojure.pprint
             table.core
             clojure.java.io
+            [clojure.java.shell :as sh]
             [clojure.string :as string]))

 ; =======
@@ -145,6 +146,15 @@
 (defmacro fc [args ret]
   `(findcore '~args '~ret))

+(defn- background-sh
+  "Execute command in the background and return its pid"
+  [cmd]
+  (->>
+   (sh/sh "bash" "-c" (format "%s 1>test.log 2>&1 & \n echo $!" cmd))
+   :out
+   (re-find #"(\d+)\n")
+   second))
+
 ; Configuration
 (set! clojure.core/*print-length* 100)
 (set! clojure.core/*print-level* 5)


add apply benchmark

add apply benchmark

--- benchmark/cljs/benchmark_runner.cljs
+++ benchmark/cljs/benchmark_runner.cljs
@@ -72,6 +72,10 @@
 (simple-benchmark [coll (take 100000 (iterate inc 0))] (reduce + 0 coll) 1)
 (simple-benchmark [coll (range 1000000)] (reduce + 0 coll) 1)
 (simple-benchmark [coll (into [] (range 1000000))] (reduce + 0 coll) 1)
+(println)
+
+(println ";; apply")
+(simple-benchmark [coll (into [] (range 1000000))] (apply + coll) 1)
 (println)

 (println ";;; map / record ops")


add simple transducers benchmark

add simple transducers benchmark

--- benchmark/cljs/benchmark_runner.cljs
+++ benchmark/cljs/benchmark_runner.cljs
@@ -312,6 +312,17 @@
 (println ";; reducers")
 (simple-benchmark [xs (into [] (range 1000000))] (r/reduce + (r/map inc (r/map inc (r/map inc xs)))) 1)

+(dotimes [_ 10]
+  (let [xs (into [] (range 1000000))]
+    (time (r/reduce + (r/map inc (r/map inc (r/map inc xs)))))))
+
+(println ";; transducers")
+(simple-benchmark [xs (into [] (range 1000000))] (transduce (comp (map inc) (map inc) (map inc)) + 0 xs) 1)
+
+(dotimes [_ 10]
+  (let [xs (into [] (range 1000000))]
+    (time (transduce (comp (map inc) (map inc) (map inc)) + 0 xs))))
+
 (println "\n")

 (println ";; multimethods")


[WM] remove datomic repo from project.clj

--- resources/leiningen/new/kraken_http_api/project.clj
+++ resources/leiningen/new/kraken_http_api/project.clj
@@ -25,9 +25,6 @@
   :plugins [[lein-immutant "2.0.0"]]
   :main ^:skip-aot {{name}}.server
   :target-path "target/%s"
-  :repositories {"my.datomic.com" {:url "https://my.datomic.com/repo"
-                                   :username [:gpg :env]
-                                   :password [:gpg :env]}}
   :uberjar-name "{{name}}.jar"
   :profiles {:uberjar {:aot :all}
              :dev {:resource-paths ["dev-resources"]}


(PE-3856) Remove executable-succeeded? function

--- src/clj/puppetlabs/master/certificate_authority.clj
+++ src/clj/puppetlabs/master/certificate_authority.clj
@@ -201,37 +201,27 @@
    standard-err, and exit code. The subject will be passed in as input, and
    the CSR stream will be provided on standard-in. The load-path will be
    prepended to the RUBYLIB found in the environment, and is intended to make
-   the Puppet and Facter Ruby libraries available to the autosign script."
+   the Puppet and Facter Ruby libraries available to the autosign script.
+   All output (stdout & stderr) will be logged at the debug level."
   [executable :- String
    subject :- String
    csr-fn :- (schema/pred fn?)
    load-path :- [String]]
+  (log/debugf "Executing '%s %s'" executable subject)
   (let [env     (into {} (System/getenv))
         rubylib (->> (if-let [lib (get env "RUBYLIB")]
                        (cons lib load-path)
                        load-path)
                      (map fs/absolute-path)
-                     (str/join (System/getProperty "path.separator")))]
-    (shell/sh executable subject
-              :in (csr-fn)
-              :env (merge env {:RUBYLIB rubylib}))))
-
-(schema/defn executable-succeeded? :- Boolean
-  "Run the autosign executable with the subject and CSR and test if it
-   exits successfully (exit code 0). All output (stdout, stderr) will
-   be captured and logged at the debug level."
-  [executable :- String
-   subject :- String
-   csr-fn :- (schema/pred fn?)
-   load-path :- [String]]
-  (log/debugf "Executing '%s %s'" executable subject)
-  (let [{:keys [out err exit]}
-        (execute-autosign-command! executable subject csr-fn load-path)]
+                     (str/join (System/getProperty "path.separator")))
+        results (shell/sh executable subject
+                          :in (csr-fn)
+                          :env (merge env {:RUBYLIB rubylib}))]
     (log/debugf "Autosign command '%s %s' exit status: %d"
-                executable subject exit)
+                executable subject (:exit results))
     (log/debugf "Autosign command '%s %s' output: %s"
-                executable subject (str err out))
-    (zero? exit)))
+                executable subject (str (:err results) (:out results)))
+    results))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Public
@@ -280,7 +270,9 @@
     autosign
     (if (fs/exists? autosign)
       (if (fs/executable? autosign)
-        (executable-succeeded? autosign subject csr-fn load-path)
+        (-> (execute-autosign-command! autosign subject csr-fn load-path)
+            :exit
+            zero?)
         (whitelist-matches? autosign subject))
       false)))


throw exception if no sentence could be generated

--- src/babel/writer.clj
+++ src/babel/writer.clj
@@ -216,8 +216,9 @@
                        (fo sentence)))]
         (if (empty? surface)
           (let [warn-mesg (str "Surface was empty for expression generated from spec: " spec)]
-            (log/warn (str "sentence: " sentence))
-            (log/warn warn-mesg)))
+            (log/error (str "sentence: " sentence))
+            (log/error warn-mesg)
+            (throw (Exception. (str warn-mesg)))))
         (log/info (str "populate-with-language:" language ": surface='"
                        surface "'"))
         (log/debug (str "populate-with-language:" language ": spec='"


Refactor incrementing counters.

Refactor incrementing counters.

--- src/baleen/queue.clj
+++ src/baleen/queue.clj
@@ -5,6 +5,14 @@
   (:require [baleen.context :as bcontext]
             [baleen.time :as btime]
             [baleen.redis :as redis]))
+
+(defn inc-counter
+  "Increment the named counter."
+  [context counter-key-name]
+  (let [redis-connection (redis/get-connection context)
+        counters-names-key-name (str (bcontext/get-app-name context) "__counters")]
+    (.incr redis-connection counter-key-name)
+    (.sadd redis-connection counters-names-key-name (into-array [counter-key-name]))))

 (defn enqueue-with-time
   "Enqueue an input as a JSON blob.
@@ -15,13 +23,10 @@
     (let [queue-key-name (str (bcontext/get-app-name context) "-" queue-name)
           log-key-name (str (bcontext/get-app-name context) "-" queue-name "-" (btime/format-ymd event-time))
           counter-key-name (str (bcontext/get-app-name context) "-" queue-name "-count")
-          counters-names-key-name (str (bcontext/get-app-name context) "__counters")]
+          ]

       ; Increment counter.
-      (.incr redis-connection counter-key-name)
-
-      ; Also maintain a set of known counter keys.
-      (.sadd redis-connection counters-names-key-name (into-array [counter-key-name]))
+      (inc-counter context counter-key-name)

       ; Push to start of queue.
       (.lpush redis-connection queue-key-name (into-array [json-blob]))
@@ -55,7 +60,7 @@
           (when success
             (.lrem redis-connection working-queue-key-name 0 item-str)

-            (.incr redis-connection counter-queue-name)
+            (inc-counter context counter-queue-name)

             (when keep-done
               (.rpush redis-connection done-queue-key-name (into-array [item-str])))))


Fix delay implementation on jvm.

Fix delay implementation on jvm.

--- src/beicon/core.cljc
+++ src/beicon/core.cljc
@@ -302,7 +302,8 @@
   "Time shifts the observable sequence by dueTime. The relative
   time intervals between the values are preserved."
   [ms ^Observable ob]
-  (.delay ob ^long ms))
+  #?(:cljs (.delay ob ms)
+     :clj  (.delay ob ^long ms TimeUnit/MILLISECONDS)))

 (defn delay-when
   "Time shifts the observable sequence based on a subscription


Don't log method metrics unless recorder is set.

--- src/blocks/meter.clj
+++ src/blocks/meter.clj
@@ -160,11 +160,12 @@
      (try
        (body-fn)
        (finally
-         (log/tracef "Method %s of %s block store on %s took %.1f ms"
-                     (name method-kw)
-                     (meter-label store)
-                     args
-                     @elapsed)
-         (record! store ::method-time @elapsed
-                  :method method-kw
-                  :args args)))))
+         (when (::recorder store)
+           (log/tracef "Method %s of %s block store on %s took %.1f ms"
+                       (name method-kw)
+                       (meter-label store)
+                       args
+                       @elapsed)
+           (record! store ::method-time @elapsed
+                    :method method-kw
+                    :args args))))))


Some more profiling

Some more profiling

--- src/blx/sortable.clj
+++ src/blx/sortable.clj
@@ -54,42 +54,38 @@
   [path]
   (with-open [rdr (io/reader path)]
     (->> (line-seq rdr)
-         ; We need to return a vector (mapv), because otherwise with-open will
-         ; close the stream before the lazy sequence is realized.
+         ; We need to parse non-lazily (mapv), because otherwise with-open will
+         ; close the stream before the seq is realized.
          (mapv parse-json))))

-(defn product-regex
-  "Generates a regex pattern that represents the product."
+(p/defnp product-regex
+  "Generates a case-insensitive regex pattern that represents the product."
   [product]
-  (let [optional-spaces (fn [s]
-                          (-> (or s "")
-                              (str/replace #"[\s_-]+" "[\\\\s_-]*")
-                              (str/replace #"(?i)(DSC|DSLR|DMC|PEN|SLT|IS)" "(?:$1)?")))]
+  (let [fmt-model (fn [s]
+                    (-> (or s "")
+                        ; [_ -] chars are equivalent and optional
+                        (str/replace #"[\s_-]+" "[\\\\s_-]*")
+                        ; common model prefixes are optional
+                        (str/replace #"(?i)(DSC|DSLR|DMC|PEN|SLT|IS)" "(?:$1)?")))]
     (re-pattern
+      ; Roughly: word{0,3} family? word? model
       (str #"(?i)^(?:[\w()]*\s*){0,3}"
-           (if-let [fam (:family product)]
-             (str "(?:"
-                  (:family product)
-                  ")?"
+           (when-let [family (:family product)]
+             (str "(?:" family ")?"
                   #"\s*\w*\s*"))
-           (optional-spaces (:model product))
-           #"[^\d]+"))))
+           (fmt-model (:model product))
+           ; Don't match if model is directly followed by a number, eg.
+           ; don't accept "EOS 100" for "EOS 10".
+           #"(?:[^\d]+|$)"))))

 (defn prepare-product [product]
-  (-> product
-      (#(assoc % :regex (product-regex %)))))
-
-(defn common-prefix-length
-  "Returns the length of the longest common prefix between sequences a and b."
-  [a b]
-  (->> (map = a b)
-       (take-while true?)
-       count))
-
-(defn starts-with? [^String s candidate]
-  (.startsWith s (or candidate "")))
-
-(defn first-word [s]
+  (assoc product :regex (product-regex product)))
+
+(defn first-word
+  "Returns first word in s, defined by splitting on whitespace. Not lazy."
+  ; For large strings (10000 chars or more), the lazy version using partition-by
+  ; is faster.
+  [s]
   (-> (or s "")
       (str/split #"\s+" 2)  ; Split at most once
       first))
@@ -105,18 +101,28 @@

 (def manufacturer-matchers
   [(fn first-word? [manufacturers candidate]
-     (some #{(first-word candidate)} manufacturers))
+     (p/p :firstword
+          (some #{(first-word candidate)} manufacturers)))

    (fn levenshtein? [manufacturers candidate]
      ; This is mainly for things like "OPYMPUS" -> "Olympus"
      (p/p :levenshtein
-     (and (> (count candidate) 3)  ; Very short strings are not likely to be similar
-          (let [max-delta 2
-                [guess lev-dist] (->> manufacturers
-                                      (map (juxt identity (partial levenshtein candidate)))
-                                      (apply min-key second))]
-            (when (<= lev-dist max-delta)
-              guess)))))])
+          (let [min-length 4
+                max-lev-dist 2]
+            (and ; Very short strings are not likely to be similar
+                 (>= (count candidate) min-length)
+
+                 ; Levenshtein is expensive, so require the first letter to match
+                 ; before trying to compute it.
+                 ((set (map first manufacturers)) (first candidate))
+
+                 (let [[guess lev-dist]
+                       (p/p :lev-lev
+                            (->> manufacturers
+                                 (map (juxt identity (partial levenshtein candidate)))
+                                 (apply min-key second)))]
+                   (when (<= lev-dist max-lev-dist)
+                     guess))))))])

 (def match-manufacturer
   (memoize
@@ -138,12 +144,13 @@
 (defn match-title
   "Attempts to match listing's title to a product in products, returning the
   matched product if successful, else nil."
-  [products listing]
-    (when-let [title (-> (or (:title listing) "")
+  [products title]
+    (when-let [title (-> (or title "")
                          (str/replace #"[_-]+" ""))]
-    (->> products
-         (filter #(re-find (:regex %) title))
-         first)))
+      (p/p :mt-filter
+           (->> products
+                (filter #(re-find (:regex %) title))
+                first))))

 (p/defnp match-listing
@@ -152,10 +159,10 @@
   [products listing]
   (when-let [manufacturer-guess
              (p/p :match-manuf (match-manufacturer (keys products)
-                                 (or (:manufacturer listing)
-                                     (first-word (:title listing)))))]
+                                                   (or (:manufacturer listing)
+                                                       (first-word (:title listing)))))]
     (if-let [product-guess (p/p :match-title (match-title (products manufacturer-guess)
-                                        listing))]
+                                                          (:title listing)))]
       [product-guess listing]
       [nil listing])))

@@ -181,15 +188,6 @@
                   matching-listings))))))

-
-
-(defn test-random [products listings]
-  (let [listing (rand-nth listings)]
-    (or (match-title products listing)
-        [nil listing])))
-
-
-
 (defn -main
   [& args]
   ; We need to read all products into memory at once, but we


I broke everything in entity management! (rewrite). Now let's see if I can put it back toghether in the tests.

--- src/brute/entity.clj
+++ src/brute/entity.clj
@@ -13,6 +13,7 @@

 (defn create-entity
     "Create the entity and return it. Entities are just UUIDs"
+    []
     (java.util.UUID/randomUUID))

 (defn get-all-entities
@@ -20,14 +21,13 @@
     [system]
     (:all-entities system))

-(defn store-entity
-    "Store the entity in the Entity System"
+(defn add-entity
+    "Add the entity in the Entity System"
     [system entity]
     (let [system (transient system)]
-        (->
-            system
-            (assoc! :all-entities (conj! (get-all-entities) entity))
-            (assoc! :entity-component-types (assoc! (:entity-component-types system) entity #{}))
+        (-> system
+            (assoc! :all-entities (conj! (get-all-entities system) entity))
+            (assoc! :entity-component-types (-> system :entity-component-types assoc! entity #{}))
             persistent!)))

 #_
@@ -49,6 +49,19 @@
            [component]
     (class component))

+
+(defn add-component
+    "Add a component instance to a given entity. Will overwrite a component if already set."
+    [system entity instance]
+    (let [type (get-component-type instance)
+          system (transient system)
+          entity-components (:entity-components system)]
+        (-> system
+            (assoc! :entity-components (assoc! entity-components type (-> entity-components (get type) (assoc! entity instance))))
+            (assoc! :entity-component-types (-> system :entity-component-types (get entity) (conj! type) (assoc! entity))))
+        persistent!))
+
+#_
 (defn add-component!
     "Add a component instance to a given entity. Will overwrite a component if already set."
     [entity instance]
@@ -59,16 +72,35 @@

 (defn get-component
     "Get the component data for a specific component type"
+    [system entity type]
+    (-> system :entity-components (get-in [type entity])))
+
+#_
+(defn get-component
+    "Get the component data for a specific component type"
     [entity type]
     (get-in @entity-components [type entity]))

 (defn get-all-entities-with-component
     "Get all the entities that have a given component type"
-    [type]
-    (if-let [entities (keys (get @entity-components type))]
+    [system type]
+    (if-let [entities (-> system :entity-components (get type) keys)]
         entities
         []))

+(defn remove-component
+    "Remove a component instance from an entity"
+    [system entity instance]
+    (let [type (get-component-type instance)
+          system (transient system)
+          entity-components (:entity-components system)
+          entity-component-types (:entity-component-types system)]
+        (-> system
+            (assoc! :entity-components (assoc! entity-components type (-> entity-components (get type) (dissoc! entity))))
+            (assoc! :entity-component-types (assoc! entity-component-types entity (-> entity-component-types (get entity) (disj! type))))
+            persistent!)))
+
+#_
 (defn remove-component!
     "Remove a component instance from an entity"
     [entity instance]
@@ -77,6 +109,26 @@
             (alter entity-components assoc type (dissoc (get @entity-components type) entity))
             (alter entity-component-types assoc entity (disj (get @entity-component-types entity) type)))))

+#_
+(reduce (fn [v e]
+            (assoc v e (dissoc (get v e) :e)))
+        m k)
+
+(defn kill-entity
+    "Destroy an entity completely."
+    [system entity]
+    (let [system (transient system)
+          entity-component-types (:entity-component-types system)]
+        (-> system
+            (assoc! :all-entities (disj! (get-all-entities system)))
+            (assoc! :entity-component-types (dissoc! entity-component-types entity))
+            (assoc! :entity-components (reduce (fn [v type] (assoc! v type (dissoc! (get v type) entity)))
+                                               (:entity-components system) (get entity-component-types entity)))
+            persistent!)
+        )
+    )
+
+#_
 (defn kill-entity!
     "Destroy an entity completely."
     [entity]
@@ -89,5 +141,5 @@

 (defn get-all-components-on-entity
     "Get all the components on a specific entity. Useful for debugging"
-    [entity]
-    (map #(get-in @entity-components [% entity]) (get @entity-component-types entity)))+    [system entity]
+    (map #(get-in (:entity-components system) [% entity]) (get (:entity-component-types system) entity)))


Prettify things up a bit

Prettify things up a bit

--- src/cake/project.clj
+++ src/cake/project.clj
@@ -116,9 +116,9 @@
     `(project-eval '~ns-forms ~(quote-if even? bindings) '~body)))

 (defn group [project]
-  (if (or (= project 'clojure) (= project 'clojure-contrib))
+  (if ('#{clojure clojure-contrib} project)
     "org.clojure"
-    (or (namespace project) (name project))))
+    (some #(% project) [namespace name])))

 (defn dep-map [deps]
   (into {}


Ball bounces around the screen.

Ball bounces around the screen.

--- src/canvas/main.cljs
+++ src/canvas/main.cljs
@@ -14,12 +14,6 @@
   [tag-name]
   (aget (.getElementsByTagName js/document tag-name) 0))

-(defn style!
-  [el attr val]
-  (let [style (aget el "style")]
-    (aset style attr val)
-    el))
-
 (defn attr!
   [el attr val]
   (aset el attr val)
@@ -33,23 +27,19 @@
 ;; Canvas Context
 ;;-----------------------------------------------------------------------------

-(defn ctx-prop!
-  [ctx attr value]
-  (aset ctx attr value)
-  ctx)
-
-(defn ctx-apply
-  [ctx fname & args]
-  (let [f (aget ctx fname)]
-    (.apply f ctx (apply array args))
-    ctx))
+(def ctx (.getContext (by-id "canvas") "2d"))
+(def SCALE-W 800)
+(def SCALE-H 450)

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

 (defrecord Rect [x y width height color])
 (defrecord Frame [x y width height color frame-width])
-(defrecord Paddle [x y width height color])
+(defrecord Paddle [x y width height vy color])
+(defrecord Ball [x y radius vx vy fill-color])

+;;-----------------------------------------------------------------------------
+;; Drawable Objects
 ;;-----------------------------------------------------------------------------

 (defprotocol IDrawable
@@ -62,6 +52,15 @@
       (aset ctx "fillStyle" color)
       (.fillRect ctx x y width height))
     ctx))
+
+(extend-type Ball
+  IDrawable
+  (draw! [{:keys [x y radius fill-color] :as ball} ctx]
+    (aset ctx "fillStyle" fill-color)
+    (.beginPath ctx)
+    (.arc ctx x y radius 0 (* 2 js/Math.PI) false)
+    (.fill ctx)
+    (.closePath ctx)))

 (extend-type Rect
   IDrawable
@@ -84,48 +83,87 @@
     ctx))

 ;;-----------------------------------------------------------------------------
+;; Moveable Objects
+;;-----------------------------------------------------------------------------

-(def ctx (.getContext (by-id "canvas") "2d"))
-(def scale-w 800)
-(def scale-h 450)
+(defprotocol IMovable
+  (move [_]))

-(def objects
+(extend-type Ball
+  IMovable
+  (move [{:keys [x y vx vy radius] :as ball}]
+    (let [low radius
+          vx (if (< low x (- SCALE-W radius)) vx (* -1 vx))
+          vy (if (< low y (- SCALE-H radius)) vy (* -1 vy))]
+      (assoc ball :x (+ x vx) :y (+ y vy) :vx vx :vy vy))))
+
+;;-----------------------------------------------------------------------------
+;; Controllable Objects
+;;-----------------------------------------------------------------------------
+
+(defprotocol IControllable
+  (control! [_ event]))
+
+(extend-type Paddle
+  IControllable
+  (control! [{:keys [y vy] :as paddle} event]
+    (case event
+      :up (assoc paddle :y (- y vy))
+      :down (assoc paddle :y (+ y vy))
+      paddle)))
+
+;;-----------------------------------------------------------------------------
+;; Game State
+;;-----------------------------------------------------------------------------
+
+(def state
   ;; Order matters
-  {:background (Rect. 0 0 scale-w scale-h "black")
-   :s1         (Rect. 10 10 110 100 "rgb(200, 0, 0)")
-   :s2         (Rect. 60 60 110 100 "rgba(0,0,200,0.5)")
-   :paddle-1   (Paddle. 20 (- scale-h 120) 20 100 "dodgerblue")
-   :paddle-2   (Paddle. (- scale-w 40) 20 20 100 "dodgerblue")
-   :border     (Frame. 0 0 scale-w scale-h "dodgerblue" 2)})
+  (atom {:background (Rect. 0 0 SCALE-W SCALE-H "black")   ;; use div behind canvas
+         :border     (Frame. 0 0 SCALE-W SCALE-H "#333" 2) ;; use div behind canvas
+         :paddle-1   (Paddle. 20 (- SCALE-H 120) 20 100 2 "dodgerblue")
+         :paddle-2   (Paddle. (- SCALE-W 40) 20 20 100 2 "peru")
+         :ball       (Ball. 400 225 13 3 2 "lime")}))

+;;-----------------------------------------------------------------------------
+;; Animation
 ;;-----------------------------------------------------------------------------

 (defn draw-phase!
   [ctx]
-  (.clearRect ctx 0 0 scale-w scale-h)
-  (doseq [o (vals objects)]
+  (.clearRect ctx 0 0 SCALE-W SCALE-H)
+  (doseq [o (vals @state)]
     (when (satisfies? IDrawable o)
       (draw! o ctx))))

+(defn move-phase!
+  []
+  (swap! state #(assoc % :ball (move (:ball %)))))
+
+(defn animate!
+  []
+  (move-phase!)
+  (draw-phase! ctx)
+  (.requestAnimationFrame js/window animate!))
+
+;;-----------------------------------------------------------------------------
+;; Control
+;;-----------------------------------------------------------------------------
+
 (defn resize!
   [e]
-  ;; Maintains 16x9
   (let [w (- (.-innerWidth js/window) 40)
         h (- (int (/ (* w 9) 16)) 40)]
     (-> (by-id "canvas")
-        ;; (style! "width" (str w "px"))
-        ;; (style! "height" (str h "px"))
         (attr! "width" w)
         (attr! "height" h))
-    (.scale ctx (/ w scale-w) (/ h scale-h))
+    (.scale ctx (/ w SCALE-W) (/ h SCALE-H))
     (draw-phase! ctx)))

 (defn- main
   []
   (println "Welcome to the Canvas Scratch App.")
   (listen! js/window "resize" resize!)
-  (draw-phase! ctx)
   (resize! nil)
-  (draw-phase! ctx))
+  (animate!))

 (set! (.-onload js/window) main)


Simplified shutdown hook

Simplified shutdown hook

areduce was reducing to a value, which is not what you need. The seq
abstraction makes iteration easy.

Also moved the let statement, getting the list of threads at the time of
shutdown.

--- src/cfpb/qu/main.clj
+++ src/cfpb/qu/main.clj
@@ -65,14 +65,18 @@
         worker (qc/create-worker cache)]
     (qc/start-worker worker)))

+(defn- print-live-threads
+  []
+  (let [mx-bean (java.lang.management.ManagementFactory/getThreadMXBean)
+        stack (seq (.dumpAllThreads mx-bean true true))]
+    (fn []
+      (doseq [thread stack]
+        (println thread)))))
+
 (defn add-shutdown-hook
   "Add a shutdown hook that prints all live threads"
   []
-  (let [mx-bean (java.lang.management.ManagementFactory/getThreadMXBean)
-        stack (.dumpAllThreads mx-bean true true)]
-    (.addShutdownHook (Runtime/getRuntime) (Thread. (fn [] (areduce stack i ret nil (println (aget stack i))))))))
-
-
+  (.addShutdownHook (Runtime/getRuntime) (Thread. (print-live-threads))))

 (defn -main
   [& args]


remove print ascii board (not needed anymore)

--- src/client/core.cljs
+++ src/client/core.cljs
@@ -53,26 +53,6 @@
 (defn get-cell-color
   [cell]
   (if (= 0 cell) "#EEE" "#F0F"))
-
-(defn get-cell-str
-  "Return a space or asterisk for the given cell."
-  [cell]
-  (if (= 0 cell) "_" "*"))
-
-(defn row-str
-  "Create a string from a board row."
-  [row]
-  (join "" (map get-cell-str row)))
-
-(defn board-str
-  "Create a string from the tetris board."
-  [board]
-  (join "\n" (map row-str board)))
-
-(defn print-board
-  "Prints the board to screen."
-  []
-  (println (board-str (:board @state))))

 (defn read-board
   "Get the current value from the given board position."


fix function order

fix function order

--- src/clj/protobuf.clj
+++ src/clj/protobuf.clj
@@ -1,17 +1,21 @@
 (ns protobuf)

-(defn protodef [class]
-  (clojure.protobuf.PersistentProtocolBufferMap$Def/create class))
-
-(defmacro defprotobuf [sym & args]
-  (let [class (apply str (interpose "$" (map name args)))]
-    `(def ~sym (protodef ~class))))
+;(set! *warn-on-reflection* true)

 (defn protobuf? [obj]
   (instance? clojure.protobuf.PersistentProtocolBufferMap obj))

 (defn protodef? [obj]
   (instance? clojure.protobuf.PersistentProtocolBufferMap$Def obj))
+
+(defn protodef [class]
+  (if (or (protodef? class) (nil? class))
+    class
+    (clojure.protobuf.PersistentProtocolBufferMap$Def/create class)))
+
+(defmacro defprotobuf [sym & args]
+  (let [class (apply str (interpose "$" (map name args)))]
+    `(def ~sym (protodef ~class))))

 (defn protobuf
   ([#^clojure.protobuf.PersistentProtocolBufferMap$Def type]


Moved function parameters onto same line as function names

--- src/clj_git/core.clj
+++ src/clj_git/core.clj
@@ -15,29 +15,24 @@

 (defn to-str [x] (apply str (map char x)))

-(defn ok-sh
-  [command & args]
+(defn ok-sh [command & args]
   (let [res (apply sh (cons command args))]
     (assert (= 0 (:exit res)))
     (assert (= "" (:err res)))
     (:out res)))

-(defn set-writable
-  [filepath]
+(defn set-writable [filepath]
   (ok-sh "chmod" "u+w" filepath))

-(defn unset-writable
-  [filepath]
+(defn unset-writable [filepath]
   (ok-sh "chmod" "u-w" filepath))

-(defn file-dev-inode
-  [filepath]
+(defn file-dev-inode [filepath]
   (let [out (ok-sh "stat" filepath)
         [dev inode] (clojure.string/split out #" ")]
     (list (read-string dev) (read-string inode))))

-(defn hash-str
-  [text]
+(defn hash-str [text]
   (let [full-text (str "blob " (count text) "\0" text)]
     (sha-1-hex full-text)))

@@ -72,8 +67,7 @@
     (.close out)
     (.toByteArray out)))

-(defn write-object
-  [full-text]
+(defn write-object [full-text]
   (let [hash-text (sha-1-hex full-text)
         [d-name f-name] (map #(apply str %) (split-at 2 hash-text))
         filepath (str (git-root) "objects/" d-name "/" f-name)
@@ -87,17 +81,14 @@
         (unset-writable filepath)))
     hash-text))

-(defn write-blob
-  [text]
+(defn write-blob [text]
   (write-object (str "blob " (count text) "\0" text)))

-(defn hash-file
-  [filepath]
+(defn hash-file [filepath]
   (hash-str (slurp filepath)))

 ;TODO: Use flags from entry hash-map
-(defn tree-entry-bytes
-  [entry]
+(defn tree-entry-bytes [entry]
   (let [flags-bs (if (= (:type entry) "tree")
                         '(52 48 48 48 48)
                         '(49 48 48 54 52 52))
@@ -118,8 +109,7 @@
             '(00)
             hash-bs)))

-(defn tree-data
-  [tree-struct]
+(defn tree-data [tree-struct]
   (let [body (apply concat (map tree-entry-bytes tree-struct))
         size-bs (map byte (str (count body)))
         tree-str-bs (map byte "tree ")
@@ -128,8 +118,7 @@
         ]
     data))

-(defn hash-tree
-  [tree-struct]
+(defn hash-tree [tree-struct]
   (->> tree-struct
        (tree-data)
        (byte-array)
@@ -144,8 +133,7 @@

     (map #(do (assert (= (count %) SHA-1-HEX-LENGTH)) %) hashes)))

-(defn complete-hash
-  [hash-prefix]
+(defn complete-hash [hash-prefix]
   (assert (<= (count hash-prefix) SHA-1-HEX-LENGTH))
   (let [len (count hash-prefix)
         all (all-objects)
@@ -161,8 +149,7 @@
                (str "Ambiguous object prefix '" hash-prefix "'")))
       :else (second (first matches)))))

-(defn read-object
-  [hash-prefix]
+(defn read-object [hash-prefix]
   (let [hash-hex (complete-hash hash-prefix)
         filepath (str (git-root)
                       "objects/"
@@ -173,13 +160,11 @@
         (assert (> ix 0))
         (split-at ix bs)))

-(defn object-type
-  [hash-hex]
+(defn object-type [hash-hex]
   (let [header (to-str (first (read-object hash-hex)))]
     (first (clojure.string/split header #" "))))

-(defn tree
-  [h]
+(defn tree [h]
   (let [[header ins] (read-object h)
         f-entry (fn [bs]
                   (let [spacex (.indexOf bs (int \space))
@@ -205,12 +190,10 @@
         (conj out e)
         (recur (f-entry r) (conj out e))))))

-(defn blob
-  [hash-hex]
+(defn blob [hash-hex]
   (to-str (second (read-object hash-hex))))

-(defn branch
-  [b]
+(defn branch [b]
   (let [filepath (str (git-root) "refs/heads/" b)]
     (clojure.string/replace (slurp filepath) #"\n" "")))

@@ -259,12 +242,10 @@
         (conj out e)
         (recur (f-entry r) (conj out e))))))

-(defn file-mtime
-  [filepath]
+(defn file-mtime [filepath]
   (java.util.Date. (.lastModified (java.io.File. filepath))))

-(defn file-size
-  [filepath]
+(defn file-size [filepath]
   (.length (clojure.java.io/file filepath)))

 ; TODO: If times differ, compute hash to check for differences
@@ -281,8 +262,7 @@

 (defn files-to-commit []) ;TODO; This

-(defn file-index-entry
-  [fp]
+(defn file-index-entry [fp]
   (let [[device inode] (file-dev-inode fp)]
     {:inode inode,
      :device device,
@@ -292,15 +272,13 @@
      :mtime (file-mtime fp),
      :hash (hash-file fp)}))

-(defn positions
-  [pred coll]
+(defn positions [pred coll]
   (keep-indexed (fn [idx x]
                   (when (pred x)
                     idx))
                 coll))

-(defn build-file-tree
-  [file-entry]
+(defn build-file-tree [file-entry]
   (let [filepath (:name file-entry)
         indexes (positions #(= \/ %) filepath)
         dirs (map #(apply str (take % filepath)) indexes)
@@ -312,8 +290,7 @@
              (into file-entry {:type :file, :parent (f-parent filepath)})
              :name))))

-(defn files-tree
-  [file-entries]
+(defn files-tree [file-entries]
   (let [objs (reduce #(into %1 %2) {} (map build-file-tree file-entries))
         find-children (fn [p]
                         (->> objs