clean up a couple things with the session age calculations.

--- src/metabase/middleware/auth.clj
+++ src/metabase/middleware/auth.clj
@@ -41,14 +41,14 @@
     (let [session (first (korma/select Session
                            ;; NOTE: we join with the User table and ensure user.is_active = true
                            (korma/with User (korma/where {:is_active true}))
-                           (korma/fields :created_at)
+                           (korma/fields :created_at :user_id)
                            (korma/where {:id metabase-sessionid})))
-          session-age (- (System/currentTimeMillis) (.getTime (get session :created_at (java.util.Date. 0))))]
+          session-age-ms (- (System/currentTimeMillis) (.getTime (get session :created_at (java.util.Date. 0))))]
       ;; If the session exists and is not expired (max-session-age > session-age) then validation is good
-      (when (and session (> (:max-session-age config/app-defaults) session-age))
-        (handler (assoc request :metabase-userid (:user_id session))))
-      ;; default response is 401
-      response-unauthentic)))
+      (if (and session (> (:max-session-age config/app-defaults) (quot session-age-ms 60000)))
+        (handler (assoc request :metabase-userid (:user_id session)))
+        ;; default response is 401
+        response-unauthentic))))

 (defmacro sel-current-user [current-user-id]


engine: remove stray dependency

engine: remove stray dependency

--- src/io/cyanite/engine.clj
+++ src/io/cyanite/engine.clj
@@ -1,7 +1,6 @@
 (ns io.cyanite.engine
   "The core of cyanite"
   (:require [com.stuartsierra.component :as component]
-            [com.climate.claypoole      :as cp]
             [io.cyanite.engine.rule     :as rule]
             [io.cyanite.engine.queue    :as q]
             [io.cyanite.engine.buckets  :as b]


change how yaml is searched in md file

change how yaml is searched in md file

--- src/io/perun/markdown.clj
+++ src/io/perun/markdown.clj
@@ -23,7 +23,7 @@
       first))

 (defn parse-file-metadata [file-content]
-  (let [metadata-str (extract-between file-content #"---" #"---")
+  (let [metadata-str (extract-between file-content #"---\n" #"---\n")
         parsed-yaml (yaml/parse-string metadata-str)]
     ; we use `original` file flag to distinguish between generated files
     ; (e.x. created those by plugins)


Stop test dependencies being bundled with the app

--- src/leiningen/new/cljskel/project.clj
+++ src/leiningen/new/cljskel/project.clj
@@ -17,18 +17,18 @@
                  [clj-http "0.5.2"]
                  [cheshire "4.0.1"]
                  [clj-time "0.4.3"]
-                 [midje "1.4.0"]
                  [environ "0.3.0"]
                  [nokia/ring-utils "0.1.2"]
-                 [rest-cljer "0.1.2"]
                  [ring/ring-jetty-adapter "1.1.0"]]

   :profiles {:dev {:dependencies [[com.github.rest-driver/rest-client-driver "1.1.22" :exclusions [org.slf4j/slf4j-nop]]
                                   [junit "4.10"]
-                                  [clj-http-fake "0.4.1"]]
+                                  [clj-http-fake "0.4.1"]
+                                  [rest-cljer "0.1.2"]
+                                  [midje "1.4.0"]]
                    :plugins [[lein-rpm "0.0.4"]
-                             [lein-midje "2.0.0-SNAPSHOT"]
-                             [jonase/kibit "0.0.4"]]}}
+                             [lein-midje "2.0.3"]]}}
+
   :plugins [[lein-ring "0.7.3"]
             [environ/environ.lein "0.3.0"]
             [lein-release "1.0.73"]]
@@ -96,6 +96,5 @@
                     :username "jetty"
                     :groupname "jetty"
                     :sources {:source [{:location "scripts/service/jetty"}]}}]}
-  :main {{name}}.web

-  )
+  :main {{name}}.web)


Adds tup+

Adds tup+


xor now trains... on to mnist

xor now trains... on to mnist

--- src/thinktopic/cortex/autoencoder.clj
+++ src/thinktopic/cortex/autoencoder.clj
@@ -66,7 +66,7 @@
   {:n-layers (count layer-sizes)
    :layer-sizes layer-sizes
    :biases (map rand-vector (next layer-sizes))
-   :weights (map rand-matrix (rest layer-sizes) (drop-last layer-sizes) )})
+   :weights (map rand-matrix (rest layer-sizes) (drop-last layer-sizes))})

 (defn feed-forward
   [{:keys [biases weights] :as net} input]
@@ -81,12 +81,23 @@
       activation)))

 ;; Gradient descent
