Make handlers for all ClojureScript types

All ClojureScript sequence, map, and set types now have write
handlers.  The list type now has a ClojureScript read handler

--- src/longshi/core.cljs
+++ src/longshi/core.cljs
@@ -78,14 +78,26 @@
               (recur (rest map-seq) (+ i 2))))))
       (write-list writer map-list))))

-(defn seq-write-handler [writer name cljs-seq]
-  "Writes out a purely sequential ClojureScript type
-
-  writer (FressianWriter) - Fressian Writer for the record
-  cljs-seq (ISeq) - ClojureScript sequence to be written"
-  (do
-    (write-tag writer name 1)
-    (write-list writer cljs-seq)))
+(def list-write-handler
+  {"list"
+   (fn [writer cljs-seq]
+     (do
+      (write-tag writer "list" 1)
+      (write-list writer cljs-seq)))})
+
+(def vector-write-handler
+  {"vector"
+   (fn [writer cljs-seq]
+     (do
+      (write-tag writer "vector" 1)
+      (write-list writer cljs-seq)))})
+
+(def set-write-handler
+  {"set"
+   (fn [writer cljs-seq]
+     (do
+      (write-tag writer "set" 1)
+      (write-list writer cljs-seq)))})
 ;;ClojureScript base writers
 (def clojure-write-handlers
   {Keyword
@@ -104,21 +116,78 @@
         (write-object writer (namespace k) true)
         (write-object writer (name k) true)))}

+   Range
+   list-write-handler
+
+   List
+   list-write-handler
+
+   Cons
+   list-write-handler
+
+   EmptyList
+   list-write-handler
+
+   LazySeq
+   list-write-handler
+
+   RSeq
+   list-write-handler
+
+   IndexedSeq
+   list-write-handler
+
+   ChunkedCons
+   list-write-handler
+
+   ChunkedSeq
+   list-write-handler
+
+   PersistentQueueSeq
+   list-write-handler
+
+   PersistentQueue
+   list-write-handler
+
+   PersistentArrayMapSeq
+   list-write-handler
+
+   PersistentTreeMapSeq
+   list-write-handler
+
+   NodeSeq
+   list-write-handler
+
+   ArrayNodeSeq
+   list-write-handler
+
+   KeySeq
+   list-write-handler
+
+   ValSeq
+   list-write-handler
+
    PersistentHashMap
    {"map" map-write-handler}

    PersistentArrayMap
    {"map" map-write-handler}

+   PersistentTreeMap
+   {"map" map-write-handler}
+
    PersistentHashSet
-   {"set"
-    (fn [writer s]
-      (seq-write-handler writer "set" s))}
+   set-write-handler
+
+   PersistentTreeSet
+   set-write-handler

    PersistentVector
-   {"vector"
-    (fn [writer v]
-      (seq-write-handler writer "vector" v))}})
+   vector-write-handler
+
+   Subvec
+   vector-write-handler
+   })

 (defn create-writer [& {:keys [handlers]}]
   "Creates a fressian writer
@@ -163,6 +232,9 @@
    "set"
    (fn [reader tag component-count]
      (cljs.core/PersistentHashSet.fromArray (read-object reader)))
+   "list"
+   (fn [reader tag component-count]
+     (into '() (reverse (read-object reader))))
    "vector"
    (fn [reader tag component-count]
      (cljs.core/PersistentVector.fromArray (read-object reader)))})


Protect core.clj from renaming/deleting

Protect core.clj from renaming/deleting

--- src/nightmod/core.clj
+++ src/nightmod/core.clj
@@ -36,13 +36,20 @@
                                       (.setBounds pane 0 0 u/editor-width)))))
       (.add pane))))

+(defn protect-file!
+  "Prevents renaming or deleting a file."
+  [path]
+  (intern 'nightcode.file-browser
+          'protect-file?
+          #(= % path)))
+
 (defn load-game!
   "Loads game into the canvas and runs it in a sandbox."
   [path]
   (pom/add-classpath path)
-  (-> (io/file path "core.clj")
-      .getCanonicalPath
-      sandbox/run-file!))
+  (let [core (.getCanonicalPath (io/file path "core.clj"))]
+    (protect-file! core)
+    (sandbox/run-file! core)))

 (defn create-window
   "Creates the main window."


don't need to populate :layer any more

don't need to populate :layer any more

--- src/pc/http/sente.clj
+++ src/pc/http/sente.clj
@@ -147,20 +147,13 @@
   (let [document-id (-> ?data :document/id)
         mouse-position (-> ?data :mouse-position)
         tool (-> ?data :tool)
-        layer (-> ?data :layer)
         layers (-> ?data :layers)
         cid (client-uuid->uuid client-uuid)]
     (doseq [[uid _] (dissoc (get @document-subs document-id) cid)]
       ((:send-fn @sente-state) uid [:frontend/mouse-move (merge
                                                           {:client-uuid cid
                                                            :tool tool
-                                                           ;; TODO: remove :layer logic, just here for backward compat
-                                                           :layer (if layer
-                                                                    layer
-                                                                    (first layers))
-                                                           :layers (if layers
-                                                                     layers
-                                                                     [layer])}
+                                                           :layers layers}
                                                           (when mouse-position
                                                             {:mouse-position mouse-position}))]))))


Store state in single atom

Store state in single atom

--- src/re_view/core.cljs
+++ src/re_view/core.cljs
@@ -43,7 +43,7 @@
   [component name]
   (some-> (.-refs component) (gobj/get name)))

-
+(def component-state (atom {}))

 ;; self-management of cljs props and state

@@ -51,21 +51,18 @@
   "React complains if we mutate props, so we always read from state.
   (this is set in componentWillReceiveProps)"
   [this]
-  (if (or *use-prior* *use-prior-props*)
-    (.. this -state -cljs$previousProps)
-    (.. this -state -cljs$props)))
+  (get-in @component-state
+          [this
+           (if (or *use-prior* *use-prior-props*)
+             :prev-props :props)]))

 (defn children [this]
-  (:view$children (props this))
-  #_(some-> this .-props .-children))
-
-(defn parse-props [props]
-  (.-cljs$props props))
+  (get-in @component-state [this :children]))

 (defn state [this]
-  (if *use-prior*
-    (some-> this .-state .-cljs$previousState)
-    (some-> this .-state .-cljs$state)))
+  (get-in @component-state
+          [this
+           (if *use-prior* :prev-state :state)]))

 ;; State manipulation

@@ -75,10 +72,9 @@
   ;; set-state! always triggers render, unless shouldComponentUpdate returns false.
   ;; if we assume that if state hasn't changed we don't re-render,
   ;; controlled inputs break.
-  (set! (.. this -state -cljs$previousState)
-        (.. this -state -cljs$state))
-  (set! (.. this -state -cljs$state)
-        new-state)
+  (swap! component-state update this #(-> %
+                                          (assoc :prev-state (:state %))
+                                          (assoc :state new-state)))
   (when-let [will-receive-state (.-componentWillReceiveState this)]
     (.call will-receive-state this))
   (when (and *trigger-state-render*
@@ -94,16 +90,14 @@
   ([this] (render-component this (props this)))
   ([this props] (render-component this props nil))
   ([this props & children]
-   (let [clj-props (cond-> props
-                           (not= '(nil) children) (assoc :view$children children))
-         js-props (js-obj "cljs$props" clj-props)]
-     ;; manually invoke componentWillReceiveProps
-     (when-let [will-receive-props (.-componentWillReceiveProps this)]
-       (.call will-receive-props this js-props))
-
-     ;; only render if shouldComponentUpdate returns true (emulate ordinary React lifecycle)
-     (when (.call (.-shouldComponentUpdate this) this clj-props (state this))
-       (force-update this)))))
+    ;; manually invoke componentWillReceiveProps
+   (when-let [will-receive-props (.-componentWillReceiveProps this)]
+     (.call will-receive-props this #js {:cljs$props props
+                                         :cljs$children children}))
+
+    ;; only render if shouldComponentUpdate returns true (emulate ordinary React lifecycle)
+   (when (.call (.-shouldComponentUpdate this) this props (state this))
+     (force-update this))))

 ;; TODO - include render loop

@@ -143,13 +137,14 @@
      (fn []
        (this-as this
          (let [initial-props (expand-props this (.. this -props -cljs$props))
-               initial-state-obj (set! (.-state this) #js {:cljs$props initial-props})
-               state (merge (when get-initial-state-fn (get-initial-state-fn this initial-props))
-                            (initial-subscription-data this initial-props))]
-
-           (doto initial-state-obj
-             (gobj/set "cljs$state" state)
-             (gobj/set "cljs$previousState" state))))))
+               initial-state (merge (when get-initial-state-fn (get-initial-state-fn this initial-props))
+                                    (initial-subscription-data this initial-props))]
+           (swap! component-state update this
+                  #(-> %
+                       (assoc :props initial-props)
+                       (assoc :children (.. this -props -cljs$children))
+                       (assoc :state initial-state)
+                       (assoc :prev-state initial-state)))))))

    "componentDidMount"
    (fn [f]
@@ -157,7 +152,9 @@
        (this-as this
          (binding [*use-prior-props* false
                    *use-prior* false]
-           (when f (f this (.. this -state -cljs$props) (.. this -state -cljs$state)))))))
+           (when f (f this
+                      (get-in @component-state [this :props])
+                      (get-in @component-state [this :state])))))))

    "componentWillMount"
    (fn [f]
@@ -178,27 +175,30 @@
    (fn [f]
      (fn []
        (this-as this
-         (let [props (.. this -state -cljs$props)]
+         (let [props (get-in @component-state [this :props])]
            (update-subscriptions this props props)
            (when f
              (f this
                 props
-                (.. this -state -cljs$state)
-                (.. this -state -cljs$previousState)))))))
+                (get-in @component-state [this :state])
+                (get-in @component-state [this :prev-state])))))))

    "componentWillReceiveProps"
    (fn [f]
-     (fn [next-props]
-       (this-as this
-         (let [next-props (expand-props this (parse-props next-props))
-               prev-props (.. this -state -cljs$props)]
-           (doto (.-state this)
-             (gobj/set "cljs$previousProps" prev-props)
-             (gobj/set "cljs$props" next-props))
-           (binding [*trigger-state-render* false
-                     *use-prior-props* true]
-             (update-subscriptions this prev-props next-props)
-             (when f (f this prev-props next-props)))))))
+     (fn [props]
+       (let [next-props (.-cljs$props props)
+             next-children (.-cljs$children props)]
+         (this-as this
+           (let [next-props (expand-props this next-props)
+                 prev-props (get-in @component-state [this :props])]
+             (swap! component-state update this #(-> %
+                                                     (assoc :prev-props prev-props)
+                                                     (assoc :props next-props)
+                                                     (assoc :children next-children)))
+             (binding [*trigger-state-render* false
+                       *use-prior-props* true]
+               (update-subscriptions this prev-props next-props)
+               (when f (f this prev-props next-props))))))))

    "shouldComponentUpdate"
    (fn [f]
@@ -207,10 +207,10 @@
          (let [update? (if f (binding [*use-prior* true
                                        *trigger-state-render* false]
                                (f this
-                                  (.. this -state -cljs$props)
-                                  (.. this -state -cljs$state)
-                                  (.. this -state -cljs$previousProps)
-                                  (.. this -state -cljs$previousState)))
+                                  (get-in @component-state [this :props])
+                                  (get-in @component-state [this :state])
+                                  (get-in @component-state [this :prev-props])
+                                  (get-in @component-state [this :prev-state])))
                              ;; by default, update if props or state have changed
                              true)]
            update?))))
