Add all defscreen functions to docstring

--- src/play_clj/core.clj
+++ src/play_clj/core.clj
@@ -97,7 +97,308 @@
      :input-listeners (global-listeners options execute-fn!)}))

 (defmacro defscreen
-  "Defines a screen, and creates vars for all the functions inside of it."
+  "Defines a screen, and creates vars for all the functions inside of it. All
+functions take a screen map and entities vector as arguments, and return the
+entities list at the end with any desired changes. If a function returns nil,
+the entities list is not changed.
+
+Below are all the possible screen functions. Some of them get special arguments
+via the screen map.
+
+    ; main screen functions
+    (defscreen my-screen
+      :on-show ; the screen first shows
+      (fn [screen entities]
+        entities)
+      :on-render ; the screen must be rendered (many times per second)
+      (fn [screen entities]
+        (println (:delta-time screen)) ; time (ms) elapsed since last frame
+        entities)
+      :on-hide ; the screen was replaced
+      (fn [screen entities]
+        entities)
+      :on-resize ; the screen was resized
+      (fn [screen entities]
+        (println (:width screen)) ; the new width of the screen
+        (println (:height screen)) ; the new height of the screen
+        entities)
+      :on-resume ; the screen resumed from a paused state (mobile only)
+      (fn [screen entities]
+        entities)
+      :on-pause ; the screen paused (mobile only)
+      (fn [screen entities]
+        entities))
+
+    ; input functions
+    (defscreen my-screen
+      :on-key-down ; a key was pressed
+      (fn [screen entities]
+        (println (:keycode screen)) ; the code of the key (see key-code)
+        entities)
+      :on-key-typed ; a key was typed
+      (fn [screen entities]
+        (println (:character screen)) ; the character that was pressed
+        entities)
+      :on-key-up ; a key was released
+      (fn [screen entities]
+        (println (:keycode screen)) ; the code of the key (see key-code)
+        entities)
+      :on-mouse-moved ; the mouse was moved without pressing any buttons
+      (fn [screen entities]
+        (println (:input-x screen)) ; the x position of the mouse
+        (println (:input-y screen)) ; the y position of the mouse
+        entities)
+      :on-scrolled ; the mouse wheel was scrolled
+      (fn [screen entities]
+        (println (:amount screen)) ; the amount scrolled
+        entities)
+      :on-touch-down ; the screen was touched or a mouse button was pressed
+      (fn [screen entities]
+        (println (:input-x screen)) ; the x position of the finger/mouse
+        (println (:input-y screen)) ; the y position of the finger/mouse
+        (println (:pointer screen)) ; the pointer for the event
+        (println (:button screen)) ; the mouse button (see button-code)
+        entities)
+      :on-touch-dragged ; a finger or the mouse was dragged
+      (fn [screen entities]
+        (println (:input-x screen)) ; the x position of the finger/mouse
+        (println (:input-y screen)) ; the y position of the finger/mouse
+        (println (:pointer screen)) ; the pointer for the event
+        entities)
+      :on-touch-up ; a finger was lifted or a mouse button was released
+      (fn [screen entities]
+        (println (:input-x screen)) ; the x position of the finger/mouse
+        (println (:input-y screen)) ; the y position of the finger/mouse
+        (println (:pointer screen)) ; the pointer for the event
+        (println (:button screen)) ; the mouse button (see button-code)
+        entities))
+
+    ; gesture functions
+    (defscreen my-screen
+      :on-fling ; the user dragged a finger over the screen and lifted it
+      (fn [screen entities]
+        (println (:velocity-x screen)) ; the x-axis velocity (s)
+        (println (:velocity-y screen)) ; the y-axis velocity (s)
+        (println (:button screen)) ; the mouse button (see button-code)
+        entities)
+      :on-long-press ; the user pressed
+      (fn [screen entities]
+        (println (:input-x screen)) ; the x position of the finger
+        (println (:input-y screen)) ; the y position of the finger
+        entities)
+      :on-pan ; the user dragged a finger over the screen
+      (fn [screen entities]
+        (println (:input-x screen)) ; the x position of the finger
+        (println (:input-y screen)) ; the y position of the finger
+        (println (:delta-x screen)) ; the x-axis distance moved
+        (println (:delta-y screen)) ; the y-axis distance moved
+        entities)
+      :on-pan-stop ; the user is no longer panning
+      (fn [screen entities]
+        (println (:input-x screen)) ; the x position of the finger
+        (println (:input-y screen)) ; the y position of the finger
+        (println (:pointer screen)) ; the pointer for the event
+        (println (:button screen)) ; the mouse button (see button-code)
+        entities)
+      :on-pinch ; the user performed a pinch zoom gesture
+      (fn [screen entities]
+        (println (:initial-pointer-1 screen)) ; the x/y start position of finger 1
+        (println (:initial-pointer-2 screen)) ; the x/y start position of finger 2
+        (println (:pointer-1 screen)) ; the x/y end position of finger 1
+        (println (:pointer-2 screen)) ; the x/y end position of finger 2
+        entities)
+      :on-tap ; the user tapped
+      (fn [screen entities]
+        (println (:input-x screen)) ; the x position of the finger
+        (println (:input-y screen)) ; the y position of the finger
+        (println (:count screen)) ; the number of taps
+        (println (:button screen)) ; the mouse button (see button-code)
+        entities)
+      :on-zoom ; the user performed a pinch zoom gesture
+      (fn [screen entities]
+        (println (:initial-distance screen)) ; the start distance between fingers
+        (println (:distance screen)) ; the end distance between fingers
+        entities))
+
+    ; 2D physics contact (for play-clj.g2d-physics)
+    (defscreen my-screen
+      :on-begin-contact ; two bodies began to touch
+      (fn [screen entities]
+        (println (:contact screen)) ; the Contact - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html
+        entities)
+      :on-end-contact ; two bodies ceased to touch
+      (fn [screen entities]
+        (println (:contact screen)) ; the Contact - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html
+        entities)
+      :on-post-solve
+      (fn [screen entities]
+        (println (:contact screen)) ; the Contact - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html
+        (println (:impulse screen)) ; the ContactImpulse - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/ContactImpulse.html
+        entities)
+      :on-pre-solve
+      (fn [screen entities]
+        (println (:contact screen)) ; the Contact - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Contact.html
+        (println (:old-manifold screen)) ; the Manifold - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Manifold.html
+        entities))
+
+    ; 3D physics contact (for play-clj.g3d-physics)
+    (defscreen my-screen
+      :on-begin-contact ; two bodies began to touch
+      (fn [screen entities]
+        (println (:first-body screen)) ; the first btCollisionObject - http://bulletphysics.org/Bullet/BulletFull/classbtCollisionObject.html
+        (println (:second-body screen)) ; the second btCollisionObject - http://bulletphysics.org/Bullet/BulletFull/classbtCollisionObject.html
+        entities)
+      :on-end-contact ; two bodies ceased to touch
+      (fn [screen entities]
+        (println (:first-body screen)) ; the first btCollisionObject - http://bulletphysics.org/Bullet/BulletFull/classbtCollisionObject.html
+        (println (:second-body screen)) ; the second btCollisionObject - http://bulletphysics.org/Bullet/BulletFull/classbtCollisionObject.html
+        entities))
+
+    ; ui input functions (for play-clj.ui)
+    (defscreen my-screen
+      :on-ui-changed ; the ui entity was changed
+      (fn [screen entities]
+        (println (:event screen)) ; the ChangeListener.ChangeEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/ChangeListener.ChangeEvent.html
+        (println (:actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html
+        entities)
+      :on-ui-clicked ; the ui entity was clicked
+      (fn [screen entities]
+        (println (:event screen)) ; the [InputEvent](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html)
+        (println (:input-x screen)) ; the x position of the finger/mouse
+        (println (:input-y screen)) ; the y position of the finger/mouse
+        entities)
+      :on-ui-enter ; the finger/mouse moved over the ui entity
+      (fn [screen entities]
+        (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
+        (println (:from-actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html
+        (println (:input-x screen)) ; the x position of the finger/mouse
+        (println (:input-y screen)) ; the y position of the finger/mouse
+        (println (:pointer screen)) ; the pointer for the event
+        entities)
+      :on-ui-exit ; the finger/mouse moved out of the ui entity
+      (fn [screen entities]
+        (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
+        (println (:to-actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html
+        (println (:input-x screen)) ; the x position of the finger/mouse
+        (println (:input-y screen)) ; the y position of the finger/mouse
+        (println (:pointer screen)) ; the pointer for the event
+        entities)
+      :on-ui-touch-down ; the finger/mouse went down on the ui entity
+      (fn [screen entities]
+        (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
+        (println (:input-x screen)) ; the x position of the finger/mouse
+        (println (:input-y screen)) ; the y position of the finger/mouse
+        (println (:pointer screen)) ; the pointer for the event
+        (println (:button screen)) ; the mouse button (see button-code)
+        entities)
+      :on-ui-touch-dragged ; the finger/mouse moved anywhere
+      (fn [screen entities]
+        (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
+        (println (:input-x screen)) ; the x position of the finger/mouse
+        (println (:input-y screen)) ; the y position of the finger/mouse
+        (println (:pointer screen)) ; the pointer for the event
+        entities)
+      :on-ui-touch-up ; the finger/mouse went up anywhere
+      (fn [screen entities]
+        (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
+        (println (:input-x screen)) ; the x position of the finger/mouse
+        (println (:input-y screen)) ; the y position of the finger/mouse
+        (println (:pointer screen)) ; the pointer for the event
+        (println (:button screen)) ; the mouse button (see button-code)
+        entities))
+
+    ; ui drag functions (for play-clj.ui)
+    (defscreen my-screen
+      :on-ui-drag
+      (fn [screen entities]
+        (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
+        (println (:input-x screen)) ; the x position of the finger/mouse
+        (println (:input-y screen)) ; the y position of the finger/mouse
+        (println (:pointer screen)) ; the pointer for the event
+        entities)
+      :on-ui-drag-start
+      (fn [screen entities]
+        (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
+        (println (:input-x screen)) ; the x position of the finger/mouse
+        (println (:input-y screen)) ; the y position of the finger/mouse
+        (println (:pointer screen)) ; the pointer for the event
+        entities)
+      :on-ui-drag-stop
+      (fn [screen entities]
+        (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
+        (println (:input-x screen)) ; the x position of the finger/mouse
+        (println (:input-y screen)) ; the y position of the finger/mouse
+        (println (:pointer screen)) ; the pointer for the event
+        entities))
+
+    ; ui focus functions (for play-clj.ui)
+    (defscreen my-screen
+      :on-ui-keyboard-focus-changed
+      (fn [screen entities]
+        (println (:event screen)) ; the FocusListener.FocusEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/FocusListener.FocusEvent.html
+        (println (:actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html
+        (println (:focused? screen)) ; whether it is focused
+        entities)
+      :on-ui-scroll-focus-changed
+      (fn [screen entities]
+        (println (:event screen)) ; the FocusListener.FocusEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/FocusListener.FocusEvent.html
+        (println (:actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html
+        (println (:focused? screen)) ; whether it is focused
+        entities))
+
+    ; ui gesture functions (for play-clj.ui)
+    (defscreen my-screen
+      :on-ui-fling ; the user dragged a finger over the screen and lifted it
+      (fn [screen entities]
+        (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
+        (println (:velocity-x screen)) ; the x-axis velocity (s)
+        (println (:velocity-y screen)) ; the y-axis velocity (s)
+        (println (:button screen)) ; the mouse button (see button-code)
+        entities)
+      :on-ui-long-press ; the user pressed
+      (fn [screen entities]
+        (println (:actor screen)) ; the Actor - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/Actor.html
+        (println (:input-x screen)) ; the x position of the finger
+        (println (:input-y screen)) ; the y position of the finger
+        entities)
+      :on-ui-pan ; the user dragged a finger over the screen
+      (fn [screen entities]
+        (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
+        (println (:input-x screen)) ; the x position of the finger
+        (println (:input-y screen)) ; the y position of the finger
+        (println (:delta-x screen)) ; the x-axis distance moved
+        (println (:delta-y screen)) ; the y-axis distance moved
+        entities)
+      :on-ui-pan-stop ; the user is no longer panning
+      (fn [screen entities]
+        (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
+        (println (:input-x screen)) ; the x position of the finger
+        (println (:input-y screen)) ; the y position of the finger
+        (println (:pointer screen)) ; the pointer for the event
+        (println (:button screen)) ; the mouse button (see button-code)
+        entities)
+      :on-ui-pinch ; the user performed a pinch zoom gesture
+      (fn [screen entities]
+        (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
+        (println (:initial-pointer-1 screen)) ; the x/y start position of finger 1
+        (println (:initial-pointer-2 screen)) ; the x/y start position of finger 2
+        (println (:pointer-1 screen)) ; the x/y end position of finger 1
+        (println (:pointer-2 screen)) ; the x/y end position of finger 2
+        entities)
+      :on-ui-tap ; the user tapped
+      (fn [screen entities]
+        (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
+        (println (:input-x screen)) ; the x position of the finger
+        (println (:input-y screen)) ; the y position of the finger
+        (println (:count screen)) ; the number of taps
+        (println (:button screen)) ; the mouse button (see button-code)
+        entities)
+      :on-ui-zoom ; the user performed a pinch zoom gesture
+      (fn [screen entities]
+        (println (:event screen)) ; the InputEvent - http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/InputEvent.html
+        (println (:initial-distance screen)) ; the start distance between fingers
+        (println (:distance screen)) ; the end distance between fingers
+        entities))"
   [n & {:keys [] :as options}]
   `(let [fn-syms# (->> (for [[k# v#] ~options]
                          [k# (intern *ns* (symbol (str '~n "-" (name k#))) v#)])


Remove commented code.

Remove commented code.

--- src/promesa/impl.cljc
+++ src/promesa/impl.cljc
@@ -58,18 +58,6 @@
          (-reject! [_ v]
            (.reject state v))))))

-;; (defn factory->promise
-;;   [f]
-;;   #?(:cljs (new *default-promise* f)
-;;      :clj  (let [p (CompletableFuture.)
-;;                  reject #(.completeExceptionally p %)
-;;                  resolve #(.complete p %)]
-;;              (try
-;;                (f resolve reject)
-;;                (catch Throwable e
-;;                  (reject e)))
-;;              p)))
-
 #?(:cljs
    (defn extend-promise!
      [t]


Fix typo

Fix typo

--- src/re_frame/rum.cljs
+++ src/re_frame/rum.cljs
@@ -13,7 +13,7 @@
                            :else (throw "Did you forget to include react?")))

 (def ^:private PropTypes (cond (exists? js/PropTypes) js/PropTypes
-                               (exists js/React.PropTypes) js/React.PropTypes
+                               (exists? js/React.PropTypes) js/React.PropTypes
                                (exists? js/require) (js/require "prop-types")
                                :else (throw "Did you forget to include prop-types?")))


Incorporated mreinhardt's usability suggestions

--- src/riemann/druid.clj
+++ src/riemann/druid.clj
@@ -7,16 +7,16 @@

 (defn post-datapoint
   "Post the riemann metrics as datapoints."
-  [host port dataset json-data]
-  (let [p (str port)
-        scheme "http://"
+  [host port dataset json-data http-opts]
+  (let [scheme "http://"
         endpoint "/v1/post/"
-        url (str scheme host ":" p endpoint dataset)
-        http-options {:body json-data
-                      :content-type :json
-                      :conn-timeout 5000
-                      :socket-timeout 5000
-                      :throw-entire-message? true}]
+        url (str scheme host ":" port endpoint dataset)
+        http-options (assoc (merge {:conn-timeout 5000
+                                    :socket-timeout 5000
+                                    :throw-entire-message? true}
+                                   http-opts)
+                            :body json-data
+                            :content-type :json)]
     (http/post url http-options)))

 (defn generate-event [event]
@@ -61,4 +61,4 @@
                      [event])
             post-data (mapv generate-event events)
             json-data (generate-string post-data)]
-        (post-datapoint (:host opts) (:port opts) (:dataset opts) json-data)))))
+        (post-datapoint (:host opts) (:port opts) (:dataset opts) json-data (get opts :http-options {}))))))


Add msg to clojure.tools.logging/error

Add msg to clojure.tools.logging/error

--- src/spiral/adapters/http_kit.clj
+++ src/spiral/adapters/http_kit.clj
@@ -31,5 +31,5 @@
                         (clojure.stacktrace/print-cause-trace e)
                         (http-kit/send! http-kit-chan (-> (response (str "Encountered error! See log."))
                                                           (status 500)))
-                        (log/error e))))))))
+                        (log/error e "Encountered unhandled error from spiral httpkit adapapter."))))))))


Fix commit button.

Fix commit button.

--- src/sqls/ui/seesaw/worksheet.clj
+++ src/sqls/ui/seesaw/worksheet.clj
@@ -50,6 +50,11 @@
     (assert (not (nil? sql-text-area)))
     (seesaw.core/listen sql-text-area :key-pressed (partial on-key-press! handler ctrl-enter-keystroke))))

+(defn set-on-commit-handler!
+  [frame handler]
+  (let [btn-commit (seesaw.core/select frame [:#commit])]
+    (seesaw.core/listen btn-commit :action (fn [_] (handler)))))
+
 (defn set-on-rollback-handler!
   [frame handler]
   (let [btn-rollback (seesaw.core/select frame [:#rollback])]
@@ -59,10 +64,12 @@
   [^JFrame frame
    handlers]
   {:pre [(:ctrl-enter handlers)
+         (:commit handlers)
          (:rollback handlers)
          (:closed handlers)]}
   (set-ctrl-enter-handler! frame (:ctrl-enter handlers))
   (set-on-rollback-handler! frame (:rollback handlers))
+  (set-on-commit-handler! frame (:commit handlers))
   (seesaw.core/listen frame :window-closed (fn [_] ((:closed handlers)))))

 (defn get-contents!
@@ -418,12 +425,6 @@
 ;     (assert (not= btn-explain nil))
 ;     (seesaw.core/listen btn-explain :action (fn [e] (handler)))))

-
-(defn set-on-commit-handler
-  [frame handler]
-  (let [btn-commit (seesaw.core/select frame [:#commit])]
-    (seesaw.core/listen btn-commit :action (fn [_] (handler)))))
-
 (defn set-on-execute-handler
   "Set Execute button handler."
   [frame handler]
@@ -431,7 +432,6 @@
     (assert (not= btn-execute nil))
     (seesaw.core/listen btn-execute :action (fn [_] (handler)))))

-
 (defn set-on-new-handler
   "Set New button handler."
   [frame handler]
@@ -439,14 +439,12 @@
     (assert (not= btn-new nil))
     (seesaw.core/listen btn-new :action (fn [_] (handler)))))

-
 (defn set-on-save-handler
   "Set Save button handler."
   [frame handler]
   (let [btn-save (seesaw.core/select frame [:#save])]
     (assert (not= btn-save nil))
     (seesaw.core/listen btn-save :action (fn [_] (handler)))))
-

 (defn set-on-open-handler
   [frame handler]


Optional single threading, random-seed, lrand-nth, and replacements of non-local random generator calls.

--- src/clojush.clj
+++ src/clojush.clj
@@ -61,6 +61,8 @@
 (def global-pop-when-tagging (atom true))
 (def global-reuse-errors (atom true))

+(def global-use-single-thread (atom false))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; random code generator

@@ -81,6 +83,11 @@
   ([] (. thread-local-random-generator (nextFloat)))
   ([n] (* n (lrand))))

+(defn lrand-nth
+  "Return a random element of the collection."
+  [coll]
+  (nth coll (. thread-local-random-generator (nextInt (count coll)))))
+
 (defn decompose
   "Returns a list of at most max-parts numbers that sum to number.
 The order of the numbers is not random (you may want to shuffle it)."
@@ -95,7 +102,7 @@
   "Returns a random expression containing the given number of points."
   [points atom-generators]
   (if (< points 2)
-    (let [element (rand-nth atom-generators)]
+    (let [element (lrand-nth atom-generators)]
       (if (fn? element)
         (element)
         element))
@@ -647,7 +654,7 @@

 (define-registered boolean_rand
   (fn [state]
-    (push-item (rand-nth [true false]) :boolean state)))
+    (push-item (lrand-nth [true false]) :boolean state)))

 (define-registered integer_rand
   (fn [state]
@@ -1555,30 +1562,30 @@
 from 0 to the specified limit (exclusive)."
   [types limit]
   (fn [] (symbol (str "tag_"
-                   (name (rand-nth types))
+                   (name (lrand-nth types))
                    "_"
-                   (str (rand-int limit))))))
+                   (str (lrand-int limit))))))

 (defn untag-instruction-erc
   "Returns a function which, when called on no arguments, returns a symbol of the form
 untag_<number> where number is in the range from 0 to the specified limit (exclusive)."
   [limit]
   (fn [] (symbol (str "untag_"
-                   (str (rand-int limit))))))
+                   (str (lrand-int limit))))))

 (defn tagged-instruction-erc
   "Returns a function which, when called on no arguments, returns a symbol of the form
 tagged_<number> where number is in the range from 0 to the specified limit (exclusive)."
   [limit]
   (fn [] (symbol (str "tagged_"
-                   (str (rand-int limit))))))
+                   (str (lrand-int limit))))))

 (defn tagged-code-instruction-erc
   "Returns a function which, when called on no arguments, returns a symbol of the form
 tagged_code_<number> where number is in the range from 0 to the specified limit (exclusive)."
   [limit]
   (fn [] (symbol (str "tagged_code_"
-                   (str (rand-int limit))))))
+                   (str (lrand-int limit))))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; tagged-code macros
@@ -1613,9 +1620,9 @@
 which is a map."
   ([instruction tag-limit num-argument-tags num-result-tags additional-arg-generator]
     (fn [] {:tagged_code_macro true :instruction instruction
-            :argument_tags (repeatedly num-argument-tags #(rand-int tag-limit))
+            :argument_tags (repeatedly num-argument-tags #(lrand-int tag-limit))
             :additional_args (additional-arg-generator)
-            :result_tags (repeatedly num-result-tags #(rand-int tag-limit))}))
+            :result_tags (repeatedly num-result-tags #(lrand-int tag-limit))}))
   ([instruction tag-limit num-argument-tags num-result-tags]
     (tagged-code-macro-erc instruction tag-limit num-argument-tags num-result-tags (fn [] ()))))

@@ -1743,9 +1750,9 @@
   [tree]
   (if (seq? tree)
     (if (> (lrand) @global-node-selection-leaf-probability)
-      (second (rand-nth (filter #(seq? (first %)) (map #(list %1 %2) (all-items tree) (iterate inc 0)))))
+      (second (lrand-nth (filter #(seq? (first %)) (map #(list %1 %2) (all-items tree) (iterate inc 0)))))
       (let [indexed-leaves (filter #(not (seq? (first %))) (map #(list %1 %2) (all-items tree) (iterate inc 0)))]
-        (if (empty? indexed-leaves) 0 (second (rand-nth indexed-leaves)))))
+        (if (empty? indexed-leaves) 0 (second (lrand-nth indexed-leaves)))))
     0))

 (defn choose-node-index-by-tournament
@@ -1881,8 +1888,8 @@
 (defn gaussian-noise-factor
   "Returns gaussian noise of mean 0, std dev 1."
   []
-  (* (Math/sqrt (* -2.0 (Math/log (rand))))
-    (Math/cos (* 2.0 Math/PI (rand)))))
+  (* (Math/sqrt (* -2.0 (Math/log (lrand))))
+    (Math/cos (* 2.0 Math/PI (lrand)))))

 (defn perturb-with-gaussian-noise
   "Returns n perturbed with std dev sd."
@@ -1895,7 +1902,7 @@
   [code per-num-perturb-probability sd]
   (postwalklist (fn [item]
                   (if (and (float? item)
-                        (< (rand) per-num-perturb-probability))
+                        (< (lrand) per-num-perturb-probability))
                     (perturb-with-gaussian-noise sd item)
                     item))
     code))
@@ -2052,15 +2059,15 @@
              evalpush-limit evalpush-time-limit node-selection-method node-selection-leaf-probability
              node-selection-tournament-size pop-when-tagging gaussian-mutation-probability
              gaussian-mutation-per-number-mutation-probability gaussian-mutation-standard-deviation
-	     reuse-errors problem-specific-report]
+	     reuse-errors problem-specific-report use-single-thread random-seed]
       :or {error-function (fn [p] '(0)) ;; pgm -> list of errors (1 per case)
            error-threshold 0
            population-size 1000
            max-points 50
            atom-generators (concat @registered-instructions
-                             (list
-                               (fn [] (lrand-int 100))
-                               (fn [] (lrand))))
+                                   (list
+                                    (fn [] (lrand-int 100))
+                                    (fn [] (lrand))))
            max-generations 1001
            mutation-probability 0.4
            mutation-max-points 20
@@ -2084,82 +2091,90 @@
            gaussian-mutation-standard-deviation 0.1
 	   reuse-errors true
 	   problem-specific-report default-problem-specific-report
+           use-single-thread false
+           random-seed (System/nanoTime)
            }}]
-  ;; set globals from parameters
-  (reset! global-atom-generators atom-generators)
-  (reset! global-max-points-in-program max-points)
-  (reset! global-evalpush-limit evalpush-limit)
-  (reset! global-evalpush-time-limit evalpush-time-limit)
-  (reset! global-node-selection-method node-selection-method)
-  (reset! global-node-selection-leaf-probability node-selection-leaf-probability)
-  (reset! global-node-selection-tournament-size node-selection-tournament-size)
-  (reset! global-pop-when-tagging pop-when-tagging)
-  (reset! global-reuse-errors reuse-errors)
-  (printf "\nStarting PushGP run.\n\n") (flush)
-  (print-params
-    (error-function error-threshold population-size max-points atom-generators max-generations
-      mutation-probability mutation-max-points crossover-probability
-      simplification-probability gaussian-mutation-probability
-      gaussian-mutation-per-number-mutation-probability gaussian-mutation-standard-deviation
-      tournament-size report-simplifications final-report-simplifications
-      trivial-geography-radius decimation-ratio decimation-tournament-size evalpush-limit
-      evalpush-time-limit node-selection-method node-selection-tournament-size
-      node-selection-leaf-probability pop-when-tagging reuse-errors
-      ))
-  (printf "\nGenerating initial population...\n") (flush)
-  (let [pop-agents (vec (doall (for [_ (range population-size)]
-                                 (agent (make-individual
-                                          :program (random-code max-points atom-generators))
-                                   :error-handler (fn [agnt except] (println except))))))
-        child-agents (vec (doall (for [_ (range population-size)]
-                                   (agent (make-individual)
-                                     :error-handler (fn [agnt except] (println except))))))
-        rand-gens (vec (doall (for [_ (range population-size)]
-                                (java.util.Random.))))]
-    (loop [generation 0]
-      (printf "\n\n-----\nProcessing generation: %s\nComputing errors..." generation) (flush)
-      (dorun (map #(send % evaluate-individual error-function %2) pop-agents rand-gens))
-      (apply await pop-agents) ;; SYNCHRONIZE ; might this need a dorun?
-      (printf "\nDone computing errors.") (flush)
-
-;; some debugging code trying to track down nil agent results.... leaving in case not fixed
-;(println (map :total-error (vec (doall (map deref pop-agents)))))(flush) ;***
-;(loop [ers (map :total-error (vec (doall (map deref pop-agents))))] ;***
-;  (when (some not ers)
-;    (println (map :total-error (vec (doall (map deref pop-agents)))))(flush)
-;    (recur (map :total-error (vec (doall (map deref pop-agents)))))))
-
-      ;; report and check for success
-      (let [best (report (vec (doall (map deref pop-agents))) generation error-function
-			 report-simplifications problem-specific-report)]
-        (if (<= (:total-error best) error-threshold)
-          (do (printf "\n\nSUCCESS at generation %s\nSuccessful program: %s\nErrors: %s\nTotal error: %s\nHistory: %s\nSize: %s\n\n"
-                generation (not-lazy (:program best)) (not-lazy (:errors best)) (:total-error best)
-                (not-lazy (:history best)) (count-points (:program best)))
-            (when print-ancestors-of-solution
-              (printf "\nAncestors of solution:\n")
-              (println (:ancestors best)))
-            (auto-simplify best error-function final-report-simplifications true 500))
-          (do (if (>= generation max-generations)
-                (printf "\nFAILURE\n")
-                (do (printf "\nProducing offspring...") (flush)
-                  (let [pop (decimate (vec (doall (map deref pop-agents)))
-                              (int (* decimation-ratio population-size))
-                              decimation-tournament-size
-                              trivial-geography-radius)]
-                    (dotimes [i population-size]
-                      (send (nth child-agents i)
-                        breed i (nth rand-gens i) pop error-function population-size max-points atom-generators
-                        mutation-probability mutation-max-points crossover-probability
-                        simplification-probability tournament-size reproduction-simplifications
-                        trivial-geography-radius gaussian-mutation-probability
-                        gaussian-mutation-per-number-mutation-probability gaussian-mutation-standard-deviation)))
-                  (apply await child-agents) ;; SYNCHRONIZE
-                  (printf "\nInstalling next generation...") (flush)
-                  (dotimes [i population-size]
-                    (send (nth pop-agents i) (fn [av] (deref (nth child-agents i)))))
-                  (apply await pop-agents) ;; SYNCHRONIZE
-                  (recur (inc generation))))))))))
+  (binding [thread-local-random-generator (java.util.Random. random-seed)]
+    ;; set globals from parameters
+    (reset! global-atom-generators atom-generators)
+    (reset! global-max-points-in-program max-points)
+    (reset! global-evalpush-limit evalpush-limit)
+    (reset! global-evalpush-time-limit evalpush-time-limit)
+    (reset! global-node-selection-method node-selection-method)
+    (reset! global-node-selection-leaf-probability node-selection-leaf-probability)
+    (reset! global-node-selection-tournament-size node-selection-tournament-size)
+    (reset! global-pop-when-tagging pop-when-tagging)
+    (reset! global-reuse-errors reuse-errors)
+    (printf "\nStarting PushGP run.\n\n") (flush)
+    (print-params
+     (error-function error-threshold population-size max-points atom-generators max-generations
+                     mutation-probability mutation-max-points crossover-probability
+                     simplification-probability gaussian-mutation-probability
+                     gaussian-mutation-per-number-mutation-probability gaussian-mutation-standard-deviation
+                     tournament-size report-simplifications final-report-simplifications
+                     trivial-geography-radius decimation-ratio decimation-tournament-size evalpush-limit
+                     evalpush-time-limit node-selection-method node-selection-tournament-size
+                     node-selection-leaf-probability pop-when-tagging reuse-errors
+                     use-single-thread random-seed
+                     ))
+    (printf "\nGenerating initial population...\n") (flush)
+    (let [pop-agents (vec (doall (for [_ (range population-size)]
+                                   ((if use-single-thread atom agent)
+                                    (make-individual
+                                     :program (random-code max-points atom-generators))
+                                    :error-handler (fn [agnt except] (println except))))))
+          child-agents (vec (doall (for [_ (range population-size)]
+                                     ((if use-single-thread atom agent)
+                                      (make-individual)
+                                      :error-handler (fn [agnt except] (println except))))))
+          rand-gens (vec (doall (for [k (range population-size)]
+                                  (java.util.Random. (+ random-seed (inc k))))))]
+      (loop [generation 0]
+        (printf "\n\n-----\nProcessing generation: %s\nComputing errors..." generation) (flush)
+        (dorun (map #((if use-single-thread swap! send) % evaluate-individual error-function %2) pop-agents rand-gens))
+        (when-not use-single-thread (apply await pop-agents)) ;; SYNCHRONIZE ; might this need a dorun?
+        (printf "\nDone computing errors.") (flush)
+
+        ;; some debugging code trying to track down nil agent results.... leaving in case not fixed
+                                        ;(println (map :total-error (vec (doall (map deref pop-agents)))))(flush) ;***
+                                        ;(loop [ers (map :total-error (vec (doall (map deref pop-agents))))] ;***
+                                        ;  (when (some not ers)
+                                        ;    (println (map :total-error (vec (doall (map deref pop-agents)))))(flush)
+                                        ;    (recur (map :total-error (vec (doall (map deref pop-agents)))))))
+
+        ;; report and check for success
+        (let [best (report (vec (doall (map deref pop-agents))) generation error-function
+                           report-simplifications problem-specific-report)]
+          (if (<= (:total-error best) error-threshold)
+            (do (printf "\n\nSUCCESS at generation %s\nSuccessful program: %s\nErrors: %s\nTotal error: %s\nHistory: %s\nSize: %s\n\n"
+                        generation (not-lazy (:program best)) (not-lazy (:errors best)) (:total-error best)
+                        (not-lazy (:history best)) (count-points (:program best)))
+                (when print-ancestors-of-solution
+                  (printf "\nAncestors of solution:\n")
+                  (println (:ancestors best)))
+                (auto-simplify best error-function final-report-simplifications true 500))
+            (do (if (>= generation max-generations)
+                  (printf "\nFAILURE\n")
+                  (do (printf "\nProducing offspring...") (flush)
+                      (let [pop (decimate (vec (doall (map deref pop-agents)))
+                                          (int (* decimation-ratio population-size))
+                                          decimation-tournament-size
+                                          trivial-geography-radius)]
+                        (dotimes [i population-size]
+                          ((if use-single-thread swap! send)
+                           (nth child-agents i)
+                           breed i (nth rand-gens i) pop error-function population-size max-points atom-generators
+                           mutation-probability mutation-max-points crossover-probability
+                           simplification-probability tournament-size reproduction-simplifications
+                           trivial-geography-radius gaussian-mutation-probability
+                           gaussian-mutation-per-number-mutation-probability gaussian-mutation-standard-deviation)))
+                      (when-not use-single-thread (apply await child-agents)) ;; SYNCHRONIZE
+                      (printf "\nInstalling next generation...") (flush)
+                      (dotimes [i population-size]
+                        ((if use-single-thread swap! send)
+                         (nth pop-agents i) (fn [av] (deref (nth child-agents i)))))
+                      (when-not use-single-thread (apply await pop-agents)) ;; SYNCHRONIZE
+                      (recur (inc generation)))))))))))

 (defn pushgp-map
   "Calls pushgp with the args in argmap."


Adds a fn for running spec from the repl. Not useful until the chdir on startup is removed

--- backend/src/circle/ruby.clj
+++ backend/src/circle/ruby.clj
@@ -96,4 +96,14 @@
   (->ruby {:x "foo" :y "bar" 5 nil}) => (eval "{:x => 'foo', :y => 'bar', 5 => nil}")

   (->ruby {:foo "bar",    5 nil,     "x" 7.0,   :baa [5 "mrah" {:boo :foo}]}) =>
-    (eval "{:foo => 'bar', 5 => nil, 'x' => 7.0, :baa=> [5, 'mrah', {:boo => :foo}]}"))+  (eval "{:foo => 'bar', 5 => nil, 'x' => 7.0, :baa=> [5, 'mrah', {:boo => :foo}]}"))
+
+(defn rspec
+  "runs rspec. Useful from clojure repl"
+  []
+  (eval "
+require 'rubygems'
+require 'rspec/core/rake_task'
+
+RSpec::Core::Runner.run(['spec'])
+"))


Fix example and add a hint

Fix example and add a hint

Fix the first example and add a hint about where to get the token from. The webhook_uri support still isn't working right, but this should be a decent work around for anyone trying to use this module for now.

--- src/riemann/slack.clj
+++ src/riemann/slack.clj
@@ -49,12 +49,16 @@
   Takes your account name, webhook token, bot username and channel name.
   Returns a function that will post a message into slack.com channel:

-  (def credentials {:account \"some_org\", :token \"53CR3T\"}
+  (def credentials {:account \"some_org\", :token \"53CR3T\"})
   (def slacker (slack credentials {:username \"Riemann bot\"
                                    :channel \"#monitoring\"
                                    :icon \":smile:\"}))

   (by [:service] slacker)
+
+  Hint: token is the last part of the webhook URL that Slack gives you.
+  https://hooks.slack.com/services/QWERSAFG0/AFOIUYTQ48/120984SAFJSFR
+  Token in this case would be 120984SAFJSFR

   You can also supply a custom formatter for formatting events into Slack
   messages. Formatter result may contain:


src/riemann/xymon.clj: *send-line-error-handler*, send-line: opts is also provided to *send-line-error-handler*

--- src/riemann/xymon.clj
+++ src/riemann/xymon.clj
@@ -77,8 +77,9 @@
   *send-line-error-handler* is the default error handler invoked by
   send-line if none is provided.
   "
-  [exception]
-  (error exception "cannot reach xymon host"))
+  [opts exception]
+  (error exception (format "cannot reach xymon host (%s:%s)"
+                           (:host opts) (:port opts))))

 (defn send-line
   "
@@ -104,7 +105,7 @@
           (.write writer line)
           (.flush writer)))
       (catch Exception e
-        ((:error-handler opts) e)))))
+        ((:error-handler opts) opts e)))))

 (defn xymon
   "


adding extra test for :a

adding extra test for :a

--- test/org/libraryweasel/ligature/core_test.clj
+++ test/org/libraryweasel/ligature/core_test.clj
@@ -42,7 +42,8 @@
     (is (statement? (statement "hello" "world" "triple" "graph")))
     (is (not (statement? (statement 5 3 66 554))))
     (is (not (statement? (statement "test" "test" :a))))
-    (is (= (statement "test" :a "test" "test") (statement "test" "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" "test" "test"))))) ; TODO more test cases
+    (is (= (statement "test" :a "test" "test") (statement "test" "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" "test" "test")))
+    (is (statement? (statement "test" :a "test" "test"))))) ; TODO more test cases

 (deftest lang-tag?-test
   (testing "Common examples"


Divide interval by function

Divide interval by function

This aligns with group-by fn, and feels more intuitve and powerful
than using keywords.

--- src/tick/interval.clj
+++ src/tick/interval.clj
@@ -588,6 +588,8 @@
   (divide-by ival t/year))

 (extend-protocol IDivisibleInterval
+  clojure.lang.Fn
+  (divide [f ival] (divide-by ival f))
   clojure.lang.Keyword
   (divide [kw ival] (divide-by-keyword ival kw))
   Duration


Fixes documentation

Fixes documentation

--- src/suricatta/dsl.clj
+++ src/suricatta/dsl.clj
@@ -487,7 +487,7 @@
     (DSL/exists @q)))

 (defn not-exists
-  "Create an exists condition."
+  "Create a not-exists condition."
   [q]
   (defer
     (DSL/notExists @q)))


add enable_dns_hostnames option

add enable_dns_hostnames option

--- src/terraboot/vpc.clj
+++ src/terraboot/vpc.clj
@@ -101,7 +101,8 @@
     (merge-in
      (resource "aws_vpc" vpc-name
                {:tags {:Name vpc-name}
-                :cidr_block vpc-cidr-block})
+                :cidr_block vpc-cidr-block
+                :enable_dns_hostnames true})

      (elasticsearch-cluster "elasticsearch" {:vpc-name vpc-name})


add fromArray method to vector builder

add fromArray method to vector builder

--- src/transit/core.cljs
+++ src/transit/core.cljs
@@ -34,7 +34,8 @@
   Object
   (init [_] (transient []))
   (add [_ v x] (conj! v x))
-  (finalize [_ v] (persistent! v)))
+  (finalize [_ v] (persistent! v))
+  (fromArray [_ arr] (cljs.core/PersistentVector.fromArray arr true)))

 (defn reader
   "Return a transit reader. type may be either :json or :json-verbose.


Simplified outer rect calculation.

Simplified outer rect calculation.

--- src/uxbox/shapes.cljs
+++ src/uxbox/shapes.cljs
@@ -230,12 +230,9 @@

 (defmethod outer-rect' ::shape
   [{:keys [group] :as shape}]
-  (let [group (get-in @st/state [:shapes-by-id group])]
-    (as-> shape $
-      (assoc $ :x (+ (:x1 shape) (:dx group 0)))
-      (assoc $ :y (+ (:y1 shape) (:dy group 0)))
-      (merge $ (size $))
-      (container-rect $))))
+  (as-> shape $
+    (assoc $ :x (:x1 shape) :y (:y1 shape))
+    (merge $ (size $))))

 (defmethod outer-rect' :builtin/line
   [{:keys [x1 y1 x2 y2 group] :as shape}]
@@ -267,15 +264,15 @@
         x' (apply max (map (fn [{:keys [x width]}] (+ x width)) shapes))
         y' (apply max (map (fn [{:keys [y height]}] (+ y height)) shapes))
         width (- x' x)
-        height (- y' y)]
-    (let [group (get-in @st/state [:shapes-by-id group])]
-      (as-> shape $
-        (merge $ {:width width
-                  :height height
-                  :x (+ x (or (:dx group) 0))
-                  :y (+ y (or (:dy group) 0))
-                  })
-        (container-rect $)))))
+        height (- y' y)
+        x (+ x dx)
+        y (+ y dy)]
+    (as-> shape $
+      (merge $ {:width width
+                :height height
+                :x x
+                :y y})
+      (container-rect $))))

 (defmethod outer-rect' :default
   [shape _]


safety checkin

safety checkin

--- src/web_sink/core.clj
+++ src/web_sink/core.clj
@@ -4,14 +4,15 @@
   ; => nil
   (:require [hiccup.core :refer [html h]]
             ;[compojure.handler :as handler]
-            [ring.middleware.defaults :refer [wrap-defaults api-defaults]]
             [compojure.route :as route]
             [compojure.core :refer [GET POST ANY context defroutes]]
-            [ring.middleware.json :refer [wrap-json-params wrap-json-response]]
             [web-sink.db :as db]
             [net.cgrand.enlive-html :as ehtml]
             [ring.adapter.jetty :refer [run-jetty]]
+            [ring.middleware.json :refer [wrap-json-params wrap-json-response]]
+            [ring.middleware.defaults :refer [wrap-defaults api-defaults]]
             [ring.middleware.cookies :refer [wrap-cookies]]
+            [ring.middleware.session.cookie :refer [cookie-store]]
             [clojure.java.shell :refer [sh]]
             [cheshire.core :refer [generate-string]]))

@@ -63,8 +64,8 @@
     (apply str t)))

 (comment (def render-to-response
-    (comp response render)))
-
+    (comp response render))
+)
 (defn record-post!
   [request]
   (db/add-to-users! (:newpost (:params request)) (str request)))
@@ -107,7 +108,13 @@

 ;http://stackoverflow.com/questions/28904260/dynamic-handler-update-in-clojure-ring-compojure-repl
 (def app
-  (-> #'app-routes (wrap-defaults  (assoc api-defaults :cookies true))))
+  (-> #'app-routes
+      (wrap-defaults
+       (assoc api-defaults
+              :cookies true
+              :proxy true
+              :session {:flash true :store (cookie-store)}
+              :security {:anti-forgery true}))))

 ;since the port can be acquired only once we create and start the server with defonce
 (defonce wserver (run-jetty app {:port 3001 :join? false}))


Add resolve-required utility

Add resolve-required utility

--- clojuresque-runtime/src/main/resources/clojuresque/util.clj
+++ clojuresque-runtime/src/main/resources/clojuresque/util.clj
@@ -19,3 +19,11 @@
 (defn namespaces
   [files]
   (distinct (keep namespace-of-file files)))
+
+(defn resolve-required
+  [fully-qualified-sym]
+  (let [slash  (.indexOf ^String fully-qualified-sym "/")
+        nspace (symbol (subs fully-qualified-sym 0 slash))
+        hfn    (symbol (subs fully-qualified-sym (inc slash)))]
+    (require nspace)
+    (ns-resolve nspace hfn)))


Add some random walk series to the test agent to help test autoscale behavior.

--- metlog-agent/config.clj
+++ metlog-agent/config.clj
@@ -1,7 +1,25 @@
 (def start-t (System/currentTimeMillis))

+(defn random-sampler [ ]
+  (let [current (atom 0.0)]
+    (fn [ ]
+      (swap! current #(+ % (/ (+ (Math/random) (Math/random)) 2) -0.5)))))
+
+(def rs-0 (random-sampler))
+(def rs-1 (random-sampler))
+(def rs-2 (random-sampler))
+
+(defsensor random-unconstrained {:poll-interval (seconds 10)}
+  (rs-0))
+
+(defsensor random-positive {:poll-interval (seconds 10)}
+  (+ 0.1 (Math/abs (rs-1))))
+
+(defsensor random-negative {:poll-interval (seconds 10)}
+  (- -0.1 (Math/abs (rs-2))))
+
 (defsensor math {:poll-interval (seconds 10)}
-  {:sine (Math/sin (/ (- (System/currentTimeMillis) start-t) (minutes 1)))
+  {:sine (+ 0.3 (Math/sin (/ (- (System/currentTimeMillis) start-t) (minutes 1))))
    :cosine (Math/cos (/ (- (System/currentTimeMillis) start-t) (minutes 1))) })

 (defsensor steps-ascending {:poll-interval (seconds 5)}


checking if redirect-uri can be derived from location


Fix bug

Fix bug


Remove default player names

Remove default player names


add defdispatch

add defdispatch

--- src/useful/experimental.clj
+++ src/useful/experimental.clj
@@ -54,4 +54,31 @@
   (let [[names thens elses] (alternates 3 bindings)]
     `(if ~test
        (let [~@(interleave names thens)] ~@forms)
-       (let [~@(interleave names elses)] ~@forms))))+       (let [~@(interleave names elses)] ~@forms))))
+
+(defn dispatcher
+  "Returns a function that dispatches using the given dispatch function to determine the
+  namespace and function to call."
+  [dispatch-fn & options]
+  (let [options (into-map options)]
+    (fn [& args]
+      (let [[ns method] (map symbol
+                             ((juxt namespace name)
+                              (symbol (apply dispatch-fn args))))]
+        (try (require ns)
+             (catch java.io.FileNotFoundException e
+               (throw (IllegalArgumentException. (str "cannot resolve namespace: " ns)))))
+        (if-let [method (ns-resolve ns method)]
+          (apply method args)
+          (throw (IllegalArgumentException. (str "cannot resolve method: " ns "/" method))))))))
+
+(defmacro defdispatch
+  "Defines a function that dispatches using the given dispatch function to determine the
+  namespace and function to call."
+  [name & options]
+  (let [[defn-options options] (split-with #(or (string? %) (map? %)) options)
+        dispatch-fn (first options)
+        options     (rest options)]
+    `(let [dispatcher# (apply dispatcher ~dispatch-fn ~options)]
+       (defn ~name ~@defn-options [& args#]
+         (apply dispatcher# args#)))))


better assert processing in future+; more robust error capture in run-flow-program

--- src/aerobio/pgmgraph.clj
+++ src/aerobio/pgmgraph.clj
@@ -64,7 +64,12 @@
      (try
        ~@body
        (catch Error e#
-         {:error (type e#), :msg ((Throwable->map e#) :cause)})
+         {:error (type e#),
+          :msg (->  ((Throwable->map e#) :cause)
+                    (str/split #"\n") first (str/split #": ") rest
+                    (->> (str/join ": ")))})
+       (catch clojure.lang.ExceptionInfo e#
+         {:error (type e#) :msg (str (.getMessage e#) ": " (.getData e#))})
        (catch Exception e#
          {:error (type e#), :msg ((Throwable->map e#) :cause)}))))

@@ -847,18 +852,22 @@
   [dfg]
   (mapv (fn[node]
           (future+
-           (let [jnres (apply job-node node)]
-             (if (proc? (first node))
-               (let [exit-code (shl/exit-code (first node))
-                     msg (if (= 0 exit-code)
-                           :success
-                           (shl/stream-to-string (first node) :err))]
-                 (infof "%s: exit code: %s\n%s"
-                        (-> node first :id)
-                        exit-code
-                        msg))
-               (infof "Done, node %s" (-> node first :id)))
-             jnres)))
+           (let [jnres (apply job-node node)
+                 msg (if (proc? (first node))
+                       (let [exit-code (shl/exit-code (first node))
+                             msg (if (= 0 exit-code)
+                                   :success
+                                   (shl/stream-to-string (first node) :err))]
+                         (format "%s: exit code: %s\n%s"
+                                 (-> node first :id)
+                                 exit-code
+                                 msg))
+                       (format "Done, node %s" (-> node first :id)))]
+             (infof "%s" msg)
+             {:request {:name (-> node first :name)
+                        :args (-> node first :args)
+                        :msg msg}
+              :result jnres})))
         dfg))


Add lcs test for a sequence of maps.

Add lcs test for a sequence of maps.


reformat PART tests

reformat PART tests

--- test/subrosa/test/rooms.clj
+++ test/subrosa/test/rooms.clj
@@ -19,32 +19,27 @@
     (is (received? s #"353 dan = #foo :dan"))
     (is (received? s #"End of NAMES list"))))

-(deftest part
-  (testing "a user"
-    (with-connection user
-      (transmit user "NICK don")
-      (transmit user "USER don 0 * :Don K. Bahls")
-      (transmit user "JOIN #foo")
-      (with-connection observer
-        (transmit observer "NICK x")
-        (transmit observer "USER x 0 * :USER X")
-        (transmit observer "JOIN #foo")
-        (transmit observer "JOIN #lolcats")
-        (testing "requesting to part"
-          (testing "should receive get an error"
-            (testing "if they don't provide a channel to part"
-              (transmit user "PART")
-              (is (received? user #"461 don :Not enough parameters")))
-            (testing "if the channel doesn't exist"
-              (transmit user "PART #bahls")
-              (is (received? user #"403 don :No such channel")))
-            (testing "if they aren't in the channel"
-              (transmit user "PART #lolcats")
-              (is (received? user #"442 don :You're not on that channel"))))
-          (transmit user "PART #foo")
-          (testing "should trigger a part message sent to the whole channel"
-            (doseq [x [user observer]]
-              (is (received? x #":don!don@localhost PART #foo :don")))))))))
+(deftest part-command
+  (with-connection s1
+    (transmit s1 "NICK dan")
+    (transmit s1 "USER dan 0 * :Dan Larkin")
+    (transmit s1 "JOIN #foo")
+    (with-connection s2
+      (transmit s2 "NICK dan2")
+      (transmit s2 "USER dan 0 * :Dan Larkin")
+      (transmit s2 "JOIN #foo")
+      (transmit s2 "JOIN #foo2")
+      (transmit s1 "PART")
+      (is (received? s1 #"461 dan PART :Not enough parameters"))
+      (transmit s1 "PART #foobar")
+      (is (received? s1 #"403 dan #foobar :No such channel"))
+      (transmit s1 "PART #foo2")
+      (is (received? s1 #"442 dan #foo2 :You're not on that channel"))
+      (transmit s1 "PART #foo")
+      (is (received? s1 #":dan!dan@.* PART #foo :dan"))
+      (is (received? s2 #":dan!dan@.* PART #foo :dan"))
+      (transmit s2 "PART #foo :Hey guys I'm outta here!")
+      (is (received? s2 #":dan2!dan@.* PART #foo :Hey guys I'm outta here!")))))

 (deftest topic-command
   (with-connection s


add catnip for now

add catnip for now

--- profiles.clj
+++ profiles.clj
@@ -1,6 +1,6 @@
 {
  :user {
-   :plugins [[lein-clojars "0.9.0"] [lein-light "0.0.4"]]
+   :plugins [[lein-clojars "0.9.0"] [lein-light "0.0.4"] [lein-catnip "0.5.0"]]
    :repl-options {
      :init (do
        (use '[table.core :only (table)])


fix clojure version

fix clojure version

--- ring-container/build.boot
+++ ring-container/build.boot
@@ -7,7 +7,7 @@
   :license {"Apache 2.0" "http://www.apache.org/licenses/LICENSE-2.0.txt"}
   :edition "community"

-  :dependencies '[[org.clojure/clojure "1.8.0"]
+  :dependencies '[[org.clojure/clojure "1.9.0-alpha14"]
                   [sixsq/build-utils "0.1.4" :scope "test"]])

 (require '[sixsq.build-fns :refer [merge-defaults


template: bump deps

template: bump deps

--- lein/src/leiningen/new/mala/project.clj
+++ lein/src/leiningen/new/mala/project.clj
@@ -10,17 +10,20 @@
   :global-vars {*warn-on-reflection* false *assert* false}

   :dependencies [[org.clojure/clojure "1.7.0"]
-                 [org.clojure/clojurescript "1.7.28"]
-                 [org.clojure/core.async "0.1.346.0-17112a-alpha"]
+                 [org.clojure/clojurescript "1.7.228"]
+                 [org.clojure/core.async "0.2.374"]
                  [org.omcljs/om "0.9.0"]
-                 [sablono "0.3.6"]
+                 [cljsjs/react "0.14.3-0"]
+                 [cljsjs/react-dom "0.14.3-1"]
+                 [cljsjs/react-dom-server "0.14.3-0"]
+                 [facjure/mesh "0.4.0"]
+                 [sablono "0.5.3"]
                  [secretary "1.2.3"]
-                 [cljs-http "0.1.37"]
-                 [facjure/mesh "0.4.0"]]
+                 [cljs-http "0.1.39"]]

-  :plugins [[lein-cljsbuild "1.0.6"]
-            [lein-figwheel "0.3.3"]
-            [lein-garden "0.2.5"]
+  :plugins [[lein-cljsbuild "1.1.2"]
+            [lein-figwheel "0.5.0"]
+            [lein-garden "0.2.6"]
             [lein-pdo "0.1.1"]]

   :source-paths ["src" "env" "target/classes"]
@@ -56,9 +59,9 @@
                                 :pretty-print? false}}]}

   :profiles {:dev {:env {:is-dev true}
-                   :dependencies [[figwheel "0.3.3"]
-                                  [figwheel-sidecar "0.3.3"]
-                                  [ring/ring-json "0.3.1"]
+                   :dependencies [[figwheel "0.5.0"]
+                                  [figwheel-sidecar "0.5.0"]
+                                  [ring/ring-json "0.4.0"]
                                   [fogus/ring-edn "0.2.0"]
                                   [compojure "1.3.4"]
                                   [javax.servlet/servlet-api "2.5"]


Fixes for sandbox build

Fixes for sandbox build

--- planck-cljs/project.clj
+++ planck-cljs/project.clj
@@ -3,12 +3,12 @@
              {:dependencies [#_[org.clojure/clojurescript "1.8.51"]
                              [tubular "1.0.0"]]
               :source-paths ["dev"]}
-             :build
-             {:dependencies [[com.cognitect/transit-clj "0.8.275"]]}}
+             :build {}}
   :dependencies [[org.clojure/clojure "1.8.0"]
                  [org.clojure/clojurescript "1.8.51"]       ; comment if building own
                  [org.clojure/tools.reader "1.0.0-beta1"]
                  [tailrecursion/cljson "1.0.7"]
+                 [com.cognitect/transit-clj "0.8.275"]
                  [com.cognitect/transit-cljs "0.8.220"]
                  [fipp "0.6.5"]
                  [malabarba/lazy-map "1.1"]


Mockito/verify functions now behave like test assertions

--- clstreams/test/clstreams/testutil/mockito.clj
+++ clstreams/test/clstreams/testutil/mockito.clj
@@ -1,4 +1,5 @@
 (ns clstreams.testutil.mockito
+  (:require [clojure.test :as test])
   (:import org.mockito.Mockito))

 (defn mock [cls] (Mockito/mock cls))
@@ -19,7 +20,10 @@
   ([mock-obj-expr method-invocation-form]
    `(verify-> ~mock-obj-expr ~method-invocation-form (Mockito/times 1)))
   ([mock-obj-expr method-invocation-form counting-predicate-expr]
-   `(-> ~mock-obj-expr (Mockito/verify ~counting-predicate-expr) ~method-invocation-form)))
+   `(try
+      (-> ~mock-obj-expr (Mockito/verify ~counting-predicate-expr) ~method-invocation-form)
+      (test/is true)
+      (catch java.lang.AssertionError ae# (test/is nil (str ae#))))))

 (defmacro verify-fn
   ([mock-fn-expr parameter-expr-list]


Small capacity -> surface fix in diagonal-lasrt.


Use Langohr 1.4.x

Use Langohr 1.4.x

--- clojure/project.clj
+++ clojure/project.clj
@@ -4,4 +4,4 @@
   :license {:name "Eclipse Public License"
             :url "http://www.eclipse.org/legal/epl-v10.html"}
   :dependencies [[org.clojure/clojure     "1.5.1"]
-                 [com.novemberain/langohr "1.3.0"]])
+                 [com.novemberain/langohr "1.4.1"]])


[lein] Enable ultra for a better REPL

[lein] Enable ultra for a better REPL


better handling of server.edn and app-state.edn

--- src/clj/searchbot/server.clj
+++ src/clj/searchbot/server.clj
@@ -14,18 +14,37 @@
             [org.httpkit.server :refer [run-server]]
             [searchbot.es :as es]))

-;; (def ^:private es-host (atom (str "http://172.18.114.55:9200")))
-;; (def ^:private es-host (atom (str "http://172.17.26.51:9200")))
-(def ^:private es-host (atom (str "http://10.2.11.1:9200")))
+(defn- has-file?
+  [filename]
+  (.exists (io/file filename)))
+
+(defn- read-edn
+  [ednfile & {:keys [default]}]
+  (if (has-file? ednfile)
+    (slurp ednfile)
+    default))
+
+;; (def ^:private es-host (atom (str "http://127.0.0.1:9200")))
+(def ^:private es-host
+  (atom (str "http://" (or (:es-host (clojure.edn/read-string (read-edn "server.edn")))
+                           "127.0.0.1") ":9200")))

 (deftemplate init-page (io/resource "index.html") []
   [:body] (if is-dev? inject-devmode-html identity))

+(def default-app-state
+  {:header-text "searchbot"
+   :menu {:top-open? false :sub-open? false :selected {} :cm nil}
+   :es-count 0
+   :agg {:div {:width "90%" :height 300}}
+   :aggregators []
+   :widgets []})

 (defroutes routes
   (resources "/react" {:root "react"})
   (GET "/" req (apply str (init-page)))
-  (GET "/_init" req (response (read-string (slurp "app-state.edn"))))
+  (GET "/_init" req (response (clojure.edn/read-string
+                               (read-edn "app-state.edn" :default (pr-str default-app-state)))))
   (GET "/es/:idx/:idxType/_count" [idx idxType]
        (response (es/es-count @es-host idx idxType)))
   (POST "/es/:idx/:idxType/_search" [idx idxType :as req]
@@ -33,38 +52,38 @@
   (resources "/")
   (not-found "Not Found"))

-
 ;; (def http-handler
 ;;   (if is-dev?
 ;;     (reload/wrap-reload (wrap-defaults #'routes api-defaults))
 ;;     (wrap-defaults routes api-defaults)))

+(defn wrap-routes []
+  (-> routes
+      (mid-json/wrap-json-body {:keywords? true})
+      (mid-json/wrap-json-response)
+      (wrap-defaults api-defaults)))
+
 (def http-handler
   (if is-dev?
-    (reload/wrap-reload
-     (-> routes
-         (mid-json/wrap-json-body {:keywords? true})
-         (mid-json/wrap-json-response)
-         (wrap-defaults api-defaults)))
+    (reload/wrap-reload (wrap-routes))
 ;;     (wrap-defaults routes api-defaults)))
-    (-> routes
-        (mid-json/wrap-json-body {:keywords? true})
-        (mid-json/wrap-json-response)
-        (wrap-defaults api-defaults))))
+    (wrap-routes)))

-(defn run-web-server [& [port]]
+(defn run-web-server [& {:keys [port host]}]
   (let [port (Integer. (or port (env :port) 10555))]
-    (print "Starting web server on port" port ".\n")
+    (if host (reset! es-host (str "http://" host ":9200")))
+    (print "# Starting web server on port" port "\n")
+    (print "# Requests will be redirect to ES on" @es-host "\n")
     (run-server http-handler {:port port :join? false})))

-(defn run-auto-reload [& [port]]
+(defn run-auto-reload []
   (auto-reload *ns*)
   (start-figwheel))

-(defn run [& [port]]
+(defn run [& {:keys [port host]}]
   (when is-dev?
     (run-auto-reload))
-  (run-web-server port))
+  (run-web-server :port port :host host))

 (defn -main [& [port]]
-  (run port))
+  (run :port port))


ideas

ideas

--- src/cljs/tictactoe/core.cljs
+++ src/cljs/tictactoe/core.cljs
@@ -6,6 +6,8 @@

 ;; TODO - Add message to indicate winner
+;; TODO - Add ready unit tests
+;; TODO - Move constants and board - hidden in logic

 (defn tic-tac-toe
   "Main entry point, assemble:


Extend and improve docstring

Extend and improve docstring

--- src/io/aviso/rook/schema.clj
+++ src/io/aviso/rook/schema.clj
@@ -29,10 +29,10 @@
    `(def ~name ~docstring (schema ~name ~docstring ~form))))

 (defprotocol SchemaUnwrapper
-  "A protocol for 'unwrapping' a Schema, to extract a nested Schema."
+  "A protocol for 'unwrapping' a Schema, to extract a nested Schema (or, in certain cases a seq of schemas)."

   (unwrap-schema [this]
-    "Returns the nested schema where appropriate, or throws an exception when a nested schema is not available."))
+    "Returns the nested schema (or schemas) where appropriate, or throws an exception when a nested schema is not available."))

 (defrecord IsInstance [^Class expected-class]
   s/Schema


Use protocol-version variable for the kernel-info header.

--- src/ipython_clojure/core.clj
+++ src/ipython_clojure/core.clj
@@ -20,7 +20,7 @@
 (defn uuid [] (str (java.util.UUID/randomUUID)))

 (def kernel-info-content
-  {:protocol_version "5.0"
+  {:protocol_version protocol-version
    :language_version "1.5.1"
    :language "clojure"})


tidy up machine listening ugens

tidy up machine listening ugens

--- src/overtone/sc/machinery/ugen/metadata/machine_listening.clj
+++ src/overtone/sc/machinery/ugen/metadata/machine_listening.clj
@@ -2,120 +2,321 @@
   (:use [overtone.sc.machinery.ugen common check]))

 (def specs
-     [
-
-      {:name "BeatTrack",
-       :args [{:name "chain" :doc "Audio input to track, already passed through an FFT UGen; the expected size of FFT is 1024 for 44100 and 48000 sampling rate, and 2048 for double those. No other sampling rates are supported. "}
-              {:name "lock", :default 0 :doc "If this argument is greater than 0.5, the tracker will lock at its current periodicity and continue from the current phase. Whilst it updates the model's phase and period, this is not reflected in the output until lock goes back below 0.5.  "}],
-       :rates #{:kr}
-       :num-outs 4
-       :doc "Autocorrelation based beat tracker
-
-The underlying model assumes 4/4, but it should work on any isochronous beat structure, though there are biases to 100-120 bpm; a fast 7/8 may not be tracked in that sense. There are four k-rate outputs, being ticks at quarter, eighth and sixteenth level from the determined beat, and the current detected tempo. Note that the sixteenth note output won't necessarily make much sense if the music being tracked has swing; it is provided just as a convenience.
-
-This beat tracker determines the beat, biased to the midtempo range by weighting functions. It does not determine the measure level, only a tactus. It is also slow reacting, using a 6 second temporal window for its autocorrelation maneouvres. Don't expect human musician level predictive tracking.
-
-On the other hand, it is tireless, relatively general (though obviously best at transient 4/4 heavy material without much expressive tempo variation), and can form the basis of computer processing that is decidedly faster than human. "}
-
-
-
-      {:name "Loudness",
-       :args [{:name "chain" :doc "Audio input to track, which has been pre-analysed by the FFT UGen"}
-              {:name "smask", :default 0.25 :doc "Spectral masking param: lower bins mask higher bin power within ERB bands, with a power falloff (leaky integration multiplier) of smask per bin"}
-              {:name "tmask", :default 1 :doc "Temporal masking param: the phon level let through in an ERB band is the maximum of the new measurement, and the previous minus tmask phons"}],
-       :rates #{:kr}
-       :doc "A perceptual loudness function which outputs loudness in sones; this is a variant of an MP3 perceptual model, summing excitation in ERB bands. It models simple spectral and temporal masking, with equal loudness contour correction in ERB bands to obtain phons (relative dB), then a phon to sone transform. The final output is typically in the range of 0 to 64 sones, though higher values can occur with specific synthesised stimuli."}
-
-
-      {:name "Onsets",
-       :args [{:name "chain" :doc "an FFT chain"}
-              {:name "threshold", :default 0.5 :doc " the detection threshold, typically between 0 and 1, although in rare cases you may find values outside this range useful"}
-              {:name "odftype"
-               :default 3
-               :doc "the function used to analyse the signal. Options: POWER, MAGSUM, COMPLEX, RCOMPLEX (default), PHASE, WPHASE and MKL. Default is RCOMPLEX."}
-
-              {:name "relaxtime", :default 1 :doc "specifies the time (in seconds) for the normalisation to forget about a recent onset. If you find too much re-triggering (e.g. as a note dies away unevenly) then you might wish to increase this value."}
-              {:name "floor", :default 0.1 :doc "is a lower limit, connected to the idea of how quiet the sound is expected to get without becoming indistinguishable from noise. For some cleanly-recorded classical music with wide dynamic variations, I found it helpful to go down as far as 0.000001."}
-              {:name "mingap", :default 10 :doc "specifies a minimum gap (in FFT frames) between onset detections, a brute-force way to prevent too many doubled detections."}
-              {:name "medianspan", :default 11.0 :doc " specifies the size (in FFT frames) of the median window used for smoothing the detection function before triggering."}
-              {:name "whtype", :default 1}
-              {:name "rawodf", :default 0}],
-       :rates #{:kr}
-       :doc "An onset detector for musical audio signals - detects the beginning of notes/drumbeats/etc. Outputs a control-rate trigger signal which is 1 when an onset is detected, and 0 otherwise.
-
-For the FFT chain, you should typically use a frame size of 512 or 1024 (at 44.1 kHz sampling rate) and 50% hop size (which is the default setting in SC). For different sampling rates choose an FFT size to cover a similar time-span (around 10 to 20 ms).
-
-The onset detection should work well for a general range of monophonic and polyphonic audio signals. The onset detection is purely based on signal analysis and does not make use of any top-down inferences such as tempo."}
-
-
-      {:name "KeyTrack",
-       :args [{:name "chain" :doc "Audio input to track. This must have been pre-analysed by a 4096 size FFT."}
-              {:name "keydecay", :default 2.0 :doc "Number of seconds for the influence of a window on the final key decision to decay by 40dB (to 0.01 its original value)"}
-              {:name "chromaleak", :default 0.5 :doc "Each frame, the chroma values are set to the previous value multiplied by the chromadecay. 0.0 will start each frame afresh with no memory. "}],
-       :rates #{:kr}
-       :doc "A (12TET major/minor) key tracker based on a pitch class profile of energy across FFT bins and matching this to templates for major and minor scales in all transpositions. It assumes a 440 Hz concert A reference. Output is 0-11  C major to B major, 12-23 C minor to B minor"}
-
-
-      {:name "MFCC",
-       :args [{:name "chain" :doc "Audio input to track, which has been pre-analysed by the FFT UGen"}
-              {:name "numcoeff", :default 13 :doc "Number of coefficients, defaults to 13, maximum of 42"}],
-       :rates #{:kr}
-       :num-outs :variable
-       :doc "Generates a set of MFCCs; these are obtained from a band-based frequency representation (using the Mel scale by default), and then a discrete cosine transform (DCT). The DCT is an efficient approximation for principal components analysis, so that it allows a compression, or reduction of dimensionality, of the data, in this case reducing 42 band readings to a smaller set of MFCCs. A small number of features (the coefficients) end up describing the spectrum. The MFCCs are commonly used as timbral descriptors.
-
-Output values are somewhat normalised for the range 0.0 to 1.0, but there are no guarantees on exact conformance to this. Commonly, the first coefficient will be the highest value. "
-;;       :init (fn [rate args spec]
-;;               {:args args
-;;                :num-outs (args 1)})
-       }
-
-
-      {:name "BeatTrack2",
-       :args [{:name "busindex" :doc "Audio input to track, already analysed into N features, passed in via a control bus number from which to retrieve consecutive streams. "}
-              {:name "numfeatures" :doc "How many features (ie how many control buses) are provided"}
-              {:name "windowsize", :default 2.0 :doc "Size of the temporal window desired (2.0 to 3.0 seconds models the human temporal window). You might use longer values for stability of estimate at the expense of reactiveness."}
-              {:name "phaseaccuracy", :default 0.02 :doc "Relates to how many different phases to test. At the default, 50 different phases spaced by phaseaccuracy seconds would be tried out for 60bpm; 16 would be trialed for 180 bpm. Larger phaseaccuracy means more tests and more CPU cost."}
-              {:name "lock", :default 0 :doc "If this argument is greater than 0.5, the tracker will lock at its current periodicity and continue from the current phase. Whilst it updates the model's phase and period, this is not reflected in the output until lock goes back below 0.5."}
-              {:name "weightingscheme", :default -2.1 :doc "Use (-2.5) for flat weighting of tempi, (-1.5) for compensation weighting based on the number of events tested (because different periods allow different numbers of events within the temporal window) or otherwise a bufnum from 0 upwards for passing an array of 120 individual tempo weights; tempi go from 60 to 179 bpm in steps of one bpm, so you must have a buffer of 120 values.  "}],
-       :rates #{:kr},
-       :num-outs 6
-       :doc "Template matching beat tracker.
-
-This beat tracker is based on exhaustively testing particular template patterns against feature streams; the testing takes place every 0.5 seconds. The two basic templates are a straight (groove=0) and a swung triplet (groove=1) pattern of 16th notes; this pattern is tried out at scalings corresponding to the tempi from 60 to 180 bpm. This is the cross-corellation method of beat tracking. A majority vote is taken on the best tempo detected, but this must be confirmed by a consistency check after a phase estimate. Such a consistency check helps to avoid wild fluctuating estimates, but is at the expense of an additional half second delay. The latency of the beat tracker with default settings is thus at least 2.5 seconds; because of block-based amortisation of calculation, it is actually around 2.8 seconds latency for a 2.0 second temporal window.
-
-This beat tracker is designed to be flexible for user needs; you can try out different window sizes, tempo weights and combinations of features. However, there are no guarantees on stability and effectiveness, and you will need to explore such parameters for a particular situation.    "}
-
-      {:name "SpecFlatness",
-       :args [{:name "chain" :doc "An FFT chain"}],
-       :rates #{:kr}
-       :doc "Given an FFT chain this calculates the Spectral Flatness measure, defined as a power spectrum's geometric mean divided by its arithmetic mean. This gives a measure which ranges from approx 0 for a pure sinusoid, to approx 1 for white noise.
-
-The measure is calculated linearly. For some applications you may wish to convert the value to a decibel scale - an example of such conversion is shown below."}
-
-
-      {:name "SpecPcile",
-       :args [{:name "chain" :doc "An FFT chain"}
-              {:name "fraction", :default 0.5 :doc "percentage of the spectral energy you which to find the frequency for"}
-              {:name "interpolate", :default 0 :doc "Interpolation toggle - 0 off 1 on."}],
-       :rates #{:kr}
-       :doc "Find a percentile of FFT magnitude spectrum
-
-Given an FFT chain this calculates the cumulative distribution of the frequency spectrum, and outputs the frequency value which corresponds to the desired percentile.
-
-For example, to find the frequency at which 90% of the spectral energy lies below that frequency, you want the 90-percentile, which means the value of fraction should be 0.9. The 90-percentile or 95-percentile is often used as a measure of spectral roll-off.
-
-The optional third argument interpolate specifies whether interpolation should be used to try and make the percentile frequency estimate more accurate, at the cost of a little higher CPU usage. Set it to 1 to enable this."}
-
-      ;; SpecCentroid : UGen
-      ;; {
-      ;;   *kr { | buffer |
-      ;;     ^this.multiNew('control', buffer)
-      ;;   }
-      ;; }
-
-      {:name "SpecCentroid",
-       :args [{:name "chain" :doc "An FFT chain"}],
-       :rates #{:kr}
-       :doc "Given an FFT chain, this measures the spectral centroid, which is the weighted mean frequency, or the centre of mass of the spectrum. (DC is ignored.)
-
-This can be a useful indicator of the perceptual brightness of a signal."}])
+  [
+   {:name "BeatTrack",
+    :args [{:name "chain"
+            :doc "Audio input to track, already passed through an FFT
+                     UGen; the expected size of FFT is 1024 for 44100
+                     and 48000 sampling rate, and 2048 for double
+                     those. No other sampling rates are supported. "}
+
+           {:name "lock",
+            :default 0
+            :doc "If this argument is greater than 0.5, the tracker
+                     will lock at its current periodicity and continue
+                     from the current phase. Whilst it updates the
+                     model's phase and period, this is not reflected in
+                     the output until lock goes back below 0.5.  "}],
+    :rates #{:kr}
+    :num-outs 4
+    :doc "Autocorrelation based beat tracker
+
+             The underlying model assumes 4/4, but it should work on any
+             isochronous beat structure, though there are biases to
+             100-120 bpm; a fast 7/8 may not be tracked in that
+             sense. There are four k-rate outputs, being ticks at
+             quarter, eighth and sixteenth level from the determined
+             beat, and the current detected tempo. Note that the
+             sixteenth note output won't necessarily make much sense if
+             the music being tracked has swing; it is provided just as a
+             convenience.
+
+             This beat tracker determines the beat, biased to the
+             midtempo range by weighting functions. It does not
+             determine the measure level, only a tactus. It is also slow
+             reacting, using a 6 second temporal window for its
+             autocorrelation maneouvres. Don't expect human musician
+             level predictive tracking.
+
+             On the other hand, it is tireless, relatively
+             general (though obviously best at transient 4/4 heavy
+             material without much expressive tempo variation), and can
+             form the basis of computer processing that is decidedly
+             faster than human. "}
+
+
+
+   {:name "Loudness",
+    :args [{:name "chain"
+            :doc "Audio input to track, which has been pre-analysed by
+                  the FFT UGen"}
+
+           {:name "smask",
+            :default 0.25
+            :doc "Spectral masking param: lower bins mask higher bin
+                  power within ERB bands, with a power falloff (leaky
+                  integration multiplier) of smask per bin"}
+
+           {:name "tmask",
+            :default 1
+            :doc "Temporal masking param: the phon level let through in
+                  an ERB band is the maximum of the new measurement, and
+                  the previous minus tmask phons"}]
+    :rates #{:kr}
+    :doc "A perceptual loudness function which outputs loudness in
+             sones; this is a variant of an MP3 perceptual model,
+             summing excitation in ERB bands. It models simple spectral
+             and temporal masking, with equal loudness contour
+             correction in ERB bands to obtain phons (relative dB), then
+             a phon to sone transform. The final output is typically in
+             the range of 0 to 64 sones, though higher values can occur
+             with specific synthesised stimuli." }
+
+
+   {:name "Onsets",
+    :args [{:name "chain"
+            :doc "an FFT chain"}
+
+           {:name "threshold",
+            :default 0.5
+            :doc "the detection threshold, typically between 0 and 1,
+                  although in rare cases you may find values outside
+                  this range useful"}
+
+           {:name "odftype"
+            :default 3
+            :doc "the function used to analyse the signal. Options:
+                  nPOWER, MAGSUM, COMPLEX, RCOMPLEX (default), PHASE,
+                  WPHASE and MKL. Default is RCOMPLEX." }
+
+           {:name "relaxtime",
+            :default 1
+            :doc "specifies the time (in seconds) for the normalisation
+                  to forget about a recent onset. If you find too much
+                  re-triggering (e.g. as a note dies away unevenly) then
+                  you might wish to increase this value." }
+
+           {:name "floor",
+            :default 0.1
+            :doc "is a lower limit, connected to the idea of how quiet
+                  the sound is expected to get without becoming
+                  indistinguishable from noise. For some
+                  cleanly-recorded classical music with wide dynamic
+                  variations, I found it helpful to go down as far as
+                  0.000001." }
+
+           {:name "mingap",
+            :default 10
+            :doc "specifies a minimum gap (in FFT frames) between onset
+                  detections, a brute-force way to prevent too many
+                  doubled detections." }
+
+           {:name "medianspan",
+            :default 11.0
+            :doc " specifies the size (in FFT frames) of the median
+                   window used for smoothing the detection function
+                   before triggering." }
+
+           {:name "whtype", :default 1}
+
+           {:name "rawodf", :default 0}],
+    :rates #{:kr}
+    :doc "An onset detector for musical audio signals - detects the
+          beginning of notes/drumbeats/etc. Outputs a control-rate
+          trigger signal which is 1 when an onset is detected, and 0
+          otherwise.
+
+          For the FFT chain, you should typically use a frame size of
+          512 or 1024 (at 44.1 kHz sampling rate) and 50% hop
+          size (which is the default setting in SC). For different
+          sampling rates choose an FFT size to cover a similar
+          time-span (around 10 to 20 ms).
+
+          The onset detection should work well for a general range of
+          monophonic and polyphonic audio signals. The onset detection
+          is purely based on signal analysis and does not make use of
+          any top-down inferences such as tempo." }
+
+
+   {:name "KeyTrack",
+    :args [{:name "chain"
+            :doc "Audio input to track. This must have been pre-analysed
+                  by a 4096 size FFT." }
+
+           {:name "keydecay",
+            :default 2.0
+            :doc "Number of seconds for the influence of a window on the
+                  final key decision to decay by 40dB (to 0.01 its
+                  original value)"}
+
+           {:name "chromaleak",
+            :default 0.5
+            :doc "Each frame, the chroma values are set to the previous
+                  value multiplied by the chromadecay. 0.0 will start
+                  each frame afresh with no memory."}],
+    :rates #{:kr}
+    :doc "A (12TET major/minor) key tracker based on a pitch class
+          profile of energy across FFT bins and matching this to
+          templates for major and minor scales in all transpositions. It
+          assumes a 440 Hz concert A reference. Output is 0-11 C major
+          to B major, 12-23 C minor to B minor"}
+
+
+   {:name "MFCC",
+    :args [{:name "chain"
+            :doc "Audio input to track, which has been pre-analysed by
+                  the FFT UGen"}
+           {:name "numcoeff",
+            :default 13
+            :doc "Number of coefficients, defaults to 13, maximum of 42"}],
+    :rates #{:kr}
+    :num-outs :variable
+    :doc "Generates a set of MFCCs; these are obtained from a band-based
+          frequency representation (using the Mel scale by default), and
+          then a discrete cosine transform (DCT). The DCT is an
+          efficient approximation for principal components analysis, so
+          that it allows a compression, or reduction of dimensionality,
+          of the data, in this case reducing 42 band readings to a
+          smaller set of MFCCs. A small number of features (the
+          coefficients) end up describing the spectrum. The MFCCs are
+          commonly used as timbral descriptors.
+
+          Output values are somewhat normalised for the range 0.0 to
+          1.0, but there are no guarantees on exact conformance to
+          this. Commonly, the first coefficient will be the highest
+          value. "
+    ;;       :init (fn [rate args spec]
+    ;;               {:args args
+    ;;                :num-outs (args 1)})
+    }
+
+
+   {:name "BeatTrack2",
+    :args [{:name "busindex"
+            :doc "Audio input to track, already analysed into N
+                  features, passed in via a control bus number from
+                  which to retrieve consecutive streams. "}
+
+           {:name "numfeatures"
+            :doc "How many features (ie how many control buses) are
+                  provided"}
+
+           {:name "windowsize",
+            :default 2.0
+            :doc "Size of the temporal window desired (2.0 to 3.0
+                  seconds models the human temporal window). You might
+                  use longer values for stability of estimate at the
+                  expense of reactiveness." }
+
+           {:name "phaseaccuracy",
+            :default 0.02
+            :doc "Relates to how many different phases to test. At the
+                  default, 50 different phases spaced by phaseaccuracy
+                  seconds would be tried out for 60bpm; 16 would be
+                  trialed for 180 bpm. Larger phaseaccuracy means more
+                  tests and more CPU cost." }
+
+           {:name "lock", :default 0
+            :doc "If this argument is greater than 0.5, the tracker will
+                  lock at its current periodicity and continue from the
+                  current phase. Whilst it updates the model's phase and
+                  period, this is not reflected in the output until lock
+                  goes back below 0.5." }
+
+           {:name "weightingscheme",
+            :default -2.1
+            :doc "Use (-2.5) for flat weighting of tempi, (-1.5) for
+                  compensation weighting based on the number of events
+                  tested (because different periods allow different
+                  numbers of events within the temporal window) or
+                  otherwise a bufnum from 0 upwards for passing an array
+                  of 120 individual tempo weights; tempi go from 60 to
+                  179 bpm in steps of one bpm, so you must have a buffer
+                  of 120 values.  "}],
+    :rates #{:kr},
+    :num-outs 6
+    :doc "Template matching beat tracker.
+
+          This beat tracker is based on exhaustively testing particular
+          template patterns against feature streams; the testing takes
+          place every 0.5 seconds. The two basic templates are a
+          straight (groove=0) and a swung triplet (groove=1) pattern of
+          16th notes; this pattern is tried out at scalings
+          corresponding to the tempi from 60 to 180 bpm. This is the
+          cross-corellation method of beat tracking. A majority vote is
+          taken on the best tempo detected, but this must be confirmed
+          by a consistency check after a phase estimate. Such a
+          consistency check helps to avoid wild fluctuating estimates,
+          but is at the expense of an additional half second delay. The
+          latency of the beat tracker with default settings is thus at
+          least 2.5 seconds; because of block-based amortisation of
+          calculation, it is actually around 2.8 seconds latency for a
+          2.0 second temporal window.
+
+          This beat tracker is designed to be flexible for user needs;
+          you can try out different window sizes, tempo weights and
+          combinations of features. However, there are no guarantees on
+          stability and effectiveness, and you will need to explore such
+          parameters for a particular situation.  "}
+
+   {:name "SpecFlatness",
+    :args [{:name "chain"
+            :doc "An FFT chain"}],
+    :rates #{:kr}
+    :doc "Given an FFT chain this calculates the Spectral Flatness
+          measure, defined as a power spectrum's geometric mean divided
+          by its arithmetic mean. This gives a measure which ranges from
+          approx 0 for a pure sinusoid, to approx 1 for white noise.
+
+          The measure is calculated linearly. For some applications you
+          may wish to convert the value to a decibel scale - an example
+          of such conversion is shown below." }
+
+
+   {:name "SpecPcile",
+    :args [{:name "chain"
+            :doc "An FFT chain"}
+
+           {:name "fraction",
+            :default 0.5
+            :doc "percentage of the spectral energy you which to find
+                  the frequency for"}
+
+           {:name "interpolate"
+            :default 0
+            :doc "Interpolation toggle - 0 off 1 on."}],
+    :rates #{:kr}
+    :doc "Find a percentile of FFT magnitude spectrum
+
+          Given an FFT chain this calculates the cumulative distribution
+          of the frequency spectrum, and outputs the frequency value
+          which corresponds to the desired percentile.
+
+          For example, to find the frequency at which 90% of the
+          spectral energy lies below that frequency, you want the
+          90-percentile, which means the value of fraction should be
+          0.9. The 90-percentile or 95-percentile is often used as a
+          measure of spectral roll-off.
+
+          The optional third argument interpolate specifies whether
+          interpolation should be used to try and make the percentile
+          frequency estimate more accurate, at the cost of a little
+          higher CPU usage. Set it to 1 to enable this." }
+
+   ;; SpecCentroid : UGen
+   ;; {
+   ;;   *kr { | buffer |
+   ;;     ^this.multiNew('control', buffer)
+   ;;   }
+   ;; }
+
+   {:name "SpecCentroid",
+    :args [{:name "chain"
+            :doc "An FFT chain"}],
+    :rates #{:kr}
+    :doc "Given an FFT chain, this measures the spectral centroid, which
+          is the weighted mean frequency, or the centre of mass of the
+          spectrum. (DC is ignored.)
+
+          This can be a useful indicator of the perceptual brightness of
+          a signal." }])


made starting angle with no order-priority random

--- src/mastersign/wordcloud.clj
+++ src/mastersign/wordcloud.clj
@@ -131,7 +131,9 @@
         radii (take-while
                   #(< (scale-radius order-priority % 1) max-test-radius)
                   (map #(* (+ 1 (* imprecision max-font-size 0.5)) %) (lazy-numbers 1)))
-        pa (priority-angle text)
+        pa (if (> order-priority 0.0)
+             (priority-angle text)
+             (rand (* Math/PI 2)))
         rings (map #(test-ring % precision pa order-priority) radii)
         boundaries (rectangle (- (/ width 2.0)) (- (/ height 2.0)) width height)
         reject-pred (fn [p] (.contains boundaries (.x p) (.y p)))]


add perms check to GET db

add perms check to GET db

--- src/metabase/api/meta/db.clj
+++ src/metabase/api/meta/db.clj
@@ -9,10 +9,11 @@
             (metabase.models common
                              [hydrate :refer [hydrate]]
                              [database :refer [Database]]
-                             [org :refer [org-can-write]]
+                             [org :refer [org-can-read org-can-write]]
                              [table :refer [Table]])))

 (defendpoint GET "/" [org]
+  (check-403 (org-can-read org))
   (-> (sel :many Database :organization_id org (order :name))
       (hydrate :organization)))


Choose your ant color!

Choose your ant color!

--- client/src/client/core.cljs
+++ client/src/client/core.cljs
@@ -28,7 +28,7 @@
 (def color-rock "#7c7c7c")
 (def color-colony "#3d2501")
 (def color-phermone "#505ffc")
-(def color-my-ant "#b50c03")
+(def color-my-ant (atom "#b50c03"))
 (def color-their-ant "#000")
 (def color-friend "#1f6d1f")
 (def color-enemy "#9e1914")
@@ -61,7 +61,7 @@
                   (recur))))))))))

 (defn show-ant [cell]
-  (let [style {:style {:color (if (get-in cell ["Object" "Mine"]) color-my-ant color-their-ant)
+  (let [style {:style {:color (if (get-in cell ["Object" "Mine"]) @color-my-ant color-their-ant)
                        :position "absolute"
                        :top "0px"
                        :right "3px"}}]
@@ -147,7 +147,10 @@
         (let [rows (get world "Points")]
           (dom/div nil
                    (dom/table nil (apply dom/tbody nil (om/build-all row-view rows)))
-                   (om/build friend-view (get world "Friends"))))))
+                   (om/build friend-view (get world "Friends"))
+                   (apply dom/ul nil (map (fn [c] (dom/li #js {:style #js {:color c}
+                                                               :onClick #(reset! color-my-ant c)} c))
+                                          ["#b50c03" "#4250f4" "#2c9916" "#f75199" "#7c7b7c"]))))))
     om/IDidMount
     (did-mount [_]
       (set! (.-onkeydown js/document.body)


add-repo-via-ws

add-repo-via-ws

--- cljs-src/index.cljs
+++ cljs-src/index.cljs
@@ -4,7 +4,9 @@
             [om.dom :as dom :include-macros true]
             [om.next :as om :refer-macros [defui]]
             [goog.dom :as gdom]
-            [cljs-http.client :as http]))
+            [goog.json :as json]
+            [cljs-http.client :as http])
+  (:import [goog.net WebSocket]))

 (enable-console-print!)

@@ -15,6 +17,15 @@
         post-url "/app/user/repos"]
     (go (let [resp (<! (http/post post-url {:json-params {:url url}}))]
           （prn resp))))
+
+(defn- add-repo-via-ws
+  [ev ws]
+  (let [el (gdom/getElement "url-input")
+        url (.-value el)
+        post-url "POST /app/user/repos"
+        body (json/serialize {:method post-url
+                              :body {:url url}})]
+    (go (.send ws body))))

 (defui RepoList
   Object
@@ -32,7 +43,17 @@

 (defui Widget
   Object
+  (componentDidMount [this]
+    ;; connect WS
+    (let [ws (WebSocket.)]
+      (.open ws "ws://:8991")
+      ;; register event handler
+      (.listenOnce ws (.. WebSocket -Event -OPENED) #(om/set-state! this {:ws ws}))
+      ;; register event handler TODO
+      (.listen ws (.. WebSocket -Event -MESSAGE #()))))
+
   (render [this]
+    (let [ws])
     (dom/div nil
       (repolist-factory)
       (dom/input #js {:id "url-input" :type "text"})


Added reset in system data2 namespace to reset unique counters.

--- dev/user.clj
+++ dev/user.clj
@@ -3,7 +3,8 @@
             [clojure.tools.namespace.repl :refer (refresh refresh-all)]
             [cmr.dev-system.system :as system]
             [cmr.common.log :as log :refer (debug info warn error)]
-            [cmr.common.dev.util :as d])
+            [cmr.common.dev.util :as d]
+            [cmr.system-int-test.data2.core :as data])
   (:use [clojure.test :only [run-all-tests]]
         [clojure.repl]
         [alex-and-georges.debug-repl]))
@@ -14,6 +15,8 @@
 (defn start
   "Starts the current development system."
   []
+  (data/reset-uniques)
+
   (let [s (system/create-system :external-dbs #_:in-memory)]
     (alter-var-root #'system
                     (constantly


add sleep/wake button

add sleep/wake button

--- qmon.clj
+++ qmon.clj
@@ -2,10 +2,10 @@
 ;; See the LICENSE file for details.

 (ns qmon
-  (:import [java.awt Color Font]
+  (:import [java.awt BorderLayout Color Font]
            [java.awt.event MouseAdapter]
            [java.io StringBufferInputStream]
-           [javax.swing JFrame JScrollPane JTextArea])
+           [javax.swing JButton JFrame JPanel JScrollPane JTextArea])
   (:use [clojure.java.shell :only [sh]])
   (:use [clojure.string :only [join]])
   (:use [clojure.xml :only [parse]]))
@@ -112,27 +112,36 @@
 (defn xutime [j]
   (let [t (xtime j :resources_used)] (if (nil? t) "-" t)))

-(let [user (myname)
-      ta (JTextArea. waitmsg)
-      sp (JScrollPane. ta)
-      active (atom true)
-      toggle (fn [x]
-               (.setBackground ta (if x (Color/BLACK) (Color/WHITE)))
-               (.setForeground ta (if x (Color/WHITE) (Color/BLACK)))
-               (.setText ta (if x "\nPaused, click to resume..." waitmsg))
-               (not x))]
+(let [user         (myname)
+      panel        (JPanel. (BorderLayout.))
+      text-area    (JTextArea. waitmsg)
+      button       (JButton. "Sleep")
+      button-panel (JPanel.)
+      scroll-pane  (JScrollPane. text-area)
+      active       (atom true)
+      toggle       (fn [x]
+                     (.setBackground text-area (if x (Color/GRAY ) (Color/WHITE)))
+                     (.setForeground text-area (if x (Color/WHITE) (Color/GRAY )))
+                     (.setText       button    (if x "Wake"       "Sleep"      ))
+                     (not x))]
   (do
-    (doto ta
+    (doto text-area
       (.setFont (Font. "Monospaced" (Font/PLAIN) 12))
-      (.addMouseListener (proxy [MouseAdapter] [] (mousePressed [e] (swap! active toggle))))
       (.setEditable false))
+    (doto button
+      (.addMouseListener (proxy [MouseAdapter] [] (mousePressed [e] (swap! active toggle)))))
+    (doto button-panel
+      (.add button))
+    (doto panel
+      (.add scroll-pane BorderLayout/CENTER)
+      (.add button-panel BorderLayout/SOUTH))
     (doto (JFrame. (str "qmon " user))
       (.setSize 800 600)
       (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
-      (.add sp)
+      (.add panel)
       (.setVisible true))
     (while true
       (if @active
         (let [newtext (show user)]
-          (if @active (.setText ta newtext))))
-      (Thread/sleep 5000))))
+          (if @active (.setText text-area newtext))))
+      (Thread/sleep 10000))))