-
+;; 1) forward propagate
+;;  * sum((weights * inputs) + biases) for each neuron, layer by layer
+;; 2) back propagate deltas
+;;  * After propagating forward, we need to figure out the error (often called the
+;;    delta) for each neuron.  For the outputs this is just the
+;;    (output - expected_output) * activation-fn-prime, but for the hidden units the output error has to
+;;    be propagated back across the weights to distributed the error according to
+;;    which hidden units were responsible for it.
+;; 3) compute gradients
+;;  * Then for each weight you multiply its output delta by its input activation to get
+;;    its gradient.  This will correspond to the direction and magnitude of the
+;;    error for that weight, so any update should happen in the opposite direction.
+;; 4) update weights
+;;  * multiply gradient by the learning-rate to smooth out jitter in updates.
 (defn backprop
   [{:keys [biases weights layer-sizes] :as net} input expected-output]
-  (println "backprop")
-  (println "input: " input " => " expected-output)
-  (println "\nforward -----------------------------")
+  ;(println "\n--------------- backprop ---------------------")
   (let [bias-gradients (map #(mat/zero-array (mat/shape %)) biases)
         weight-gradients (map #(mat/zero-array (mat/shape %)) weights)
         [activations zs] (reduce
@@ -94,48 +105,58 @@
                              (let [z (mat/add (mat/mmul layer-weights (last activations)) layer-biases)
                                    activation (mat-sigmoid z)]
                                [(conj activations activation) (conj zs z)]))
-                           [[input] []]
+                           [[input] []] ; initialize zs to nil so it's the same shape as activations
                            (map vector biases weights))
-        _ (println "\nbackward -----------------------------")
         output (last activations)
+
+        ;; Compute the output error and gradients for the output weights
         output-error (mat/sub output expected-output)
+        ;_ (println "input: " input " => " output " target: " expected-output "error: " output-error)
         output-deltas (mat/emul output-error (mat-sigmoid-prime (last zs)))
-        ; TODO: I don't like that we have to reshape here...
-        ;output-deltas (mat/reshape output-deltas [1 (first (mat/shape output-deltas))])
+        ;_ (println "output-error: " output-error)
+        ;_ (println "output-delta: " output-deltas)
         bias-gradients [output-deltas]
-        layer-activations (mat/transpose [(last (drop-last activations))])
-        ;layer-activations (mat/reshape layer-activations [1 (first (mat/shape layer-activations))])
-        _ (println "output-deltas: " (mat/shape output-deltas))
-        ;_ (println "activations: " (mat/shape layer-activations))
-        output-weight-gradients (mat/mmul output-deltas layer-activations)
-        weight-gradients [output-weight-gradients]
-        layer-indices (reverse (range (- (count layer-sizes) 2)))
+        ; TODO: not nice to have to wrap this into another layer...
+        layer-activations (mat/array [(last (drop-last activations))])
+        weight-gradients [(mat/mmul output-deltas [layer-activations])]
+        ;_ (println "output weight gradients: " (mat/shape (first weight-gradients)))
+
+        ;; Now compute deltas and gradients for the hidden layers
+        layer-indices (reverse (range 1 (dec (count layer-sizes))))
+        ;_ (println "zs: " (map mat/shape zs))
+        ;_ (println "weights: " (map mat/shape weights))
+        ;_ (println "layer-indices: " layer-indices)
         [_ bias-gradients weight-gradients]
         (reduce
-          (fn [[delta d-biases d-weights] i] ; layer weights, zs and activations, in top down order
-            (let [lws (nth weights i)
-                  lzs (nth zs i)
-                  las (nth activations i)
-                  sp (mat-sigmoid-prime lzs)
-                  _ (println "ws: " (count weights) " i: " (inc i))
-                  _ (println "weights: " (mat/shape (mat/transpose (nth weights (inc i)))))
-                  _ (println "deltas: " (mat/shape delta))
-                  _ (println "sp: " (mat/shape sp) sp)
-                  weight-delta (mat/mmul (mat/transpose (nth weights (inc i))) delta)
-                  _ (println "deltas: " (mat/shape weight-delta))
-                  delta (mat/mmul weight-delta sp)
-                  weight-grad (mat/mmul delta (mat/transpose (nth activations (dec i))))
-                  d-biases (cons delta d-biases)
-                  d-weights (cons weight-grad d-weights)]
-              [delta d-biases d-weights]))
+          (fn [[delta bias-grads weight-grads] i]
+            ;(print "i: " i " -> " )
+            ;(println (nth layer-sizes i) "neurons and" (mat/shape (nth zs (dec i))) "activations")
+            ;(println (nth layer-sizes i) "weights")
+            (let [sp (mat-sigmoid-prime (nth zs (dec i)))
+                  outgoing-weights (mat/transpose (nth weights i))
+                  ;_ (println "delta: " (mat/shape delta))
+                  ;_ (println "outgoing-weights: " (mat/shape outgoing-weights))
+                  errors (mat/mmul outgoing-weights delta)
+                  ;_ (println "deltas: " (mat/shape errors-deltas))
+                  ;_ (println "sp: " (mat/shape sp))
+                  delta (mat/emul errors sp)
+                  ;_ (println "new-delta: " (mat/shape delta))
+                  ;_ (println "activations: " (mat/shape (mat/transpose (nth activations (dec i)))))
+                  weight-grad (mat/outer-product delta (mat/transpose (nth activations (dec i))))
+                  ;_ (println "weight-grad: " (mat/shape weight-grad))
+                  bias-grads (cons delta bias-grads)
+                  weight-grads (cons weight-grad weight-grads)]
+              [delta bias-grads weight-grads]))
           [output-deltas bias-gradients weight-gradients]
           layer-indices)]
+    ;(println "weight-gradients: " (map mat/shape weight-gradients))
+    ;(println "\n--------------- end backprop ---------------------")
     [bias-gradients weight-gradients]))

 (defn update-mini-batch
   [{:keys [biases weights] :as net} learning-rate data labels batch]
-  (println "update-mini-batch")
+  ;(println "update-mini-batch")
   (let [bias-gradients (map #(mat/zero-array (mat/shape %)) biases)
         weight-gradients (map #(mat/zero-array (mat/shape %)) weights)
         batch-size (count batch)
@@ -147,16 +168,20 @@
           (fn [[bias-gradients weight-gradients] sample-index]
             (let [input (mat/get-row data sample-index)
                   label (mat/get-row labels sample-index)
-                  [bias-deltas weight-deltas] (backprop net input label)
-                  bias-gradients (map mat/add! bias-gradients bias-deltas)
-                  weight-gradients (map mat/add! weight-gradients weight-deltas)]
+                  [bias-grad weight-grad] (backprop net input label)
+                  ;_ (println "bias-grad:" bias-grad)
+                  ;_ (println "weight-grad:" weight-grad)
+                  bias-gradients (doall (map mat/add! bias-gradients bias-grad))
+                  weight-gradients (doall (map mat/add! weight-gradients weight-grad))]
+              ;(println "bottom")
               [bias-gradients weight-gradients]))
           [bias-gradients weight-gradients]
           batch)
+        ;_ (println "accumulated gradients...")
         biases (map (fn [b nb] (mat/sub! b (mat/mul batch-rate nb))) biases bias-gradients)
         weights (map (fn [w nw] (mat/sub! w (mat/mul batch-rate nw))) weights weight-gradients)]
-    (println "biases:\n" biases)
-    (println "weights:\n" weights)
+    ;(println "biases:\n" biases)
+    ;(println "weights:\n" weights)
     (assoc net :biases biases :weights weights)))

 (defn sgd
@@ -187,8 +212,12 @@
   [net test-data test-labels]
   (let [results (map (fn [data label]
                        (let [res (feed-forward net data)]
-                         (argmax res)))
+                         ;(argmax res)
+                         [(Math/round (first res))]
+                         ))
                      (mat/rows test-data) (mat/rows test-labels))
+        _ (println "RESULTS: " results)
+        _ (println "LABELS: " test-labels)
         score (count (filter #(= (first %) (second %)) (map vector results test-labels)))]
     score))

@@ -223,10 +252,12 @@
 (defn xor-test
   []
   (let [net (network [2 3 1])
-        optim-options {:n-epochs 500
-                       :batch-size 1
+        optim-options {:n-epochs 10000
+                       :batch-size 2
                        :learning-rate 0.1}
+        _ (println "initial: " (:weights net))
         trained (sgd net optim-options XOR-DATA XOR-LABELS)
+        _ (println "trained: " (:weights net))
         score (evaluate trained XOR-DATA XOR-LABELS)
         label-count (count XOR-LABELS)
         score-percent (float (/ score label-count))]


Rewrite tree-shake using update-forms

Rewrite tree-shake using update-forms

Because the existing implementation was causing reordering. And it was
just an ad-hoc inline implementation of update-forms.

--- src/oxcart/passes/tree_shake.clj
+++ src/oxcart/passes/tree_shake.clj
@@ -13,7 +13,7 @@
    :added "0.0.5"}
   (:require [oxcart.util :as util]
             [oxcart.pattern :as pattern]
-            [oxcart.passes :refer [require-pass record-pass clobber-passes]]
+            [oxcart.passes :refer [update-forms require-pass record-pass clobber-passes]]
             [oxcart.passes.defs :as defs]
             [clojure.set :as set]
             [clojure.tools.analyzer.ast :as ast]
@@ -58,28 +58,14 @@
   Rewrites a Whole-AST to eliminate definitions of vars which are not
   used. Note that this operation _preserves_ non def top level forms
   rather than discarding them."
-  [{:keys [modules] :as whole-program-ast} reach-set]
-  {:pre [(every? (partial contains? whole-program-ast) modules)
-         (every? #(get-in whole-program-ast [%1 :forms]) modules)
-         (every? var? reach-set)]}
-  (let [new-ast (atom {:modules modules})]
-
-    (doseq [m modules]
-      (assert (:forms (get whole-program-ast m)))
-
-      (doseq [ast (:forms (get whole-program-ast m))]
-        (if (pattern/def? ast)
-          (if (contains? reach-set (:var ast))
-            (swap! new-ast update-in [m :forms] conj ast)
-
-            (info "Discarding unused def form,"
-                  (util/format-line-info ast)))
-
-          (swap! new-ast update-in [m :forms] conj ast)))
-
-      (swap! new-ast update-in [m :forms] vec))
-
-    @new-ast))
+  [whole-ast reach-set]
+  (update-forms whole-ast
+                (fn [ast]
+                  (if (and (pattern/def? ast)
+                           (contains? reach-set (:var ast)))
+                    ast
+                    (do (info "Discarding unused def form," (util/format-line-info ast))
+                        nil)))))

 (defn analyze-var-dependencies


Fixed CLI; enhanced Capabilities (see issue #2).

--- src/leiningen/ancient.clj
+++ src/leiningen/ancient.clj
@@ -177,7 +177,7 @@
                  ["--allow-snapshots" :flag true :default false]
                  ["--allow-qualified" :flag true :default false]
                  ["--[no-]profiles" :flag true :default true]))]
-    (cond (:all data) (assoc data :dependencies true :plugins true :profiles true)
+    (cond (:all data) (assoc data :dependencies true :plugins true)
           (:plugins data) data
           :else (assoc data :dependencies true))))

@@ -194,7 +194,16 @@
           (when (:plugins settings) (mapcat :plugins (vals (:profiles project)))))))))

 (defn ^:no-project-needed ancient
-  "Check your Projects for outdated Dependencies."
+  "Check your Projects for outdated Dependencies.
+
+   Commandline Options:
+
+     :all                 Check Dependencies and Plugins.
+     :dependencies        Check Dependencies. (default)
+     :plugins             Check Plugins.
+     :no-profiles         Do not check Dependencies/Plugins in Profiles.
+     :allow-qualified     Allow '*-alpha*' versions & co. to be reported as new.
+     :allow-snapshots     Allow '*-SNAPSHOT' versions to be reported as new."
   [project & args]
   (let [settings (parse-cli args)
         repos (get-repository-urls project)


Fix compiling of namespace that include a - character.

--- src/leiningen/compile.clj
+++ src/leiningen/compile.clj
@@ -11,7 +11,9 @@
   ;; TODO: use a java subprocess in case a different clojure version is needed
   (doseq [n (or (:namespaces project)
                 (find-namespaces-in-dir (file (:root project) "src")))]
-    (let [ns-file (str (.replaceAll (name n) "\\." "/"))]
+    (let [ns-file (str (-> (name n)
+                           (.replaceAll "\\." "/")
+                           (.replaceAll "-" "_")))]
       (when (> (.lastModified (file (:root project) "src" (str ns-file ".clj")))
                (.lastModified (file (:root project) "classes"
                                     (str ns-file "__init.class"))))


Watch for pjax transitions

Watch for pjax transitions

This technique is taken from https://github.com/lxe/require-navigator

--- src/gitique/core.cljs
+++ src/gitique/core.cljs
@@ -22,7 +22,9 @@
   (last (string/split (.getAttribute (.querySelector element ".commit-id") "href") "/")))

 (defn- commit-shas [item]
-  (map commit-sha (.querySelectorAll (:element item) ".commit")))
+  (if-let [element (:element item)]
+    (map commit-sha (.querySelectorAll (:element item) ".commit"))
+    []))

 (defn- item-type [creator item]
   (let [classes (.-classList item)]
@@ -161,17 +163,24 @@

 (defn- maybe-show-new [repo]
   (let [{:keys [last-reviewed-commit new-commits]} (commit-info)]
-    (if last-reviewed-commit
+    (if (and last-reviewed-commit (not-empty new-commits))
       (do
         (get-new-commits! repo (-> last-reviewed-commit commit-shas last) (-> new-commits last commit-shas last))
         (dorun (map add-icons! new-commits)))
       (log "No unreviewed commits"))))

-(defn ^:export main []
+(defn- main []
   (let [components (string/split (aget js/window "location" "pathname") "/")
         repo (str (get components 1) "/" (get components 2))]
     (if (= (get components 3) "pull")
       (maybe-show-new repo)
       (log (str "Not a pull request: " components)))))

-(main)
+(defn- watch []
+  (let [target (js/document.querySelector "#js-repo-pjax-container")
+        is-valid-mutation? #(and (= (.-type %) "childList") (not-empty (.-addedNodes %)))
+        observer (js/MutationObserver. #(when (some is-valid-mutation? %) (main)))]
+    (.observe observer target #js{:childList true :attributes false :characterData false})
+    (main)))
+
+(watch)


Use normalize-uri in server/wrap-static-index.

--- src/incise/server.clj
+++ src/incise/server.clj
@@ -3,7 +3,7 @@
                        [core :refer [routes]])
             (hiccup [page :refer [html5]])
             (incise [config :as conf]
-                    [utils :refer [getenv]]
+                    [utils :refer [getenv normalize-uri]]
                     [load :refer [load-parsers-and-layouts]])
             (ring.middleware [reload :refer [wrap-reload]]
                              [incise :refer [wrap-incise]]
@@ -16,9 +16,7 @@

 (defn wrap-static-index [handler]
   (fn [{:keys [uri] :as request}]
-    (handler (if (= (last uri) \/)
-               (assoc request :uri (str uri "index.html"))
-               request))))
+    (handler (assoc request :uri (normalize-uri uri)))))

 (defn wrap-log-exceptions [func & {:keys [bubble] :or {bubble true}}]
   "Log (i.e. print) exceptions received from the given function."


Correct indentation

Correct indentation

--- src/io/aviso/rook.clj
+++ src/io/aviso/rook.clj
@@ -84,13 +84,13 @@
   [namespace-name]
   (when-not (find-ns namespace-name)
     (require namespace-name))
-  (->> namespace-name
-   ns-publics
-   (map second)
-   (filter symbol-for-function?)
-   (map function-entry)
-   (remove nil?)
-   (concat default-mappings)))
+  (->> namespace-name
+       ns-publics
+       (map second)
+       (filter symbol-for-function?)
+       (map function-entry)
+       (remove nil?)
+       (concat default-mappings)))

 (defn- get-function-meta
   "Get meta for route-mapping and namespace."
@@ -236,6 +236,6 @@
                    rook-handler
                    (apply compojure/routes (concat handlers [rook-handler])))
          handler' (namespace-middleware handler namespace-name)]
-     (compojure/context path [] handler'))) )
-
-
+     (compojure/context path [] handler'))))
+
+


Looks like the defapplet macro needs bind-applets to be public.

--- src/rosado/processing/applet.clj
+++ src/rosado/processing/applet.clj
@@ -3,7 +3,7 @@
         [clojure.contrib.java-utils :only [as-str]])
   (:import (java.awt Frame)))

-(defn- bind-applets
+(defn bind-applets
   "Turn the method map into something one that update-proxy can use."
   [methods [method-name f]]
   (assoc methods (name method-name)


make start-editing/stop-editing ops more robust

--- cljs/src/main/plastic/main/editor/ops.cljs
+++ cljs/src/main/plastic/main/editor/ops.cljs
@@ -28,11 +28,23 @@
 (defn structural-up [editor]
   (-> editor editing/stop-editing cursor/structural-up))

+(defn can-edit? [editor]
+  (let [new-editor (cursor/structural-down editor)]
+    (identical? new-editor editor)))                                                                                ; we are at bottom "token level"
+
 (defn structural-down [editor]
   (let [new-editor (cursor/structural-down editor)]
     (if (identical? new-editor editor)
       (dispatch :editor-op (editor/get-id editor) :toggle-editing))
     new-editor))
+
+(defn start-editing [editor]
+  (if (and (not (editor/editing? editor)) (can-edit? editor))
+    (editing/start-editing editor)))
+
+(defn stop-editing [editor]
+  (if (editor/editing? editor)
+    (editing/stop-editing editor)))

 (defn toggle-editing [editor]
   (if (editor/editing? editor)
@@ -78,8 +90,8 @@
    :structural-down    structural-down
    :next-token         editing/next-token
    :prev-token         editing/prev-token
-   :start-editing      editing/start-editing
-   :stop-editing       editing/stop-editing
+   :start-editing      start-editing
+   :stop-editing       stop-editing
    :toggle-editing     toggle-editing
    :enter              enter
    :alt-enter          alt-enter


lt and gt to creation date

lt and gt to creation date

--- src/ontrail/mongerfilter.clj
+++ src/ontrail/mongerfilter.clj
@@ -58,7 +58,7 @@

 (defn make-query-from [params]
   (let [basic-query (make-basic-query (select-keys params [:user :tags :sport :distance :duration]))
-  		date-range-query (make-range-query parse-date (select-keys params [:lte_creationDate :gte_creationDate]))
+  		date-range-query (make-range-query parse-date (select-keys params [:lt_creationDate :gt_creationDate :lte_creationDate :gte_creationDate]))
   		long-range-query (make-range-query parse-long (select-keys params (long-cmp-keys)))
   		group-query (make-group-query (:group params))]
   	{$and (vec (concat basic-query date-range-query long-range-query group-query))}))


Fix merge error.

Fix merge error.

--- src/onyx/messaging/aeron.clj
+++ src/onyx/messaging/aeron.clj
@@ -161,8 +161,8 @@
         aeron (Aeron/connect ctx)
         channel (aeron-channel bind-addr (:aeron/port assigned))

-        send-handler (data-handler (partial handle-sent-message inbound-ch))
-        acker-handler (data-handler (partial handle-acker-message acking-daemon (:decompress-f messenger)))
+        send-handler (data-handler (partial handle-sent-message inbound-ch (:decompress-f messenger)))
+        acker-handler (data-handler (partial handle-acker-message acking-daemon))
         completion-handler (data-handler (partial handle-completion-message release-ch))

         send-subscriber (.addSubscription aeron channel send-stream-id send-handler)


Fix use of sleep and currentTimeMillis These are susceptible to clock changes

--- src/onyx/messaging/aeron.clj
+++ src/onyx/messaging/aeron.clj
@@ -18,6 +18,7 @@
            [org.agrona.concurrent
             UnsafeBuffer IdleStrategy BackoffIdleStrategy BusySpinIdleStrategy]
            [java.util.function Consumer]
+           [java.util.concurrent.locks LockSupport]
            [java.util.concurrent TimeUnit]))

 (defn aeron-channel [addr port]
@@ -336,9 +337,9 @@
   (let [ch (:inbound-ch messenger-buffer)
         batch-size (long (:onyx/batch-size task-map))
         ms (arg-or-default :onyx/batch-timeout task-map)
-        yield-time (+ (System/currentTimeMillis) ms)]
+        yield-time (+ (System/nanoTime) (* 1000000 ms))]
     (loop [segments (transient []) i 0]
-      (if (or (> (System/currentTimeMillis) yield-time)
+      (if (or (> (System/nanoTime) yield-time)
               (>= i batch-size))
         (persistent! segments)
         (if-let [v (poll! ch)]
@@ -346,7 +347,8 @@
           (do
            ;; set to less than the resolution for "alts!!"
            ;; so we get similar behaviour
-           (Thread/sleep 10)
+           ;; park for 5ms
+           (LockSupport/parkNanos 5000000)
            (recur segments i)))))))

 (defn lookup-channels [messenger id]


no need to nest additions! Also s/note/interval/

--- src/overtone/music/pitch.clj
+++ src/overtone/music/pitch.clj
@@ -72,9 +72,9 @@
     (for [n notes] (- pivot (- n pivot)))))

 (defn octave-note
-  "Convert an octave and note to a midi note."
-  [octave note]
-  (+ (+ (* octave 12) note) 12))
+  "Convert an octave and interval to a midi note."
+  [octave interval]
+  (+ (* octave 12) interval 12))

 (def NOTES {:C  0  :c  0  :b# 0  :B# 0
             :C# 1  :c# 1  :Db 1  :db 1  :DB 1  :dB 1


stat-data local

stat-data local

--- src/paulkrake/datacenter.clj
+++ src/paulkrake/datacenter.clj
@@ -1,5 +1,7 @@
 (ns paulkrake.datacenter
-  (:require [clojure.data.json :as json]))
+  (:require [clojure.data.json :as json]
+            [clojure.java.io]
+            [clojure.edn]))

 (def all-kategories (list "passes_complete_percentage" "score_foot_against" "crosses" "passes_complete" "duels_lost_ground" "score" "duels_lost_header" "duels_won" "shot_assists" "tracking_fast_runs" "corner_kicks_left" "fouls_committed" "crosses_left" "card_red" "saves" "shots_inside_box" "fouls_suffered" "score_foot" "shots_header" "balls_touched_percentage" "shots_foot" "freekicks" "duels_won_percentage" "passes_failed" "crosses_right" "balls_touched" "score_header_against" "tracking_sprints" "shots" "corner_kicks" "duels_won_header" "score_header" "average_age" "duels_won_ground" "offsides" "passes_failed_percentage" "card_yellow_red" "shots_outside_box" "tracking_max_speed" "shots_on_goal" "tracking_average_speed" "score_penalty" "score_against" "duels_lost_percentage" "duels_lost" "tracking_distance" "team" "corner_kicks_right" "card_yellow" "score_penalty_against"))
@@ -96,7 +98,7 @@
     (map (fn [[k v]] [v k]) x)
     (into {} x)))

-(defn stat-data [saison spieltag-nr]
+(defn stat-data-remote [saison spieltag-nr]
   (as-> (season-by-competition saison) x
     (get x "id")
     (matches-by-season x spieltag-nr)
@@ -112,6 +114,20 @@
                        ag       (team-stats-by-match match-id away-id)]
                    (vector home away hg ag)))
          x)))
+
+(defn stat-data-local [p-saison p-spieltag-nr f]
+  (as-> (line-seq (clojure.java.io/reader f)) x
+    (map clojure.edn/read-string x)
+    (filter (fn [{:keys [saison spieltagtag] :as m}]
+              (and (= (str p-saison) saison)
+                   (= p-spieltag-nr spieltag))) x)
+    (map :data x)))
+
+(defn stat-data [saison spieltag-nr]
+  (let [f (clojure.java.io/file (str "resources/stat-%s.txt" (str saison)))]
+    (if (not (.exists f))
+      (stat-data-remote saison spieltag-nr)
+      (stat-data-local saison spieltag-nr f))))

 (defn teams [saison spieltag-nr]
   (as-> (stat-data saison spieltag-nr) x


Fix docstring

Fix docstring

--- src/play_clj/core_basics.clj
+++ src/play_clj/core_basics.clj
@@ -84,7 +84,7 @@
 (defmacro net!
   "Calls a single method on [Gdx.net](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Net.html).

-    (net! :open-uri \"https://sekao.net/\")"
+    (net! :open-u-r-i \"https://sekao.net/\")"
   [k & options]
   `(u/call! ^Net (Gdx/net) ~k ~@options))


Make function work in multithreaded code

--- src/play_clj/core_render.clj
+++ src/play_clj/core_render.clj
@@ -13,19 +13,20 @@
     (isa? (type renderer) Stage)
     (.draw ^Stage renderer)))

-(defn tiled-map-layer
-  [{:keys [^BatchTiledMapRenderer renderer]} layer]
-  (assert renderer)
-  (if (isa? (type layer) MapLayer)
-    layer
-    (-> renderer .getMap .getLayers (.get ^String layer))))
-
 (defn tiled-map-layers
   [{:keys [^BatchTiledMapRenderer renderer]}]
   (assert renderer)
   (let [layers (-> renderer .getMap .getLayers)]
     (for [^long i (range (.getCount layers))]
       (.get layers i))))
+
+(defn tiled-map-layer
+  [screen layer]
+  (if (isa? (type layer) MapLayer)
+    layer
+    (->> (tiled-map-layers screen)
+         (filter #(= layer (.getName ^MapLayer %)))
+         first)))

 (defn tiled-map-layer-name
   [screen layer]


Add support for cmd.config; fix paired read bug

--- src/aerobio/htseq/common.clj
+++ src/aerobio/htseq/common.clj
@@ -258,16 +258,23 @@
          (reduce (fn[M [bc v]] (assoc M bc (conj (get M bc []) v))) {}))))

+(defn get-cmds-args [cfgfile]
+  (if (fs/exists? cfgfile)
+    (-> cfgfile slurp read-string)
+    {}))
+
+
 (def exp-info (atom {}))
 ;;; "/data1/NextSeq/TVOLab/AHL7L3BGXX"
 ;;; "/data1/NextSeq/TVOLab/AHL7L3BGXX/Docs/SampleSheet.csv"
 ;;; "/data1/NextSeq/TVOLab/AHL7L3BGXX/Docs/Exp-AntibioticsRTS_KZ_SD_index.csv"
-(defn init-exp-data [base ssheet exp-ssheet]
+(defn init-exp-data [base ssheet exp-ssheet cfgfile]
   (-> {}
       (assoc :sample-sheet
              (get-sample-info ssheet))
       ((fn[m]
          (assoc m :base base
+                :cmdsargs  (get-cmds-args cfgfile)
                 :refs      (pams/get-params :refdir)
                 :index     (fs/join (pams/get-params :refdir) "Index")
                 :bt1index  (fs/join (pams/get-params :refdir) "BT1Index")
@@ -374,11 +381,12 @@
         nextseq-base (pams/get-params :nextseq-base)
         expdir (fs/join nextseq-base eid)
         sample-sheet (fs/join expdir "SampleSheet.csv")
-        exp-sample-sheet (fs/join expdir "Exp-SampleSheet.csv")]
+        exp-sample-sheet (fs/join expdir "Exp-SampleSheet.csv")
+        cfgfile (fs/join expdir "cmd.config")]
     (swap! exp-info
            (fn[m]
              (assoc m eid
-                    (init-exp-data base sample-sheet exp-sample-sheet))))))
+                    (init-exp-data base sample-sheet exp-sample-sheet cfgfile))))))

 (defn del-exp [eid]
   (swap! exp-info (fn[m] (dissoc m eid)))
@@ -538,7 +546,9 @@
                        base exp-illumina-xref illumina-sample-xref)
         ifastqs (->> (fs/directory-files (get-exp-info eid :fastq) "fastq.gz")
                      (group-by #(->> % fs/basename
-                                     (re-find #"R[1-2]") keyword)))
+                                     (re-find #"_R[1-2]")
+                                     (str/drop 1)
+                                     keyword)))
         sample-illumina-xref (clojure.set/map-invert illumina-sample-xref)
         sample-ifq-xref (reduce (fn[M fq]
                                   (let [samp (->> fq fs/basename
@@ -602,7 +612,7 @@

 (defn get-paired-fqs [eid repname repk]
   (->> (get-replicate-fqzs eid repname repk)
-       (group-by (fn[fq] (if (re-find #"R2" fq) :R2 :R1)))
+       (group-by (fn[fq] (if (re-find #"-R2\." fq) :R2 :R1)))
        (map (fn[[k v]] [k (cljstr/join "," v)]))
        (into {})))


Fix regex finding R2 reads...

Fix regex finding R2 reads...

--- src/aerobio/htseq/paired.clj
+++ src/aerobio/htseq/paired.clj
@@ -88,7 +88,8 @@
         sampdir (fs/join sampbase samp)
         R1fqs (fs/glob (fs/join sampdir "*R1.fastq.gz"))
         fastqdir (fs/join expoutdir eid (pams/get-params :fastq-dirname))
-        R2infqs (fs/glob (fs/join fastqdir (str samp "*R2*.fastq.gz")))]
+        fpattern (re-pattern (str "^" samp "*_R2_*.fastq.gz"))
+        R2infqs (fs/re-directory-files fastqdir fpattern)]
     (doseq [R2-infq R2infqs]
       (doseq [R1fq R1fqs]
         (let [R2-otfq (R2fq-name R1fq)]


CMR-346: Added browsable to boolean parameter validation list.

--- src/cmr/search/services/parameters/parameter_validation.clj
+++ src/cmr/search/services/parameters/parameter_validation.clj
@@ -342,7 +342,7 @@

 (defn boolean-value-validation
   [concept-type params]
-  (let [bool-params (select-keys params [:downloadable])]
+  (let [bool-params (select-keys params [:downloadable :browsable])]
     (mapcat
       (fn [[key value]]
         (if (or (= "true" value) (= "false" value) (= "unset" (s/lower-case value)))


+refer to reload

+refer to reload

--- src/babel/english/writer.clj
+++ src/babel/english/writer.clj
@@ -9,7 +9,7 @@
 (require '[babel.writer :as writer
            :refer [delete-from-expressions
                    fill-language-by-spec
-                   process write-lexicon]])
+                   process write-lexicon reload]])
 (require '[clojure.tools.logging :as log])
 (require '[dag-unify.core :refer (fail? get-in strip-refs unify)])


add :pre assert to prevent incorrect node-repl use

--- src/main/shadow/cljs/devtools/api.clj
+++ src/main/shadow/cljs/devtools/api.clj
@@ -509,6 +509,7 @@
   ([]
    (node-repl {}))
   ([{:keys [build-id] :or {build-id :node-repl} :as opts}]
+   {:pre [(map? opts)]}
    (let [{:keys [supervisor] :as app}
          (runtime/get-instance!)


putting group times in chronological order

--- src/anyviz/views.clj
+++ src/anyviz/views.clj
@@ -20,7 +20,7 @@
     [:ul.nav.navbar-nav]])

 (def match-operators ["=","!=","<","<=",">",">="])
-(def group-times ["year","month","hour","day","minute"])
+(def group-times ["year","month","day","hour","minute"])
 (def reduce-operators ["count","min","max","sum","avg","stdev"])

 (defn dropdown-item [item]


definde request filters

definde request filters

--- src/ca_recipe/tnywb/core.clj
+++ src/ca_recipe/tnywb/core.clj
@@ -43,3 +43,10 @@
     (str "
Friendly Greetings
" rendered-greetings)))

 (defn logging-filter [http-request]
+  (println (str "In Logging Filter - request for path: " (:path http-request)))
+  http-request)
+
+(def request-handlers
+  {"/greeting" {:controller handle-greeting :view greeting-view}})
+
+(def filters [logging-filter])


remove splitted company schema

remove splitted company schema

--- src/open_company/resources/common.clj
+++ src/open_company/resources/common.clj
@@ -77,24 +77,18 @@
   (into {} (for [sn section-names] [(s/optional-key sn) Section])))

 ;; TODO check for non-blank?
-(def CompanyMinimum
+(def Company
   {:name        s/Str
-   :description s/Str})
-
-(def CompanyOptional
-  {:currency    s/Str
-   :slug        Slug})
-
-(def Company
-  (merge CompanyMinimum
-         CompanyOptional
-         {:org-id      s/Str
-          :sections    SectionsOrder
-          :categories  (s/pred #(cset/subset? (set %) category-names))
-          (s/optional-key :logo)        s/Str
-          (s/optional-key :created-at)  s/Str
-          (s/optional-key :updated-at)  s/Str}
-          InlineSections))
+   :description s/Str
+   :slug        Slug
+   :currency    s/Str
+   :org-id      s/Str
+   :sections    SectionsOrder
+   :categories  (s/pred #(cset/subset? (set %) category-names))
+   (s/optional-key :logo)        s/Str
+   (s/optional-key :created-at)  s/Str
+   (s/optional-key :updated-at)  s/Str}
+  InlineSections)

 (def User
   {:name        s/Str


CMR-5035: Allow dots in version.

CMR-5035: Allow dots in version.


stop ip clear fix

stop ip clear fix

--- src/aws/provider.clj
+++ src/aws/provider.clj
@@ -70,7 +70,7 @@
        (debug "created" instance-id)
        (handle-volumes spec endpoint instance-id)
        (when-let [ip (get-in spec [:machine :ip])]
-         (debug (<<  "Associating existing ip ~{ip} to instance-id"))
+         (debug (<<  "Associating existing ip ~{ip} to ~{instance-id}"))
          (assoc-pub-ip endpoint instance-id ip))
        (update-ip spec endpoint instance-id)
        (wait-for-ssh (pub-dns endpoint instance-id) user [5 :minute])
@@ -103,7 +103,7 @@
   (stop [this]
     (with-instance-id
        (debug "stopping" instance-id)
-       (when-not (first (:addresses (describe-eip endpoint instance-id)))
+       (when-not (describe-eip endpoint instance-id)
          (debug "clearing dynamic ip from system")
          (s/update-system (spec :system-id)
            (dissoc-in* (s/get-system (spec :system-id)) [:machine :ip])))
@@ -143,7 +143,7 @@
   (.start m)
   (clojure.pprint/pprint
     (celestial.model/set-env :dev
-     (first (:addresses (eip/describe-eip (assoc (creds) :endpoint "ec2.eu-west-1.amazonaws.com") "i-cdd59781")))))
+     (first (:addresses (describe-eip "ec2.ap-southeast-2.amazonaws.com" "i-b6974489")))))
   )


remove unneeded dependency on babel.over

--- src/babel/index.cljc
+++ src/babel/index.cljc
@@ -8,18 +8,13 @@
    #?(:cljs [babel.logjs :as log])
    [dag_unify.core :refer [fail? dissoc-paths get-in label-of
                            remove-top-values-log strip-refs
-                           unifyc]]
-
-   [babel.over :as over]))
+                           unifyc]]))

 (defn exception [error-string]
   #?(:clj
      (throw (Exception. error-string)))
   #?(:cljs
      (throw (js/Error. error-string))))
-
-;; For now, this index is just a stub; no actual caching is done; it simply calls
-;; the over/ equivalents of each of the defined functions.

 (def head-index {})
 (def comp-index {})
@@ -111,12 +106,6 @@
     (if (empty? result)
       (log/trace (str "comp-phrases of parent: " (label-of parent) " is empty.")))
     result))
-
-(defn overc-with-index-1 [parent lex]
-  (if (not (empty? lex))
-    (do
-      (lazy-cat (over/overc parent (first lex))
-                (overc-with-index-1 parent (rest lex))))))

 ;; TODO: remove this: has already been removed in favor of (map-subset-by-path)
 ;; TODO: document how this works and especially what 'phrase-constraint' means.


(defn read-one []): simply return given spec for now

--- src/babel/latin.cljc
+++ src/babel/latin.cljc
@@ -109,7 +109,7 @@
   ;; for now, stubbed out: imagine a curriculum narrowly based on a single verb and
   ;; the imperfect tense.
   (let [spec-for-curriculum (intersection spec curriculum model)]
-    (get-spec spec-for-curriculum)))
+    (get-spec spec)))

 (def curriculum
   {:nouns ["lui" "lei"]


s/:fo/:morph/

s/:fo/:morph/

--- src/babel/latin.cljc
+++ src/babel/latin.cljc
@@ -87,5 +87,5 @@
        {:root (first (shuffle roots))})))

 (def model {:lexicon lexicon
-            :fo fo
+            :morph fo
             :generate-fn generate})


Improved catch function (now accepts a optional predicate).

--- src/beicon/core.cljs
+++ src/beicon/core.cljs
@@ -507,10 +507,23 @@
 (defn catch
   "Continues an observable sequence that is terminated
   by an exception with the next observable sequence."
-  [handler ob]
-  {:pre [(or (observable? handler)
-             (fn? handler))]}
-  (.catch ob handler))
+  ([handler ob]
+   {:pre [(or (observable? handler) (fn? handler))]}
+   (.catch ob (fn [value]
+                (let [value (handler value)]
+                  (cond
+                    (observable? value) value
+                    (-end? value) (empty)
+                    (-error? value) (throw value)
+                    (-next? value) (of value))))))
+
+  ([pred handler ob]
+   {:pre [(fn? pred)]}
+   (catch (fn [value]
+            (if (pred value)
+              (handler value)
+              (throw value)))
+       ob)))

 (defn tap
   "Invokes an action for each element in the


cleaned up a bit

cleaned up a bit

--- src/moomoo/rooms.cljs
+++ src/moomoo/rooms.cljs
@@ -17,5 +17,5 @@
           (c [err reply]
             (callback err (users-to-list err reply)))]
   (.hgetall redis-client (string/join [room ":users"])
-    (fn [err reply callback]
+    (fn [err reply]
       (c err reply)))))


continuing to work through cheatsheet

continuing to work through cheatsheet

--- src/mortgage/core.clj
+++ src/mortgage/core.clj
@@ -7,12 +7,12 @@

 ; ok so
 ; paredit keys to remember / try out:
-; cmd+shift+j, cmd+shift+k
-; cmd+ctrl+j, cmd+ctrl+k
+; cmd+shift+j, cmd+shift+k - move right paren back/forth
+; cmd+ctrl+j, cmd+ctrl+k - move left paren back/forth
 ; cmd-shift-9 wraps with ()
 ; ctrl-S splices: removes a ()
 ; cmd-shift-up and cmd-shift-down move a form forward and backward in its containing list, neat
-; option-shift-s is split
+; alt-shift-s is split
 ; cmd-ctrl-s is join (?! i hate this pair of keybinds)
 ;
 ; repl commands
@@ -20,22 +20,31 @@
 ; cmd-shift-p sends current form to repl (equivalent of cpp in fireplace)
 ;
 ; assorted intellij commands
-; https://cursive-ide.com/userguide/navigation.html
-; cmd-alt-fn-f7: show usages
-; alt-fn-f7: find usages
-; cmd-e: recent files
 ; esc: focus editor window (as opposed to eg repl, project, etc)
-; fn-f3 - toggle anonymous bookmark
-; option-fn-f3 - add bookmark with mnemonic (use numbers)
-; ctrl-<number> - jump to numbered mnemonic bookmark
-; cmd-fn-f3 - view all bookmarks
+; cmd-alt-e: view repl history
+;
+; documentation+etc
+; cmd-p: show parameters this function takes
+;
+; navigation
+; cmd-alt-f7: show usages
+; alt-f7: find usages
+; cmd-e: recent files - cursive docs say you can use this instead of tabs, we'll see about that
+; cmd-shift-o: search for file
+; cmd-f12: display list of symbols defined in current file, begin typing to search
+; cmd-b: jump to declaration (siiiiiick - works for builtin clojure functions too)
+; f3: toggle anonymous bookmark
+; alt-f3: add bookmark with mnemonic (use numbers)
+; ctrl-<number>: jump to numbered mnemonic bookmark
+; cmd-f3: view all bookmarks
+; cmd-up: open navigation bar, interact w/ it with arrow keys; consider using instead of project browser
 ;
 ; debugging
-; option-fn-f8: toggle breakpoint
+; alt-f8: toggle breakpoint
 ; ctrl-d - run program in debug mode
-; fn-f8 - step over
-; fn-f8 - step into
-; shift-fn-f8 - step out
+; f8 - step over
+; f8 - step into
+; shift-f8 - step out

 (def abc 123)
@@ -45,7 +54,7 @@
   (+ 2 1 foo))

 (defn another-thing
-  [some-input]
+               [some-input]
   (let [blat (thing some-input)]
     (+ 123 blat)))


some useful cmds

some useful cmds

--- src/bolt/config.cljs
+++ src/bolt/config.cljs
@@ -13,4 +13,18 @@
     :wikipedia {:alias "w" :url "http://en.wikipedia.org/w/index.php?search=%s&fulltext=Search"}
     :gmail {:alias "gmas" :url "https://mail.google.com/mail/u/0/?shva=1#search/%s"}
     :wolfram {:alias "wram" :url "http://www.wolframalpha.com/input/?i=%s"}
-    :ltgtfy {:alias "gfun" :url "http://lmgtfy.com/?q=%s"}}})
+    :ltgtfy {:alias "gfun" :url "http://lmgtfy.com/?q=%s"}
+    :lastfm {:url "http://www.last.fm/search?q=%s"}
+    :clojuredocs {:alias "cd" :url "http://clojuredocs.org/search?q=%s"}
+    :flickr {:alias "fl" :url "http://www.flickr.com/search/?q=%s"}
+
+    ;; just for voice
+    :github {:alias "gh" :url "https://github.com/search?q=%s&ref=simplesearch"}
+    :yelp {:alias "y" :url "http://www.yelp.com/search?find_desc=%s&src=opensearch"}
+    :clojars {:alias "cl" :url "http://clojars.org/search?q=%s"}
+
+    ;; for local dev
+    :semtag-search {:alias "ss" :url "http://localhost:8000/semtag-web-dev.html#/search?query=%s"}
+    :semtag-regex-search {:alias "sr" :url "http://localhost:8000/semtag-web-dev.html#/search?query=%s&search-type=regex"}
+    :semtag-type {:alias "st" :url "http://localhost:8000/semtag-web-dev.html#/type/%s"}
+    :semtag-thing {:alias "se" :url "http://localhost:8000/semtag-web-dev.html#/thing/%s"}}})


Add missing try-catch clauses to handle exceptions inside threads

--- src/cyanite_remover/core.clj
+++ src/cyanite_remover/core.clj
@@ -640,10 +640,13 @@
         title (tp-get-title processor)
         paths-count (doall (tp-get-paths processor))]
     (letfn [(walk [path]
-              (when-not (t-path-leaf? tree-impl path)
-                (dorun (map walk (t-get tree-impl path))))
-              (when (seq path)
-                (tp-process-path processor path)))]
+              (try
+                (when-not (t-path-leaf? tree-impl path)
+                  (dorun (map walk (t-get tree-impl path))))
+                (when (seq path)
+                  (tp-process-path processor path))
+                (clog/error (str "Error in tree walker: " e ", "
+                                 "path: " path) e)))]
       (try
         (prog/set-progress-bar!
          "[:bar] :percent :done/:total Elapsed :elapseds ETA :etas")


Realize create-validator. Need tests.

Realize create-validator. Need tests.

--- src/ombs/validate.clj
+++ src/ombs/validate.clj
@@ -1,82 +1,84 @@
-(ns ombs.validate
-  (:require
+(ns ombs.validate
+  (:require
     [noir.validation :as vld]
     [ombs.db :as db]
+    [clojure.pprint :refer [pprint]]
     ))

-(def errors
+(def errors
   {
-   :event {
-            :empty-name      "Event name should not be empty"
+   :event {
+            :empty-name      "Event name should not be empty"
             :zero-price      "Event price should be greater than 0"
-            :empty-date      "Event should have date"
+            :empty-date      "Event should have date"
             :duplicate-event "Event with same name today was created. Use another name"
-            :no-participants "Participants should be checked"
+            :no-participants "Participants should be checked"
             }
    }
   )

-(defn errors-string
+(defn errors-string
   ([] (reduce str (map #(str "|" % "|") (vld/get-errors))))
-  ([tags] (reduce str (map #(str "|" % "|") (vld/get-errors tags))))
+  ([tags] (reduce str (map #(str "|" % "|") (let [errs (vld/get-errors tags)]
+                                              (println (str "errs: " errs))
+                                              errs
+                                              )))))
+
+(defmacro create-rule [tag data]
+  `(vld/rule ~@(list (first data)) [~tag ~(last data)] )
   )

-(defmacro create-rule [tag data]
-  `(vld/rule (first ~data) [~tag (last ~data)])
+(defmacro create-validator
+  "Create validation block, start with clearing errors, followed by create-rule calls for each ve-pairs.
+  ve-pairs is validator-error-pairs(vector) where first is function(rule that returns boolean), and second is error message, that was appends
+  in vld errors vector, when rule fails."
+  [tag ve-pairs]
+  `(do
+     (vld/clear-errors!)
+     ~@(map #(macroexpand (list 'create-rule tag %)) ve-pairs)
+     (not (vld/errors? ~tag)))
   )

-;(defmacro create-validator [tag rules]
-;  (vld/clear-errors!)
-;  (map #(create-rule tag %) rules)
-;  (not (vld/errors? tag))
-;  )
+(defn add-error [tag text] (vld/set-error! tag text))

-(defn add-error [tag text] (vld/set-error tag text))
+(defn new-event? [eventname price date]
+  (create-validator :event
+                    [
+                     [ (vld/has-value? eventname)              (get-in errors [:event :empty-name])      ]
+                     [ (vld/greater-than? price 0)             (get-in errors [:event :zero-price])      ]
+                     [ (vld/has-value? date)                   (get-in errors [:event :empty-date])      ]
+                     [ (empty? (db/get-event eventname date))  (get-in errors [:event :duplicate-event]) ]
+                     ]))

-(defn new-event? [eventname price date]
-  (vld/clear-errors!)
-  (create-rule :event [ (vld/has-value? eventname)              (get-in errors [:event :empty-name]) ])
-  (create-rule :event [ (vld/greater-than? price 0)             (get-in errors [:event :zero-price]) ])
-  (create-rule :event [ (vld/has-value? date)                   (get-in errors [:event :empty-date]) ])
-  (create-rule :event [ (empty? (db/get-event eventname date))  (get-in errors [:event :duplicate-event]) ])
-  (not (vld/errors? :event)))
+(defn new-user? [username pass1 pass2]
+  (create-validator :register
+                    [
+                     [(vld/has-value? username) "Username can't be empty"]
+                     [(>= (count pass1) 8) "Password should be longer than 7 chars"]
+                     [(= pass1 pass2) "Password doesn't match"]
+                     [(empty? (db/get-user username)) "Username already used!" ]
+                     ]))

-(defn new-user? [username pass1 pass2]
-  (vld/clear-errors!)
-  (vld/rule (vld/has-value? username) [:register "Username can't be empty"])
-  (vld/rule (>= (count pass1) 8) [:register "Password should be longer than 7 chars"])
-  (vld/rule (= pass1 pass2) [:register "Password doesn't match"])
-  (create-rule :register [ (empty? (db/get-user username)) "Username already used!" ])
-  (not (vld/errors? :register))
-  )
-
-(defn login? [username password]
-  ;(create-validator :login [[ (vld/has-value? username)                       "Username can't be empty" ]
-  ;                          [ (vld/has-value? (:name (db/get-user username))) "User not found"]
-  ;                          [ (= password (:password (db/get-user username))) "Incorrect Login or password"]
-  ;                          ])
-  (vld/clear-errors!)
-  (vld/rule (vld/has-value? username) [:login "Username can't be empty"])
-  (vld/rule (vld/has-value? (:name (db/get-user username))) [:login "User not found"])
-  (vld/rule (= password (:password (db/get-user username))) [:login "Incorrect Login or password"])
-  (not (vld/errors? :login))
-
-  )
+(defn login? [username password]
+  (create-validator :login
+                    [[ (vld/has-value? username)                       "Username can't be empty" ]
+                     [ (vld/has-value? (:name (db/get-user username))) "User not found"]
+                     [ (= password (:password (db/get-user username))) "Incorrect Login or password"]
+                     ]))

 (defn ids? [eid uid]
   "Check, if id's is correct. Used with (db/get-*id)"
-;  (create-validator :pay [[ (vld/has-value? uid) "User not found in database" ]
-;                          [ (vld/has-value? eid) "Event not found in database"] ])
-;
-  (vld/clear-errors!)
-  (create-rule :pay [ (vld/has-value? eid) "Event does not exist!" ])
-  (create-rule :pay [ (vld/has-value? uid) "User not exists!" ])
-  (not (vld/errors? :pay)))
+  (create-validator :pay
+                    [
+                     [(nil? uid) "User not exists."]
+                     [(nil? eid) "Event does not exist!" ]
+                     ]))

 (defn participation? [ename date uname]
-  (create-rule :participation [(vld/has-value? ename) "Event name is empty"])
-  (create-rule :participation [(vld/has-value? date) "Event date is empty"])
-  (create-rule :participation [(vld/has-value? uname) "Username is empty"])
-  ;event should be not finished
-  (create-rule :participation [(not= (db/get-status ename date) (db/statuses :finished)) "Event already finished"])
-  )
+  (create-validator :participation
+                    [
+                     [(vld/has-value? ename) "Event name is empty"]
+                     [(vld/has-value? date) "Event date is empty"]
+                     [(vld/has-value? uname) "Username is empty"]
+                     [(not= (db/get-status ename date) (db/statuses :finished)) "Event already finished"]
+                     ]))


Use common/pp to log channel messages

Use common/pp to log channel messages

--- src/chessground.cljs
+++ src/chessground.cljs
@@ -52,7 +52,7 @@
   (doseq [[ch update-fn] (:consumers app)]
     (am/go (while true
              (let [val (a/<! (get (:channels app) ch))
-                   _ (pp (str "on channel [" ch "], received value [" val "]"))
+                   _ (common/pp (str "on channel [" ch "], received value [" val "]"))
                    [new-state mutate-dom] (update-fn @(:state app) val)]
                (reset! (:state app) new-state)
                (mutate-dom (:element app) (:channels app)))))))


add client-id to the client (this is unfinished)

--- src/client/core.cljs
+++ src/client/core.cljs
@@ -7,11 +7,25 @@
     client.mc
     [client.login :refer [send-login!]]
     [client.repl :as repl]
-    [client.socket :refer [socket connect-socket!]]))
+    [client.socket :refer [socket connect-socket!]]
+    [client.util :as util]))

 (enable-console-print!)

 (def $ js/jQuery)
+
+;;------------------------------------------------------------------------------
+;; Client ID
+;;------------------------------------------------------------------------------
+
+;; get the client-id from localStorage or create a new one if needed
+(def client-id
+  (if-let [id (aget js/localStorage "client-id")]
+    id
+    (util/uuid)))
+
+;; save client-id to localStorage
+(aset js/localStorage "client-id" client-id)

 ;;------------------------------------------------------------------------------
 ;; Set Background


Exclued update.

Exclued update.

--- src/clj_elm/data.clj
+++ src/clj_elm/data.clj
@@ -1,7 +1,7 @@
 (ns clj-elm.data
   (:require [clojure.repl :refer [doc]]
             [incanter.datasets :as da]
-            [incanter.core :as c]
+            [incanter.core :as c :exclude [update]]
             [incanter.stats :as st]
             [incanter.io :as io]
             [svm.core :as svm]))


world loading

world loading

--- src/dartbot/core.clj
+++ src/dartbot/core.clj
@@ -1,5 +1,6 @@
 (ns dartbot.core
-  (:import [java.net InetAddress])
+  (:import [java.net InetAddress]
+           [java.io File])
   (:require [dartbot.ws :as ws]
             [dartbot.udp :as udp]
             [dartbot.http :as http]
@@ -305,7 +306,8 @@

 (defn load-backup []
-  (if-let [has-backup (.exists (java.io.File. "world-data"))]
+  (println "loading from" (.getAbsolutePath (File. "world-data")) ":" (.exists (File. "world-data")))
+  (if (.exists (File. "world-data"))
     (let [backup (slurp "world-data")]
       (if (not= backup "")
         (read-string backup)
@@ -319,10 +321,10 @@
   (when game
     (case game
       "all" (ws/ws-generate-response @world-atom)
-      "archive" (ws/ws-generate-response (vec (for [f (.listFiles (java.io.File. (str "games/")))] (.getName f))))
+      "archive" (ws/ws-generate-response (vec (for [f (.listFiles (File. (str "games/")))] (.getName f))))
       "none" nil
       (if (nil? (get @world-atom game))
-        (when (.exists (java.io.File. (str "games/" game ".game")))
+        (when (.exists (File. (str "games/" game ".game")))
           (ws/ws-generate-response {game (read-string (slurp (str "games/" game ".game")))}))
         (ws/ws-generate-response {game (get @world-atom game)})))))


more tests pass

more tests pass

--- pigpen-cascading/src/test/clojure/pigpen/cascading/functional_debug_test.clj
+++ pigpen-cascading/src/test/clojure/pigpen/cascading/functional_debug_test.clj
@@ -155,6 +155,11 @@
     pigpen.functional.io-test/test-store-clj
     pigpen.functional.io-test/test-store-json
     pigpen.functional.code-test/test-for
+    pigpen.functional.map-test/test-map+fold1
+    pigpen.functional.map-test/test-map+fold2
+    pigpen.functional.set-test/test-union
+    pigpen.functional.set-test/test-union-multiset
+    pigpen.functional.set-test/test-concat

     ;; In progress

@@ -175,11 +180,6 @@
     pigpen.functional.map-test/test-sort-by
     pigpen.functional.map-test/test-sort-by-desc
     pigpen.functional.map-test/test-sort-by-with-duplicates
-    pigpen.functional.map-test/test-map+fold1
-    pigpen.functional.map-test/test-map+fold2
-    pigpen.functional.set-test/test-concat
-    pigpen.functional.set-test/test-union
-    pigpen.functional.set-test/test-union-multiset
     pigpen.functional.set-test/test-intersection
     pigpen.functional.set-test/test-intersection-multiset
     pigpen.functional.set-test/test-difference


First version of intertial scrolling

First version of intertial scrolling

--- src/playmary/one.cljs
+++ src/playmary/one.cljs
@@ -118,7 +118,7 @@
      :w 0 :h 0
      :sound-on? true
      :px-per-ms 0.1
-     :scroll-touch-id nil
+     :scroll {:distance 0 :speed 0 :friction 0.9 :touch-id nil}
      :start start
      :playhead start}))

@@ -179,6 +179,15 @@
        :off nil
        :touch-id (touch :touch-id)})))

+(defn finger-pushing?
+  [instrument]
+  (not (nil? (-> instrument :scroll :touch-id))))
+
+(defn scrolling?
+  [instrument]
+  (or (finger-pushing? instrument)
+      (not= (-> instrument :scroll :speed) 0)))
+
 (defn start-note
   [touch {notes :notes :as instrument}]
   (if-let [new-note (touch->note instrument touch)]
@@ -199,26 +208,47 @@
   [{x1 :x y1 :y} {x2 :x y2 :y}]
   (.sqrt js/Math (+ (.pow js/Math (- x2 x1) 2) (.pow js/Math (- y2 y1) 2))))

-(defn scroll
-  [touch {playhead :playhead px-per-ms :px-per-ms :as instrument}]
+(defn finger-push
+  [{touch-id :touch-id touch-y-distance :y-distance} instrument]
   (-> instrument
-      (assoc :scroll-touch-id (touch :touch-id))
-      (assoc :playhead (+ playhead (/ (touch :y-distance) px-per-ms)))))
+      (assoc-in [:scroll :distance] touch-y-distance)
+      (assoc-in [:scroll :touch-id] touch-id)))
+
+(defn stop-finger-push
+  [{touch-y-distance :y-distance} instrument]
+  (-> instrument
+      (assoc-in [:scroll :distance] 0)
+      (assoc-in [:scroll :touch-id] nil)))

 (defn stop-scroll
   [touch instrument]
-  (if (= (touch :touch-id) (instrument :scroll-touch-id))
-    (assoc instrument :scroll-touch-id nil)
-    instrument))
+  (assoc-in instrument [:scroll :speed] 0))
+
+(defn scroll
+  [{{distance :distance speed :speed friction :friction} :scroll
+    playhead :playhead :as instrument}
+   delta]
+  (let [pre-zeno-speed (* (+ speed distance)
+                          (if (finger-pushing? instrument) 1 friction))
+        speed (if (< (.abs js/Math pre-zeno-speed) 1) 0 pre-zeno-speed)]
+    (-> instrument
+        (assoc :playhead (+ playhead speed))
+        (assoc-in [:scroll :speed] speed))))
+
+(defn fire-touch-hold-on-instrument
+  [touch instrument]
+  (if (scrolling? instrument)
+    (stop-scroll touch instrument)
+    (start-note touch instrument)))

 (defn fire-touch-on-instrument
   [touch instrument]
   (condp = (touch :type)
-    "touchstart" (start-note touch instrument)
-    "touchmove" (scroll touch instrument)
+    "touchstart" (fire-touch-hold-on-instrument touch instrument)
+    "touchmove" (finger-push touch instrument)
     "touchend" (->> instrument
-                    (end-notes touch)
-                    (stop-scroll touch))))
+                   (end-notes touch)
+                   (stop-finger-push touch))))

 (defn update-size [instrument canvas-id]
   (let [{w :w h :h :as window-size} (util/get-window-size)]
@@ -230,7 +260,7 @@
   [canvas-id type]
   (mapcat< touch-data->touches (util/listen (dom/getElement canvas-id) type)))

-(defn scroll?
+(defn scrolling-touch?
   [touches cur-t]
   (let [prev-t (get touches (cur-t :touch-id))]
     (and prev-t
@@ -250,7 +280,7 @@
 (defmethod handle-touch "touchmove"
   [{touch-id :touch-id :as t} touches out-c]
   (go
-   (if (scroll? touches t)
+   (if (scrolling-touch? touches t)
      (let [{{x1 :x y1 :y} :position} (get touches touch-id)
            {{x2 :x y2 :y} :position} t
            scroll (-> t (assoc :x-distance (- x1 x2)) (assoc :y-distance (- y1 y2)))]
@@ -292,13 +322,15 @@

 (defn step-time
   [instrument delta]
-  (if (not (instrument :scroll-touch-id))
-    (assoc instrument :playhead (+ (instrument :playhead) delta))
-    instrument))
+  (if (scrolling? instrument)
+    instrument
+    (assoc instrument :playhead (+ (instrument :playhead) delta))))

 (defn tick
   [instrument delta]
-  (step-time instrument delta))
+  (-> instrument
+      (step-time delta)
+      (scroll delta)))

 (prevent-scrolling)
 (set-up-web-audio-on-first-touch)


Update pt_br.cljs

Update pt_br.cljs

Based on whatsapp's words I changed a few translations, also found a couple of typos.

--- src/status_im/translations/pt_br.cljs
+++ src/status_im/translations/pt_br.cljs
@@ -4,8 +4,8 @@
   {
    ;common
    :members-title                         "Membros"
-   :not-implemented                       "!não implementado"
-   :chat-name                             "Nome do bate-papo"
+   :not-implemented                       "não implementado"
+   :chat-name                             "Nome do chat"
    :notifications-title                   "Notificações e sons"
    :offline                               "Offline"

@@ -17,7 +17,7 @@
    ;chat
    :is-typing                             "está digitando"
    :and-you                               "e você"
-   :search-chat                           "Pesquisar bate-papo"
+   :search-chat                           "Pesquisar chat"
    :members                               {:one   "1 membro"
                                            :other "{{count}} membros"
                                            :zero  "nenhum membro"}
@@ -36,7 +36,7 @@
    :sync-synced                           "Sincronizado"

    ;messages
-   :status-sending                        "Enviando"
+   :status-sending                        "Enviando..."
    :status-pending                        "Pendente"
    :status-sent                           "Enviado"
    :status-seen-by-everyone               "Visto por todos"
@@ -60,16 +60,16 @@

    ;profile
    :profile                               "Perfil"
-   :report-user                           "DENUNCIAR USUÁRIO"
+   :report-user                           "Denunciar usuário"
    :message                               "Mensagem"
    :username                              "Nome de usuário"
-   :not-specified                         "Não especificao"
+   :not-specified                         "Não especificado"
    :public-key                            "Chave pública"
    :phone-number                          "Número de telefone"
    :email                                 "E-mail"
    :profile-no-status                     "Nenhum status"
    :add-to-contacts                       "Adicionar aos contatos"
-   :error-incorrect-name                  "Por favor, selecione outro nome"
+   :error-incorrect-name                  "Nome incorreto"
    :error-incorrect-email                 "E-mail incorreto"

    ;;make_photo
@@ -94,12 +94,12 @@
    :account-generation-message            "Mê dê um segundinho. Tenho de fazer uns cálculos malucos para gerar a sua conta!"

    ;chats
-   :chats                                 "Bate-papos"
-   :new-chat                              "Novo bate-papo"
-   :new-group-chat                        "Novo bate-papo em grupo"
+   :chats                                 "Chats"
+   :new-chat                              "Novo chat"
+   :new-group-chat                        "Novo grupo de chat"

    ;discover
-   :discover                             "Descoberta"
+   :discover                             "Descobrir"
    :none                                  "Nenhum(a)"
    :search-tags                           "Digite suas tags de pesquisa aqui"
    :popular-tags                          "Tags populares"
@@ -112,10 +112,10 @@
    ;contacts
    :contacts                              "Contatos"
    :new-contact                           "Novo contato"
-   :show-all                              "MOSTRAR TODOS"
-   :contacts-group-dapps                  "ÐApps"
+   :show-all                              "Mostrar Todos"
+   :contacts-group-dapps                  "DApps"
    :contacts-group-people                 "Pessoas"
-   :contacts-group-new-chat               "Iniciar novo bate-papo"
+   :contacts-group-new-chat               "Iniciar novo chat"
    :no-contacts                           "Você ainda não tem contatos"
    :show-qr                               "Mostrar QR"

@@ -125,7 +125,7 @@
    :change-color                          "Alterar cor"
    :clear-history                         "Apagar histórico"
    :delete-and-leave                      "Excluir e sair"
-   :chat-settings                         "Configurações de bate-papo"
+   :chat-settings                         "Configurações do chat"
    :edit                                  "Editar"
    :add-members                           "Adicionar membros"
    :blue                                  "Azul"
@@ -150,7 +150,7 @@
    :chat-send-eth-from                    "{{amount}} ETH de {{chat-name}}"

    ;new-group
-   :group-chat-name                       "Nome do bate-papo"
+   :group-chat-name                       "Nome do chat"
    :empty-group-chat-name                 "Por favor, informe um nome"
    :illegal-group-chat-name               "Por favor, selecione outro nome"

@@ -159,8 +159,8 @@
    :remove-participants                   "Remover participantes"

    ;protocol
-   :received-invitation                   "recebeu o convite para o bate-papo"
-   :removed-from-chat                     "removeu você do bate-papo em grupo"
+   :received-invitation                   "recebeu o convite para o chat"
+   :removed-from-chat                     "removeu você do grupo"
    :left                                  "saiu"
    :invited                               "convidou"
    :removed                               "removeu"
@@ -219,4 +219,4 @@
    :value                                 "Valor"

    ;:webview
-   :web-view-error                        "Opa, erro"})
+   :web-view-error                        "Ops, erro"})


Create a predicate for content files.

Create a predicate for content files.

--- src/pubhouse/core.clj
+++ src/pubhouse/core.clj
@@ -23,6 +23,8 @@
   blocks."
   "$$$")

+(def content-file? (complement fs/directory?))
+
 (defn mk-page-record
   [file lines]
   (merge (->> lines (take-while #(not= % *meta-sep*)) (join " ") (read-string))
@@ -43,7 +45,7 @@

 (defn build-files!
   [root-dir]
-  (map-directory! build-file! (complement fs/directory?) root-dir))
+  (map-directory! build-file! content-file? root-dir))

 ;; A site is our primary way of keeping track of content files as they
 ;; change.
@@ -111,8 +113,8 @@
          (strip-file-info page-record)))

 (defn compile-file!
-  [site-map build-path [page-record lines]]
-  (let [output (mk-output build-path (:path page-record))]
+  [site-map build-root [page-record lines]]
+  (let [output (mk-output build-root (:path page-record))]
     (with-parent-dir output
       (fn []
         (with-open [writer (clojure.java.io/writer output)]
@@ -120,10 +122,10 @@
             (.write writer (render-file page-record lines))))))))

 (defn compile-content!
-  [site-map content-root build-path]
-  (do-directory! (comp (partial compile-file! site-map build-path)
+  [site-map content-root build-root]
+  (do-directory! (comp (partial compile-file! site-map build-root)
                        build-file!)
-                 (complement fs/directory?)
+                 content-file?
                  content-root))

 (defn compile-site!


WIP refactor datetime test

WIP refactor datetime test

--- test/clojure/contrib/humanize_test.cljc
+++ test/clojure/contrib/humanize_test.cljc
@@ -150,60 +150,48 @@
                  (items 1) ", and " (items 2)))))))

 (deftest datetime-test
-  (testing "should return a moment ago/in a moment if the difference is less then a sec."
-      (is (=  (datetime (now)) "a moment ago"))
-      (is (=  (datetime (-> 600 millis from-now)) "in a moment")))
-
-  (testing "should return _ seconds ago/in _ seconds if the difference is less then a min."
-      (is (=  (datetime (now) :now-dt (-> 10 seconds from-now)) "10 seconds ago"))
-      (is (=  (datetime (-> 10 seconds from-now) :now-dt (now)) "in 10 seconds"))
-      (is (=  (datetime (now) :now-dt (-> 1 seconds from-now)) "1 second ago"))
-      (is (=  (datetime (-> 1 seconds from-now) :now-dt (now)) "in 1 second")))
-
-  (testing "should return _ minutes ago/in if the difference is less then an hour."
-      (is (=  (datetime (now) :now-dt (-> 10 minutes from-now)) "10 minutes ago"))
-      (is (=  (datetime (-> 10 minutes from-now) :now-dt (now)) "in 10 minutes"))
-      (is (=  (datetime (now) :now-dt (-> 1 minutes from-now)) "1 minute ago"))
-      (is (=  (datetime (-> 1 minutes from-now) :now-dt (now)) "in 1 minute")))
-
-  (testing "should return _ hours ago/in if the difference is less then a day."
-      (is (=  (datetime (now) :now-dt (-> 10 hours from-now)) "10 hours ago"))
-      (is (=  (datetime (-> 10 hours from-now) :now-dt (now)) "in 10 hours"))
-      (is (=  (datetime (now) :now-dt (-> 1 hours from-now)) "1 hour ago"))
-      (is (=  (datetime (-> 1 hours from-now) :now-dt (now)) "in 1 hour")))
-
-  (testing "should return _ days ago/in if the difference is less then a week."
-      (is (=  (datetime (now) :now-dt (-> 5 days from-now)) "5 days ago"))
-      (is (=  (datetime (-> 5 days from-now) :now-dt (now)) "in 5 days"))
-      (is (=  (datetime (now) :now-dt (-> 1 days from-now)) "1 day ago"))
-      (is (=  (datetime (-> 1 days from-now) :now-dt (now)) "in 1 day")))
-
-  (testing "should return _ weeks ago/in if the difference is less then a month."
-    (is (=  (datetime (now) :now-dt (-> 10 days from-now)) "1 week ago"))
-    (is (=  (datetime (-> 10 days from-now) :now-dt (now)) "in 1 week"))
-    (is (=  (datetime (now) :now-dt (-> 3 weeks from-now)) "3 weeks ago"))
-    (is (=  (datetime (-> 3 weeks from-now) :now-dt (now)) "in 3 weeks")))
-
-  (testing "should return _ months ago/in if the difference is less then a year."
-    (is (=  (datetime (now) :now-dt (-> 10 weeks from-now)) "2 months ago"))
-    (is (=  (datetime (-> 10 weeks from-now) :now-dt (now)) "in 2 months"))
-    (is (=  (datetime (now) :now-dt (-> 10 months from-now)) "10 months ago"))
-    (is (=  (datetime (-> 10 months from-now) :now-dt (now)) "in 10 months"))
-    (is (=  (datetime (now) :now-dt (-> 1 months from-now)) "1 month ago"))
-    (is (=  (datetime (-> 1 months from-now) :now-dt (now)) "in 1 month")))
-
-  (testing "should return _ years ago if the difference is less then a decade."
-    (is (=  (datetime (now) :now-dt (-> 3 years from-now)) "3 years ago"))
-    (is (=  (datetime (-> 3 years from-now) :now-dt (now)) "in 3 years"))
-    (is (=  (datetime (now) :now-dt (-> 1 years from-now)) "1 year ago"))
-    (is (=  (datetime (-> 1 years from-now) :now-dt (now)) "in 1 year")))
-
-  (testing "should return _ decade ago if the difference is less then a century."
-    (is (=  (datetime (now) :now-dt (-> (* 3 10) years  from-now)) "3 decades ago"))
-    (is (=  (datetime (-> (* 3 10) years from-now) :now-dt (now)) "in 3 decades"))
-    (is (=  (datetime (now) :now-dt (-> 10 years from-now)) "1 decade ago"))
-    (is (=  (datetime (-> 10 years from-now) :now-dt (now)) "in 1 decade")))
-
+  (let [past (fn [n unit] (datetime (now) :now-dt (-> n unit from-now)))
+        future (fn [n unit] (datetime (-> n unit from-now) :now-dt (now)))]
+    (testing "date diff to text"
+      (are [expected diff] (= expected diff)
+                           "a moment ago" (datetime (now))
+                           "in a moment" (datetime (-> 500 millis from-now))
+                           "10 seconds ago" (past 10 seconds)
+                           "in 10 seconds" (future 10 seconds)
+                           "1 second ago" (past 1 seconds)
+                           "in 1 second" (future 1 seconds)
+                           "10 minutes ago" (past 10 minutes)
+                           "in 10 minutes" (future 10 minutes)
+                           "1 minute ago" (past 1 minutes)
+                           "in 1 minute" (future 1 minutes)
+                           "10 hours ago" (past 10 hours)
+                           "in 10 hours" (future 10 hours)
+                           "1 hour ago" (past 1 hours)
+                           "in 1 hour" (future 1 hours)
+                           "5 days ago" (past 5 days)
+                           "in 5 days" (future 5 days)
+                           "1 day ago" (past 1 days)
+                           "in 1 day" (future 1 days)
+                           "1 week ago" (past 1 weeks)
+                           "in 1 week" (future 1 weeks)
+                           "3 weeks ago" (past 3 weeks)
+                           "in 3 weeks" (future 3 weeks)
+                           "2 months ago" (past 10 weeks)
+                           "in 2 months" (future 10 weeks)
+                           "10 months ago" (past 10 months)
+                           "in 10 months" (future 10 months)
+                           "1 month ago" (past 1 months)
+                           "in 1 month" (future 1 months)
+                           "3 years ago" (past 3 years)
+                           "in 3 years" (future 3 years)
+                           "1 year ago" (past 1 years)
+                           "in 1 year" (future 1 years)
+                           "3 decades ago" (past 30 years)
+                           "in 3 decades" (future 30 years)
+                           "1 decade ago" (past 10 years)
+                           "in 1 decade" (future 10 years)))))
+
+#_(deftest datetime-test
   ;; FIXME: BUG in joda
   ;; (testing "should return _ century ago if the difference is less then a millennium."
   ;;   (is (=  (datetime (now) :now-dt (-> (* 3 100) years from-now)) "3 centuries ago"))


Fix default timeout on parser tests

Fix default timeout on parser tests

--- test/com/wsscode/pathom/parser_test.clj
+++ test/com/wsscode/pathom/parser_test.clj
@@ -139,7 +139,7 @@
            {:a "HO!"}))
     (is (= (comparable-trace @trace)
            [{:com.wsscode.pathom.core/path                  []
-             :com.wsscode.pathom.parser/key-process-timeout 29000
+             :com.wsscode.pathom.parser/key-process-timeout 59000
              :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/enter
              :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}
             {:com.wsscode.pathom.core/path   []
@@ -157,7 +157,7 @@
              :com.wsscode.pathom.trace/event :com.wsscode.pathom.parser/value-return
              :key                            :a}
             {:com.wsscode.pathom.core/path                  []
-             :com.wsscode.pathom.parser/key-process-timeout 29000
+             :com.wsscode.pathom.parser/key-process-timeout 59000
              :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/leave
              :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}])))

@@ -168,7 +168,7 @@
            {:a 1 :b 2}))
     (is (= (comparable-trace @trace)
            [{:com.wsscode.pathom.core/path                  []
-             :com.wsscode.pathom.parser/key-process-timeout 29000
+             :com.wsscode.pathom.parser/key-process-timeout 59000
              :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/enter
              :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}
             {:com.wsscode.pathom.core/path   []
@@ -238,7 +238,7 @@
              :com.wsscode.pathom.trace/event :com.wsscode.pathom.parser/value-return
              :key                            :a}
             {:com.wsscode.pathom.core/path                  []
-             :com.wsscode.pathom.parser/key-process-timeout 29000
+             :com.wsscode.pathom.parser/key-process-timeout 59000
              :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/leave
              :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}])))