@@ -222,28 +222,28 @@
          (when f (binding [*use-prior* true
                            *trigger-state-render* false]
                    (f this
-                      (.. this -state -cljs$props)
-                      (.. this -state -cljs$state)
-                      (.. this -state -cljs$previousProps)
-                      (.. this -state -cljs$previousState)))))))
+                      (get-in @component-state [this :props])
+                      (get-in @component-state [this :state])
+                      (get-in @component-state [this :prev-props])
+                      (get-in @component-state [this :prev-state])))))))

    "componentDidUpdate"
    (fn [f]
      (fn [_ _]
        (this-as this
          (f this
-            (.. this -state -cljs$props)
-            (.. this -state -cljs$state)
-            (.. this -state -cljs$previousProps)
-            (.. this -state -cljs$previousState)))))
+            (get-in @component-state [this :props])
+            (get-in @component-state [this :state])
+            (get-in @component-state [this :prev-props])
+            (get-in @component-state [this :prev-state])))))

    "render"
    (fn [f]
      (fn []
        (this-as this
          (let [element (f this
-                          (.. this -state -cljs$props)
-                          (.. this -state -cljs$state))]
+                          (get-in @component-state [this :props])
+                          (get-in @component-state [this :state]))]
            ;; wrap in sablono.core/html if not already a valid React element
            (if (js/React.isValidElement element)
              element
@@ -302,10 +302,8 @@
                                            (keyfn props) key)
                                          (.-displayName class))
                          :ref        ref
-                         :cljs$props (cond->
-                                       (dissoc props :keyfn :ref :key)
-                                       (not= '(nil) children) (assoc :view$children children))}
-                    children)]
+                         :cljs$props (dissoc props :keyfn :ref :key)
+                         :cljs$children (when (not= '(nil) children) children)})]
       ;;
       #_(set! (.-reactClass element) class)
       element)))


Fix missing bracket in slack documentation

--- src/riemann/slack.clj
+++ src/riemann/slack.clj
@@ -49,7 +49,7 @@
   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:\"}))


removed test code

removed test code

--- src/selmer/parser.clj
+++ src/selmer/parser.clj
@@ -49,12 +49,6 @@
   (let [ch (.read rdr)]
     (if-not (== -1 ch) (char ch))))

-#_(defn tag-handler [handler open-tag & end-tags]
-  (fn [args rdr]
-    (if (not-empty end-tags)
-      (let [content (apply (partial tag-content rdr) end-tags)]
-        (handler args content)))))
-
 (defn assoc-in*
   "Works best for small collections seemingly."
   [m ks v]
@@ -62,8 +56,6 @@
     (if (= (count ks) 0)
       (assoc m k (assoc-in* (get m k) (next ks) v))
       (assoc m k v))))
-
-(map-indexed vector ["foo" "Bar"])

 (defn for-handler [[^String id _ items] rdr]
   (let [content (:content (:endfor (tag-content rdr :endfor)))
@@ -127,6 +119,12 @@
 (defn block-handler [args rdr]
   (let [content (tag-content rdr :endblock)]
     (fn [args] (render content args))))
+
+(defn tag-handler [handler open-tag & end-tags]
+  (fn [args rdr]
+    (if (not-empty end-tags)
+      (let [content (apply (partial tag-content rdr) end-tags)]
+        (handler args content)))))

 (def expr-tags
   {:if if-handler


Eliminate the schema looping constructs that were used to support multiple schemas.

--- src/sql_file/core.clj
+++ src/sql_file/core.clj
@@ -27,9 +27,6 @@
   (:require [clojure.tools.logging :as log]
             [clojure.java.jdbc :as jdbc]
             [sql-file.script :as script]))
-
-(defn- fail [ & args ]
-  (throw (Exception. (apply str args))))

 (defn- locate-schema-script [ conn basename ]
   (or (some identity
@@ -119,11 +116,19 @@
       (safe-run-script conn (schema-migrate-script conn [ schema-name to-version ]))
       (set-schema-version! conn schema-name to-version))))

+(defn- conn-assoc-schema [ conn schema ]
+  "Add a sql-file schema to the connection map."
+  (assoc conn
+    :sql-file-schemas
+    (conj (get conn :sql-file-schemas [])
+          schema)))
+
 (defn- ensure-schema [ conn schema ]
   "Locate and run the scripts necessary to install the specified
 schema in the target database instance."
   (log/debug "Ensuring schema:" schema)
-  (let [[req-schema-name req-schema-version] schema
+  (let [conn (conn-assoc-schema conn schema)
+        [req-schema-name req-schema-version] schema
         cur-schema-version (get-schema-version conn req-schema-name)]
       (cond
         (nil? cur-schema-version)
@@ -136,26 +141,9 @@
         (migrate-schema conn req-schema-name cur-schema-version req-schema-version)

         :else
-        (fail "Cannot downgrade schema " req-schema-name " from version " cur-schema-version " to " req-schema-version))))
+        (fail "Cannot downgrade schema " req-schema-name " from version " cur-schema-version " to " req-schema-version))
+      conn))

-
-(defn- conn-assoc-schema [ conn schema ]
-  "Add a sql-file schema to the connection map."
-  (assoc conn
-    :sql-file-schemas
-    (conj (get conn :sql-file-schemas [["sql-file" 0]])
-          schema)))
-
-(defn- conn-ensure-schemas [ conn ]
-  "Ensure that the sql-file schemas defined within the connection map
-are present in the target database."
-  (let [ req-schemas (:sql-file-schemas conn)]
-    (log/debug "Ensuring requested schemas:" req-schemas)
-    (reduce (fn [ conn schema ]
-              (ensure-schema conn schema)
-              conn)
-            conn
-            req-schemas)))

 ;; Public Entry points

@@ -164,7 +152,9 @@
 the specified schema is available within that database."
   (let [ conn (conn-assoc-schema conn schema) ]
     (log/info "Opening sql-file:" conn)
-    (conn-ensure-schemas conn)))
+    (-> conn
+        (ensure-schema [ "sql-file" 0])
+        (ensure-schema schema))))

 ;; HSQLDB Specific


setting timeout

setting timeout

--- src/supernal/sshj.clj
+++ src/supernal/sshj.clj
@@ -40,10 +40,13 @@
   [out host]
   (doseq [line (line-seq (clojure.java.io/reader out))] (debug  (<< "[~{host}]:") line)))

