cleaned up :integer type

cleaned up :integer type

--- src/push/types/base/integer.clj
+++ src/push/types/base/integer.clj
@@ -19,7 +19,6 @@
 ;; INSTRUCTIONS

-
 (def integer-abs (t/simple-1-in-1-out-instruction
   "`:integer-abs` pushes the absolute value of the top `:integer` item"
   :integer "abs" 'math/abs))
@@ -41,32 +40,6 @@
     (d/calculate [:arg]
       #(into '() (reverse (exotics/integer-to-truth-table (math/abs %1) 1))) :as :bits)
     (d/push-onto :exec :bits)))
-
-
-
-(def integer->bits
-  (core/build-instruction
-    integer->bits
-    "`:integer->bits` pops the top `:integer` and pushes a vector of its 'bits' (as `true` and `false` in low-to-high order) to the `:booleans` stack. Negative numbers are made positive. The minimal binary representation is used, but always at least two bits are produced."
-    :tags #{:numeric :conversion}
-    (d/consume-top-of :integer :as :arg)
-    (d/calculate [:arg]
-      #(exotics/integer-to-truth-table (math/abs %1) 1) :as :bits)
-    (d/push-onto :booleans :bits)))
-
-
-
-
-(def integer->numerals
-  (core/build-instruction
-    integer->numerals
-    "`:integer->numerals` pops the top `:integer` and pushes a vector of its numerals (not including negative sign or bigint decorations) to `:chars` "
-    :tags #{:numeric :conversion}
-    (d/consume-top-of :integer :as :arg)
-    (d/calculate [:arg]
-      #(into [] (filter #{\0 \1 \2 \3 \4 \5 \6 \7 \8 \9} (seq (str %1)))) :as :numbers)
-    (d/push-onto :chars :numbers)))
-

@@ -134,6 +107,7 @@
     (d/push-onto :integer :scaled)))

+
 (def integer-many
   (core/build-instruction
     integer-many
@@ -142,6 +116,7 @@
     (d/consume-top-of :integer :as :arg)
     (d/calculate [:arg] #(mod %1 1000) :as :scaled)
     (d/push-onto :integer :scaled)))
+

 (def integer-mod
@@ -157,8 +132,8 @@
     (d/push-these-onto :integer [:replacement :remainder])
     (d/calculate [:denominator]
       #(if (zero? %1) ":integer-mod 0 denominator" nil) :as :warning)
-    (d/record-an-error :from :warning)
-    ))
+    (d/record-an-error :from :warning)))
+

 (def integer-multiply (t/simple-2-in-1-out-instruction
@@ -166,6 +141,7 @@
   :integer  "multiply" '*'))

+
 (def integer-sign (t/simple-1-in-1-out-instruction
   "`:integer-sign` examines the top `:integer` item, and pushes -1 if negative, 0 if zero, and 1 if positive"
   :integer  "sign" 'sign))
@@ -182,11 +158,24 @@
     (d/push-onto :integer :scaled)))

+
 (def integer-subtract (t/simple-2-in-1-out-instruction
   "`:integer-subtract` pops the top two `:integer` items, and pushes their difference, subtracting the top from the second" :integer "subtract" '-'))

-;; conversion
+
+(def integer-totalistic3
+  (core/build-instruction
+    integer-totalistic3
+    "`:integer-totalistic3` pops the top `:integer`. Each digit is replaced by the sum of its current value and the two neighbors to the right, modulo 10, wrapping cyclically around the number. If it is negative, the result returned is still negative."
+    :tags #{:numeric :conversion}
+    (d/consume-top-of :integer :as :arg)
+    (d/calculate [:arg] #(exotics/rewrite-digits %1 3) :as :result)
+    (d/push-onto :integer :result)))
+
+
+
+;; CONVERSIONS

 (def boolean->integer
@@ -199,6 +188,7 @@
     (d/push-onto :integer :logic)))

+
 (def boolean->signedint
   (core/build-instruction
     boolean->signedint
@@ -209,6 +199,18 @@
     (d/push-onto :integer :logic)))

+
+(def char->integer
+  (core/build-instruction
+    char->integer
+    "`:char->integer` pops the top `:char` item, and converts it to an (integer) index"
+    :tags #{:base :conversion}
+    (d/consume-top-of :char :as :arg1)
+    (d/calculate [:arg1] #(long %1) :as :int)
+    (d/push-onto :integer :int)))
+
+
+
 (def float->integer
   (core/build-instruction
     float->integer
@@ -219,14 +221,29 @@
     (d/push-onto :integer :int)))

-(def char->integer
-  (core/build-instruction
-    char->integer
-    "`:char->integer` pops the top `:char` item, and converts it to an (integer) index"
-    :tags #{:base :conversion}
-    (d/consume-top-of :char :as :arg1)
-    (d/calculate [:arg1] #(long %1) :as :int)
-    (d/push-onto :integer :int)))
+
+(def integer->bits
+  (core/build-instruction
+    integer->bits
+    "`:integer->bits` pops the top `:integer` and pushes a vector of its 'bits' (as `true` and `false` in low-to-high order) to the `:booleans` stack. Negative numbers are made positive. The minimal binary representation is used, but always at least two bits are produced."
+    :tags #{:numeric :conversion}
+    (d/consume-top-of :integer :as :arg)
+    (d/calculate [:arg]
+      #(exotics/integer-to-truth-table (math/abs %1) 1) :as :bits)
+    (d/push-onto :booleans :bits)))
+
+
+
+(def integer->numerals
+  (core/build-instruction
+    integer->numerals
+    "`:integer->numerals` pops the top `:integer` and pushes a vector of its numerals (not including negative sign or bigint decorations) to `:chars` "
+    :tags #{:numeric :conversion}
+    (d/consume-top-of :integer :as :arg)
+    (d/calculate [:arg]
+      #(into [] (filter #{\0 \1 \2 \3 \4 \5 \6 \7 \8 \9} (seq (str %1)))) :as :numbers)
+    (d/push-onto :chars :numbers)))
+

 (def string->integer
@@ -239,21 +256,6 @@
       #(try (Long/parseLong %1) (catch NumberFormatException _ nil))
         :as :result)
     (d/push-onto :integer :result)))
-
-
-;; exotic
-
-
-(def integer-totalistic3
-  (core/build-instruction
-    integer-totalistic3
-    "`:integer-totalistic3` pops the top `:integer`. Each digit is replaced by the sum of its current value and the two neighbors to the right, modulo 10, wrapping cyclically around the number. If it is negative, the result returned is still negative."
-    :tags #{:numeric :conversion}
-    (d/consume-top-of :integer :as :arg)
-    (d/calculate [:arg] #(exotics/rewrite-digits %1 3) :as :result)
-    (d/push-onto :integer :result)))
-
-

 (def integer-type


Minor formatting change

Minor formatting change

--- src/io/aviso/twixt.clj
+++ src/io/aviso/twixt.clj
@@ -25,9 +25,15 @@
 (defprotocol Twixt
   "Captures the configuration and logic for asset access and transformation."

-  (get-asset-uri [this asset-path] "Given an asset path (under the configured asset root), returns the URI that can be used to access the asset, or null if the asset does not exist.")
-  (get-streamable [this path] "Gets the Streamable defined by the path. May return nil if the path does not map to a streamable.")
-  (create-middleware [this] "Creates a Ring middleware function (a function that takes and returns a Ring handler function)."))
+  (get-asset-uri
+    [this asset-path]
+    "Given an asset path (under the configured asset root), returns the URI that can be used to access the asset, or null if the asset does not exist.")
+  (get-streamable
+    [this path]
+    "Gets the Streamable defined by the path. May return nil if the path does not map to a streamable.")
+  (create-middleware
+    [this]
+    "Creates a Ring middleware function (a function that takes and returns a Ring handler function)."))

 (defn- wrap-cache-handler [delegate]
   (let [streamable-cache (atom {})]


Remove unneeded logging.

Remove unneeded logging.

--- src/ruuvi_server/client_api.clj
+++ src/ruuvi_server/client_api.clj
@@ -120,7 +120,6 @@
         ids (util/remove-nil-values {:tracker_ids tracker-ids
              :event_session_ids session-ids})
         ]
-    (info "IDS" ids)
     (json-response request (select-event-sessions-data {:event_sessions (db/get-event-sessions ids)} ))))


Use transients for better caching performance

--- src/reagent/ratom.cljs
+++ src/reagent/ratom.cljs
@@ -5,7 +5,6 @@
             [reagent.debug :refer-macros [dbg log warn error dev?]]))

 (declare ^:dynamic *ratom-context*)
-(defonce cached-reactions {})
 (defonce ^boolean debug false)
 (defonce ^boolean silent false)
 (defonce generation 0)
@@ -18,8 +17,7 @@
 ;;; Utilities

 (defn running []
-  (+ @-running
-     (count cached-reactions)))
+  (+ @-running))

 (defn capture-derefed [f obj]
   (set! (.-cljsCaptured obj) nil)
@@ -177,34 +175,47 @@

 (declare make-reaction)

-(defn- cached-reaction [f key obj destroy]
-  (if-some [r (get cached-reactions key)]
-    (-deref r)
-    (if-not (nil? *ratom-context*)
-      (let [r (make-reaction
-               f :on-dispose (fn [x]
-                               (set! cached-reactions
-                                     (dissoc cached-reactions key))
-                               (when-not (nil? obj)
-                                 (set! (.-reaction obj) nil))
-                               (when-not (nil? destroy)
-                                 (destroy x))
-                               nil))
-            v (-deref r)]
-        (set! cached-reactions (assoc cached-reactions key r))
-        (when-not (nil? obj)
-          (set! (.-reaction obj) r))
-        v)
-      (f))))
-
-(deftype Track [f key ^:mutable reaction]
+(defonce cached-reactions (transient {}))
+
+(defn- cached-reaction [f k1 k2 obj destroy]
+  (let [m (if-some [v (get cached-reactions k1)]
+            v
+            (let [newm (transient {})]
+              (assoc! cached-reactions k1 newm)
+              newm))]
+    (if-some [r (get m k2)]
+      (-deref r)
+      (if-not (nil? *ratom-context*)
+        (let [r (make-reaction
+                 f :on-dispose (fn [x]
+                                 (when debug (swap! -running dec))
+                                 (let [m (get cached-reactions k1)]
+                                   (->> (dissoc! m k2)
+                                        (assoc! cached-reactions k1)
+                                        (set! cached-reactions)))
+                                 (when-not (nil? obj)
+                                   (set! (.-reaction obj) nil))
+                                 (when-not (nil? destroy)
+                                   (destroy x))
+                                 nil))
+              v (-deref r)]
+          (->> (assoc! m k2 r)
+               (assoc! cached-reactions k1)
+               (set! cached-reactions))
+          (when debug (swap! -running inc))
+          (when-not (nil? obj)
+            (set! (.-reaction obj) r))
+          v)
+        (f)))))
+
+(deftype Track [f args ^:mutable reaction]
   IReactiveAtom

   IDeref
   (-deref [this]
     (if-some [r reaction]
       (-deref r)
-      (cached-reaction f key this nil)))
+      (cached-reaction #(apply f args) f args this nil)))

   IEquiv
   (-equiv [_ other]
@@ -218,7 +229,7 @@
   (-pr-writer [a w opts] (pr-atom a w opts "Track:")))

 (defn make-track [f args]
-  (Track. #(apply f args) [f args] nil))
+  (Track. f args nil))

 (defn make-track! [f args]
   (let [t (make-track f args)
@@ -267,7 +278,7 @@
                      (let [f (if (satisfies? IDeref ratom)
                                #(get-in @ratom path)
                                #(ratom path))]
-                       (cached-reaction f [::cursor ratom path] this nil)))]
+                       (cached-reaction f ratom path this nil)))]
       (._set-state this oldstate newstate)
       newstate))

@@ -318,7 +329,7 @@

 (defn with-let-values [key]
   (if-some [c *ratom-context*]
-    (cached-reaction array [(reaction-key c) key]
+    (cached-reaction array key (reaction-key c)
                      nil with-let-destroy)
     (array)))


Write log before savegame

Write log before savegame

--- src/robinson/error.clj
+++ src/robinson/error.clj
@@ -19,14 +19,15 @@
   (try
     (let [log-path (str "log/" h ".log")
           save-path (str "log/" h ".edn")]
-      (with-open [o (io/output-stream save-path)]
-        (nippy/freeze-to-out! (DataOutputStream. o) (get state :world)))
       (with-open [o (io/writer (io/output-stream log-path))]
         (binding [*out* o]
           (log/error (str "Keyin:" keyin))
+          (log/error (str "Current-State:" (get-in state [:world :current-state])))
           (log/error (str e))
           (st/print-stack-trace e)
-          (st/print-cause-trace e))))
+          (st/print-cause-trace e)))
+      (with-open [o (io/output-stream save-path)]
+        (nippy/freeze-to-out! (DataOutputStream. o) (get state :world))))
     (catch Throwable t
       (log/error t))))