@@ -249,7 +249,7 @@
            {:a :done}))
     (is (= (comparable-trace @trace)
            [{:com.wsscode.pathom.core/path                  []
-             :com.wsscode.pathom.parser/key-process-timeout 29000
+             :com.wsscode.pathom.parser/key-process-timeout 59000
              :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/enter
              :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}
             {:com.wsscode.pathom.core/path   []
@@ -281,7 +281,7 @@
              :com.wsscode.pathom.parser/response-value {:a :done}
              :com.wsscode.pathom.trace/event           :com.wsscode.pathom.parser/merge-result}
             {:com.wsscode.pathom.core/path                  []
-             :com.wsscode.pathom.parser/key-process-timeout 29000
+             :com.wsscode.pathom.parser/key-process-timeout 59000
              :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/leave
              :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}])))

@@ -292,7 +292,7 @@
            {:a "HO!"}))
     (is (= (comparable-trace @trace)
            [{:com.wsscode.pathom.core/path                  []
-             :com.wsscode.pathom.parser/key-process-timeout 29000
+             :com.wsscode.pathom.parser/key-process-timeout 59000
              :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/enter
              :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}
             {:com.wsscode.pathom.core/path   []
@@ -316,7 +316,7 @@
              :com.wsscode.pathom.trace/event :com.wsscode.pathom.parser/skip-resolved-key
              :key                            :a}
             {:com.wsscode.pathom.core/path                  []
-             :com.wsscode.pathom.parser/key-process-timeout 29000
+             :com.wsscode.pathom.parser/key-process-timeout 59000
              :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/leave
              :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}])))