+(def ^:dynamic timeout (* 1000 60 10))
+
 (defnk ssh-strap [host {user (@config :user)}]
   (doto (SSHClient.)
     (.addHostKeyVerifier (PromiscuousVerifier.))
     (.loadKnownHosts)
+    (.setTimeout timeout)
     (.connect host)
     (.authPublickey user #^"[Ljava.lang.String;" (into-array [(@config :key)]))))


add influxdb machine

add influxdb machine

--- src/terraboot/vpc.clj
+++ src/terraboot/vpc.clj
@@ -97,17 +97,33 @@
                                                :associate_public_ip_address true
                                                })

+             (aws-instance "influxdb" {:ami "ami-9b9c86f7"
+                                       :vpc_security_group_ids [(id-of "aws_security_group" "influxdb")
+                                                                (id-of "aws_security_group" "allow_ssh")
+                                                                ]
+                                       :subnet_id (vpc-id-of "aws_subnet" "public-a")
+                                       })
+
+             (security-group "influxdb" {}
+                             {:port 222
+                              :protocol "tcp"
+                              :cidr_blocks [all-external]})
+
+             (resource "aws_eip" "influxdb"
+                       {:vpc true
+                        :instance (id-of "aws_instance" "influxdb")})
+
+             (route53_record "influxdb" { :records [(output-of "aws_eip" "influxdb" "public_ip")]})
+
+             (route53_record "logstash" {:records [(vpc-output-of "aws_eip" "logstash" "public_ip")]})
+
+             (vpc-security-group "sends_gelf" {})
+
+
              (vpc-resource "aws_eip" "vpn" {:instance (vpc-id-of "aws_instance" "vpn")
                                             :vpc true})

-             (resource "aws_route53_zone" "kixi" {:name "kixi.io"})
-
-             (vpc-resource "aws_route53_record" "vpn"
-                           {:zone_id (id-of "aws_route53_zone" "kixi")
-                            :name "vpn.kixi.io"
-                            :type "A"
-                            :ttl 300
-                            :records [(vpc-output-of "aws_instance" "vpn" "public_ip")]})
+             (route53_record "vpn" {:records [(vpc-output-of "aws_instance" "vpn" "public_ip")]})

              (security-group "allow_outbound" {}
                              {:type "egress"


Add java.lang.Iterable; fix error reporting for unsupported types

--- src/transit/write.clj
+++ src/transit/write.clj
@@ -271,6 +271,7 @@

 (defn emit-encoded
   [em h tag o as-map-key cache]
+  (prn "EMIT ENCODED" em h tag o as-map-key cache)
   (if (= (.length ^String tag) 1)
     (let [rep (rep h o)]
       (if (string? rep)
@@ -288,9 +289,10 @@
 (defn marshal
   [em o as-map-key cache]
   ;;(prn "marshal" o (tag o) (rep o))
-  (if-let [h (handler o)]
-    (let [tag (tag h o)
-          rep (rep h o)]
+  (let [h (handler o)
+        tag (when h (tag h o))
+        rep (when h (rep h o))]
+    (if (and h tag)
       ;;(prn "marshal" tag rep)
       (case tag
         "_" (emit-nil em as-map-key cache)
@@ -302,8 +304,8 @@
         "'" (emit-quoted em rep cache)
         "array" (emit-array em rep as-map-key cache)
         "map" (emit-map em rep as-map-key cache)
-        (emit-encoded em h tag o as-map-key cache)))
-    (throw (ex-info "Not supported" {:o o :type (type o)}))))
+        (emit-encoded em h tag o as-map-key cache))
+      (throw (ex-info "Not supported" {:o o :type (type o)})))))

 (defn maybe-quoted
   [o]
@@ -419,6 +421,12 @@
  (reify Handler
    (tag [_ l] (if (seq? l) "list" "array"))
    (rep [_ l] (if (seq? l) (as-tag "array" l nil) l))
+   (str-rep [_ _] nil))
+
+ java.lang.Iterable
+ (reify Handler
+   (tag [_ _] "array")
+   (rep [_ i] i)
    (str-rep [_ _] nil))

  AsTag


De-dup'ing some of the header

De-dup'ing some of the header

--- src/tutorial/core.clj
+++ src/tutorial/core.clj
@@ -5,7 +5,8 @@
 (def c-major-root "\"Am\"")
 (def tempo-root "Q:1/4=")
 (def default-tempo 120)
-(def header "X:1\nT:Hello World\nM:4/4\nL:1/4\nK:C\n%%MIDI program 0\n%%MIDI drum zd 60\n%%MIDI drumon\n%%MIDI gchord c\nQ:1/4=120\n")
+(def drum-beat "%%MIDI program 0\n%%MIDI drum zd 60\n%%MIDI drumon\n%%MIDI gchord c")
+(def header (str "X:1\nT:Hello World\nM:4/4\nL:1/4\nK:C\n" drum-beat "\n" tempo-root default-tempo "\n"))

 (defn- metric-line-to-bits [metric]
 	(clojure.string/split metric #"\s+"))
@@ -31,11 +32,14 @@
 		]
 		note-index))

+(defn- complexity-to-tempo [complexity]
+	(str tempo-root (+ (* 20 complexity) default-tempo)))
+
 (defn- metric-to-note [metric]
 	(let [complexity (complexity-from-metric metric)
 				note (nth c-major-notes (metric-to-note-index metric))]
 		(cond (> complexity 1)
-			(str "\n" tempo-root (+ (* 20 complexity) default-tempo) "\n" note)
+			(str "\n" (complexity-to-tempo complexity) "\n" note)
 			; note
 			:else note)))

@@ -47,11 +51,13 @@
 		; _ (prn completed-score)
 		]
 		(spit notation-file-name, completed-score)
+		notation-file-name
 		)
 	)

 (defn -main [& args]
 	(println (str "Generating ABC Notation from " (first args) "..."))
 	(with-open [rdr (clojure.java.io/reader (first args))]
-     (generate-notation 4 (line-seq rdr) (str (first args) ".abc")))
+     (let [notation-file-name (generate-notation 4 (line-seq rdr) (str (first args) ".abc"))]
+     	(println (str "Generated " notation-file-name))))
 	)


adding ssh-key and ostemplates

adding ssh-key and ostemplates

--- src/celestial/config.clj
+++ src/celestial/config.clj
@@ -99,6 +99,8 @@
 (def ^{:doc "digital ocean section validation"} digital-v
   {:digital-ocean {
      :token #{:required :String}
+     :ssh-key #{:required :String}
+     :ostemplates #{:required :Map}
      }})

 (def ^{:doc "aws section validation"} aws-v


Version 1.2.1-SNAPSHOT

Version 1.2.1-SNAPSHOT

--- backend/project.clj
+++ backend/project.clj
@@ -1,4 +1,4 @@
-(defproject lambdaui "1.2.0"
+(defproject lambdaui "1.2.1-SNAPSHOT"
   :description "LambdaCD-Plugin that provides a modern UI for your pipeline."
   :url "https://github.com/sroidl/lambda-ui"
   :license {:name "Apache License 2.0"


Fixed temp extraction in assembly instruction for the use case

--- src/clj/minijava/gas.clj
+++ src/clj/minijava/gas.clj
@@ -77,19 +77,40 @@
 (deftype ret []
    clojure.lang.IPersistentMap)

+;; precondition: instr is a cmpl/imull/subl/addl/movl
+(defn extract-use-temps [instr set]
+  (case (type instr)
+    :minijava.gas/cmpl (let [arg1 (:a instr)
+                             arg2 (:b instr)
+                             set  (if (= (type arg2) :minijava.temp/Temp)
+                                      (hash-set arg2)
+                                      (hash-set))]
+                         (if (= (type arg1) :minijava.temp/Temp)
+                             (conj set arg1)
+                             set))
+    (let [arg1 (:src instr)
+          arg2 (:dst instr)
+          set  (if (= (type arg2) :minijava.temp/Temp)
+                   (hash-set arg2)
+                   (hash-set))]
+      (if (= (type arg1) :minijava.temp/Temp)
+          (conj set arg1)
+          set))))
+
 ;;returns a list of all temps used by this instruction
 (defn uses [instr]
-  (case (type instr)
-    :minijava.gas/ret   (hash-set (tm/temp :eip))
-    :minijava.gas/jcc   nil
-    :minijava.gas/jmp   nil
-    :minijava.gas/call  nil
-    :minijava.gas/cmpl  (hash-set (:a instr)   (:b instr))
-    :minijava.gas/imull (hash-set (:src instr) (:dst instr))
-    :minijava.gas/subl  (hash-set (:src instr) (:dst instr))
-    :minijava.gas/addl  (hash-set (:src instr) (:dst instr))
-    :minijava.gas/movl  (hash-set (:src instr) (:dst instr))
-    nil)) ;;catch LABEL, MEMORY, CONST
+  (let [use-set (hash-set)]
+    (case (type instr)
+      :minijava.gas/ret   (hash-set (tm/temp :eip))
+      :minijava.gas/jcc   nil
+      :minijava.gas/jmp   nil
+      :minijava.gas/call  nil
+      :minijava.gas/cmpl  (extract-use-temps instr use-set)
+      :minijava.gas/imull (extract-use-temps instr use-set)
+      :minijava.gas/subl  (extract-use-temps instr use-set)
+      :minijava.gas/addl  (extract-use-temps instr use-set)
+      :minijava.gas/movl  (extract-use-temps instr use-set)
+      nil))) ;;catch LABEL, MEMORY, CONST

 ;;the set of temps defined by this instruction
 (defn defs [instr]


Replace hard coded request with functions passed to run scenario

--- src/clj_gatling/core.clj
+++ src/clj_gatling/core.clj
@@ -7,23 +7,25 @@
             [clojure-csv.core :as csv])
   (:gen-class))

-(def test-scenario {:requests ["Request1" "Request2"]})
+(defn run-request [id]
+  ;(println (str "Simulating request for " id))
+  (Thread/sleep (rand 1000))
+  "OK")
+
+(def test-scenario
+  {:requests [{:name "Request1" :fn run-request}
+              {:name "Request2" :fn run-request}]})

 (defmacro bench [expr]
   `(let [start# (System/currentTimeMillis)
          result# ~expr]
       {:result result# :start start# :end (System/currentTimeMillis) }))

-(defn run-request [name id]
-  ;(println (str "Simulating request for " id))
-  (Thread/sleep (rand 1000))
-  "OK")
-
 (defn run-scenario [scenario id]
   (assoc
     (rename-keys
       (bench
-        (map #(assoc (bench (run-request % id)) :name % :id id) (:requests scenario)))
+        (map #(assoc (bench ((:fn %) id)) :name (:name %) :id id) (:requests scenario)))
       {:result :requests})
     :id id))


remove unneeded vec

remove unneeded vec

--- src/clj_scraper/core.clj
+++ src/clj_scraper/core.clj
@@ -63,7 +63,7 @@
   [dom]
   (let [imgs (map find-imglocs (extract-imgs dom))]
      (let [links (map find-linkvalues (filter filter-links (extract-links dom)))]
-        (vec (map combine-imgslinks imgs links)))))
+        (map combine-imgslinks imgs links))))

 (defn extract-arrows
   "Extract all << or >> from the DOM"


More munging

More munging

--- src/cljs/go/compiler.clj
+++ src/cljs/go/compiler.clj
@@ -860,6 +860,7 @@
   [{:keys [env code segs args]}]
   (let [segs (map #(string/replace % "$" "__") segs)
         segs (map #(string/replace % "''" "\"\"") segs)
+        segs (map #(string/replace % "cljs.core" "cljs_core") segs)
         numeric (or (= ["(" "- " ")"] segs)
                  (some  #(= ["(" (format " %s " %) ")"] segs)
                         ["+" "-" "*" "/" "<" "<=" ">=" ">" "==" "===" "&"]))


Change architecture

Change architecture

--- src/cljs/gtfve/core.cljs
+++ src/cljs/gtfve/core.cljs
@@ -1,9 +1,7 @@
 (ns gtfve.core
   (:require-macros [cljs.core.async.macros :refer [go go-loop]]
                    [gtfve.macros :refer [<?]])
-  (:require [reagent.core :as reagent :refer [atom]]
-            [reagent.session :as session]
-            [om.core :as om]
+  (:require [om.core :as om]
             [sablono.core :as html :refer-macros [html]]
             [secretary.core :as secretary :include-macros true]
             [cljs.core.async :as async :refer [put! chan <! close!]]
@@ -11,7 +9,8 @@
             [goog.history.EventType :as EventType]
             [cljsjs.react :as react]
             [gtfve.maps :as m]
-            [gtfve.data :as data])
+            [gtfve.data :as data]
+            [gtfve.components.app :as app])
   (:import goog.History))

 ;; -------------------------
@@ -29,44 +28,10 @@
 (defonce gmap (atom nil))

 ;; -------------------------
-;; Views
-
-(defn home-page [data owner]
-  (om/component
-   (html [:div [:h2 "Home Page"]
-          [:div [:a {:href "#/about"} "go to the about page"]]])))
-
-(defn about-page [data owner]
-  (om/component
-   (html [:div [:h2 "About gtfve"]
-          [:div [:a {:href "#/"} "go to the home page"]]])))
-
-(defmulti page #(:current-page %))
-
-(defmethod page nil
-  [data] home-page)
-
-(defmethod page :home
-  [state] home-page)
-
-(defmethod page :about
-  [state] about-page)
-
-(defn current-page [data owner]
-  (om/component
-   (om/build (page (om/value data)) data)))
-
-;; -------------------------
 ;; Routes
 (secretary/set-config! :prefix "#")

-(secretary/defroute "/" []
-  (session/swap! assoc
-                 :current-page :home
-                 :map {:opts m/default-map-opts}))
-
-(secretary/defroute "/about" []
-  (session/put! :current-page :about))
+(secretary/defroute "/" [])

 ;; -------------------------
 ;; History
@@ -82,7 +47,6 @@
 ;; -------------------------
 ;; Initialize app
 (defn init! []
-  (hook-browser-navigation!)
-  (om/root current-page
-           session/state
+  (om/root app/app
+           (atom {})
            {:target (. js/document (getElementById "app"))}))


Fix :features initialization time.

Fix :features initialization time.

--- src/cljs/quil/sketch.clj
+++ src/cljs/quil/sketch.clj
@@ -9,15 +9,14 @@
   [app-name & options]
   (let [raw-opts (apply hash-map options)
         opts     (if (:host raw-opts) raw-opts
-                     (merge raw-opts {:host app-name}))
-        features (set (:features opts))]
+                     (merge raw-opts {:host app-name}))]
     `(do
        (defn ~(vary-meta app-name assoc :export true) []
          (quil.sketch/sketch
-          ~@(apply concat (seq (merge (dissoc opts :features) features)))))
+          ~@(apply concat (seq opts))))

-       ~(when (not (:no-start features))
-          `(quil.sketch/add-sketch-to-init-list
+       (when-not (some #(= :no-start %) ~(:features opts))
+          (quil.sketch/add-sketch-to-init-list
             {:fn ~app-name
              :host-id (if (:host raw-opts)
                           (:host raw-opts)


core.async: Add transducer examples.

core.async: Add transducer examples.

--- test/com/nomistech/clojure_the_language/core_async_mapping_etc_test.clj
+++ test/com/nomistech/clojure_the_language/core_async_mapping_etc_test.clj
@@ -67,3 +67,33 @@
   (chan->seq (a/mapcat< (fn [x] [x :plop])
                         (a/to-chan (range 5))))
   => [0 :plop 1 :plop 2 :plop 3 :plop 4 :plop])
+
+
+;;;; Transducers
+
+
+;;;; #### A zero buffer size does not to the xform!!!
+
+(fact "My first transducer example -- "
+  (let [c (a/chan 1 (map (partial * 100)))]
+    (a/onto-chan c (range 5))
+    (chan->seq c))
+  => [0 100 200 300 400])
+
+(fact "My second transducer example"
+  (let [c (a/chan 1 (filter even?))]
+    (a/onto-chan c (range 5))
+    (chan->seq c))
+  => [0 2 4])
+
+(fact "My third transducer example"
+  ;; #### Huh? Wrong order of composition??
+  ;; See http://clojure.org/transducers :
+  ;; - "Composition of the transformer runs right-to-left but builds a
+  ;;    transformation stack that runs left-to-right (filtering happens
+  ;;    before mapping in this example)."
+  (let [c (a/chan 1 (comp (filter even?)
+                          (map (partial * 100))))]
+    (a/onto-chan c (range 5))
+    (chan->seq c))
+  => [0 200 400])


(PDB-3302) Clean up deactivated_nodes integration test

--- test/puppetlabs/puppetdb/integration/storeconfigs/deactivated_nodes.clj
+++ test/puppetlabs/puppetdb/integration/storeconfigs/deactivated_nodes.clj
@@ -3,31 +3,31 @@
             [puppetlabs.puppetdb.integration.fixtures :as int]
             [me.raynes.fs :as fs]))

+
+(defn test-collection [ps pdb should-be-active?]
+  (let [{agent-stdout :out} (int/run-puppet-as "collector" ps pdb "Notify <<| |>>")
+        {status-stdout :out} (int/run-puppet-node-status pdb "exporter") ]
+    (if should-be-active?
+      (do
+        (is (re-find #"Hello from exporter" agent-stdout))
+        (is (re-find #"Currently active" status-stdout)))
+      (do
+        (is (not (re-find #"Hello from exporter" agent-stdout)))
+        (is (re-find #"Deactivated at" status-stdout))))))
+
 (deftest ^:integration deactivated-nodes
   (with-open [pg (int/setup-postgres)
               pdb (int/run-puppetdb pg {})
               ps (int/run-puppet-server [pdb] {})]
-
-    (let [exporter-manifest  "@@notify { 'Hello from exporter': }"
-          test-collection (fn test-collection [should-be-active]
-                            (let [{agent-stdout :out} (int/run-puppet-as "collector" ps pdb "Notify <<| |>>")
-                                  {status-stdout :out} (int/run-puppet-node-status pdb "exporter") ]
-                              (if should-be-active
-                                (do
-                                  (is (re-find #"Hello from exporter" agent-stdout))
-                                  (is (re-find #"Currently active" status-stdout)))
-                                (do
-                                  (is (not (re-find #"Hello from exporter" agent-stdout)))
-                                  (is (re-find #"Deactivated at" status-stdout))))))]
-
+    (let [exporter-manifest  "@@notify { 'Hello from exporter': }"]
       (testing "Resources should be collected before deactivation"
         (int/run-puppet-as "exporter" ps pdb exporter-manifest)
-        (test-collection true))
+        (test-collection ps pdb true))

       (testing "Resources from deactivated nodes should be ignored"
         (int/run-puppet-node-deactivate pdb "exporter")
-        (test-collection false))
+        (test-collection ps pdb false))

       (testing "Resources from reactivated nodes should be collected"
         (int/run-puppet-as "exporter" ps pdb exporter-manifest)
-        (test-collection true)))))
+        (test-collection ps pdb true)))))


Add defined exit codes to Clojure version

--- clojure/src/biotool/core.clj
+++ clojure/src/biotool/core.clj
@@ -27,6 +27,27 @@

 ;; Set up logging infrastructure
 (timbre/refer-timbre)
+
+;; Program exit status codes
+(def exit-success 0)
+(def exit-failure 1)
+(def exit-failure-cli 2) ; Command line argument error
+
+(defn exit-with-error
+  "Print an error message to stderr and then exit the program
+  with a given exit status.
+
+  Arguments:
+    status: The exit status of the program (non-negative integer).
+    msg: Error message to display on stderr (string).
+
+  Result:
+    nil"
+  [status msg]
+  ;; for some reason printing to stderr is not working
+  ;; (binding [*out* *err*] println msg)
+  (println msg)
+  (System/exit status))

 (def initial-stats
   "Initial value of stats, before any sequences have been considered"
@@ -152,8 +173,10 @@

   [minlen filename]
   (timbre/info "Processing FASTA file from" filename)
-  (with-open [reader (bs/bs-reader (bs/init-fasta-file filename :iupacAminoAcids))]
-    (process-fasta-reader minlen filename reader)))
+  (try
+    (with-open [reader (bs/bs-reader (bs/init-fasta-file filename :iupacAminoAcids))]
+      (process-fasta-reader minlen filename reader))
+    (catch Exception e (exit-with-error exit-failure (.getMessage e)))))

 (defn process-stdin
   "Compute the statistics for a single input FASTA file from stdin,
@@ -224,22 +247,6 @@
   [errors]
   (str "The following errors occurred while parsing your command:\n\n"
        (string/join \newline errors)))
-
-(defn exit
-  "Print an error message to stderr and then exit the program
-  with a given exit status.
-
-  Arguments:
-    status: The exit status of the program (non-negative integer).
-    msg: Error message to display on stderr (string).
-
-  Result:
-    nil"
-  [status msg]
-  ;; for some reason printing to stderr is not working
-  ;; (binding [*out* *err*] println msg)
-  (println msg)
-  (System/exit status))

 (def cli-options
   "Define the command line options of the program."
@@ -273,16 +280,14 @@
     (timbre/info "Program started")
     (timbre/info "Command line: " (string/join " " *command-line-args*)))

-
-(def exit-success 0)
-(def exit-failure-cli 2) ; Command line argument error
-
 (defn -main
   "Orchestrate the computation"
   [& args]
   (let [{:keys [options arguments errors summary]} (parse-opts args cli-options)]
     (cond
-      (:help options) (exit exit-success (usage summary))
-      errors (exit exit-failure-cli (error-msg errors)))
+      (:help options)
+         (do (println (usage summary))
+               (System/exit exit-success))
+      errors (exit-with-error exit-failure-cli (error-msg errors)))
     (init-logging (:log options))
     (process-fasta-files (:minlen options) arguments)))


open image in new tab

open image in new tab

--- iwaswhere-web/src/cljs/iwaswhere_web/ui/media.cljs
+++ iwaswhere-web/src/cljs/iwaswhere_web/ui/media.cljs
@@ -4,7 +4,7 @@
   "Renders image view."
   [entry]
   (when-let [img-file (:img-file entry)]
-    [:a {:href (str "/photos/" img-file)}
+    [:a {:href (str "/photos/" img-file) :target "_blank"}
      [:img {:src (str "/photos/" img-file)}]]))

 (defn audioplayer-view


env can take a vector, implying a default

--- src/aero/core.clj
+++ src/aero/core.clj
@@ -3,10 +3,13 @@
 (ns aero.core
   (:require
    [clojure.edn :as edn]
-   [clojure.java.io :as io]))
+   [clojure.java.io :as io]
+   [schema.core :as s]))

 (defn readers [profile]
-  {'env (fn [x] (System/getenv (str x)))
+  {'env (fn [x]
+          (cond (vector? x) (or (System/getenv (str (first x))) (second x))
+                :otherwise (System/getenv (str x))))
    'cond (fn [m]
            (cond (contains? m profile) (clojure.core/get m profile)
                  (contains? m :default) (clojure.core/get m :default)


new pose proof step required for reintroducing local definitions

--- src/latte/fun.clj
+++ src/latte/fun.clj
@@ -172,10 +172,10 @@
   [[T :type] [U :type] [f (==> T U)] [b (bijective T U f)]]
   (surjective U T (inverse T U f b)))

-(proof inverse-surjective
+(latte/try-proof inverse-surjective
     :script
   (have <a> (injective T U f) :by ((bijective-is-injective T U f) b))
-  (have inv-f (==> U T) :by (inverse T U f b))
+  (pose inv-f :as (inverse T U f b)) ;; TODO TODO !
   (assume [x T]
     (have y U :by (f x))
     (have <b> (equal U (f (inv-f y)) (f x))


Replace conman by hikari and hugsql in db namespace

--- src/madouc/db.clj
+++ src/madouc/db.clj
@@ -1,6 +1,7 @@
 (ns madouc.db
   (:require [mount.core :refer [defstate]]
-            [conman.core :as conman]
+            [hikari-cp.core :refer [make-datasource close-datasource]]
+            [hugsql.core :as hugsql]
             [madouc.config :refer [env]]))

 (defn- make-pool-spec
@@ -10,13 +11,12 @@
    :password pass})

 (defstate con
-  :start (conman/connect! (make-pool-spec
+  :start (make-datasource (make-pool-spec
                            (env :db-host)
                            (env :db-name)
                            (env :db-user)
                            (env :db-password)))
-  :stop (conman/disconnect! con))
+  :stop (close-datasource con))

-(conman/bind-connection con "sql/queries.sql")


Implimentation of REST for  Select All documents

--- src/rrms/core.clj
+++ src/rrms/core.clj
@@ -24,6 +24,11 @@
        (rr/content-type
         (rr/response  (db/get-documents-by-title
                        {:title title}))
+        content-type))
+
+  (GET "/documents/all" []
+       (rr/content-type
+        (rr/response (db/get-all-documents))
         content-type))

   (GET "/documents/id/:id" [id]


Simplify sort function

Simplify sort function

--- resources/isometric-rpg/utils.clj
+++ resources/isometric-rpg/utils.clj
@@ -178,22 +178,4 @@

 (defn sort-entities
   [entities]
-  (sort (fn [e1 e2]
-          (cond
-            (and (:health e1)
-                 (:health e2)
-                 (= (:health e1) 0)
-                 (> (:health e2) 0))
-            -1
-            (and (:health e1)
-                 (:health e2)
-                 (> (:health e1) 0)
-                 (= (:health e2) 0))
-            1
-            (> (:y e1) (:y e2))
-            -1
-            (> (:y e2) (:y e1))
-            1
-            :else
-            0))
-        entities))
+  (sort-by :y #(compare %2 %1) entities))


carry-debugger: bump carry-reagent dep

carry-debugger: bump carry-reagent dep

--- contrib/debugger/project.clj
+++ contrib/debugger/project.clj
@@ -1,5 +1,5 @@
 (defproject
-  carry-debugger "0.2.0"
+  carry-debugger "0.3.0"
   :description "Middleware for debugging Carry applications."
   :url "https://github.com/metametadata/carry/tree/master/contrib/debugger"
   :license {:name "MIT" :url "http://opensource.org/licenses/MIT"}
@@ -8,7 +8,7 @@
                  [org.clojure/clojurescript "1.8.51" :scope "provided"]

                  [carry-schema "0.3.0"]
-                 [carry-reagent "0.2.0"]
+                 [carry-reagent "0.3.0"]

                  [org.clojure/core.match "0.3.0-alpha4"]
                  [reagent "0.6.0-alpha2"]


Allow for nil target vectors

Allow for nil target vectors

--- src/cortex/optimise.cljc
+++ src/cortex/optimise.cljc
@@ -177,9 +177,14 @@
 (defn process-nulls
   "Replaces non-numbers in the target vector with the activation (to ensure zero gradient)"
   [activation target]
-  (if (= Object (m/element-type target))
-    (m/emap (fn [a b] (if (number? a) a b)) target activation)
-    target))
+  (cond
+    ;; if the target vector is nil, just use the current activation (i.e. completely zero gradient)
+    (nil? target)
+      activation
+    ;; if the target potentially contains nils, replace nils with the corresponding activation
+    (= Object (m/element-type target))
+      (m/emap (fn [a b] (if (number? a) a b)) target activation)
+    :else target))

 (defn mean-squared-error
   "Computes the mean squared error of an activation array and a target array"


Fixed indentations.

Fixed indentations.

--- src/dragon/blog/post.clj
+++ src/dragon/blog/post.clj
@@ -47,11 +47,13 @@
         file-src (.getPath file-obj)
         filename-old (.getName file-obj)
         filename (format "%s.html" (util/sanitize-str (:title data)))]
-    (assoc data :filename filename
-                :file-src file-src
-                :uri-path (-> file-src
-                              (string/replace filename-old filename)
-                              (string/replace-first "posts/" "")))))
+    (assoc data
+           :filename filename
+           :src-file file-src
+           :src-dir (.getParent file-obj)
+           :uri-path (-> file-src
+                         (string/replace filename-old filename)
+                         (string/replace-first "posts/" "")))))

 (defn add-link
   [uri-base data]
@@ -65,18 +67,18 @@
 (defn add-dates
   [data]
   (log/debug "Adding post dates ...")
-  (let [date (util/path->date (:file-src data))
+  (let [date (util/path->date (:src-file data))
         timestamp (util/format-timestamp date)
         timestamp-clean (string/replace timestamp #"[^\d]" "")
         datestamp (util/format-datestamp date)]
     (assoc
       data
-        :date date
-        :month (util/month->name (:month date))
-        :month-short (util/month->short-name (:month date))
-        :timestamp timestamp
-        :timestamp-long (Long/parseLong timestamp-clean)
-        :datestamp datestamp)))
+      :date date
+      :month (util/month->name (:month date))
+      :month-short (util/month->short-name (:month date))
+      :timestamp timestamp
+      :timestamp-long (Long/parseLong timestamp-clean)
+      :datestamp datestamp)))

 (defn add-counts
   [data]
@@ -85,9 +87,9 @@
     (log/trace "Body data:" data)
     (assoc
       data
-        :char-count (util/count-chars body)
-        :word-count (util/count-words body)
-        :line-count (util/count-lines body))))
+      :char-count (util/count-chars body)
+      :word-count (util/count-words body)
+      :line-count (util/count-lines body))))

 (defn add-post-data
   ""


cleaning the funcification of constrain lists

--- src/fogus/me/provide.clj
+++ src/fogus/me/provide.clj
@@ -29,7 +29,7 @@

             '([n] [pos?])])

-(defn build-pre-post [cnstr]
+(defn build-pre-post-map [cnstr]
   (let [[L M R] (partition-by #{'=>} cnstr)]
     {:pre  (when (not= L '(=>)) L)
      :post (if (= L '(=>)) M R)}))
@@ -43,8 +43,10 @@

 (defn build-map [args cnstr]
   [args
-   (manip-map (partial funcify args)
-              [:pre :post]
-              (build-pre-post cnstr))])
+   (manip-map (partial funcify '[%])
+             [:post]
+             (manip-map (partial funcify args)
+                        [:pre]
+                        (build-pre-post-map cnstr)))])

 (map (fn [[a c]] (build-map a c)) (take 2 tests))


fixed typo

fixed typo

--- src/grape/visualizer.clj
+++ src/grape/visualizer.clj
@@ -22,7 +22,6 @@
   (swap! ctr-atom (fn [c] (+ 1 c)))
   (deref ctr-atom))

-(defn dot->render [g]
 (defn dot->render [g]
   (dorothy/render g {:format :png}))


Bugfix: fix usage of the old munge for HTTP URLs

--- src/grimoire/api/web.clj
+++ src/grimoire/api/web.clj
@@ -32,7 +32,7 @@
          (string? op)]}
   (str (:host config)
        api-base-str
-       (when thing (t/thing->url-path thing util/url-munge))
+       (when thing (t/thing->url-path thing))
        "?op=" op
        (when-let [type (:type config :edn)]
          (when-let [t' (normalize-type type)]
@@ -51,4 +51,4 @@
              (nil? thing))]}
   (str (:host config)
        store-base-str
-       (when thing (t/thing->url-path thing util/url-munge))))
+       (when thing (t/thing->url-path thing))))


when-let is better here

when-let is better here

--- src/gts_move_on/core.clj
+++ src/gts_move_on/core.clj
@@ -20,7 +20,7 @@
                      (html/set-attr :href (str "https://gitlab.com/" gitlab-path))))

 (defn repo-handler [project repository]
-  (if-let [gitlab-path (get mapping (str project "/" repository))]
+  (when-let [gitlab-path (get mapping (str project "/" repository))]
     (template gitlab-path)))

 (defroutes app


remove dummy messages

remove dummy messages

--- barge-ui/src/barge/core.cljs
+++ barge-ui/src/barge/core.cljs
@@ -15,20 +15,17 @@
     {:node1 {
       :uri "ws://127.0.0.1:56789/events"
       :ws nil
-      :msgs [{:msg "this is a message" :timestamp "2014-06-11"}
-        {:msg "this is another message" :timestamp "2014-06-11"}]
+      :msgs []
       }
      :node2 {
       :uri "ws://127.0.0.1:56790/events"
       :ws nil
-      :msgs [{:msg "this is a message" :timestamp "2014-06-11"}]
+      :msgs []
       }
      :node3 {
       :uri "ws://127.0.0.1:56791/events"
       :ws nil
-      :msgs [{:msg "this is a message" :timestamp "2014-06-11"}
-       {:msg "this is a message" :timestamp "2014-06-11"}
-       {:msg "this is another message" :timestamp "2014-06-11"}]
+      :msgs []
       }
      }))


[skip ci] ws

[skip ci] ws

--- src/java_time/graph.cljc
+++ src/java_time/graph.cljc
@@ -99,7 +99,7 @@
   (u/fast-memoize
     (fn [n]
       (let [rng (range n)]
-        (into [] (comp (map inc )
+        (into [] (comp (map inc)
                        (map #(combinations % rng))
                        cat
                        (filter #(apply = 1 (map - (rest %) %))))


Target-path boot env option has been removed

--- src/adzerk/boot_reload.clj
+++ src/adzerk/boot_reload.clj
@@ -55,11 +55,11 @@
       (adzerk.boot-reload.server/send-visual!
         ~messages))))

-(defn- send-changed! [pod asset-path cljs-asset-path changed]
+(defn- send-changed! [pod asset-path cljs-asset-path target-path changed]
   (when-not (empty? changed)
     (pod/with-call-in pod
       (adzerk.boot-reload.server/send-changed!
-       {:target-path ~(get-env :target-path)
+       {:target-path ~target-path
         :asset-path ~asset-path
         :cljs-asset-path ~cljs-asset-path}
         ~changed))))
@@ -110,6 +110,7 @@
    c cljs-asset-path PATH str "The actual asset path. This is added to the start of reloaded urls. (optional)"
    o open-file COMMAND str "The command to run when warning or exception is clicked on HUD. Passed to format. (optional)"
    v disable-hud      bool "Toggle to disable HUD. Defaults to false (visible)."
+   t target-path       str "Target path to load files from, used WHEN serving files using file: protocol. (optional)"
    _ only-by-re REGEXES [regex] "Vector of path regexes (for `boot.core/by-re`) to restrict reloads to only files within these paths (optional)."]

   (let [ns   (name (gensym "init"))
@@ -157,6 +158,7 @@
               (send-changed! @pod
                              asset-path
                              cljs-asset-path
+                             target-path
                              (changed @prev fileset only-by-re static-files))
               (reset! prev fileset))
             fileset))))))


Map rest of lights for Thursday demo.

Map rest of lights for Thursday demo.

--- src/afterglow/examples.clj
+++ src/afterglow/examples.clj
@@ -52,10 +52,18 @@
                        :y-rotation (tf/degrees 180))
   (show/patch-fixture! :hex-1 (chauvet/slimpar-hex3-irc) universe 129 :y (tf/inches 4) :z (tf/inches 10)
                        :x-rotation (tf/degrees 90))
-  (show/patch-fixture! :blade-1 (blizzard/blade-rgbw) universe 270 :y (tf/inches 9))
+  (show/patch-fixture! :hex-2 (chauvet/slimpar-hex3-irc) universe 145 :y (tf/inches 4) :z (tf/inches 30)
+                       :x-rotation (tf/degrees 90))
+  (show/patch-fixture! :blade-1 (blizzard/blade-rgbw) universe 225
+                       :x (tf/inches -88) :y (tf/inches 9) :z (tf/inches 66)
+                       :y-rotation (tf/degrees -180))
   (show/patch-fixture! :blade-2 (blizzard/blade-rgbw) universe 240
                        :x (tf/inches 40) :y (tf/inches 58) :z (tf/inches -15)
                        :y-rotation (tf/degrees -45))
+  (show/patch-fixture! :blade-3 (blizzard/blade-rgbw) universe 255
+                       :x (tf/inches -58) :y (tf/inches 9) :z (tf/inches 66)
+                       :y-rotation (tf/degrees 90))
+  (show/patch-fixture! :blade-4 (blizzard/blade-rgbw) universe 270 :y (tf/inches 9))
   (show/patch-fixture! :ws-1 (blizzard/weather-system) universe 161
                        :x (tf/inches 22) :y (tf/inches 7) :z (tf/inches 7)
                        :x-rotation (tf/degrees 180) :y-rotation (tf/degrees 180))
@@ -71,8 +79,9 @@
 (defn global-color-effect
   "Make a color effect which affects all lights in the sample show.
   This became vastly more useful once I implemented dynamic color
-  parameters."
-  [color & {:keys [include-color-wheels]}]
+  parameters. Can include only a specific set of lights by passing
+  them with :lights"
+  [color & {:keys [include-color-wheels lights] :or {lights (show/all-fixtures)}}]
   (try
     (let [[c desc] (cond (= (type color) :com.evocomputing.colors/color)
                        [color (color-name color)]
@@ -81,7 +90,7 @@
                        [color "variable"]
                        :else
                        [(create-color color) color])]
-      (color-effect (str "Color: " desc) c (show/all-fixtures) :include-color-wheels include-color-wheels))
+      (color-effect (str "Color: " desc) c lights :include-color-wheels include-color-wheels))
     (catch Exception e
       (throw (Exception. (str "Can't figure out how to create color from " color) e)))))

@@ -313,7 +322,16 @@
                  (cues/cue :color (fn [_] (global-color-effect
                                            (params/build-color-param :s 100 :l 50 :h hue-gradient
                                                                      :adjust-hue hue-bar)))
-                         :short-name "Rainbow Grid+Bar"))
+                           :short-name "Rainbow Grid+Bar"))
+
+    (ct/set-cue! (:cue-grid *show*) 7 1
+                 (cues/cue :color (fn [_] (global-color-effect
+                                           (params/build-color-param :s 100 :l 50 :h hue-gradient
+                                                                     :adjust-hue hue-bar)
+                                           :lights (show/fixtures-named "blade")))
+                         :short-name "Rainbow Blades"))
+
+
     ;; TODO: Write a macro to make it easier to bind cue variables.
     (ct/set-cue! (:cue-grid *show*) 0 7
                  (cues/cue :sparkle (fn [var-map] (fun/sparkle (show/all-fixtures)


Fix console/error getting cut off

Fix console/error getting cut off

Picked up from warnings

--- src/lt/objs/plugins.cljs
+++ src/lt/objs/plugins.cljs
@@ -100,7 +100,7 @@
           (assoc :dir dir)
           (validate "plugin.edn"))
       (catch :default e
-        (console/error "FAILED to load plugin.edn: " dir)))
+        (console/error (str "FAILED to load plugin.edn: " dir))))
     ))

 (defn plugin-json [dir]


Add (currently all) images to the files properties of an album

--- src/h5gal/core.clj
+++ src/h5gal/core.clj
@@ -47,6 +47,7 @@
 (import 'java.util.Locale)
 (import '(java.text DateFormat))
 (require 'digest)
+(use '[clojure.set])

 (def dataDir "data")

@@ -63,6 +64,10 @@
   (flatten (map (fn [{ext :extensions}] ext) imageConversions))
   )

+(imageFormats)
+
+()
+
 (defn isLeafDirectory [path]
   (and
    (.isDirectory path)
@@ -76,24 +81,50 @@
               ))
   )

-(defn walked [baseDir leafDir]
-  {:b baseDir :l leafDir}
+(defn isImage [filename]
+  #(some (re-find #"[^\.]+$" %) (imageFormats))
+  )
+
+(defn parseDirectory [baseDir leafDir]
+  (let [
+        readmeFilename (str leafDir "/" "README.md")
+        hasReadme (.exists (as-file readmeFilename))
+        isImage (fn isImage [img] (> (count (filter #(= (re-find #"[^\.]+$" img) %) (imageFormats))) 0))
+        ]
+    (conj
+     {
+      :files (filter isImage (map #(.getName %) (file-seq leafDir)))
+      }
+     (if hasReadme
+       {:description (slurp readmeFilename)}
+       )
+     )
+    )
+  )
+
+(parseDirectory (file "data") (file "data/2011/05/09/Going Fishing")
+                )
+
+(defn getRelativePath [baseDir leafDir]
+  (subs (.getAbsolutePath leafDir) (+ (count (.getAbsolutePath baseDir)) 1))
   )

 (defn extractPathInfo [baseDir leafDir]
   (let
-    [ relativePath (subs (.getAbsolutePath leafDir) (+ (count (.getAbsolutePath baseDir)) 1))
+    [ relativePath (getRelativePath baseDir leafDir)
       matches (re-matches #"^([0-9]{4})\/([0-9]{2})\/([0-9]{2})\/?(.*)?" relativePath)
       localDate (if matches (local-date (Integer. (matches 1)) (Integer. (matches 2)) (Integer. (matches 3))) nil)
-      dateTime (if matches (date-time (Integer. (matches 1)) (Integer. (matches 2)) (Integer. (matches 3))))
+      dateTime (if matches (date-time (Integer. (matches 1)) (Integer. (matches 2)) (Integer. (matches 3))) nil)
       ]
     (if matches
       (conj {
+             :albumPath relativePath
              :dateInst localDate
              :dateComm (clojure.string/join "-" [(matches 1) (matches 2) (matches 3)])
              :dateDisp (formatLocalDate localDate)
              :id (digest/md5 relativePath)
              }
+            (parseDirectory baseDir leafDir)
             (if (> (count (matches 4)) 0)
               {:title (matches 4)  :subtitle (formatLocalDate localDate)}
               {:title (formatLocalDate localDate)}
@@ -104,8 +135,13 @@
     )
   )

-(extractPathInfo (file "data") (file "data/2012/11/25/Christmas"))
-(extractPathInfo (file "data") (file "data/2012/11/25"))
+(def epi (partial extractPathInfo (file dataDir)))
+(epi (file "data/2011/06/22/Mountain Biking"))
+(epi (file "data/2011/06/22/Drinking Beer"))
+(epi (file "data/2011/05/09/Going Fishing"))
+(epi (file "data/2011/02"))
+
+(walk dataDir)

 (remove nil? (map (partial extractPathInfo (file dataDir)) (walk dataDir)))


Remove commented out code.

Remove commented out code.

--- src/isla/story.clj
+++ src/isla/story.clj
@@ -14,8 +14,6 @@
   (get-item [this name]))

 (defprotocol Playable
-  ;; (move [this arguments])
-  (look [this arguments]))

 (defrecord Story [player rooms]
   Queryable
@@ -29,8 +27,6 @@
         nil)))

   Playable
-  ;; (move [this arguments]
-  ;;   (println "move!"))
   (look [this arguments]
     (if (nil? arguments)
       (:summary (get player :room))


Add go fn for moving between rooms.

Add go fn for moving between rooms.

--- src/isla/story.clj
+++ src/isla/story.clj
@@ -25,6 +25,7 @@
   (item [this name]))

 (defprotocol Playable
+  (go [this arguments-str])
   (look [this arguments-str]))

 (def room-defaults ["" "" [] :undefined])
@@ -46,6 +47,16 @@
         nil)))

   Playable
+  (go [this arguments-str]
+    (let [arguments (extract-arguments arguments-str)]
+      (if (= "into" (first arguments))
+        (let [name (second arguments)]
+          (if (some #{name} (map (fn [x] (:name x))
+                                 (connected-rooms (:room player) this)))
+            (creturn
+             (assoc this :player (assoc player :room (get rooms name)))
+             (str "You are in the " name))
+            (creturn this (str "You cannot go into the " name)))))))
   (look [this arguments-str]
     (let [arguments (extract-arguments arguments-str)]
       (if (empty? arguments)


setting up starting of forwarding, fake implementation may be off

--- src/bitsplit_cli/core.cljs
+++ src/bitsplit_cli/core.cljs
@@ -1,5 +1,7 @@
 (ns bitsplit-cli.core
     (:use [cljs.core.async :only (chan put! <!)]
+          [bitsplit.core :only (handle-unspents!)]
+          [bitsplit.client.protocol :only (unspent-channel)]
           [bitsplit-cli.filesystem :only (->File)]
           [bitsplit-cli.client :only (->FakeClient)]
           [bitsplit-cli.commands :only (execute)])
@@ -29,8 +31,14 @@
           seq
           (= (take 4 command))))

+(defn- start-forwarding [storage client]
+    (let [unspents (unspent-channel client)]
+        (handle-unspents! client storage unspents)))
+
 (defn start-repl []
     (.start prompt)
+    ; not really tied to repl in long term, but whatever
+    (start-forwarding storage client)
     (execute {
         :storage storage
         :command "list"


Drop some log lines in cache store.

Drop some log lines in cache store.

--- src/blocks/store/cache.clj
+++ src/blocks/store/cache.clj
@@ -97,8 +97,7 @@
   (start
     [this]
     (if @state
-      (do (log/info "CachingStore is already initialized")
-          this)
+      this
       (do
         (when-not primary
           (throw (IllegalStateException.
@@ -106,7 +105,6 @@
         (when-not cache
           (throw (IllegalStateException.
                    "Cannot start caching store without backing cache store")))
-        (log/debug "Scanning cache store to build state...")
         (let [initial-state (scan-state cache)
               cached-bytes (:total-size initial-state)]
           (reset! state initial-state)


Re-loading a thread when a thought on it is removed successfully

Previously I was only reloading it if the thread was being displayed,
this is cleaner as it allows me to keep threads cached (and decouples
it from display).

--- src/cljs/memento/core.cljs
+++ src/cljs/memento/core.cljs
@@ -315,23 +315,21 @@

 (register-handler
   :memory-forget
-  (fn [app-state [_ root-id]]
-    (let [url (str "/api/thoughts/" root-id)]
+  (fn [app-state [_ memory]]
+    (let [url (str "/api/thoughts/" (:id memory))]
       (DELETE url {:headers       {:authorization (str "Token " (get-in app-state [:credentials :token]))}
-                   :handler       #(dispatch [:memory-forget-success %])
+                   :handler       #(dispatch [:memory-forget-success memory %])
                    :error-handler #(dispatch [:memory-forget-error %])}))
     app-state))

 (register-handler
   :memory-forget-success
-  (fn [app-state [_ msg]]
-    (let [thread-id  (get-in app-state [:ui-state :show-thread-id])
-          in-thread? (and thread-id
-                          (get-in app-state [:ui-state :show-thread?]))]
+  (fn [app-state [_ memory msg]]
+    (let [thread-id (:root_id memory)]
       (dispatch [:state-message (str "Thought forgotten") "alert-success"])
       (if (= :remember (get-in app-state [:ui-state :section])) ; Just in case we allow editing from elsewhere...
         (dispatch [:memories-load]))
-      (if in-thread?
+      (when thread-id
         (dispatch [:thread-load thread-id]))
       (-> app-state
           (assoc-in [:ui-state :is-busy?] false)
@@ -660,7 +658,7 @@
             {:placement :top
              :overlay   tooltip}
             [:span {:class    "btn btn-danger btn-xs icon-margin-left show-on-hover"
-                    :on-click #(dispatch [:memory-forget (:id memory)])}
+                    :on-click #(dispatch [:memory-forget memory])}
              [:i {:class "fa fa-remove"}]]
             ])

@@ -698,7 +696,7 @@
         ; to the @path... but the subscription is not refreshed when the @path changes.
         threads   (subscribe [:cache :threads])
         thread    (reaction (get @threads @thread-id))
-        ready?    (reaction (and @show? (some? @thread)))]
+        ready?    (reaction (and @show? (not (empty? @thread))))]
     (fn []
       [Modal {:show @ready? :onHide #(dispatch [:state-show-thread false])}
        [ModalBody


Re-loading a thread when a thought on it is successfully edited

--- src/cljs/memento/core.cljs
+++ src/cljs/memento/core.cljs
@@ -139,6 +139,11 @@
        thoughts))

+(defn thread-in-cache?
+  "Receives an application state and a thread-id, and returns true if the
+  application cache currently contains that thread."
+  [app-state thread-id]
+  (contains? (get-in app-state [:cache :threads]) (str thread-id)))

 ;;;;------------------------------
 ;;;; Handlers
@@ -284,19 +289,19 @@
           url    (str "/api/thoughts/" (:id memory))]
       (PUT url {:params        {:thought note}
                 :headers       {:authorization (str "Token " (get-in app-state [:credentials :token]))}
-                :handler       #(dispatch [:memory-edit-save-success note])
-                :error-handler #(dispatch [:memory-edit-save-error %])}))
+                :handler       #(dispatch [:memory-edit-save-success memory note])
+                :error-handler #(dispatch [:memory-edit-save-error memory %])}))
     (assoc-in app-state [:ui-state :is-busy?] true)))

 (register-handler
   :memory-edit-save-success
-  (fn [app-state [_ msg]]
-    (let [thread-id (get-in app-state [:ui-state :show-thread-id])]
+  (fn [app-state [_ memory msg]]
+    (let [thread-id (:root_id memory)]
       (dispatch [:state-message (str "Updated memory to: " msg) "alert-success"])
       (if (= :remember (get-in app-state [:ui-state :section])) ; Just in case we allow editing from elsewhere...
         (dispatch [:memories-load]))
-      (if thread-id
+      (when (thread-in-cache? app-state thread-id)
         (dispatch [:thread-load thread-id]))
       (-> app-state
           (assoc-in [:ui-state :is-busy?] false)
@@ -308,8 +313,8 @@

 (register-handler
   :memory-edit-save-error
-  (fn [app-state [_ result]]
-    (dispatch [:state-message (str "Error editing note: " result) "alert-danger"])
+  (fn [app-state [_ memory result]]
+    (dispatch [:state-message (str "Error editing memory: " result) "alert-danger"])
     (clear-token-on-unauth result)
     (assoc-in app-state [:ui-state :is-busy?] false)))

@@ -329,7 +334,7 @@
       (dispatch [:state-message (str "Thought forgotten") "alert-success"])
       (if (= :remember (get-in app-state [:ui-state :section])) ; Just in case we allow editing from elsewhere...
         (dispatch [:memories-load]))
-      (when thread-id
+      (when (thread-in-cache? app-state thread-id)
         (dispatch [:thread-load thread-id]))
       (-> app-state
           (assoc-in [:ui-state :is-busy?] false)
@@ -671,7 +676,7 @@
         is-busy?    (subscribe [:ui-state :is-busy?])
         ;; On the next one, we can't use not-empty because (= nil (not-empty nil)), and :show expects true/false,
         ;; not a truth-ish value.
-        show?       (reaction (seq @edit-memory))]
+        show?       (reaction (not (empty? @edit-memory)))]
     (fn []
       [Modal {:show @show? :onHide #(dispatch [:memory-edit-set nil])}
        [ModalBody
@@ -696,7 +701,7 @@
         ; to the @path... but the subscription is not refreshed when the @path changes.
         threads   (subscribe [:cache :threads])
         thread    (reaction (get @threads @thread-id))
-        ready?    (reaction (and @show? (not (empty? @thread))))]
+        ready?    (reaction (and (not-empty @thread) @show?))]
     (fn []
       [Modal {:show @ready? :onHide #(dispatch [:state-show-thread false])}
        [ModalBody


Docstring typo.

Docstring typo.

--- src/clojure/parkour/fs.clj
+++ src/clojure/parkour/fs.clj
@@ -218,7 +218,7 @@
   [conf] (path (temp-root conf) (run-id)))

 (def ^:private cancel-doe-method?
-  "True iff the `Job` class has a static factory method."
+  "True iff the `FileSystem` class has a static factory method."
   (->> FileSystem reflect/type-reflect :members
        (some #(= 'cancelDeleteOnExit (:name %)))))


Bump version, make compatible with provided bukkit (the future tm)

--- resources/leiningen/new/bukkure/project.clj
+++ resources/leiningen/new/bukkure/project.clj
@@ -1,5 +1,8 @@
 (defproject {{name}} "0.1.0-SNAPSHOT"
   :description "A bukkure plugin to..."
   :dependencies [[org.clojure/clojure "1.7.0"]
-                 [bukkure "0.4.1-SNAPSHOT"]]
+                 [bukkure "0.4.2-SNAPSHOT"]]
+  :repositories [["spigot-repo" "https://hub.spigotmc.org/nexus/content/groups/public/"]]
+  :profiles {:provided
+             {:dependencies [[org.bukkit/bukkit "1.8.8-R0.1-SNAPSHOT"]]}}
   :java-source-paths ["javasrc"])


Better varargs test

Better varargs test

--- test/cljs/go_test.clj
+++ test/cljs/go_test.clj
@@ -119,7 +119,7 @@
           2 '(bar 1 2)
           "`bar`" '(baz)
           1 '(baz 1)
-          "[]interface{}{2}" '(baz 1 2)) ;; this should be a seq
+          "[]interface{}{2, 3}" '(baz 1 2 3)) ;; this should be a seq
     (test "New"
           "&js.Date{Millis: 0}" '(js/Date. 0))
     (test "Dot"


components.page: Fix vendor-prefixes.

components.page: Fix vendor-prefixes.

--- src-cljs/pepa/components/page.cljs
+++ src-cljs/pepa/components/page.cljs
@@ -7,10 +7,10 @@

 (defn ^:private rotate [deg]
   (let [t (str "rotate(" deg "deg)")]
-    #js {:-webkit-transform t
-         :-moz-transform t
-         :-o-transform t
-         :-ms-transform t
+    #js {:WebkitTransform t
+         :MozTransform t
+         :OTransform t
+         :MsTransform t
          :transform t}))

 (defn ^:private page-image [page owner {:keys [size]}]
@@ -20,7 +20,7 @@
                  :style (rotate (:rotation page))})))

 (defn ^:private rotate-clicked [page rotation e]
-  (println "rotating" page "by" rotation "degrees")
+  (println "rotating" page "to" rotation "degrees")
   (api/rotate-page! page rotation)
   (doto e
     (.preventDefault)


refactoring to reduce duplication

refactoring to reduce duplication

--- src/rodeo/core.clj
+++ src/rodeo/core.clj
@@ -41,18 +41,24 @@
           url (str geocode-base-url api-key)]
       (geocodio-post url addr-json))))

+(defn- handle-single-with-env [base-url address]
+    (if-let [env-api-key (get-env-variable)]
+      (geocodio-get (str base-url env-api-key) address)
+      (throw (Exception. env-exception-text))))
+
+(defn- handle-single-with-key [base-url address api-key]
+  (let [url (str base-url api-key)]
+    (geocodio-get url address)))
+
 (defn single
   "Takes a single address string and an optional api key and
   makes a request to Geocodio. Returns
   a Clojure map of results"
   ([address]
-    (if-let [env-api-key (get-env-variable)]
-      (geocodio-get (str geocode-base-url env-api-key) address)
-      (throw (Exception. env-exception-text))))
+    (handle-single-with-env geocode-base-url address))

   ([address api-key]
-    (let [url (str geocode-base-url api-key)]
-      (geocodio-get url address))))
+    (handle-single-with-key geocode-base-url address api-key)))

 (defn components
   "Takes a single address string and an optional
@@ -60,10 +66,7 @@
   of that address (street, city, etc as a
   Clojure map"
   ([address]
-    (if-let [env-api-key (get-env-variable)]
-      (geocodio-get (str parse-base-url env-api-key) address)
-      (throw (Exception. env-exception-text))))
+    (handle-single-with-env parse-base-url address))

   ([address api-key]
-   (let [url (str parse-base-url api-key)]
-     (geocodio-get url address))))
+    (handle-single-with-key parse-base-url address api-key)))


Authorizer depends on authenticator

Authorizer depends on authenticator

--- src/cylon/authorization.clj
+++ src/cylon/authorization.clj
@@ -3,7 +3,9 @@
 (ns cylon.authorization
   (:require
    [schema.core :as s]
-   [cylon.restricted :as restricted]))
+   [cylon.restricted :as restricted]
+   [cylon.authentication :refer (authenticate)]
+   [clojure.tools.logging :refer :all]))

 ;; Now we can define authorization for Ring handlers (and other
 ;; functions). In Cylon, it is handlers that are restricted, rather than
@@ -23,14 +25,31 @@
   ;; requirement
   (authorized? [_ req requirement]))

+(extend-protocol Authorizer
+  nil
+  (authorized? [_ req requirement]
+    (warnf "Authorizer is nil, so failing authorization check")
+    false))
+
+;; Note: this implementation will cause the authenticator to be called twice if calling code wraps an invoke call with a restricted/authorized? check
+
 (defrecord RestrictedHandler [f authorizer requirement rejectfn]
   restricted/Restricted
   (restricted/authorized? [this req]
-    (authorized? authorizer req requirement))
+    (authorized?
+     authorizer
+     (if-let [authenticator (:authenticator authorizer)]
+       (merge req (authenticate authenticator req))
+       req)
+     requirement))

   clojure.lang.IFn
   (invoke [this req]
-    (if (restricted/authorized? this req)
+    (if (restricted/authorized?
+         this
+         (if-let [authenticator (:authenticator authorizer)]
+           (merge req (authenticate authenticator req))
+           req))
       (f req)
       ;; If you don't want this default, call authorized? first
       (rejectfn req))))


Negative test for the function start-server

--- test/zg/core_test.clj
+++ test/zg/core_test.clj
@@ -122,3 +122,13 @@
             (is (= app (start-server "65534")))
             (is (= app (start-server "65535"))))))

+(deftest test-start-server-wrong-port-number
+    (testing "zg.core/start-server"
+        ; use mock instead of jetty/run-jetty
+        (with-redefs [jetty/run-jetty (fn [app port] port)]
+            (is (= {:port -1}      (start-server "-1")))
+            (is (= {:port 0}       (start-server "0")))
+            (is (= {:port 65536}   (start-server "65536")))
+            (is (= {:port 65537}   (start-server "65537")))
+            (is (= {:port 1000000} (start-server "1000000"))))))
+


add pre check to make sure you pass an existing unit

--- src/tick/core.cljc
+++ src/tick/core.cljc
@@ -613,8 +613,8 @@
       [k (.get x tu)])))

 (defn truncate [x u]
-  (when-let [u (get unit-map u)]
-    (.truncatedTo ^Instant x u)))
+  {:pre [(contains? unit-map u)]}
+  (.truncatedTo ^Instant x (get unit-map u)))

 ;; Durations & Periods


Modify email content to include an entry's abstract if it is present

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -313,7 +313,8 @@
         avatar-url (user-avatar/fix-avatar-url config/filestack-api-key (:avatar-url publisher))
         headline (post-headline entry)
         vid (:video-id entry)
-        cleaned-body (text/truncated-body (:body entry))
+        cleaned-body (or (:abstract entry)
+                         (text/truncated-body (:body entry)))
         has-body (seq cleaned-body)]
     [:table
       {:cellpadding "0"
@@ -370,7 +371,8 @@
   (let [publisher (:publisher entry)
         avatar-url (user-avatar/fix-avatar-url config/filestack-api-key (:avatar-url publisher))
         vid (:video-id entry)
-        cleaned-body (text/truncated-body (:body entry))
+        cleaned-body (or (:abstract entry)
+                         (text/truncated-body (:body entry)))
         has-body (seq cleaned-body)
         published-date (time-format/unparse date-format-no-dot (time-format/parse iso-format (:published-at entry)))
         superuser-token (auth/user-token {:user-id (:user-id user)} config/auth-server-url config/passphrase "Email")]
@@ -1184,4 +1186,4 @@

   (def reminder-alert (json/decode (slurp "./opt/samples/reminders/alert.json")))
   (spit "./hiccup.html" (content/reminder-alert-html reminder-alert))
-  )+  )


Remove stray println.

Remove stray println.

--- src/onyx/test_helper.clj
+++ src/onyx/test_helper.clj
@@ -44,7 +44,6 @@
   is subject to change as nodes come online and go offline."
   [test-env job]
   (let [peers-per-task (job->min-peers-per-task job)
-        _ (println "peers " peers-per-task)
         required-peers (reduce + (map :min-peers peers-per-task))]
     (when (< (:n-peers test-env) required-peers)
       (throw (ex-info (format "test-env requires at least %s peers to start the job.


added gather operation

added gather operation

--- src/ophion/aggregate.clj
+++ src/ophion/aggregate.clj
@@ -21,12 +21,8 @@
   ([field]
    (let [path (dollar field)]
      [{:$project {:_id false}}
-      ;; {:$group {:_id path :dedup {:$addToSet "$$ROOT"}}}
-      ;; {:$unwind "$dedup"}
       {:$group {:_id {field path "_history" "$_history"} :dedup {:$first "$$ROOT"}}}
       {:$replaceRoot {:newRoot "$dedup"}}])))
-
-    ;; {:$group {:_id dollar (keyword field) {:$first dollar} :_history {:$addToSet "$_history"}}}

 (defn where
   [where]
@@ -61,14 +57,12 @@
 (defn from-vertex
   ([label] (from-vertex label {}))
   ([label where]
-   [;; {:$group {:_id "$from" :to {:$first "$from"} :_history {:$addToSet "$_history"}}}
-    {:$lookup
+   [{:$lookup
      {:from label
       :localField "from"
       :foreignField "gid"
       :as "vertex"}}
     {:$unwind "$vertex"}
-    ;; {:$unwind "$_history"}
     {:$match where}
     {:$addFields {"vertex._history" "$_history"}}
     {:$replaceRoot {:newRoot "$vertex"}}]))
@@ -76,14 +70,12 @@
 (defn to-vertex
   ([label] (to-vertex label {}))
   ([label where]
-   [;; {:$group {:_id "$to" :to {:$first "$to"} :_history {:$addToSet "$_history"}}}
-    {:$lookup
+   [{:$lookup
      {:from label
       :localField "to"
       :foreignField "gid"
       :as "vertex"}}
     {:$unwind "$vertex"}
-    ;; {:$unwind "$_history"}
     {:$match where}
     {:$addFields {"vertex._history" "$_history"}}
     {:$replaceRoot {:newRoot "$vertex"}}]))
@@ -195,7 +187,7 @@
   [direction]
   (if (= "desc" (name direction)) -1 1))

-(defn sortBy
+(defn psort
   [field direction]
   (let [order (sort-order direction)]
     [{:$sort {(name field) order}}]))
@@ -249,6 +241,11 @@
         "else" "$$PRUNE"}}}
      {:$replaceRoot {:newRoot "$_root"}}]))

+(defn gather
+  [query-map]
+  (let [queries (into {} (map (fn [[k query]] [k (translate query)]) query-map))]
+    [{:$facet queries}]))
+
 (def steps
   {:fromEdge from-edge
    :toEdge to-edge
@@ -269,7 +266,8 @@
    :order order
    :offset offset
    :count qount
-   :sort sortBy
+   :sort psort
+   :gather gather
    :groupCount group-count})

 (defn apply-step
@@ -353,11 +351,14 @@
 (defn ingest-labels-from-path!
   [graph path]
   (doseq [file (kafka/dir->files path)]
-    (let [filename (.getName file)
-          element (string/lower-case (kafka/path->label filename))
-          lines (line-seq (io/reader file))
-          parsed (map #(json/parse-string % keyword) lines)]
-      (ingest-label-collections! graph element parsed filename))))
+    (try
+      (let [filename (.getName file)
+            element (string/lower-case (kafka/path->label filename))
+            lines (line-seq (io/reader file))
+            parsed (map #(json/parse-string % keyword) lines)]
+        (ingest-label-collections! graph element parsed filename))
+      (catch Exception e
+        (log/info "file failed to parse: " (.getName file))))))

 (def parse-args
   [["-c" "--config CONFIG" "path to config file"]


Fix bug introduced in commit dd8b59d with java.util.Formatter argument exception.

--- src/overtone/sc/node.clj
+++ src/overtone/sc/node.clj
@@ -227,7 +227,7 @@
   (to-synth-id [_] id))

 (defmethod print-method SynthGroup [s-group w]
-  (.write w (format "#<synth-node[%s]: %s %d>" (:group s-group) (:id s-group))))
+  (.write w (format "#<synth-group[%s]: %s %d>" (name @(:status s-group)) (:group s-group) (:id s-group))))

 (defn group
   "Create a new synth group as a child of the target group. By default


introduce silent flag to defcomponentrecord

--- src/ow/starbuck/core.clj
+++ src/ow/starbuck/core.clj
@@ -29,8 +29,9 @@
       (warn "ERROR in component:" (pr-str e))
       (merge req {:error e}))))

-(defmacro defcomponentrecord [name]
-  (let [stopkw (keyword (str *ns*) "stop")]
+(defmacro defcomponentrecord [name & {:keys [silent]}]
+  (let [stopkw (keyword (str *ns*) "stop")
+        fres (gensym "fres-")]
     `(defrecord ~name [~'processfn ~'ch-in ~'ch-out     ;; constructor-initialized fields
                        ]                                ;; start/stop-initialized fields

@@ -41,12 +42,13 @@
          (go-loop [req# (<! ~'ch-in)]
            (if-not (= req# ~stopkw)
              (do (debug "got request")
-                 (let [res# (safe-process this# ~'processfn req#)]
-                   (debug "sending response(s)")
-                   (cond
-                     (nil? res#)        nil
-                     (sequential? res#) (dorun (map #(put! ~'ch-out %) res#))
-                     true               (put! ~'ch-out res#)))
+                 (let [~fres (future (safe-process this# ~'processfn req#))]
+                   ~@(when (not silent)
+                       `[(debug "sending response(s)")
+                         (cond
+                           (nil? @~fres)        nil
+                           (sequential? @~fres) (dorun (map #(put! ~'ch-out %) @~fres))
+                           true                 (put! ~'ch-out @~fres))]))
                  (recur (<! ~'ch-in)))
              (info "stopped.")))
          (info "started.")


make shift-tab dedent

make shift-tab dedent

--- src/parinfer/editor.cljs
+++ src/parinfer/editor.cljs
@@ -190,6 +190,8 @@
 (def editor-opts
   {:mode "clojure-parinfer"
    :extraKeys {:Tab on-tab}})
+
+(aset js/CodeMirror "keyMap" "default" "Shift-Tab" "indentLess")

 (defn on-state-change
   "Called everytime the state changes to sync the code editor."


Use Cheshire json to prep data for mongo

--- src/polismath/poller.clj
+++ src/polismath/poller.clj
@@ -102,13 +102,20 @@
             (println "zid: " zid)
             (println "time: " (System/currentTimeMillis))
             (println "\n\n")
-            (println (generate-string (prep-for-uploading (@conversations zid))))
-            (println
-              (mongo-upsert-results
-                zid
-                lastVoteTimestamp
-                (generate-string
-                  (prep-for-uploading
-                    (@conversations zid)))))
+            (let [
+              ; For now, convert to json and back (using cheshire to cast NDArray and Vector)
+              ; This is a quick-n-dirty workaround for Monger's missing supoort for these types.
+              json (generate-string (prep-for-uploading (@conversations zid)))
+              obj (parse-string json)]
+
+              (println json)
+              ; (debug-repl)
+              (println
+                (mongo-upsert-results
+                  zid
+                  lastVoteTimestamp
+                  obj)))
+
         (swap! last-timestamp (fn [_] (:created (last new-votes))))
+
       ))))))


Use yield instead of (timeout 0)

Use yield instead of (timeout 0)

(timeout 0) resolves to using js/setTimeout which will actually take 4+
msecs in browsers. This is an eternity. The nextTick approach was
proposed by Patrick O'Brien and implemented here.

Docs on nextTick from Closure library:

Fires the provided callbacks as soon as possible after the current JS
execution context. setTimeout(…, 0) takes at least 4ms when called from
within another setTimeout(…, 0) for legacy reasons.

This will not schedule the callback as a microtask (i.e. a task that can
preempt user input or networking callbacks). It is meant to emulate what
setTimeout(_, 0) would do if it were not throttled. If you desire
microtask behavior, use goog.Promise instead.

--- src/re_frame/router.cljs
+++ src/re_frame/router.cljs
@@ -4,7 +4,8 @@
   (:require [reagent.core        :refer [flush]]
             [re-frame.handlers   :refer [handle]]
             [re-frame.utils      :refer [warn error]]
-            [cljs.core.async     :refer [chan put! <! timeout]]))
+            [cljs.core.async     :refer [chan put! <! timeout close!]]
+            [goog.async.nextTick]))

 ;; -- The Event Conveyor Belt  --------------------------------------------------------------------
 ;;
@@ -25,7 +26,7 @@
 ;; In a perpetual loop, read events from "event-chan", and call the right handler.
 ;;
 ;; Because handlers occupy the CPU, before each event is handled, hand
-;; back control to the browser, via a (<! (timeout 0)) call.
+;; back control to the browser, via a (<! (yield)) call.
 ;;
 ;; In some cases, we need to pause for an entire animationFrame, to ensure that
 ;; the DOM is fully flushed, before then calling a handler known to hog the CPU
@@ -34,13 +35,22 @@
 ;;   (dispatch ^:flush-dom  [:event-id other params])
 ;;

+(defn yield
+  "Yields control to the browser. Faster than (timeout 0).
+  See http://dev.clojure.org/jira/browse/ASYNC-137"
+  []
+  (let [ch (chan)]
+    (goog.async.nextTick #(close! ch))
+    ch))
+
+
 (defn router-loop
   []
   (go-loop []
            (let [event-v  (<! event-chan)                   ;; wait for an event
                  _        (if (:flush-dom (meta event-v))   ;; check the event for metadata
                             (do (flush) (<! (timeout 20)))  ;; wait just over one annimation frame (16ms), to rensure all pending GUI work is flushed to the DOM.
-                            (<! (timeout 0)))]              ;; just in case we are handling one dispatch after an other, give the browser back control to do its stuff
+                            (<! (yield)))]              ;; just in case we are handling one dispatch after an other, give the browser back control to do its stuff
              (try
                (handle event-v)


:eval-fn -> :eval :load-fn -> :load

:eval-fn -> :eval
:load-fn -> :load

--- src/main/cljs/cljs/js.cljs
+++ src/main/cljs/cljs/js.cljs
@@ -132,8 +132,8 @@
     (require
       {:*compiler*     (env/default-compiler-env)
        :*data-readers* tags/*cljs-data-readers*
-       :*load-fn*      (or (:load-fn opts) *load-fn*)
-       :*eval-fn*      (or (:eval-fn opts) *eval-fn*)}
+       :*load-fn*      (or (:load opts) *load-fn*)
+       :*eval-fn*      (or (:eval opts) *eval-fn*)}
       name opts cb))
   ([bound-vars name opts cb]
    (require bound-vars name nil opts cb))
@@ -385,8 +385,8 @@
    opts (map)
      compilation options.

-   :eval-fn - the eval function to invoke, see *eval-fn*
-   :load-fn - library resolution function, see *load-fn*
+   :eval - the eval function to invoke, see *eval-fn*
+   :load - library resolution function, see *load-fn*

    cb (function)
      callback, will be invoked with a map. If successful the map will contain
@@ -403,8 +403,8 @@
    (analyze*
      {:*compiler*     state
       :*data-readers* tags/*cljs-data-readers*
-      :*load-fn*      (or (:load-fn opts) *load-fn*)
-      :*eval-fn*      (or (:eval-fn opts) *eval-fn*)}
+      :*load-fn*      (or (:load opts) *load-fn*)
+      :*eval-fn*      (or (:eval opts) *eval-fn*)}
      source name opts cb)))

 ;; -----------------------------------------------------------------------------
@@ -449,8 +449,8 @@
    opts (map)
      compilation options.

-     :eval-fn - the eval function to invoke, see *eval-fn*
-     :load-fn - library resolution function, see *load-fn*
+     :eval - the eval function to invoke, see *eval-fn*
+     :load - library resolution function, see *load-fn*

    cb (function)
      callback, will be invoked with the evalution result."
@@ -462,8 +462,8 @@
       :*cljs-ns*      'cljs.user
       :*ns*           (create-ns 'cljs.user)
       :*data-readers* tags/*cljs-data-readers*
-      :*load-fn*      (or (:load-fn opts) *load-fn*)
-      :*eval-fn*      (or (:eval-fn opts) *eval-fn*)}
+      :*load-fn*      (or (:load opts) *load-fn*)
+      :*eval-fn*      (or (:eval opts) *eval-fn*)}
      form opts cb)))

 ;; -----------------------------------------------------------------------------
@@ -533,7 +533,7 @@
    opts (map)
      compilation options.

-     :load-fn    - library resolution function, see *load-fn*
+     :load       - library resolution function, see *load-fn*
      :source-map - set to true to generate inline source map information

    cb (function)
@@ -553,8 +553,8 @@
       :*data-readers* tags/*cljs-data-readers*
       :*analyze-deps* (or (:analyze-deps opts) true)
       :*load-macros*  (or (:load-macros opts) true)
-      :*load-fn*      (or (:load-fn opts) *load-fn*)
-      :*eval-fn*      (or (:eval-fn opts) *eval-fn*)
+      :*load-fn*      (or (:load opts) *load-fn*)
+      :*eval-fn*      (or (:eval opts) *eval-fn*)
       :*sm-data*      (when (:source-map opts) (sm-data))}
      source name opts cb)))

@@ -640,8 +640,8 @@
   opts (map)
     compilation options.

-    :eval-fn    - eval function to invoke, see *eval-fn*
-    :load-fn    - library resolution function, see *load-fn*
+    :eval       - eval function to invoke, see *eval-fn*
+    :load       - library resolution function, see *load-fn*
     :source-map - set to true to generate inline source map information

   cb (function)
@@ -660,6 +660,6 @@
       :*data-readers* tags/*cljs-data-readers*
       :*analyze-deps* (or (:analyze-deps opts) true)
       :*load-macros*  (or (:load-macros opts) true)
-      :*load-fn*      (or (:load-fn opts) *load-fn*)
-      :*eval-fn*      (or (:eval-fn opts) *eval-fn*)}
+      :*load-fn*      (or (:load opts) *load-fn*)
+      :*eval-fn*      (or (:eval opts) *eval-fn*)}
      source name opts cb)))


throw an exception if the task does not have exactly 2 arguments

--- src/matross/tasks/core.clj
+++ src/matross/tasks/core.clj
@@ -20,6 +20,8 @@

   (let [type (first fdecl)
         param_count (count (some #(if (vector? %1) %1) fdecl))]
+    (if (not (= param_count 2))
+      (throw (IllegalArgumentException. "Tasks must be a function of two arguments, an IRun for the target machine, and the current configuration.")))
     `(do
        (defn ~@fdecl)


stop importing things we don't need

stop importing things we don't need

--- src/metabase/api/tiles.clj
+++ src/metabase/api/tiles.clj
@@ -1,7 +1,5 @@
 (ns metabase.api.tiles
   (:require [clojure.core.match :refer [match]]
-            [clojure.data.json :as json]
-            [clojure.tools.logging :as log]
             [compojure.core :refer [GET]]
             [metabase.api.common :refer :all]
             [metabase.db :refer :all]


Fix H2 week bucketing :scream_cat: #1709

--- src/metabase/driver/h2.clj
+++ src/metabase/driver/h2.clj
@@ -148,7 +148,7 @@
     :day-of-week     (k/sqlfn :DAY_OF_WEEK expr)
     :day-of-month    (k/sqlfn :DAY_OF_MONTH expr)
     :day-of-year     (k/sqlfn :DAY_OF_YEAR expr)
-    :week            (trunc-with-format "yyyyww" expr) ; ww = week of year
+    :week            (trunc-with-format "YYYYww" expr) ; Y = week year; w = week in year
     :week-of-year    (kx/week expr)
     :month           (trunc-with-format "yyyyMM" expr)
     :month-of-year   (kx/month expr)


Report project version as default response

--- src/nhl_score_api/core.clj
+++ src/nhl_score_api/core.clj
@@ -4,20 +4,22 @@
             [org.httpkit.server :as server]
             [clojure.data.json :as json]))

+(def version (System/getProperty "nhl-score-api.version"))
+
 (declare app)

 (defn -main [& args]
   (let [ip (get (System/getenv) "OPENSHIFT_CLOJURE_HTTP_IP" "0.0.0.0")
         port (Integer/parseInt (get (System/getenv) "OPENSHIFT_CLOJURE_HTTP_PORT" "8080"))]
-    (println "Starting server, listening on" (str ip ":" port))
+    (println "Starting server version" (str version ",") "listening on" (str ip ":" port))
     (server/run-server app {:ip ip :port port})))

-(defn get-response [request-path]
+(defn- get-response [request-path]
   (case request-path
     "/api/scores/latest"
     (api/fetch-latest-scores)

-    {}))
+    {:version version}))

 (defn app [req]
   (println "Received request" req)


Added check in data collector to ensure a tracking term is present.

--- data_collection/profanity-power-index/src/profanity_power_index/core.clj
+++ data_collection/profanity-power-index/src/profanity_power_index/core.clj
@@ -97,7 +97,7 @@
     ;; Send to Elasticsearch.
     [:sink :to-out
       (fn [t]
-          (esd/put
+        (esd/put
             es-conn
             ;; Name of the index.
             elastic-index
@@ -134,6 +134,11 @@
                         (:elasticsearch-url env "http://localhost:9200")
                         (:elasticsearch-index env "profanity_power_index"))))]

+    ;; Validate that there's something to track.
+    (when (nil? (get-in options [:options :track]))
+      (println "Requires at least one tracking term.")
+      (System/exit 1))
+
     ;; Read from the dechunker chan in a go loop and drop into turbine.
     (go-loop []
       (let [tweet-chunk (<! transfer-chan)]


CMR-6537-4 updated subscription utils to search json raw

--- system-int-test/src/cmr/system_int_test/utils/subscription_util.clj
+++ system-int-test/src/cmr/system_int_test/utils/subscription_util.clj
@@ -120,6 +120,18 @@
                                 {:raw? true
                                  :http-options {:accept :json}})))))

+(defn search-json-raw
+  "Searches for subscription using the given parameters without formatting."
+  ([]
+   (search-json-raw {}))
+  ([params]
+   (search-json-raw params {}))
+  ([params options]
+   (:body (transmit-search/search-for-subscriptions
+           (s/context) params (merge options
+                                     {:raw? true
+                                      :http-options {:accept :json}})))))
+
 (defn subscription-result->xml-result
   [subscription]
   (let [base-url (format "%s://%s:%s/concepts"