Remove if-cljs macro

Remove if-cljs macro

--- src/konserve/core.cljc
+++ src/konserve/core.cljc
@@ -8,18 +8,6 @@
             [clojure.core.async :refer [chan poll! put! <! go]])
   #?(:cljs (:require-macros [konserve.core :refer [go-locked]])))

-
-(defn- cljs-env?
-  "Take the &env from a macro, and tell whether we are expanding into cljs."
-  [env]
-  (boolean (:ns env)))
-
-#?(:clj
-   (defmacro if-cljs
-     "Return then if we are generating cljs code and else for Clojure code.
-     https://groups.google.com/d/msg/clojurescript/iBY5HaQda4A/w1lAQi9_AwsJ"
-     [then else]
-     (if (cljs-env? &env) then else)))

 ;; TODO we keep one chan for each key in memory
 ;; as async ops seem to interfere with the atom state changes


fix typo

fix typo

--- src/github_bot_app/action/composite_pr.clj
+++ src/github_bot_app/action/composite_pr.clj
@@ -17,7 +17,7 @@
                 "opened"))
     (let [owner (get-in payload [:repository :owner :login])
           repo (get-in payload [:repository :name])
-          pull-id (get-in payload [:pull_request :numer])
+          pull-id (get-in payload [:pull_request :number])
           commits (github-api-time!
                     (gh-pulls/commits
                      owner repo pull-id


Make arglist check error more explicit.

Make arglist check error more explicit.

--- src/leiningen/core.clj
+++ src/leiningen/core.clj
@@ -45,8 +45,8 @@
                                   :root root#))))
      (def ~(symbol (name project-name)) project)))

-(defn abort [msg]
-  (println msg)
+(defn abort [& msg]
+  (apply println msg)
   (System/exit 1))

 (defn get-home-dir
@@ -124,29 +124,30 @@
       (replace \_ \-)
       (replace \/ \.)))

-(defn arglists [task-name not-found]
-  (:arglists (meta (resolve-task task-name not-found))))
+(defn arglists [task-name]
+  (:arglists (meta (resolve-task task-name))))

-(defn project-needed [task-name not-found]
-  (some #{'project} (map first (arglists task-name not-found))))
+(defn project-needed? [task-name]
+  (some #{'project} (map first (arglists task-name))))

-(defn matching-arity [task-name project args not-found]
-  (let [arg-count (if (project-needed task-name not-found)
+(defn matching-arity? [task-name project args]
+  (let [arg-count (if (project-needed? task-name)
                     (inc (count args))
                     (count args))]
     (some (fn [defined-args]
             (if (= '& (last (butlast defined-args)))
               (>= arg-count (- (count defined-args) 2))
               (= arg-count (count defined-args))))
-      (arglists task-name not-found))))
+      (arglists task-name))))

 (defn apply-task [task-name project args not-found]
   (let [task (resolve-task task-name not-found)]
-    (if (matching-arity task-name project args not-found)
-      (if (project-needed task-name not-found)
+    (if (matching-arity? task-name project args)
+      (if (project-needed? task-name)
         (apply task project args)
         (apply task args))
-      (not-found))))
+      (abort "Wrong number of arguments to" task-name "task."
+             "\nExpected"  (arglists task-name)))))

 (def arg-separator ",")

@@ -167,7 +168,7 @@
 (defn -main
   ([& [task-name & args]]
      (let [task-name (or (@aliases task-name) task-name "help")
-           project (if (project-needed task-name task-not-found) (read-project))
+           project (if (project-needed? task-name) (read-project))
            compile-path (:compile-path project)]
        (when compile-path (.mkdirs (File. compile-path)))
        (binding [*compile-path* compile-path]


refactoring and adding todo's

refactoring and adding todo's

--- dispatcher/src/systems/casemgr/utils/dispatcher/dispatcher.cljs
+++ dispatcher/src/systems/casemgr/utils/dispatcher/dispatcher.cljs
@@ -9,6 +9,27 @@
             [cljsjs.phoenix]
             [goog.events :as events]
             )
+  )
+
+(defn socket-opened [socket publisher v]
+  (println "dispatcher->socket-opened->v:" v)
+  )
+
+(defn generic-server-msg [socket v]
+  (println "dispatcher->generic-server-msg->v:" v)
+                                        ; (.send socket v)
+  )
+
+(defn user-logged-in [socket publisher v]
+  (println "dispatcher->user-logged-in->v:" v)
+  (when (:logged-in v)
+    ))
+
+;; TODO how do we connect to a different channel?
+;; TODO log in should id the shop
+;; TODO one per shop
+;; TODO we need an login for a channel
+(defn login-to-channel[]
   )

 (defn receive-ok [params]
@@ -26,7 +47,8 @@
   (println (aget params "path"))
   (println (aget params "body"))
   )
-;; todo we need to replace this
+;; TODO we need to replace this
+;; TODO save off channel
 (defn ^:private startup
   "Actually connects the web socket to the server and starts the local event loop."
   [cursor owner]
@@ -47,16 +69,14 @@
   )

 ;; call close on the channel or the socket?
+;; TODO Close sockets and channels?
 (defn ^:private shutdown
   "Tears down the web socket connection."
   [{:keys [socket]}]
                                         ; (.close socket)
   )

-;; this is where we do the socket connection and room:lobby
-;; how do we connect to a different channel?
-;; log in should id the shop
-;; one per shop
+;; this is where we do the socket connection
 (defn ^:private make-init-state
   "Creates the initial state for the web socket widget.  In particular, this
   instantiates a WebSocket instance and creates a core.async channel for
@@ -88,20 +108,8 @@
     )
   )

-(defn socket-opened [socket publisher v]
-  (println "dispatcher->socket-opened->v:" v)
-  )
-
-(defn generic-server-msg [socket v]
-  (println "dispatcher->generic-server-msg->v:" v)
-                                        ; (.send socket v)
-  )
-
-(defn user-logged-in [socket publisher v]
-  (println "dispatcher->user-logged-in->v:" v)
-  (when (:logged-in v)
-    ))
-
+;; TODO move the loops and matches out
+;; TODO we need to respond to incoming messages
 (defn ws-widget [cursor owner]
   (reify
     om/IInitState
@@ -116,6 +124,7 @@
       (startup cursor owner))
     om/IDidMount
     (did-mount [_]
+      ;; TODO Subscribe to topic router
       (let [publication (:publication (om/get-shared owner))
             server-message-events (sub publication :server-msg (chan))
             dispatcher-events (sub publication :dispatcher (chan))


backfill correct tests

backfill correct tests

--- test/swanson/utils_test.clj
+++ test/swanson/utils_test.clj
@@ -8,12 +8,12 @@
 (deftest get-csv-test
   (testing "Test basic CSV functionality"
     (let [csv (swanson.utils/get-csv filepath)]
-      (is (= (first csv) ["2014-07-26" "683734.5288" "fake description 1"]))
+      (is (= (first csv) ["2014-07-26" "683734.5288" "" "" "fake description 1"]))
       (is (= (count csv) 2))
-      (is (= (last csv) ["2014-07-27" "730393.8492" "fake description 2"])))))
+      (is (= (last csv) ["2014-07-27" "730393.8492" "" "" "fake description 2"])))))

 (deftest parse-bank-csv
   (testing "test CSV to seq of maps functionality"
     (let [csv (swanson.utils/parse-bank-csv filepath)]
-      (is (= (first csv) {:date "2014-07-26" :amount "683734.5288" :description "fake description 1"}))
-      (is (= (last csv) {:date "2014-07-27" :amount "730393.8492" :description "fake description 2"})))))
+      (is (= (keys (first csv)) [:date :amount :description]))
+      (is (= (vals (last csv)) ["2014-07-27" "730393.8492" "fake description 2"])))))


Respect lower-bound of `choose` during shrinking

--- src/simple_check/generators.clj
+++ src/simple_check/generators.clj
@@ -248,7 +248,9 @@
   (make-gen
     (fn [^Random rnd _size]
       (let [value (rand-range rnd lower upper)]
-        [value (clojure.core/map int-rose-tree (shrink-int value))]))))
+        (rose-filter
+          #(>= % lower)
+          [value (clojure.core/map int-rose-tree (shrink-int value))])))))

 (defn one-of
   "Create a generator that randomly chooses a value from the list of
@@ -339,7 +341,7 @@
 (def int
   "Generates a positive or negative integer bounded by the generator's
   `size` parameter.
-  (Really returns a long."
+  (Really returns a long"
   (sized (fn [size] (choose (- size) size))))

 (def nat


changed defonce to def

changed defonce to def

--- src/server/config.cljs
+++ src/server/config.cljs
@@ -5,4 +5,4 @@
 (defonce fs (nodejs/require "fs"))

 (defn load-file! [filename]
-  (defonce data (js->clj (.parse toml (.readFileSync fs filename)))))
+  (def data (js->clj (.parse toml (.readFileSync fs filename)))))


save sysnteheis

save sysnteheis

--- src/synthesis_crawlers/core.clj
+++ src/synthesis_crawlers/core.clj
@@ -524,7 +524,6 @@
                          (zipmap (map parse-css-selector (keys container-cand-exprs))
                                  (vals container-cand-exprs))
                          threshold)
-        a (println "nodes-in-pages: " nodes-in-pages)
         attr-exprs (generate-attr-exprs container-expr nodes-in-pages pages threshold)]
     {(decode-node-path container-expr) attr-exprs}))

@@ -548,21 +547,5 @@
         (for [[site container-extractor] (filter (fn [[site container-extractor]]
                                                    (incomplete-extractors? container-extractor))
                                                  s-extractors)]
-          (let [nodes-in-pages (find-nodes-in-page (:pages (sites site)) new-knowledge)
-                reachable-attrs (find-reachable-attrs nodes-in-pages)
-                support-nodes (count-support-nodes (find-support-nodes nodes-in-pages))
-                container-cand-nodes (find-container reachable-attrs
-                                                     (find-best-attr-set
-                                                       nodes-in-pages))
-                container-cand-exprs (generate-container-cand-exprs
-                                       container-cand-nodes support-nodes)
-                container-expr (unify-exprs
-                                 (zipmap (map parse-css-selector (keys container-cand-exprs))
-                                         (vals container-cand-exprs))
-                                 threshold)
-                attr-exprs (generate-attr-exprs container-expr nodes-in-pages threshold)]
-            [site {(decode-node-path container-expr) attr-exprs}]
-            ))
-        )
-      )))
-
+          (generate-extractors (:pages (sites site)) new-knowledge threshold))))))
+


Tundra: add TODO for fetch-key rushing

Tundra: add TODO for fetch-key rushing

--- src/taoensso/carmine/tundra.clj
+++ src/taoensso/carmine/tundra.clj
@@ -11,6 +11,11 @@
             [taoensso.timbre        :as timbre]))

 ;; TODO Redis 2.8+ http://redis.io/topics/notifications
+;; TODO Consider implementing some kind of de-dupe mechanism for key fetching
+;; (perhaps a delay map?). The current implementation can result in multiple
+;; threads rushing the datastore to get the same key, unnecessarily duplicating
+;; work. Could solve this easily with a tstore `fetch-key` sm-memoize closure.
+;; Any alternatives that'd avoid the extra code import though?

 ;;;; Public interfaces


restore -init

restore -init

--- ex2b/src/ex2b/filter.clj
+++ ex2b/src/ex2b/filter.clj
@@ -2,6 +2,11 @@
   (:import (javax.servlet Filter FilterChain FilterConfig
                           ServletRequest ServletResponse))
   (:gen-class :implements [javax.servlet.Filter]))
+
+;; since we're implementing an interace rather than extending a class,
+;; all methods must be implemented!
+
+(defn -init [^Filter this ^FilterConfig cfg])

 (defn -doFilter
   [^Filter this


removed old comment

removed old comment

--- src/lights/my_show.clj
+++ src/lights/my_show.clj
@@ -469,7 +469,6 @@
     :short-name "TEST 255"
     ))