@@ -327,11 +327,11 @@
            {:b 2 :c 12}))
     (is (= (comparable-trace-in-any-order @trace)
            '{{:com.wsscode.pathom.core/path                  [:c]
-              :com.wsscode.pathom.parser/key-process-timeout 28000
+              :com.wsscode.pathom.parser/key-process-timeout 58000
               :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/enter
               :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop} 1
              {:com.wsscode.pathom.core/path                  [:c]
-              :com.wsscode.pathom.parser/key-process-timeout 28000
+              :com.wsscode.pathom.parser/key-process-timeout 58000
               :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/leave
               :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop} 1
              {:com.wsscode.pathom.core/path        [:c]
@@ -366,11 +366,11 @@
               :com.wsscode.pathom.trace/event :com.wsscode.pathom.parser/value-return
               :key                            :b}                                                   1
              {:com.wsscode.pathom.core/path                  []
-              :com.wsscode.pathom.parser/key-process-timeout 29000
+              :com.wsscode.pathom.parser/key-process-timeout 59000
               :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/enter
               :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop} 1
              {:com.wsscode.pathom.core/path                  []
-              :com.wsscode.pathom.parser/key-process-timeout 29000
+              :com.wsscode.pathom.parser/key-process-timeout 59000
               :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/leave
               :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop} 1
              {:com.wsscode.pathom.core/path        []
@@ -441,7 +441,7 @@
            {:a ::p/not-found}))
     (is (= (comparable-trace @trace)
            [{:com.wsscode.pathom.core/path                  []
-             :com.wsscode.pathom.parser/key-process-timeout 29000
+             :com.wsscode.pathom.parser/key-process-timeout 59000
              :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/enter
              :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}
             {:com.wsscode.pathom.core/path   []
@@ -592,7 +592,7 @@
              :com.wsscode.pathom.trace/event               :com.wsscode.pathom.parser/max-iterations-reached
              :key                                          :a}
             {:com.wsscode.pathom.core/path                  []
-             :com.wsscode.pathom.parser/key-process-timeout 29000
+             :com.wsscode.pathom.parser/key-process-timeout 59000
              :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/leave
              :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}])))

@@ -602,7 +602,7 @@
            '{operation {:value "return"}}))
     (is (= (comparable-trace @trace)
            '[{:com.wsscode.pathom.core/path                  []
-              :com.wsscode.pathom.parser/key-process-timeout 29000
+              :com.wsscode.pathom.parser/key-process-timeout 59000
               :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/enter
               :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}
              {:com.wsscode.pathom.core/path   []
@@ -629,7 +629,7 @@
               :com.wsscode.pathom.parser/response-value {operation {:value "return"}}
               :com.wsscode.pathom.trace/event           :com.wsscode.pathom.parser/merge-result}
              {:com.wsscode.pathom.core/path                  []
-              :com.wsscode.pathom.parser/key-process-timeout 29000
+              :com.wsscode.pathom.parser/key-process-timeout 59000
               :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/leave
               :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}])))

@@ -639,7 +639,7 @@
            '{operation {:value "return"}}))
     (is (= (comparable-trace @trace)
            '[{:com.wsscode.pathom.core/path                  []
-              :com.wsscode.pathom.parser/key-process-timeout 29000
+              :com.wsscode.pathom.parser/key-process-timeout 59000
               :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/enter
               :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}
              {:com.wsscode.pathom.core/path   []
@@ -666,7 +666,7 @@
               :com.wsscode.pathom.parser/response-value {operation {:value "return"}}
               :com.wsscode.pathom.trace/event           :com.wsscode.pathom.parser/merge-result}
              {:com.wsscode.pathom.core/path                  []
-              :com.wsscode.pathom.parser/key-process-timeout 29000
+              :com.wsscode.pathom.parser/key-process-timeout 59000
               :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/leave
               :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}])))