-  ; 2DO: write MIDI controlled dimmers, to control lights dimmer from Live
   (ct/set-cue! (:cue-grid *show*) 7 6
     (cues/cue :dimmers (fn [_]
       (afterglow.effects/scene


save video feed

save video feed

--- src/sormilla/video.clj
+++ src/sormilla/video.clj
@@ -91,7 +91,7 @@
     (try
       (while (run?)
         (let [socket      (open-socket)
-              out         (io/output-stream (io/file (str "sormilla-" (.format (java.text.SimpleDateFormat. "yyyyMMdd-HHmmss") (java.util.Date.)) ".h264")))
+              out         (agent (io/output-stream (io/file (str "sormilla-" (.format (java.text.SimpleDateFormat. "yyyyMMdd-HHmmss") (java.util.Date.)) ".h264"))))
               reader      (make-reader (BufferedInputStream. (.getInputStream socket)))
               decoder     (make-decoder)]
           (try
@@ -100,14 +100,14 @@
               (.flush))
             (while (run?)
               (let [data (reader)]
-                #_(save out data)
+                (send-off out save data)
                 (swap! status assoc :image (decoder (second data)))))
             (catch java.io.IOException e
               (println "I/O error:" e ": reconnecting...")
               (Thread/sleep 1000))
             (finally
               (try (.close socket) (catch Exception _))
-              (try (.close ^OutputStream out) (catch Exception _))))))
+              (try (.close ^OutputStream @out) (catch Exception _))))))
       (catch Throwable e
         (println "exception while processing video stream" e)
         (.printStackTrace e))


whitespace cleanup

whitespace cleanup


🏗 Coerce instants on clipboard to ISO format