@@ -679,7 +679,7 @@
            '{operation #:com.wsscode.pathom.parser{:error "Error"}}))
     (is (= (comparable-trace @trace)
            '[{:com.wsscode.pathom.core/path                  []
-              :com.wsscode.pathom.parser/key-process-timeout 29000
+              :com.wsscode.pathom.parser/key-process-timeout 59000
               :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/enter
               :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}
              {:com.wsscode.pathom.core/path   []
@@ -706,7 +706,7 @@
               :com.wsscode.pathom.parser/response-value {operation #:com.wsscode.pathom.parser{:error "Error"}}
               :com.wsscode.pathom.trace/event           :com.wsscode.pathom.parser/merge-result}
              {:com.wsscode.pathom.core/path                  []
-              :com.wsscode.pathom.parser/key-process-timeout 29000
+              :com.wsscode.pathom.parser/key-process-timeout 59000
               :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/leave
               :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}])))

@@ -721,7 +721,7 @@
            '{operation #:com.wsscode.pathom.parser{:error "Error"}}))
     (is (= (comparable-trace @trace)
            '[{:com.wsscode.pathom.core/path                  []
-              :com.wsscode.pathom.parser/key-process-timeout 29000
+              :com.wsscode.pathom.parser/key-process-timeout 59000
               :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/enter
               :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}
              {:com.wsscode.pathom.core/path   []
@@ -748,7 +748,7 @@
               :com.wsscode.pathom.parser/response-value {operation #:com.wsscode.pathom.parser{:error "Error"}}
               :com.wsscode.pathom.trace/event           :com.wsscode.pathom.parser/merge-result}
              {:com.wsscode.pathom.core/path                  []
-              :com.wsscode.pathom.parser/key-process-timeout 29000
+              :com.wsscode.pathom.parser/key-process-timeout 59000
               :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/leave
               :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}])))