--- src/territory_bro/migration.clj
+++ src/territory_bro/migration.clj
@@ -15,7 +15,9 @@
             [territory-bro.territory :as territory]
             [territory-bro.user :as user])
   (:import (java.time Instant OffsetDateTime ZoneOffset ZoneId ZonedDateTime)
-           (java.time.format DateTimeFormatter DateTimeParseException)))
+           (java.time.format DateTimeFormatter DateTimeParseException)
+           (java.awt Toolkit)
+           (java.awt.datatransfer DataFlavor StringSelection)))

 (def patterns [(DateTimeFormatter/ofPattern "EE LLL d y H:m:s 'GMT'Z")
                (-> (DateTimeFormatter/ofPattern "d LLL H:m:s y")
@@ -87,6 +89,15 @@
   (log/info "Migrated tenant" tenant))

 (comment
+  (let [cp (-> (Toolkit/getDefaultToolkit)
+               (.getSystemClipboard))
+        in (.getData cp DataFlavor/stringFlavor)
+        time (parse-instant in)
+        out (.toString time)
+        contents (StringSelection. out)]
+    (.setContents cp contents contents)
+    [in out])
+
   (doseq [tenant (keys (:tenant config/env))]
     (binding [events/*current-system* "migration"]
       (migrate-congregation tenant))))


(PDB-3537) Call .await with timeout in admin-clean-test

--- test/puppetlabs/puppetdb/admin_clean_test.clj
+++ test/puppetlabs/puppetdb/admin_clean_test.clj
@@ -7,6 +7,7 @@
             [puppetlabs.puppetdb.cheshire :as json]
             [puppetlabs.puppetdb.cli.services :as cli-svc]
             [puppetlabs.puppetdb.http :as http]
+            [puppetlabs.puppetdb.testutils :refer [default-timeout-ms]]
             [puppetlabs.puppetdb.testutils.db :refer [*db* with-test-db]]
             [puppetlabs.puppetdb.testutils.services :as svc-utils
              :refer [*server*
@@ -16,7 +17,10 @@
             [puppetlabs.trapperkeeper.app :refer [get-service]]
             [puppetlabs.trapperkeeper.services :refer [service-context]])
   (:import
-   [java.util.concurrent CyclicBarrier]))
+   [java.util.concurrent CyclicBarrier TimeUnit]))
+
+(defn await-a-while [x]
+  (.await x default-timeout-ms TimeUnit/MILLISECONDS))

 (defmacro with-pdb-with-no-gc [& body]
   `(with-test-db
@@ -63,17 +67,17 @@
           test-finished (CyclicBarrier. 2)
           cleanup-result (promise)]
       (with-redefs [cli-svc/clean-up (fn [& args]
-                                       (.await in-clean)
-                                       (.await test-finished)
+                                       (await-a-while in-clean)
+                                       (await-a-while test-finished)
                                        (let [result (apply orig-clean args)]
                                             (deliver cleanup-result result)
                                             result))]
         (utils/noisy-future (checked-admin-post "cmd" (clean-cmd [])))
         (try
-          (.await in-clean)
+          (await-a-while in-clean)
           (is (= http/status-conflict (:status (post-clean []))))
           (finally
-            (.await test-finished)
+            (await-a-while test-finished)
             (is (not= ::timed-out
                       (deref cleanup-result 120000 ::timed-out)))))))))

@@ -91,23 +95,23 @@
           after-clear (CyclicBarrier. 2)]
       (with-redefs [cli-svc/clean-puppetdb (fn [& args]
                                              (apply orig-clean args)
-                                             (.await after-clean))
+                                             (await-a-while after-clean))
                     cli-svc/clear-clean-status! (fn [& args]
-                                                  (.await before-clear)
-                                                  (.await after-test)
+                                                  (await-a-while before-clear)
+                                                  (await-a-while after-test)
                                                   (apply orig-clear args)
-                                                  (.await after-clear))]
+                                                  (await-a-while after-clear))]
         (doseq [what (combinations ["expire_nodes" "purge_nodes" "purge_reports" "package_gc" "other"]
                                    3)]
           (let [expected (cli-svc/clean-options->status what)]
             (utils/noisy-future (checked-admin-post "cmd" (clean-cmd what)))
             (try
-              (.await before-clear)
+              (await-a-while before-clear)
               (is (= expected (clean-status)))
               (finally
-                (.await after-test)
-                (.await after-clear)
-                (.await after-clean)))))))))
+                (await-a-while after-test)
+                (await-a-while after-clear)
+                (await-a-while after-clean)))))))))

 (defn- inc-requested [counts requested]
   (into {}


(PDB-3173) Remove vestigial pdb services from admin-clean-test

--- test/puppetlabs/puppetdb/admin_clean_test.clj
+++ test/puppetlabs/puppetdb/admin_clean_test.clj
@@ -46,19 +46,17 @@

 (deftest admin-clean-basic
   (with-pdb-with-no-gc
-    (let [pdb (get-service *server* :PuppetDBServer)]
-      (is (= http/status-ok (:status (post-clean []))))
-      (is (= http/status-ok (:status (post-clean ["expire_nodes"]))))
-      (is (= http/status-ok (:status (post-clean ["purge_nodes"]))))
-      (is (= http/status-ok (:status (post-clean ["purge_reports"]))))
-      (is (= http/status-ok (:status (post-clean ["package_gc"]))))
-      (is (= http/status-ok (:status (post-clean ["other"]))))
-      (is (= http/status-bad-request (:status (post-clean ["?"])))))))
+    (is (= http/status-ok (:status (post-clean []))))
+    (is (= http/status-ok (:status (post-clean ["expire_nodes"]))))
+    (is (= http/status-ok (:status (post-clean ["purge_nodes"]))))
+    (is (= http/status-ok (:status (post-clean ["purge_reports"]))))
+    (is (= http/status-ok (:status (post-clean ["package_gc"]))))
+    (is (= http/status-ok (:status (post-clean ["other"]))))
+    (is (= http/status-bad-request (:status (post-clean ["?"]))))))

 (deftest admin-clean-competition
   (with-pdb-with-no-gc
-    (let [pdb (get-service *server* :PuppetDBServer)
-          orig-clean cli-svc/clean-up
+    (let [orig-clean cli-svc/clean-up
           in-clean (CyclicBarrier. 2)
           test-finished (CyclicBarrier. 2)
           cleanup-result (promise)]
@@ -82,8 +80,7 @@

 (deftest admin-clean-status
   (with-pdb-with-no-gc
-    (let [pdb (get-service *server* :PuppetDBServer)
-          orig-clean @#'cli-svc/clean-puppetdb
+    (let [orig-clean @#'cli-svc/clean-puppetdb
           after-clean (CyclicBarrier. 2)
           orig-clear @#'cli-svc/clear-clean-status!
           before-clear (CyclicBarrier. 2)
@@ -137,14 +134,14 @@

 (defn- check-counts [get-counts]
   (with-pdb-with-no-gc
-    (let [pdb (get-service *server* :PuppetDBServer)]
-      (doseq [requested (combinations ["expire_nodes" "purge_nodes" "purge_reports" "package_gc" "other"]
-                                      3)]
-        (let [requested (set requested)
-              before (get-counts)
-              expected (inc-requested before requested)]
-          (checked-admin-post "cmd" (clean-cmd requested))
-          (is (= expected (get-counts))))))))
+    (doseq [requested (combinations ["expire_nodes" "purge_nodes"
+                                     "purge_reports" "package_gc" "other"]
+                                    3)]
+      (let [requested (set requested)
+            before (get-counts)
+            expected (inc-requested before requested)]
+        (checked-admin-post "cmd" (clean-cmd requested))
+        (is (= expected (get-counts)))))))

 (deftest admin-clean-counts (check-counts clean-counts))
 (deftest admin-clean-timers (check-counts clean-timer-counts))


(PDB-5484) storage-test: remove (comment ...) block

Apparently the current version of clj-kondo doesn't ignore it.

--- test/puppetlabs/puppetdb/scf/storage_test.clj
+++ test/puppetlabs/puppetdb/scf/storage_test.clj
@@ -185,27 +185,6 @@
                    :producer producer})
       (is (= facts (factset-map "some_certname"))))))

-(comment
-  (def certname "some_certname")
-  (def facts {"domain" "mydomain.com"
-              "fqdn" "myhost.mydomain.com"
-              "hostname" "myhost"
-              "kernel" "Linux"
-              "operatingsystem" "Debian"})
-
-  (def new-facts {"domain" "mynewdomain.com"
-                  "fqdn" "myhost.mynewdomain.com"
-                  "hostname" "myhost"
-                  "kernel" "Linux"
-                  "uptime_seconds" 3600})
-
-  (def producer "bar.com")
-
-  (alter-var-root #'*db*
-                  (constantly jdbc/*db*))
-
-  )
-
 (defn delete-certname-facts!
   [certname]
   (jdbc/do-prepared "delete from factsets where certname = ?" [certname]))


use regexp for origin check

use regexp for origin check

--- src/wombats/components/pedestal.clj
+++ src/wombats/components/pedestal.clj
@@ -26,9 +26,9 @@
      ::http/file-path "/public"
      ::http/allowed-origins (if (contains? #{:dev :dev-ddb} env)
                               (fn [origin] true)
-                              ["qa.wombats.io"
-                               "wombats.io"
-                               "docs.wombats.io"])
+                              (fn [origin]
+                                (or (re-matches #".wombats.io" origin)
+                                    (re-matches #"//wombats.io" origin))))
      ::http/routes api-routes
      ::http/port port
      ::http/type type


unique iref keys

unique iref keys

--- src/minreact/core.cljs
+++ src/minreact/core.cljs
@@ -92,22 +92,26 @@
      (or (not= next-props props)
          (not= next-state state)))))

-;; TODO: Fix: Can't use the same watch key if iref ends up bound in
-;; multiple components
-
 ;; TODO: One should be allowed to specifiy a getter that is watched
 ;; explicitly as an optimization.  In the normal usecase this would be
 ;; a keyword.

 (defn- install-watch [c iref]
-  (set-state! c iref @iref)
-  (add-watch iref ::watch
-             (fn [_ r _ n]
-               (set-state! c r n))))
+  (let [k (gensym "minreact-watch__")]
+    (transact-state! c (fn [s]
+                         (-> s
+                             (update-in [:watches iref] k)
+                             (assoc iref @iref))))
+    (add-watch iref k
+               (fn [_ r _ n]
+                 (set-state! c r n)))))

 (defn- uninstall-watch [c iref]
-  (remove-watch iref ::watch)
-  (transact-state! c iref dissoc iref))
+  (remove-watch iref (get-in (state c) [:watches iref]))
+  (transact-state! c (fn [s]
+                       (-> s
+                           (dissoc iref)
+                           (update :watches dissoc iref)))))

 (defreact watch-irefs
   "React component that watches changes of irefs and invokes


reduce dubstepbass volume now that limiter is more sensitive

--- examples/dubstepbass.clj
+++ examples/dubstepbass.clj
@@ -52,6 +52,7 @@
             son (select (< (t-rand:kr :trig trig) 0.05) [son (round son 0.1)])

             son (tanh (* son 5))
-            son (+ son (* 0.3 (g-verb son 10 0.1 0.7)))]
+            son (+ son (* 0.3 (g-verb son 10 0.1 0.7)))
+            son (* 0.3 son)]

         [son son]))


Add util fns to turn SCUgen trees into simple nested maps.

--- src/overtone/sc/machinery/ugen/sc_ugen.clj
+++ src/overtone/sc/machinery/ugen/sc_ugen.clj
@@ -1,5 +1,8 @@
-(ns
-    ^{:doc "Records and fns for representing SCUgens. These are to be distinguised with ugens which are Overtone functions which compile down into SCUGens. Trees of SCUGens can then, in turn, be compiled down into a binary synth format for shipping to SCServer."
+(ns ^{:doc "Records and fns for representing SCUgens. These are to be
+            distinguished from ugens which are Overtone functions which
+            compile down into SCUGens. Trees of SCUGens can then, in
+            turn, be compiled down into a binary synth format for
+            shipping to SCServer."
       :author "Sam Aaron"}
     overtone.sc.machinery.ugen.sc-ugen
   (:use [overtone.sc.machinery.ugen defaults]
@@ -81,3 +84,20 @@
 (defn output-proxy?
   [obj]
   (isa? (type obj) ::output-proxy))
+
+(defn mappify-ugen
+  "Converts all nested SCUgen records into maps creating a data
+   structure that can play more nicely with Clojure's functions"
+  [scug]
+  (if (map? scug)
+    (assoc
+        (into {} scug) :args (map mappify-ugen (:args scug)))
+    scug))
+
+(defn simplify-ugen
+  "Turns SCUgen-tree into a simple map of maps and removes all specs"
+  [scug]
+  (if (map? scug)
+    (assoc
+        (dissoc (into {} scug) :spec) :args (map simplify-ugen (:args scug)))
+    scug))


Add gs-dowload dialog to the task input/output display.

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/monitor/workflow_details.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/monitor/workflow_details.cljs
@@ -3,6 +3,7 @@
     [dmohs.react :as react]
     [org.broadinstitute.firecloud-ui.common :as common]
     [org.broadinstitute.firecloud-ui.common.components :as comps]
+    [org.broadinstitute.firecloud-ui.common.dialog :as dialog]
     [org.broadinstitute.firecloud-ui.common.icons :as icons]
     [org.broadinstitute.firecloud-ui.common.style :as style]
     [org.broadinstitute.firecloud-ui.endpoints :as endpoints]
@@ -34,7 +35,10 @@
       (when (:expanded @state)
         [:div {:style {:padding "0.25em 0 0.25em 1em"}}
          (for [[k v] (:data props)]
-           [:div {} k [:span {:style {:margin "0 1em"}} "→"] v])])])})
+           [:div {} k [:span {:style {:margin "0 1em"}} "→"]
+            (if-let [parsed (common/parse-gcs-uri v)]
+              [dialog/GCSFilePreviewLink (assoc parsed :gcs-uri v)]
+              v)])])])})

 (react/defc CallDetail


(maint) - Add sender endpoint to client message

--- src/puppetlabs/cthun/connection_states.clj
+++ src/puppetlabs/cthun/connection_states.clj
@@ -108,13 +108,13 @@
       "http://puppetlabs.com/loginschema" (process-login-message host ws message-body)
       (log/warn "Invalid server message type received: " data-schema))))

-; Forwards a message to the defined endpoints. Getting the endpoints is left as an exercise
-; to the reader.
+; Forwards a message to the defined endpoints.
 (defn- process-client-message
   "Process a message directed at a connected client"
   [host ws message-body]
   (doseq [websocket (parse-endpoints (:endpoints message-body) @endpoint-map)]
-    (jetty-adapter/send! websocket (cheshire/generate-string message-body))))
+    (let [modified-body (assoc message-body :sender (:endpoint (get (get @connection-map host) ws)))]
+      (jetty-adapter/send! websocket (cheshire/generate-string modified-body))))

  (defn- logged-in?
   "Determine if host/websocket combination has logged in"


own comments are also now messages which youve commented

--- src/ontrail/unread.clj
+++ src/ontrail/unread.clj
@@ -20,7 +20,11 @@
   (sort-by :lastModifiedDate time/after? (filter identity (map find-exercise (get-oids user)))))

 (defn comments-all [user]
-  (ex/decorate-results user (get-unread-objs user)))
+  (ex/decorate-results user (take 100 (get-unread-objs user))))
+
+(defn is-own [user ex]
+  (or (= user (:user ex))
+      (contains? (set (map :user (:comments ex))) user)))

 (defn comments-own [user]
-  (ex/decorate-results user (filter #(= (:user %) user) (get-unread-objs user))))
+  (ex/decorate-results user (filter (partial is-own user) (get-unread-objs user))))


remove dead code

remove dead code

--- src/paredit/parser.clj
+++ src/paredit/parser.clj
@@ -18,8 +18,12 @@
 (defn eof [s eof?]
   (when (and (= 0 (.length ^String s)) eof?) [0 eof]))

-(defn bracket-end [s eof?]
-  (lr+/match #{")" "]" "}" eof} s eof?))
+#_(reify MatcherFactory
+  (matcher-fn [this id]
+    (fn [s eof?] (when (and (= 0 (.length ^String s)) eof?) [0 id]))))
+
+;(defn bracket-end [s eof?]
+;  (lr+/match #{")" "]" "}" eof} s eof?))

 (def gspaces #{:whitespace :comment :discard})
 (def only-code (partial remove (comp (conj gspaces


feat: extra stats and info

feat: extra stats and info


adjusted logo position and site title padding

--- src/prais2/chrome.cljc
+++ src/prais2/chrome.cljc
@@ -90,9 +90,11 @@
      [:img.img-responsive.pull-left {:src   "/assets/logo3.png"
                                      :style {:margin-top     "-50px"
                                              :padding-bottom "10px"
+                                             :padding-right "20px"
                                              :transform      "rotate(180deg)"
                                              }}]]
     [:.pull-left.main-title
+     {:style {:padding-right "40px"}}
      "UNDERSTANDING CHILDREN'S HEART SURGERY OUTCOMES"]


add ip

add ip

--- src/publisher/core.clj
+++ src/publisher/core.clj
@@ -77,7 +77,7 @@
 (def disqus-comment-count-code "<script type=\"text/javascript\">
   /* * * CONFIGURATION VARIABLES * * */
   var disqus_shortname = 'kuntotiedot';
-
+
   /* * * DON'T EDIT BELOW THIS LINE * * */
   (function () {
   var s = document.createElement('script'); s.async = true;
@@ -105,9 +105,9 @@
                  "<meta charset=\"utf-8\">
     <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
     <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"
-
+
                  [:title title]
-
+
                  "<link href=\"/bootstrap-3.3.4-dist/css/bootstrap.min.css\" rel=\"stylesheet\">

                  <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
@@ -117,20 +117,20 @@
       <script src=\"https://oss.maxcdn.com/respond/1.4.2/respond.min.js\"></script>
     <![endif]-->"
                  [:link {:href "/publisher.css" :rel "stylesheet"}]]
-
+
                 [:body

                  styles
-
+
                  facebook-sdk
-
+
                  [:div {:class "container"}
                   [:div {:class "header"}
                    [:a {:href "/" :style "color: black"} [:h3 "Vantaan kaupungin kiinteistöjen kuntotiedot"]]
                    breadcrumb]
-
+
                   content]
-
+
                  google-analythics

                  "<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
@@ -149,7 +149,7 @@

       (string/replace "î" "ö")
       (string/replace "ô" "Ö")
-
+
       (string/replace "Ü" "å")
       (string/replace "è" "Å")))

@@ -169,6 +169,9 @@

 (defn date-string [{:keys [year month day]}]
   (str day "." month "." year))
+
+(defn date-time-string [{:keys [year month day hour minute second]}]
+  (str  day "." month "." year " " hour ":" minute ":" second))

 (defn last-modified-date [file]
   (date-to-map (Date. (.lastModified file))))
@@ -184,7 +187,7 @@
                            (sort-by #(fix-file-name (.getName %))))]
              (let [files (->> (.listFiles file)
                               (filter #(not (.isDirectory %))))]
-
+
                [:tr [:td [:a {:href (str "/" (URLEncoder/encode (.getName file)))}
                           (file-name file)]]
                 [:td (count files)]
@@ -207,7 +210,7 @@
                                  reverse)]
                    [:tr [:td [:a {:href (str "/" folder "/" (URLEncoder/encode (.getName file)))}
                               (file-name file)]]
-
+
                     [:td (->> file
                               last-modified-date
                               date-string)]
@@ -233,23 +236,23 @@
            " / " [:a {:href (str "/" folder)} kiinteistön-nimi]
            " / " tiedoston-nimi]

-          [:a {:href (str "/" folder) :style "color: black;"} [:h1 kiinteistön-nimi]]
-
+          [:a {:href (str "/" folder) :style "color: black;"} [:h1 kiinteistön-nimi]]
+
           [:a {:href (str "/get/" folder "/" file) :class "file-download-link"}
            tiedoston-nimi]

           [:div {:style "margin-left: 10px; display: inline-block"}
-           "(" (-> (str "files/" folder "/" file)
+           "(" (-> (str "files/" folder "/" file)
                    (URLDecoder/decode)
                    (File.)
                    last-modified-date
                    date-string)
            ")"]
-
-
+
+
           [:div {:style "margin-top: 20px"}
            (like-button (str site-url "/" folder "/" file))]
-
+
           [:h2 {:class "comments-header"} "Kommentit"]
           (disqus (str folder "/" file) (str kiinteistön-nimi " / " tiedoston-nimi)))))

@@ -262,12 +265,12 @@
           [:div
            [:a {:href "/"} "Kaikki kiinteistöt"]
            " / " kiinteistön-nimi]
-
+
           [:h1 kiinteistön-nimi]

           [:div {:style "margin-top: 20px; margin-bottom: 20px"}
            (like-button (str site-url "/" folder))]
-
+
           (file-table folder)

           [:h2 {:class "comments-header"} "Kommentit"]
@@ -290,7 +293,7 @@
               [:li [:a {:href "http://www.sirpakauppinen.fi/node/914"} "Koulukapinan ABC"]]
               [:li [:a {:href "https://vanvary-fi.directo.fi/vanvary/sisailmatoimikunta/kysely-vanhemmille/"} "Vanvaryn eli (Vantaan vanhempien yhdistyksen) sisäilmatoimikunnan kysely sisäilmaoireista 2017"]]
               [:li [:a {:href "http://www.sisailmayhdistys.fi/Perustietoa-sisailmasta/Mista-apua-sisailmaongelmiin"} "Sisäilmayhdistys"]]]
-
+
              [:p "Palautetta sivuston toteutuksesta voit lähettää osoitteeseen
 <script>var dot = '.'; document.write('sirpa' + dot + 'kauppinen' + '@' + 'vihreat' + dot + 'fi'); </script>

@@ -304,20 +307,38 @@
             [:h2 "Muut"]
             muut)))

+(def ips-atom (atom []))
+
+(defn add-ip! [ip]
+  (swap! ips-atom (fn [ips]
+                    (take 10 (conj ips {:ip ip
+                                        :time (date-to-map (Date.))})))))
+
+(defn report-ips [ips]
+  (hiccup/html
+   [:ul
+    (map (fn [ip]
+           [:li  (date-time-string (:time ip)) [:br]
+            [:strong (:ip ip)]])
+         ips)]))

 (defn app []
   (compojure/routes (compojure/GET "/" []
                                    (front-page))
-
+
+                    (compojure/GET "/ip" request
+                                   (add-ip! (:remote-addr request))
+                                   (report-ips @ips-atom))
+
                     (compojure/GET ["/get/:folder/:file" :folder #"[^/]+" :file #"[^/]+"]  [folder file]
                                    (do (timbre/info (str "load file " (URLDecoder/decode folder) "/" (URLDecoder/decode file)))
                                        (response/file-response (str files-directory "/" (URLDecoder/decode folder) "/" (URLDecoder/decode file)))))
-
+
                     (compojure/GET ["/:folder" :folder #"[^/]+"]  [folder]
-                                   (show-folder folder))
+                                     (show-folder folder))

                     (compojure/GET ["/:folder/:file" :folder #"[^/]+" :file #"[^/]+"] [folder file]
-                                   (show-file folder file))))
+                                     (show-file folder file))))

 (def handler (-> (app)
                  (file/wrap-file "resources")))


Add "un" for 1 in italian (#123)

Add "un" for 1 in italian (#123)

--- resources/languages/it/corpus/numbers.clj
+++ resources/languages/it/corpus/numbers.clj
@@ -9,6 +9,7 @@

   "1"
   "uno"
+  "un"
   (number 1)

   "2"


fix bug in seq-metadata

fix bug in seq-metadata

--- dada-core/src/main/clojure/org/dada/core.clj
+++ dada-core/src/main/clojure/org/dada/core.clj
@@ -105,6 +105,7 @@

 (defmulti attribute-key (fn [arg] (class arg)))
 (defmethod attribute-key Date [#^Date date] (attribute-key (str "attribute" date)))
+(defmethod attribute-key Integer [#^Integer i] (attribute-key (str "attribute" i)))
 (defmethod attribute-key clojure.lang.Keyword [#^Keyword keyword] (attribute-key (name keyword)))

 (def string-replacements
@@ -246,7 +247,7 @@
        [1]
        (proxy [Metadata$Comparator][] (higher [[_ v1] [_ v2]] (> v2 v1)))
        (map
-	(fn [i] (Attribute. i Integer (= i 0) (proxy [Getter] [] (get [s] (nth s i)))))
+	(fn [i] (Attribute. i Object (= i 0) (proxy [Getter] [] (get [s] (nth s i)))))
 	(range length))))


Add normalization and a couple of more tests (to be moved)


Clean up

Clean up


Moar tests

Moar tests

--- test/benjaminwarfield/integration_test.clj
+++ test/benjaminwarfield/integration_test.clj
@@ -21,7 +21,23 @@
         (visit "/")
         (within [:.content :h2]
           (has (text? "Welcome to Thunderdome, bitch.")
-              "Index has expected content"))))
+              "Index has expected content"))
+         (within [:.content :a]
+           (has (text? "Who the crap do I think I am?")))))
+
+(deftest about-status-test
+  (-> (session app)
+      (visit "/about")
+      (has (status? 200))))
+
+(deftest about-content-test
+  (-> (session app)
+      (visit "/about")
+      (within [:.content :h2]
+        (has (text? "Developer and Ops guy.")
+             "Page header has expected content"))
+      (within [:.content :p]
+        (has (text? "I run Bartertown.")))))

 (deftest four-oh-four-status-test
   (-> (session app)


fixing role

fixing role

--- test/celestial/integration/persistency.clj
+++ test/celestial/integration/persistency.clj
@@ -29,7 +29,7 @@

 (with-state-changes [(before :facts (clear-all))]
   (fact "generated crud user ops" :integration :redis
-     (let [user {:username "foo" :password "bla" :roles #{::user}} id (p/add-user user)]
+     (let [user {:username "foo" :password "bla" :roles #{:celestial.roles/user}} id (p/add-user user)]
           (p/get-user id) => user
           (p/user-exists? id) => truthy
           (p/update-user (merge user {:username "foo" :password "123"}))
@@ -39,7 +39,7 @@
           ))

    (fact "non valid user" :integration :redis
-      (let [user {:username "foo" :password "bla" :roles #{::user}} id (p/add-user user)]
+      (let [user {:username "foo" :password "bla" :roles #{:celestial.roles/user}} id (p/add-user user)]
           (p/add-user (dissoc user :username)) =>
                (throws clojure.lang.ExceptionInfo (is-type? :celestial.persistency/non-valid-user))
           (p/update-user (dissoc user :username)) =>


Server: Log TCP startup.

Server: Log TCP startup.

--- src/reimann/server.clj
+++ src/reimann/server.clj
@@ -50,12 +50,12 @@
             (close channel))))))))

 (defn tcp-server
-  ([core]
-    (tcp-server core {}))
+  ([core] (tcp-server core {}))
   ([core opts]
-  (let [handler (handler core)]
-    (start-tcp-server handler
-      (merge {
-        :port 5555
-        :frame (finite-block :int32)
-      } opts)))))
+    (let [opts (merge {:port 5555
+                       :frame (finite-block :int32)}
+                      opts)
+        handler (handler core)
+        server (start-tcp-server handler opts)]
+      (info (str "TCP server " (select-keys [:host :port] opts) " online"))
+      server)))


riemann.config: use :refer instead of def for logstash & graphite

--- src/riemann/config.clj
+++ src/riemann/config.clj
@@ -13,7 +13,7 @@
                      [datadog     :refer [datadog]]
                      [email       :refer [mailer]]
                      [folds       :as folds]
-                     [graphite    :as graphite-client]
+                     [graphite    :as graphite-client :refer [graphite]]
                      [hipchat     :refer [hipchat]]
                      [index       :as index]
                      [influxdb    :refer [influxdb]]
@@ -22,7 +22,7 @@
                      [librato     :refer [librato-metrics]]
                      [logentries  :refer [logentries]]
                      [logging     :as logging]
-                     [logstash    :as logstash-client]
+                     [logstash    :as logstash :refer [logstash]]
                      [mailgun     :refer [mailgun]]
                      [nagios      :refer [nagios]]
                      [opentsdb    :refer [opentsdb]]
@@ -58,9 +58,6 @@
 (def next-core "The core which will replace the current core."
   (atom (core/core)))

-(def graphite #'graphite-client/graphite)
-(def logstash #'logstash-client/logstash)
-
 (defn kwargs-or-map
   "Takes a sequence of arguments like


Simplify Basic auth and json parsing in test-utils/spotify-oauth-token

--- test/clj_spotify/test_utils.clj
+++ test/clj_spotify/test_utils.clj
@@ -1,25 +1,17 @@
 (ns clj-spotify.test-utils
   (:require
             [clojure.data.json :as json]
-            [clojure.data :as data]
             [clj-http.client :as client]
-            [clojure.data.codec.base64 :as b64]
             ))

-(def enc-auth-string
-  (str "Basic "
-  (->
-    (str (System/getenv "SPOTIFY_CLIENT_ID") ":" (System/getenv "SPOTIFY_SECRET_TOKEN"))
-    (.getBytes)
-    (b64/encode)
-    (String. "UTF-8"))))
-
-(defonce spotify-oauth-token (->
-                           "https://accounts.spotify.com/api/token"
-                           (client/post {:form-params {:grant_type "client_credentials"} :headers {:Authorization enc-auth-string}})
-                           :body
-                           (json/read-str :key-fn keyword)
-                           :access_token))
+(defonce spotify-oauth-token
+  (-> "https://accounts.spotify.com/api/token"
+      (client/post {:form-params {:grant_type "client_credentials"}
+                    :basic-auth [(System/getenv "SPOTIFY_CLIENT_ID")
+                                 (System/getenv "SPOTIFY_SECRET_TOKEN")]
+                    :as :json})
+      :body
+      :access_token))

 (defn reset-volatile-vals
   "Function to reset values that change over time such as amount of followers or popularity ranking."


Doesn't break anymore.

Doesn't break anymore.

--- test/http/async/client/test.clj
+++ test/http/async/client/test.clj
@@ -482,7 +482,6 @@
                                   :password "boys"})))
        200)))

-;; breaks with AsyncHttpClient 1.6.3
 (deftest preemptive-authentication
   (is (=
        (:code (status (GET "http://localhost:8123/preemptive-auth"


Explicitly set replication factor to 1

Explicitly set replication factor to 1

--- test/onyx/plugin/test_utils.clj
+++ test/onyx/plugin/test_utils.clj
@@ -21,7 +21,11 @@
    (k-topics/create-topic!
     (k-admin/make-zk-utils {:servers [zk-address]} false)
     topic-name
-    partitions)))
+    partitions
+    ;; Replication factor needs to be set because we're only running a single
+    ;; embedded Kafka server.
+    1
+    )))

 (defn mock-kafka
   "Starts a Kafka in-memory instance, preloading a topic with xs.


fix example pipeline

fix example pipeline

--- backend/src/lambdaui/api.clj
+++ backend/src/lambdaui/api.clj
@@ -53,3 +53,5 @@

 (defn api-routes [pipeline]
   (routes (GET "/summaries" [] (summaries-response pipeline))))
+
+


Adapt platform independent tests for run with both implementations.

--- test/bytebuf/tests/core.cljx
+++ test/bytebuf/tests/core.cljx
@@ -16,11 +16,45 @@
   (:require #+clj [clojure.test :as t]
             #+cljs [cljs.test :as t]
             [bytebuf.core :as buf]
-            [bytebuf.buffer :as impl]
-            [bytebuf.bytes :as bytes])
+            [bytebuf.buffer :as impl])
   #+clj
   (:import java.nio.ByteBuffer
            io.netty.buffer.ByteBuf))
+
+
+#+clj
+(defn random-bytes
+  [^long numbytes]
+  (let [sr (java.util.Random.)
+        buffer (byte-array numbytes)]
+    (.nextBytes sr buffer)
+    buffer))
+
+#+cljs
+(defn random-bytes
+  [^long numbytes]
+  (let [buffer (js/Int8Array. numbytes)]
+    (doseq [i (range numbytes)]
+      (aset buffer i (rand-int 10)))
+    buffer))
+
+#+clj
+(defn equals?
+  "Check if two byte arrays are equals."
+  [^bytes a ^bytes b]
+  (java.util.Arrays/equals a b))
+
+#+cljs
+(defn equals?
+  [^bytes a ^bytes b]
+  (if (not= (.-length a) (.-length b))
+    false
+    (reduce (fn [acc i]
+              (if (not= (aget a i) (aget b i))
+                (reduced false)
+                true))
+            true
+            (range (.-length a)))))

 #+clj
 (t/deftest allocate-heap-nio-buffer
@@ -51,75 +85,65 @@
   (let [buffer (buf/allocate 16 {:impl :es6})]
     (t/is (instance? js/DataView buffer))))

-;; #+cljs
-;; (t/deftest allocate-direct-node-buffer
-;;   (let [bf (js/require "buffer")
-;;         bf (.-Buffer bf)
-;;         buffer (buf/allocate 16 {:impl :node})]
-;;     (t/is (instance? bf buffer))))
-
-#+clj
 (t/deftest spec-constructor
   (let [spec (buf/spec :field1 (buf/int32)
-                       :field2 (buf/int64))]
+                       :field2 (buf/int16))]
     (t/is (= (count spec) 2))
-    (t/is (= (buf/size spec) 12))))
-
-#+clj
+    (t/is (= (buf/size spec) 6))))
+
 (t/deftest associative-specs-write
   (let [spec (buf/spec :field1 (buf/int32)
-                       :field2 (buf/int64))
+                       :field2 (buf/int16))
         buffer (buf/allocate 12)
         data {:field1 1 :field2 4}]
-    (t/is (= (buf/write! buffer data spec) 12))
-    (t/is (= (.getInt buffer 0) 1))
-    (t/is (= (.getLong buffer 4) 4))))
-
-#+clj
+    (t/is (= (buf/write! buffer data spec) 6))
+    (t/is (= (impl/read-int buffer 0) 1))
+    (t/is (= (impl/read-short buffer 4) 4))))
+
 (t/deftest associative-specs-write-with-offset
   (let [spec (buf/spec :field1 (buf/int32))
         buffer (buf/allocate 12)
         data {:field1 500}]
     (t/is (= (buf/write! buffer data spec {:offset 3}) 4))
-    (t/is (= (.getInt buffer 3) 500))))
-
-#+clj
+    (t/is (= (impl/read-int buffer 3) 500))))
+
 (t/deftest associative-specs-write-wrong-buffer
   ;; write data to wrong buffer (less space)
   (let [spec (buf/spec :field1 (buf/int32))
         buffer (buf/allocate 2)
         data {:field1 1}]
+    #+clj
     (t/is (thrown? java.lang.IndexOutOfBoundsException
-                 (buf/write! buffer data spec) 12))))
-
-#+clj
+                   (buf/write! buffer data spec) 12))
+    #+cljs
+    (t/is (thrown? js/Error
+                   (buf/write! buffer data spec) 12))))
+
 (t/deftest associative-specs-read
   (let [spec (buf/spec :field1 (buf/int32)
-                       :field2 (buf/int64))
-        buffer (buf/allocate 12)]
-    (.putInt buffer 0 10)
-    (.putLong buffer 4 100)
-    (let [[readed data] (buf/read* buffer spec)]
-      (t/is (= readed 12))
+                       :field2 (buf/int16))
+        buffer (buf/allocate 12)]
+    (impl/write-int buffer 0 10)
+    (impl/write-short buffer 4 100)
+    (let [[readed data] (buf/read* buffer spec)]
+      (t/is (= readed 6))
       (t/is (= data {:field2 100 :field1 10})))))

-#+clj
 (t/deftest associative-specs-read-with-offset
   (let [spec (buf/spec :field1 (buf/int32))
         buffer (buf/allocate 12)]
-    (.putInt buffer 8 1000)
+    (impl/write-int buffer 8 1000)
     (let [[readed data] (buf/read* buffer spec {:offset 8})]
       (t/is (= readed 4))
       (t/is (= data {:field1 1000})))))

-#+clj
 (t/deftest indexed-specs-write
-  (let [spec (buf/spec (buf/int32) (buf/int64))
+  (let [spec (buf/spec (buf/int32) (buf/int16))
         buffer (buf/allocate 12)
         data [1 4]]
-    (t/is (= (buf/write! buffer data spec) 12))
-    (t/is (= (.getInt buffer 0) 1))
-    (t/is (= (.getLong buffer 4) 4))))
+    (t/is (= (buf/write! buffer data spec) 6))
+    (t/is (= (impl/read-int buffer 0) 1))
+    (t/is (= (impl/read-short buffer 4) 4))))

 #+clj
 (t/deftest indexed-specs-write-with-offset
@@ -129,36 +153,38 @@
     (t/is (= (buf/write! buffer data spec {:offset 3}) 4))
     (t/is (= (.getInt buffer 3) 500))))

-#+clj
+
 (t/deftest indexed-specs-write-wrong-buffer
   (let [spec (buf/spec (buf/int32))
         buffer (buf/allocate 2)
         data [1]]
+    #+clj
     (t/is (thrown? java.lang.IndexOutOfBoundsException
-                 (buf/write! buffer data spec) 12))))
-
-#+clj
+                   (buf/write! buffer data spec) 12))
+    #+cljs
+    (t/is (thrown? js/Error
+                   (buf/write! buffer data spec) 12))))
+
 (t/deftest indexed-specs-read
-  (let [spec (buf/spec (buf/int32) (buf/int64))
-        buffer (buf/allocate 12)]
-    (.putInt buffer 0 10)
-    (.putLong buffer 4 100)
-    (let [[readed data] (buf/read* buffer spec)]
-      (t/is (= readed 12))
+  (let [spec (buf/spec (buf/int32) (buf/int16))
+        buffer (buf/allocate 12)]
+    (impl/write-int buffer 0 10)
+    (impl/write-short buffer 4 100)
+    (let [[readed data] (buf/read* buffer spec)]
+      (t/is (= readed 6))
       (t/is (= data [10 100])))))

-#+clj
 (t/deftest indexed-specs-read-with-offset
   (let [spec (buf/spec (buf/int32))
         buffer (buf/allocate 12)]
-    (.putInt buffer 8 1000)
+    (impl/write-int buffer 8 1000)
     (let [[readed data] (buf/read* buffer spec {:offset 8})]
       (t/is (= readed 4))
       (t/is (= data [1000])))))

 #+clj
 (t/deftest spec-data-types
-  (let [data [;; (buf/string 5) "12345"
+  (let [data [(buf/string 5) "12345"
               (buf/short)    100
               (buf/long)     1002
               (buf/integer)  1001
@@ -173,7 +199,6 @@
                      (buf/allocate (buf/size spec) {:type :heap :impl :netty})
                      (buf/allocate (buf/size spec) {:type :direct :impl :netty})]]
         (doseq [buffer buffers]
-          ;; (println buffer spec)
           (let [written (buf/write! buffer data spec)]
             (t/is (= written (buf/size spec)))
             (let [[readed data'] (buf/read* buffer spec)]
@@ -182,14 +207,14 @@

 #+cljs
 (t/deftest spec-data-types
-  (let [data [;; (buf/string 5) "12345"
+  (let [data [(buf/string 5) "äåéëþ"
               (buf/short)    100
               (buf/integer)  1001
               (buf/bool)     false
               (buf/double)   (double 4.3)
               (buf/float)    (float 3.5)
-              (buf/byte)     (byte 32)]]
-              ;; (buf/bytes 5)  (bytes/random-bytes 5)]]
+              (buf/byte)     (byte 32)
+              (buf/bytes 5)  (random-bytes 5)]]
     (doseq [[spec data] (partition 2 data)]
       (let [buffers [(buf/allocate (buf/size spec) {:impl :es6})]]
         (doseq [buffer buffers]
@@ -197,33 +222,35 @@
             (t/is (= written (buf/size spec)))
             (let [[readed data'] (buf/read* buffer spec)]
               (t/is (= readed (buf/size spec)))
-              (t/is (= data data')))))))))
-
-;; #+clj
-;; (t/deftest spec-data-with-dynamic-types-single
-;;   (let [spec (buf/spec (buf/string*))
-;;         buffer (buf/allocate 20)]
-;;     (buf/write! buffer ["1234567890"] spec)
-;;     (let [[readed data] (buf/read* buffer spec)]
-;;       (t/is (= readed 14))
-;;       (t/is (= data ["1234567890"])))))
-
-;; #+clj
-;; (t/deftest spec-data-with-dynamic-types-combined
-;;   (let [spec (buf/spec (buf/string*) (buf/int64))
-;;         buffer (buf/allocate 40)]
-;;     (buf/write! buffer ["1234567890" 1000] spec)
-;;     (let [[readed data] (buf/read* buffer spec)]
-;;       (t/is (= readed 22))
-;;       (t/is (= data ["1234567890" 1000])))))
-
-;; #+clj
-;; (t/deftest spec-composition
-;;   (let [spec (buf/spec (buf/compose-type (buf/int32) (buf/int32))
-;;                        (buf/compose-type (buf/string 10) (buf/string 5)))
-;;         buffer (buf/allocate (buf/size spec))
-;;         data [[100 200] ["foo" "bar"]]]
-;;     (buf/write! buffer data spec)
-;;     (let [[readed data'] (buf/read* buffer spec)]
-;;       (t/is (= readed (buf/size spec)))
-;;       (t/is (= data' data)))))
+              (cond
+                (instance? js/Int8Array data')
+                (t/is (equals? data data'))
+
+                :else
+                (t/is (= data data'))))))))))
+
+(t/deftest spec-data-with-dynamic-types-single
+  (let [spec (buf/spec (buf/string*))
+        buffer (buf/allocate 20)]
+    (buf/write! buffer ["1234567890"] spec)
+    (let [[readed data] (buf/read* buffer spec)]
+      (t/is (= readed 14))
+      (t/is (= data ["1234567890"])))))
+
+(t/deftest spec-data-with-dynamic-types-combined
+  (let [spec (buf/spec (buf/string*) (buf/int32))
+        buffer (buf/allocate 40)]
+    (buf/write! buffer ["1234567890" 1000] spec)
+    (let [[readed data] (buf/read* buffer spec)]
+      (t/is (= readed 18))
+      (t/is (= data ["1234567890" 1000])))))
+
+(t/deftest spec-composition
+  (let [spec (buf/spec (buf/compose-type (buf/int32) (buf/int32))
+                       (buf/compose-type (buf/string 10) (buf/string 5)))
+        buffer (buf/allocate (buf/size spec))
+        data [[100 200] ["foo" "bar"]]]
+    (buf/write! buffer data spec)
+    (let [[readed data'] (buf/read* buffer spec)]
+      (t/is (= readed (buf/size spec)))
+      (t/is (= data' data)))))


Remove propietary dialects from dialect translate map.

--- src/suricatta/impl.clj
+++ src/suricatta/impl.clj
@@ -27,15 +27,9 @@
       :pgsql      SQLDialect/POSTGRES
       :mariadb    SQLDialect/MARIADB
       :firebird   SQLDialect/FIREBIRD
-      :oracle     SQLDialect/ORACLE
-      :oracle10g  SQLDialect/ORACLE10G
-      :oracle11g  SQLDialect/ORACLE11G
-      :oracle12g  SQLDialect/ORACLE12G
       :mysql      SQLDialect/MYSQL
       :h2         SQLDialect/H2
       :sqlite     SQLDialect/SQLITE
-      :sqlserver  SQLDialect/SQLSERVER
-      :ingres     SQLDialect/INGRES
       SQLDialect/SQL99)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Added function for getting a User resource by UUID.  Fixes #12


Comment out debug code

Comment out debug code

--- cortex/test/cljc/cortex/nn/network_test.cljc
+++ cortex/test/cljc/cortex/nn/network_test.cljc
@@ -94,11 +94,11 @@
         net (net/train net optimizer loss data labels batch-size n-epochs)
         mse (net/evaluate-mse net data results)]
 ;; uncomment as needed for debug output
-    (println (str (class o) " :: "
-                  " mse = " mse
-                  " predicted = " (mapv (fn [v] (m/coerce [] (calc-output net v))) CORN-DATA)))
-    (when-not (< mse 25)
-      (println net))
+;    (println (str (class o) " :: "
+;                  " mse = " mse
+;                  " predicted = " (mapv (fn [v] (m/coerce [] (calc-output net v))) CORN-DATA)))
+;    (when-not (< mse 25)
+;      (println net))
     (is (< mse 25))))

 (deftest corn-test


we don't need slf4j here any more

we don't need slf4j here any more

--- dada-core/src/main/clojure/org/dada/core.clj
+++ dada-core/src/main/clojure/org/dada/core.clj
@@ -20,7 +20,6 @@
    Lock)
   (org.springframework.context.support ClassPathXmlApplicationContext)
   (org.springframework.beans.factory BeanFactory)
-  (org.slf4j Logger LoggerFactory)
   (org.dada.asm ClassFactory)
   (org.dada.core
    AbstractModel
@@ -47,8 +46,6 @@
 ;;--------------------------------------------------------------------------------

 (set! *warn-on-reflection* true)
-
-(def #^Logger *logger* (LoggerFactory/getLogger "org.dada.core"))

 ;; TODO: Spring should look after this - see application-context.xml...
 (if (not (System/getProperty "dada.broker.name")) (System/setProperty "dada.broker.name" "DADA"))


NPE check for obj.contains?

NPE check for obj.contains?

--- test/emender_jenkins/utils_test.clj
+++ test/emender_jenkins/utils_test.clj
@@ -214,3 +214,11 @@
             true  (contains "Hello world!" "o w")
             true  (contains "Hello world!" "world!"))))

+(deftest test-contains-NPE
+    "Check the function emender-jenkins.utils/contains."
+    (testing "the function emender-jenkins.utils/contains."
+        (is (thrown? NullPointerException (contains nil "")))
+        (is (thrown? NullPointerException (contains "" nil)))
+        (is (thrown? NullPointerException (contains nil nil)))))
+
+


Show restaurants grouped by area

Show restaurants grouped by area

--- src/varjocafe/view.clj
+++ src/varjocafe/view.clj
@@ -19,21 +19,19 @@
                  [[:.restaurant-name]] (html/content (:name restaurant))
                  [[:.menu]] (html/substitute (map #(menu-cell restaurant %) dates)))

-(html/defsnippet area-row "templates/layout.html" [:.area-row]
-                 [area]
-                 [[:.area-name]] (html/content (:name area)))
-
+(html/defsnippet area-restaurants "templates/layout.html" [#{:.area-row :.restaurant-row}]
+                 [area dates]
+                 [:.area-name] (html/content (:name area))
+                 [:.restaurant-row] (html/substitute (map #(restaurant-row % dates)
+                                                          (:restaurants area))))

 (html/deftemplate layout "templates/layout.html"
-                  [{:keys [data dates areadata]}]
+                  [{:keys [dates areadata]}]
                   [:.date] (html/substitute (map #(date-cell %) dates))
-                  [:.area-row] (html/substitute (map #(area-row %)
-                                                     areadata))
-                  ; TODO: areas and restaurants must be in groups
-                  [:.restaurant-row] (html/substitute (map #(restaurant-row % dates)
-                                                           (vals data))))
+                  [:.restaurant-row] nil                    ; inserted by area-restaurants
+                  [:.area-row] (html/substitute (map #(area-restaurants % dates)
+                                                     areadata)))

 (defn main-page [data settings]
-  (layout {:data     data
-           :dates    (take 5 (core/dates data))
+  (layout {:dates    (take 5 (core/dates data))
            :areadata (core/restaurants-by-area data (:areacode-names settings))}))


Share router between history tests

Share router between history tests

--- test/cljs/reitit/frontend/history_test.cljs
+++ test/cljs/reitit/frontend/history_test.cljs
@@ -1,21 +1,20 @@
 (ns reitit.frontend.history-test
   (:require [clojure.test :refer [deftest testing is are]]
             [reitit.core :as r]
+            [reitit.frontend :as rf]
             [reitit.frontend.history :as rfh]
             [reitit.frontend.test-utils :refer [capture-console]]))

 (def browser (exists? js/window))

+(def router (r/router ["/"
+                       ["" ::frontpage]
+                       ["foo" ::foo]
+                       ["bar/:id" ::bar]]))
+
 (deftest fragment-history-test
   (when browser
-    (let [router (r/router ["/"
-                            ["" ::frontpage]
-                            ["foo" ::foo]
-                            ["bar/:id" ::bar]])
-          history (rfh/start! router
-                              (fn [_])
-                              {:use-fragment true
-                               :path-prefix "/"})]
+    (let [history (rfh/start! router (fn [_]) {:use-fragment true})]

       (testing "creating urls"
         (is (= "#/foo"
@@ -34,14 +33,7 @@

 (deftest html5-history-test
   (when browser
-    (let [router (r/router ["/"
-                            ["" ::frontpage]
-                            ["foo" ::foo]
-                            ["bar/:id" ::bar]])
-          history (rfh/start! router
-                              (fn [_])
-                              {:use-fragment false
-                               :path-prefix "/"})]
+    (let [history (rfh/start! router (fn [_]) {:use-fragment false})]

       (testing "creating urls"
         (is (= "/foo"


allow counts on autocompletion query

allow counts on autocompletion query

--- src/wb_es/web/core.clj
+++ src/wb_es/web/core.clj
@@ -107,48 +107,50 @@
               (throw e)))]
       (json/parse-string (:body response) true))))

+(defn- compose-autocomplete-query [q options]
+  {:function_score
+   {:query
+    {:bool
+     {:filter (get-filter options)
+      :should [{:term {:wbid.autocomplete_keyword q}}
+               {:term {:label.autocomplete_keyword q}}
+               {:match_phrase {:label.autocomplete {:query q
+                                                    :slop 12}}}]
+      :minimum_should_match 1}}
+    :boost_mode "replace"
+    :score_mode "multiply"
+    :functions
+    [{:weight 1
+      :filter
+      {:match_all {}}}
+     {:weight 2
+      :filter
+      {:term {:species.key {:value "c_elegans"}}}}
+     {:weight 2
+      :filter
+      {:bool
+       {:must_not
+        {:exists
+         {:field :species.key}}}}}
+     {:weight 0.8
+      :filter
+      {:bool
+       {:must
+        [{:term {:wbid.autocomplete_keyword q}}]}}}
+     {:weight 0.1
+      :filter
+      {:bool
+       {:must_not
+        [{:term {:label.autocomplete_keyword q}}]
+        :must
+        [{:match_phrase {:label.autocomplete {:query q
+                                              :slop 12}}}]}}}]}})
+

 (defn autocomplete [es-base-url index q options]
   (let [query {:sort [:_score
                       {:label.raw {:order :asc}}]
-               :query
-               {:function_score
-                {:query
-                 {:bool
-                  {:filter (get-filter options)
-                   :should [{:term {:wbid.autocomplete_keyword q}}
-                            {:term {:label.autocomplete_keyword q}}
-                            {:match_phrase {:label.autocomplete {:query q
-                                                                 :slop 12}}}]
-                   :minimum_should_match 1}}
-                 :boost_mode "replace"
-                 :score_mode "multiply"
-                 :functions
-                 [{:weight 1
-                   :filter
-                   {:match_all {}}}
-                  {:weight 2
-                   :filter
-                   {:term {:species.key {:value "c_elegans"}}}}
-                  {:weight 2
-                   :filter
-                   {:bool
-                    {:must_not
-                     {:exists
-                      {:field :species.key}}}}}
-                  {:weight 0.8
-                   :filter
-                   {:bool
-                    {:must
-                     [{:term {:wbid.autocomplete_keyword q}}]}}}
-                  {:weight 0.1
-                   :filter
-                   {:bool
-                    {:must_not
-                     [{:term {:label.autocomplete_keyword q}}]
-                     :must
-                     [{:match_phrase {:label.autocomplete {:query q
-                                                           :slop 12}}}]}}}]}}}
+               :query (compose-autocomplete-query q options)}

         response
         (http/get (format "%s/%s/_search?size=%s&explain=%s"
@@ -197,15 +199,15 @@

 (defn count [es-base-url index q options]
-  (if (:autocomplete options)
-    (autocomplete es-base-url index q options)
-    (let [query
-          {:query (compose-search-query q options)}
-
-          response
-          (http/get (format "%s/%s/_count"
-                            es-base-url
-                            index)
-                    {:content-type "application/json"
-                     :body (json/generate-string query)})]
-      (json/parse-string (:body response) true))))
+  (let [query
+        {:query (if (:autocomplete options)
+                  (compose-autocomplete-query q options)
+                  (compose-search-query q options))}
+
+        response
+        (http/get (format "%s/%s/_count"
+                          es-base-url
+                          index)
+                  {:content-type "application/json"
+                   :body (json/generate-string query)})]
+    (json/parse-string (:body response) true)))


Fix mux test.

Fix mux test.

--- test/multicodec/codecs/mux_test.clj
+++ test/multicodec/codecs/mux_test.clj
@@ -17,8 +17,8 @@
         "construction with no codecs should throw exception")
     (is (thrown? IllegalArgumentException (mux/mux-codec :foo))
         "construction with odd args should throw exception")
-    (is (thrown? IllegalArgumentException (mux/mux-codec :foo (mock-codec :foo nil)))
-        "construction with no-header arg should throw exception"))
+    (is (mux/mux-codec :foo (mock-codec :foo nil))
+        "construction with no-header arg should not throw exception"))
   (let [mux (mux/mux-codec
               :foo (mock-codec :foo "/foo")
               :bar (mock-codec :bar "/bar"))]


Adjust test sleeps

Adjust test sleeps

--- test/photon/current/projections.clj
+++ test/photon/current/projections.clj
@@ -105,6 +105,7 @@
             (api/projection stm "chatter-proj2") => nil)
       (let [processed (:processed @(:stats stm))]
         (post-one-event m s-name)
+        (Thread/sleep 5000)
         (let [current (:processed @(:stats stm))]
           (fact "2 events processed"
                 (- current processed) => 2)
@@ -112,19 +113,23 @@
           (fact "chatter-proj does not exist"
                 (api/projection stm "chatter-proj") => nil)
           (post-one-event m s-name)
+          (Thread/sleep 5000)
           (let [current-2 (:processed @(:stats stm))]
             (fact "1 event processed"
                   (- current-2 current) => 1)
             (api/delete-projection! stm "dummy-proj")
             (post-one-event m s-name)
+            (Thread/sleep 5000)
             (let [current-3 (:processed @(:stats stm))]
               (fact "1 events processed"
                     (- current-3 current-2) => 1)
               (api/delete-projection! stm "__streams__")
+              (Thread/sleep 5000)
               (fact "__streams__ does not get deleted"
                     (:projection-name (api/projection stm "__streams__"))
                     => "__streams__")
               (post-one-event m s-name)
+              (Thread/sleep 5000)
               (let [current-4 (:processed @(:stats stm))]
                 (fact "1 events processed"
                       (- current-4 current-3) => 1)
@@ -136,6 +141,7 @@
                                               :initial-value "0"}))
                 (Thread/sleep 5000)
                 (post-one-event m s-name)
+                (Thread/sleep 5000)
                 (let [current-5 (:processed @(:stats stm))]
                   (fact "1010 events processed"
                         (- current-5 current-4) => 1010)
@@ -154,6 +160,7 @@
                     (api/delete-projection! stm "chatter-proj")
                     (Thread/sleep 5000)
                     (post-one-event m s-name)
+                    (Thread/sleep 5000)
                     (let [current-7 (:processed @(:stats stm))]
                       (fact "1 events processed"
                             (- current-7 current-6) => 1)))))))))))


Don’t do “docker rm” in CirleCI

Don’t do “docker rm” in CirleCI

See https://discuss.circleci.com/t/docker-error-removing-intermediate-container/70

--- test/powderkeg/integration_test.clj
+++ test/powderkeg/integration_test.clj
@@ -51,7 +51,8 @@

 (defn stop-spark [instance]
   (sh! "docker" "stop" instance)
-  (sh! "docker" "rm" instance))
+  (when-not (System/getenv "CIRCLECI")
+    (sh! "docker" "rm" instance)))

 (defn with-cluster [f]
   (let [pwd (.getAbsolutePath (java.io.File. ""))]


Rounded out the LocalImageStorage tests.

--- test/vignette/storage/core_test.clj
+++ test/vignette/storage/core_test.clj
@@ -28,13 +28,30 @@
 (facts :local-image-storage :unit
   (let [store (create-local-image-storage ..disk-store.. "originals" "thumbs")
         file-name "a/bc/d.png"]
+
     (save-thumbnail store ..file.. ..map..) => truthy
-
     (provided
       (mt/wikia ..map..) => "lotr"
       (mt/thumbnail-path ..map..) => file-name
-      (#'put* ..disk-store.. ..file.. "lotr" "thumbs" file-name) => true)
-  ))
+      (put* ..disk-store.. ..file.. "lotr" "thumbs" file-name) => true)
+
+    (get-thumbnail store ..map..) => "bytes"
+    (provided
+      (mt/wikia ..map..) => "lotr"
+      (mt/thumbnail-path ..map..) => file-name
+      (get* ..disk-store.. "lotr" "thumbs" file-name) => "bytes")
+
+    (save-original store ..file.. ..map..) => true
+    (provided
+      (mt/wikia ..map..) => "lotr"
+      (mt/original-path ..map..) => file-name
+      (put* ..disk-store.. ..file.. "lotr" "originals" file-name) => true)
+
+    (get-original store ..map..) => "bytes"
+    (provided
+      (mt/wikia ..map..) => "lotr"
+      (mt/original-path ..map..) => file-name
+      (get* ..disk-store.. "lotr" "originals" file-name) => "bytes")))

 (with-state-changes
   [(before :facts (do
@@ -51,7 +68,7 @@
   (facts :get-thumbnail :integration
     (let [local (create-local-object-storage "/tmp/vignette-local-storage")
           image-store (create-local-image-storage local "originals" "thumbs")]
-      ;(get-thumbnail image-store sample-thumbnail-hash) => falsey
+      (get-thumbnail image-store sample-thumbnail-hash) => falsey
       (save-thumbnail image-store (io/file "image-samples/ropes.jpg") sample-thumbnail-hash) => truthy
       (get-thumbnail image-store sample-thumbnail-hash) => truthy))


Moved away from java

Moved away from java

--- test/iroh/java/util_test.clj
+++ test/iroh/java/util_test.clj
@@ -1,18 +1,7 @@
 (ns iroh.java.util-test
   (:use midje.sweet)
   (:require [iroh.common :refer [class-array]]
-            [iroh.util :as util])
-  (:import im.chit.iroh.Util))
-
-(fact "boxArg"
-  (Util/boxArg Float/TYPE 2)
-  => 2.0
-
-  (Util/boxArg Integer/TYPE 2.001)
-  => 2
-
-  (type (Util/boxArg Short/TYPE 1.0))
-  => java.lang.Short)
+            [iroh.util :as util]))

 (fact "boxArg"
   (util/box-arg Float/TYPE 2)
@@ -23,7 +12,6 @@

   (type (util/box-arg Short/TYPE 1.0))
   => java.lang.Short)
-

 (fact "paramArgTypeMatch basics"
   (.isPrimitive Integer/TYPE)


Move cljs inspector so it doesn't overlap w/ left aside nav

--- frontend/components/app.cljs
+++ frontend/components/app.cljs
@@ -103,13 +103,13 @@
               (om/build keyq/KeyboardHandler app-without-container-data
                         {:opts {:keymap keymap
                                 :error-ch (get-in app [:comms :errors])}})
-              (when show-inspector?
-                ;; TODO inspector still needs lots of work. It's slow and it defaults to
-                ;;     expanding all datastructures.
-                (om/build inspector/inspector app))
               (when (and inner? logged-in?)
                 (om/build aside/aside app-without-container-data))
               [:main.app-main
+               (when show-inspector?
+                 ;; TODO inspector still needs lots of work. It's slow and it defaults to
+                 ;;     expanding all datastructures.
+                 (om/build inspector/inspector app))
                (om/build header/header app-without-container-data)
                [:div.main-body
                 (om/build dom-com app)]


Put the error flash back inside #account-settings

--- src-cljs/frontend/components/account.cljs
+++ src-cljs/frontend/components/account.cljs
@@ -311,36 +311,36 @@

 (defn default-email-pref [owner email-pref]
   [:div.card
-  [:div.header
-   [:h2
-    "Default Email Notifications"]]
-  [:div.body
-   [:div.section
-    [:form
-     [:div.radio
-      [:label
-       [:input
-        {:name "email_pref",
-         :type "radio"
-         :checked (= email-pref "all")
-         :on-change (partial handle-email-notification-change owner "all")}]
-       "Send me a personalized email for every build in my projects."]]
-     [:div.radio
-      [:label
-       [:input
-        {:name "email_pref",
-         :type "radio"
-         :checked (= email-pref "smart")
-         :on-change (partial handle-email-notification-change owner "smart")}]
-       "Send me a personalized email every time a build on a branch I've pushed to fails; also once they're fixed."]]
-     [:div.radio
-      [:label
-       [:input
-        {:name "email_pref",
-         :type "radio"
-         :checked (= email-pref "none")
-         :on-change (partial handle-email-notification-change owner "none")}]
-       "Don't send me emails."]]]]]])
+   [:div.header
+    [:h2
+     "Default Email Notifications"]]
+   [:div.body
+    [:div.section
+     [:form
+      [:div.radio
+       [:label
+        [:input
+         {:name "email_pref" ,
+          :type "radio"
+          :checked (= email-pref "all")
+          :on-change (partial handle-email-notification-change owner "all")}]
+        "Send me a personalized email for every build in my projects."]]
+      [:div.radio
+       [:label
+        [:input
+         {:name "email_pref" ,
+          :type "radio"
+          :checked (= email-pref "smart")
+          :on-change (partial handle-email-notification-change owner "smart")}]
+        "Send me a personalized email every time a build on a branch I've pushed to fails; also once they're fixed."]]
+      [:div.radio
+       [:label
+        [:input
+         {:name "email_pref" ,
+          :type "radio"
+          :checked (= email-pref "none")
+          :on-change (partial handle-email-notification-change owner "none")}]
+        "Don't send me emails."]]]]]])

 (defn granular-email-prefs [{:keys [projects user] :as x} owner]
   (let [followed-orgs (into (sorted-set-by (fn [[x-vcs-type x-name]
@@ -425,7 +425,7 @@
                          :beta          beta-program}
             subpage-com (get coms subpage)]
         (html
+         [:div#account-settings
           [:div.row (om/build common/flashes (get-in app state/error-message-path))]
-          [:div#account-settings
-           [:div#subpage
-             (om/build subpage-com (select-in app [state/general-message-path state/user-path state/projects-path]))]])))))
+          [:div#subpage
+           (om/build subpage-com (select-in app [state/general-message-path state/user-path state/projects-path]))]])))))


(MAINT) Bump jruby-pool-code-id test timeout

This commit bumps up the maximum amount of time that the
`test-jruby-pool-not-full-during-code-id-generation` test will wait for
a catalog request to complete from 5 seconds to 10 seconds.  This test
frequently failed for me locally when run in isolation from the command
line because the first catalog request takes right around 5 seconds,
although subsequent ones were much faster (~100 milliseconds).

--- test/unit/puppetlabs/services/request_handler/request_handler_core_test.clj
+++ test/unit/puppetlabs/services/request_handler/request_handler_core_test.clj
@@ -311,9 +311,13 @@
         (jruby-bootstrap/with-puppetserver-running-with-services
          app services {:jruby-puppet {:max-active-instances 1}}
          (jruby-testutils/wait-for-jrubies app)
-         (let [jruby-service (tk-app/get-service app :JRubyPuppetService)]
-           (future (testutils/get-catalog))
-           (is (deref first-promise 5000 false))
+         (let [in-catalog-request-future (promise)
+               jruby-service (tk-app/get-service app :JRubyPuppetService)]
+           (future
+            (deliver in-catalog-request-future true)
+            (testutils/get-catalog))
+           (deref in-catalog-request-future)
+           (is (deref first-promise 10000 false))
            ; Because we are blocking inside current-code-id, which happens to be
            ; used during a jruby request, we can assert that there will be no
            ; jruby instances left in the pool.


[skip ci] tweak bb script

[skip ci] tweak bb script

--- bin/bb-test-runner.clj
+++ bin/bb-test-runner.clj
@@ -1,11 +1,11 @@
-#!/usr/bin/env bb
+;; run via ./bin/bb-test-runner.sh
 (ns bb-test-runner
   (:require [clojure.test :as t]
             [babashka.classpath :as cp]))

 ;;TODO
 (def test-nsyms [#_'java-time-test
-                 #_'java-time.graph-test])
+                 'java-time.graph-test])

 (some->> (seq test-nsyms)
          (apply require))


Fix rank adjustments locally to match pig

--- pigpen-pig/src/main/clojure/pigpen/pig_rx.clj
+++ pigpen-pig/src/main/clojure/pigpen/pig_rx.clj
@@ -322,7 +322,7 @@
 (defmethod graph->local :rank [{:keys [sort-keys]} data]
   (cond->> (first data)
     (not-empty sort-keys) (rx/sort (partial pig-compare sort-keys))
-    true                  (rx/map-indexed (fn [i v] (assoc v '$0 i)))))
+    true                  (rx/map-indexed (fn [i v] (assoc v '$0 (inc i)))))) ; inc to match pig's 1-based rank

 ;; ********** Filter **********


Remove unused import

Remove unused import

--- src/braid/core/client/bots/views/bots_page.cljs
+++ src/braid/core/client/bots/views/bots_page.cljs
@@ -1,6 +1,5 @@
 (ns braid.core.client.bots.views.bots-page
   (:require
-    [braid.core.client.ui.views.pills :refer [user-pill-view]]
     [braid.core.client.ui.views.upload :refer [avatar-upload-view]]
     [braid.core.common.util :refer [bot-name-re]]
     [clojure.string :as string]


Support flexible loads when dispatching

Support flexible loads when dispatching

--- src/cider_ci/dispatcher/dispatch/next_trial.clj
+++ src/cider_ci/dispatcher/dispatch/next_trial.clj
@@ -52,7 +52,11 @@
       (sql-merge-join [:executors_with_load :exs]
                       (sql-raw "(tasks.traits <@ exs.traits)"))
       (sql-select :trials.id :trials.task_id [:exs.id :executor_id])
+      ; TODO write this out more explicitly
       (sql-merge-where [:< :exs.relative_load 1])
+      (sql-merge-where (sql-raw (str "tasks.load < "
+                                     "exs.max_load * exs.temporary_overload_factor "
+                                     " - exs.current_load ")))
       (sql-merge-where [:= :exs.enabled true])
       (sql-merge-where (sql-raw (str "(exs.last_ping_at >  "
                                      "(now() - interval '1 Minutes'))")))


Use event-details component on owned events

--- src/cljs/elevent_client/pages/events/owned.cljs
+++ src/cljs/elevent_client/pages/events/owned.cljs
@@ -9,6 +9,7 @@
             [elevent-client.routes :as routes]
             [elevent-client.locale :as locale]
             [elevent-client.components.action-button :as action-button]
+            [elevent-client.components.event-details :as event-details]
             [elevent-client.pages.events.core :as events]))

 (defn delete-event [form]
@@ -41,18 +42,7 @@
                [:a.header {:href (routes/event event)}
                 (:Name event)]
                [:div.meta
-                [:strong "Date:"]
-                (let [start (from-string (:StartDate event))
-                      end   (from-string (:EndDate   event))]
-                  (str (unparse locale/datetime-formatter start)
-                       (when (after? end start)
-                         (str " to "
-                              (unparse locale/datetime-formatter end)))))]
-               [:div.meta
-                [:strong "Venue:"]
-                (:Venue event)]
-               [:div.description
-                (:Description event)]
+                [event-details/component event]]
                (when (get-in (:EventPermissions (:permissions @state/session))
                              [(:EventId event) :EditEvent])
                  [:div.extra


chart scale

chart scale

--- src/cljs/iwaswhere_web/ui/charts/pomodoros.cljs
+++ src/cljs/iwaswhere_web/ui/charts/pomodoros.cljs
@@ -157,12 +157,12 @@
           {:viewBox (str "0 0 600 " chart-h)}
           [:g
            [cc/chart-title "Time tracked"]
-           [bars-by-story indexed-20 local chart-h 0.0045 put-fn]]]
+           [bars-by-story indexed-20 local chart-h 0.0035 put-fn]]]
          [:svg
           {:viewBox (str "0 0 600 " chart-h)}
           [:g
            [cc/chart-title "Time tracked"]
-           [bars-by-book indexed-20 local chart-h 0.0045 put-fn]]]
+           [bars-by-book indexed-20 local chart-h 0.0035 put-fn]]]
          [:div.times-by-day
           [:time (:date-string day-stats)]


lein/abort accepts multiple string arguments just fine

--- src/appengine_magic/leiningen_helpers.clj
+++ src/appengine_magic/leiningen_helpers.clj
@@ -13,7 +13,7 @@
                        (nil? appengine-sdk)
                        (if-let [from-env (System/getenv "APPENGINE_HOME")]
                            from-env
-                           (lein/abort (str task-name "no App Engine SDK specified: set :appengine-sdk in project.clj, or APPENGINE_HOME in the environment")))
+                           (lein/abort task-name "no App Engine SDK specified: set :appengine-sdk in project.clj, or APPENGINE_HOME in the environment"))
                        ;; a string
                        (string? appengine-sdk)
                        appengine-sdk
@@ -23,8 +23,8 @@
                              raw (get appengine-sdk username)]
                          (when (nil? raw)
                            (lein/abort
-                            (format "no valid App Engine SDK directory defined for user %s"
-                                    username)))
+                            "no valid App Engine SDK directory defined for user"
+                                    username))
                          raw))
         appengine-sdk (let [appengine-sdk (File. appengine-sdk)]
                         (when-not (.isDirectory appengine-sdk)
@@ -35,9 +35,9 @@
                     version ; just use the given version
                     (let [versions (if (contains? project :appengine-app-versions)
                                        (:appengine-app-versions project)
-                                       (lein/abort (str task-name
-                                                        " requires :appengine-app-versions"
-                                                        " in project.clj")))]
+                                       (lein/abort task-name
+                                                        "requires :appengine-app-versions"
+                                                        "in project.clj"))]
                       (cond
                        ;; not a map
                        (not (map? versions))
@@ -53,9 +53,9 @@
         in-appengine-web-xml-tmpl (File. web-inf-dir "appengine-web.xml.tmpl")
         out-appengine-web-xml (File. web-inf-dir "appengine-web.xml")]
     (when (not (.exists in-appengine-web-xml-tmpl))
-      (lein/abort (str task-name "requires WEB-INF/appengine-web.xml.tmpl template file")))
+      (lein/abort task-name "requires WEB-INF/appengine-web.xml.tmpl template file"))
     (when (.exists out-appengine-web-xml)
-      (lein/abort (str task-name "cannot run when a WEB-INF/appengine-web.xml file exists")))
+      (lein/abort task-name "cannot run when a WEB-INF/appengine-web.xml file exists"))
     (try
       (xpath-replace-all in-appengine-web-xml-tmpl out-appengine-web-xml
                          {"//application" app-name


enable test

enable test

--- test/babel/test/en.clj
+++ test/babel/test/en.clj
@@ -153,10 +153,5 @@
                             :number :sing,
                             :person :3rd},
                       :english "Juan"}}}]
-    (is (or true (= (fo form)
+    (is (or false (= (fo form)
                     "your name is Juan")))))
-
-
-
-
-