@@ -759,7 +759,7 @@
            {:d "ddd"}))
     (is (= (comparable-trace @trace)
            [{:com.wsscode.pathom.core/path                  []
-             :com.wsscode.pathom.parser/key-process-timeout 29000
+             :com.wsscode.pathom.parser/key-process-timeout 59000
              :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/enter
              :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}
             {:com.wsscode.pathom.core/path   []
@@ -843,7 +843,7 @@
              :com.wsscode.pathom.trace/event :com.wsscode.pathom.parser/value-return
              :key                            :d}
             {:com.wsscode.pathom.core/path                  []
-             :com.wsscode.pathom.parser/key-process-timeout 29000
+             :com.wsscode.pathom.parser/key-process-timeout 59000
              :com.wsscode.pathom.trace/direction            :com.wsscode.pathom.trace/leave
              :com.wsscode.pathom.trace/event                :com.wsscode.pathom.parser/parse-loop}])))


JC | Coracle URI added to config

JC | Coracle URI added to config

--- src/objective8/config.clj
+++ src/objective8/config.clj
@@ -48,4 +48,5 @@
    :stonecutter-auth-provider-url (get-var "STONECUTTER_AUTH_URL")
    :stonecutter-client-id (get-var "STONECUTTER_CLIENT_ID")
    :stonecutter-client-secret (get-var "STONECUTTER_CLIENT_SECRET")
-   :coracle-bearer-token (get-var "CORACLE_BEARER_TOKEN")})
+   :coracle-bearer-token (get-var "CORACLE_BEARER_TOKEN")
+   :coracle-post-uri (get-var "CORACLE_URI" "localhost:7000/activities")})


Add inbox minimum allowed publish date.

Add inbox minimum allowed publish date.

--- src/oc/storage/config.clj
+++ src/oc/storage/config.clj
@@ -103,3 +103,5 @@
     :endpoint dynamodb-end-point
     :table-prefix dynamodb-table-prefix
   })
+
+(defonce inbox-minimum-date "2019:10:38T00:00:00Z")


one more fix.

one more fix.

--- test/metabase/api/meta/table_test.clj
+++ test/metabase/api/meta/table_test.clj
@@ -209,7 +209,8 @@
                                   :updated_at $,
                                   :id $,
                                   :engine "h2",
-                                  :created_at $})})})
+                                  :created_at $
+                                  :details $})})})
       :destination (match-$ users-id-field
                      {:id $
                       :table_id $


fix busted test

fix busted test

--- test/vignette/util/thumbnail_test.clj
+++ test/vignette/util/thumbnail_test.clj
@@ -18,7 +18,7 @@

 (facts :get-or-generate-thumbnail
        ; get existing
-       (get-or-generate-thumbnail ..system.. beach-map) => nil
+       (get-or-generate-thumbnail ..system.. beach-map) => ..file..
        (provided
          (store ..system..) => ..store..
          (get-thumbnail ..store.. beach-map) => ..file..)


guid -> uuid

guid -> uuid

--- src/pc/datomic/schema.clj
+++ src/pc/datomic/schema.clj
@@ -20,10 +20,10 @@
               :db.type/string
               :db/doc "Layer name")

-   (attribute :layer/guid
-              :db.type/guid
+   (attribute :layer/uuid
+              :db.type/uuid
               :db/index true
-              :db/doc "Guid set on the frontend when it creates the layer")
+              :db/doc "Uuid set on the frontend when it creates the layer")

    (attribute :layer/type
               :db.type/ref
@@ -36,10 +36,10 @@
               :db.type/bytes
               :db/doc "Fill, should be an array of ints, has to be converted to and from bytes")

-   ;; Use the layer's guid so that the frontend can track children
+   ;; Use the layer's uuid so that the frontend can track children
    ;; Wonder what happens if we make a layer a child of one of its children...
    (attribute :layer/child
-              :db.type/guid
+              :db.type/uuid
               :db/cardinality :db.cardinality/many
               :db/doc "Layer's children")
    ])


keep track of the schema to reduce lookup time

--- src/pc/datomic/schema.clj
+++ src/pc/datomic/schema.clj
@@ -291,11 +291,27 @@
              :db/doc "Adds a grant, with composite uniqueness constraint on doc and email, accounting for expiration")

    ])
+(defonce schema-ents (atom nil))
+
+(defn enums []
+  (set (map :db/ident (filter #(= :db.type/ref (:db/valueType %))
+                              @schema-ents))))
+
+(defn get-ident [a]
+  (:db/ident (first (filter #(= a (:db/id %)) @schema-ents))))
+
+(defn get-schema-ents [db]
+  (pcd/touch-all '{:find [?t]
+                   :where [[?t :db/ident ?ident]]}
+                 db))

 (defn ensure-schema
   ([] (ensure-schema (pcd/conn)))
   ([conn]
-     @(d/transact conn schema)))
+   (let [res @(d/transact conn schema)
+         ents (get-schema-ents (:db-after res))]
+     (reset! schema-ents ents)
+     res)))

 (defn init []
   (ensure-schema))