refining figwheel repl controls

refining figwheel repl controls

--- sidecar/src/figwheel_sidecar/auto_builder.clj
+++ sidecar/src/figwheel_sidecar/auto_builder.clj
@@ -11,6 +11,7 @@
    [clojurescript-build.auto :as auto]
    [clojure.java.io :as io]
    [clojure.string :as string]
+   [clojure.set :refer [intersection]]
    [cljsbuild.util :as util]))

 (defn notify-cljs [command message]
@@ -75,80 +76,109 @@
   (let [f (io/file fpath)]
     (when-let [dir (.getParentFile f)] (.mkdirs dir))))

-(defn wrap-special-no-args [f]
+(defn namify [arg]
+  (if (seq? arg)
+    (when (= 'quote (first arg))
+      (str (second arg)))
+    (name arg)))
+
+(defn make-special-fn [f]
   (fn self
     ([a b c] (self a b c nil))
-    ([_ _ _ _] (f))))
+    ([_ _ [_ & args] _]
+     ;; are we only accepting string ids?
+     (f (keep namify args)))))

 (defn setup-control-fns [all-builds build-ids figwheel-server]
   (let [logfile-path (or (:server-logfile figwheel-server) "figwheel_server.log")
         _ (mkdirs logfile-path)
-        log-writer (io/writer logfile-path :append true)
-        autobuilder-atom     (atom nil)
-        focus-ids-atom  (atom build-ids)
-        build-once*     #(mapv (builder figwheel-server)
-                               (config/narrow-builds* all-builds @focus-ids-atom))
-        clean-build*    #(do
-                           (mapv cbuild/clean-build (map :build-options all-builds))
-                            (println "Deleting ClojureScript compilation target files."))
+        log-writer        (io/writer logfile-path :append true)
+        state-atom        (atom {:autobuilder nil
+                                 :focus-ids  build-ids})
+        validate-build-ids (let [bs (set (keep :id all-builds))]
+                             (fn [ids]
+                               (or (not-empty (intersection bs (set ids)))
+                                   (println "No such build id"))))
+        get-ids            (fn [ids]
+                             (or (and (empty? ids)
+                                      (:focus-ids @state-atom))
+                                 (validate-build-ids ids)))
+        builder-fn        (builder figwheel-server)
+        builder-running? #(:autobuilder @state-atom)
+        ;; we are going to take an optiona id here
+        build-once*     (fn [ids]
+                          (let [bs (set (get-ids ids))]
+                            (mapv builder-fn
+                                  (filter #(bs (:id %)) all-builds))))
+        clean-build*    (fn [_]
+                          (mapv cbuild/clean-build (map :build-options all-builds))
+                          (println "Deleting ClojureScript compilation target files."))
         run-autobuilder (fn [figwheel-server build-ids]
-                           (binding [*out* log-writer
-                                     *err* log-writer]
-                             (reset! focus-ids-atom build-ids)
-                             (build-once*)
-                             (if-not @autobuilder-atom
-                               (when-let [abuild (autobuild-ids
-                                                  { :all-builds all-builds
-                                                    :build-ids build-ids
-                                                    :figwheel-server figwheel-server })]
-                                 (reset! autobuilder-atom abuild)))))
-        stop-autobuild*  #(if @autobuilder-atom
-                            (do
-                              (auto/stop-autobuild! @autobuilder-atom)
-                              (reset! autobuilder-atom nil)
-                              (println "Stopped Figwheel autobuild"))
-                            (println "Autobuild not running."))
-        start-autobuild* #(if-not @autobuilder-atom
-                            (do
-                              (run-autobuilder figwheel-server build-ids)
-                              (println "Started Figwheel autobuilder see:" logfile-path ))
-                            (println "Autobuilder already running."))
-        reset-autobuild* #(do
-                            (stop-autobuild*)
-                            (clean-build*)
-                            (start-autobuild*))]
+                          (binding [*out* log-writer
+                                    *err* log-writer]
+                            (when-not (builder-running?)
+                              (build-once* build-ids)
+                              (when-let [abuild (autobuild-ids
+                                                 { :all-builds all-builds
+                                                   :build-ids build-ids
+                                                  :figwheel-server figwheel-server })]
+                                (reset! state-atom { :autobuilder abuild
+                                                     :focus-ids build-ids})))))
+        stop-autobuild*  (fn [_]
+                           (if (builder-running?)
+                             (do
+                               (auto/stop-autobuild! (:autobuilder state-atom))
+                               (swap! state-atom assoc :autobuilder nil)
+                               (println "Stopped Figwheel autobuild"))
+                             (println "Autobuild not running.")))
+        start-autobuild* (fn [ids]
+                           (if-not (builder-running?)
+                             (when-let [build-ids' (not-empty (get-ids ids))]
+                               (run-autobuilder figwheel-server build-ids')
+                               (println "Started Figwheel autobuilder see:" logfile-path ))
+                             (println "Autobuilder already running.")))
+        switch-to-build*     (fn [ids]
+                               (when-not (empty? ids)
+                                 (stop-autobuild* [])
+                                 (start-autobuild* ids)))
+        reset-autobuild* (fn [_]
+                           (stop-autobuild* [])
+                           (clean-build* [])
+                           (start-autobuild* (:focus-ids @state-atom)))]
     ;; add these functions to the browser-callbacks? YES
     { 'stop-autobuild  stop-autobuild*
       'start-autobuild start-autobuild*
+      'switch-to-build switch-to-build*
       'reset-autobuild reset-autobuild*
       'build-once      build-once*
       'clean-build     clean-build*}))

 (defn repl-function-docs  []
   "Figwheel Controls:
-          (stop-autobuild)  ;; stops Figwheel autobuilder
-          (start-autobuild) ;; starts Figwheel autobuilder
-          (reset-autobuild) ;; stops, cleans, and starts autobuilder
-          (build-once)      ;; builds source once time
-          (clean-build)     ;; deletes compiled cljs target files
+          (stop-autobuild)           ;; stops Figwheel autobuilder
+          (start-autobuild [id ...]) ;; starts autobuilder focused on option ids
+          (switch-to-build id ...)   ;; switches  autobuilder
+          (reset-autobuild)          ;; stops, cleans, and starts autobuilder
+          (build-once [id ...])      ;; builds source once time
+          (clean-build)              ;; deletes compiled cljs target files
     Docs: (doc function-name-here)
     Exit: Control+C or :cljs/quit
  Results: Stored in vars *1, *2, *3")

 (defn autobuild-repl [{:keys [all-builds build-ids figwheel-server] :as opts}]
   (let [all-builds'  (mapv auto/prep-build all-builds)
-        builds'      (config/narrow-builds* all-builds' build-ids)
+        repl-build   (first (config/narrow-builds* all-builds' build-ids))
+        build-ids    (or (not-empty build-ids) [(:id repl-build)]) ;; give a default build-id
         control-fns  (setup-control-fns all-builds' build-ids figwheel-server)
-        special-fns  (into {} (map (fn [[k v]] [k (wrap-special-no-args v)]) control-fns))]
-
-    ((get control-fns 'start-autobuild))
+        special-fns  (into {} (map (fn [[k v]] [k (make-special-fn v)]) control-fns))]
+    ((get control-fns 'start-autobuild) build-ids)
     (newline)
-    (if (:id (first builds'))
-      (println "Launching ClojureScript REPL for build:" (:id (first builds')))
-      (println "Launching ClojureScript REPL"))
+    (print "Launching ClojureScript REPL")
+    (when-let [id (:id repl-build)] (println " for build:" id))
     (println (repl-function-docs))
     (println "Prompt will show when figwheel connects to your application")
-    (fig-repl/repl (first builds') figwheel-server {:special-fns special-fns})))
+    ;; it would be cool to switch the repl's build as well is this possible?
+    (fig-repl/repl repl-build figwheel-server {:special-fns special-fns})))

 (defn autobuild [src-dirs build-options figwheel-options]
   (autobuild* {:builds [{:source-paths src-dirs


Make use of consume macro

Make use of consume macro

--- src/io/aviso/rook/dispatcher.clj
+++ src/io/aviso/rook/dispatcher.clj
@@ -39,7 +39,7 @@
             [clojure.string :as string]
             [clojure.set :as set]
             [io.aviso.tracker :as t]
-            [io.aviso.rook.internals :as internals]
+            [io.aviso.rook.internals :as internals :refer [consume]]
             [clojure.string :as str]
             [clojure.tools.logging :as l]
             [io.aviso.rook.utils :as utils]))
@@ -142,32 +142,32 @@
   without introducing a separate route."
   [dispatch-table]
   (letfn [(unnest-entry [default-middleware [x :as entry]]
-            (cond
-              (keyword? x)
-              (let [[method pathvec verb-fn middleware & nested-table] entry]
-                (if nested-table
-                  (let [mw (or middleware default-middleware)]
-                    (into [[method pathvec verb-fn mw]]
-                      (unnest-table pathvec mw nested-table)))
-                  (cond-> [entry]
-                    (nil? middleware) (assoc-in [0 3] default-middleware))))
-
-              (vector? x)
-              (let [[context-pathvec & maybe-middleware+entries] entry
-                    middleware (if-not (vector?
-                                         (first maybe-middleware+entries))
-                                 (first maybe-middleware+entries))
-                    entries (if middleware
-                              (next maybe-middleware+entries)
-                              maybe-middleware+entries)]
-                (unnest-table context-pathvec middleware entries))))
+                        (cond
+                          (keyword? x)
+                          (let [[method pathvec verb-fn middleware & nested-table] entry]
+                            (if nested-table
+                              (let [mw (or middleware default-middleware)]
+                                (into [[method pathvec verb-fn mw]]
+                                      (unnest-table pathvec mw nested-table)))
+                              (cond-> [entry]
+                                      (nil? middleware) (assoc-in [0 3] default-middleware))))
+
+                          (vector? x)
+                          (let [[context-pathvec & maybe-middleware+entries] entry
+                                middleware (if-not (vector?
+                                                     (first maybe-middleware+entries))
+                                             (first maybe-middleware+entries))
+                                entries (if middleware
+                                          (next maybe-middleware+entries)
+                                          maybe-middleware+entries)]
+                            (unnest-table context-pathvec middleware entries))))
           (unnest-table [context-pathvec default-middleware entries]
-            (mapv (fn [[_ pathvec :as unnested-entry]]
-                    (assoc unnested-entry 1
-                           (with-meta (into context-pathvec pathvec)
-                             {:context (into context-pathvec
-                                         (:context (meta pathvec)))})))
-              (mapcat (partial unnest-entry default-middleware) entries)))]
+                        (mapv (fn [[_ pathvec :as unnested-entry]]
+                                (assoc unnested-entry 1
+                                                      (with-meta (into context-pathvec pathvec)
+                                                                 {:context (into context-pathvec
+                                                                                (:context (meta pathvec)))})))
+                              (mapcat (partial unnest-entry default-middleware) entries)))]
     (unnest-table [] nil dispatch-table)))

 (defn- keywords->symbols
@@ -473,36 +473,36 @@
   (let [arg-symbol (symbol-for-argument arg)
         arg-meta (meta arg-symbol)]
     (t/track #(format "Identifying argument resolver for `%s'." arg-symbol)
-      (cond
-        ;; route param resolution takes precedence
-        (contains? route-params arg)
-        (make-route-param-resolver arg-symbol)
-
-        ;; explicit ::rook/resolver metadata takes precedence for non-route params
-        (contains? arg-meta :io.aviso.rook/resolver)
-        (find-resolver arg-resolvers arg-symbol (:io.aviso.rook/resolver arg-meta))
-
-        :else
-        (if-let [resolver-tag (find-argument-resolver-tag
-                                arg-resolvers arg-symbol arg-meta)]
-          ;; explicit tags attached to the arg symbol itself come next
-          (find-resolver arg-resolvers arg-symbol resolver-tag)
-
-          ;; non-route-param name-based resolution is implicit and
-          ;; should not override explicit tags, so this check comes
-          ;; last; NB. the value at arg-symbol might be a keyword
-          ;; identifying a resolver factory, so we still need to call
-          ;; find-resolver
-          (if (contains? arg-resolvers arg-symbol)
-            (find-resolver arg-resolvers arg-symbol (get arg-resolvers arg-symbol))
-
-            ;; only static resolution is supported
-            (throw (ex-info
-                     (format "Unable to identify argument resolver for symbol `%s'." arg-symbol)
-                     {:symbol        arg-symbol
-                      :symbol-meta   arg-meta
-                      :route-params  route-params
-                      :arg-resolvers arg-resolvers}))))))))
+             (cond
+               ;; route param resolution takes precedence
+               (contains? route-params arg)
+               (make-route-param-resolver arg-symbol)
+
+               ;; explicit ::rook/resolver metadata takes precedence for non-route params
+               (contains? arg-meta :io.aviso.rook/resolver)
+               (find-resolver arg-resolvers arg-symbol (:io.aviso.rook/resolver arg-meta))
+
+               :else
+               (if-let [resolver-tag (find-argument-resolver-tag
+                                       arg-resolvers arg-symbol arg-meta)]
+                 ;; explicit tags attached to the arg symbol itself come next
+                 (find-resolver arg-resolvers arg-symbol resolver-tag)
+
+                 ;; non-route-param name-based resolution is implicit and
+                 ;; should not override explicit tags, so this check comes
+                 ;; last; NB. the value at arg-symbol might be a keyword
+                 ;; identifying a resolver factory, so we still need to call
+                 ;; find-resolver
+                 (if (contains? arg-resolvers arg-symbol)
+                   (find-resolver arg-resolvers arg-symbol (get arg-resolvers arg-symbol))
+
+                   ;; only static resolution is supported
+                   (throw (ex-info
+                            (format "Unable to identify argument resolver for symbol `%s'." arg-symbol)
+                            {:symbol        arg-symbol
+                             :symbol-meta   arg-meta
+                             :route-params  route-params
+                             :arg-resolvers arg-resolvers}))))))))

 (defn- create-arglist-resolver
   "Returns a function that is passed the Ring request and returns an array of argument values which
@@ -517,12 +517,12 @@

 (defn- add-dispatch-entries
   [dispatch-map method pathvec handler]
-  (let [pathvec'      (mapv #(if (variable? %) ::param %) pathvec)
+  (let [pathvec' (mapv #(if (variable? %) ::param %) pathvec)
         dispatch-path (conj pathvec' method)
-        route-params  (filterv variable? pathvec)]
+        route-params (filterv variable? pathvec)]
     (assoc-in dispatch-map dispatch-path
-      {:handler handler
-       :route-param-keys (mapv keyword route-params)})))
+              {:handler          handler
+               :route-param-keys (mapv keyword route-params)})))

 (defn- build-dispatch-map
   "Returns a dispatch-map for use with map-traversal-dispatcher."
@@ -531,49 +531,49 @@
   (reduce (fn [dispatch-map [[method pathvec] handler-key]]
             (t/track #(format "Compiling handler for `%s'."
                               (get-in handlers [handler-key :verb-fn-sym]))
-              (let [{:keys           [middleware-key route-params
-                                      verb-fn-sym arglist
-                                      metadata context]
-                     extra-resolvers :arg-resolvers}
-                    (get handlers handler-key)
-
-                    arglist-resolver (create-arglist-resolver
-                                       (if (:replace (meta extra-resolvers))
-                                         extra-resolvers
-                                         (merge
-                                           arg-resolvers
-                                           extra-resolvers))
-                                       (set route-params)
-                                       arglist)
-
-                    middleware (get middleware middleware-key)
-
-                    resource-handler-fn (eval verb-fn-sym)
-
-                    request-handler (fn [request]
-                                      (apply resource-handler-fn (arglist-resolver request)))
-
-
-                    request-handler (if (and async? (:sync metadata))
-                                      (internals/ring-handler->async-handler request-handler)
-                                      request-handler)
-
-                    middleware-applied (or (middleware request-handler metadata) request-handler)
-
-                    context-maintaining-handler (if context
-                                                  (fn [request]
-                                                    (-> request
-                                                        (update-in [:context] str context)
-                                                        middleware-applied))
-                                                  middleware-applied)
-
-                    logging-handler (fn [request]
-                                      (l/debugf "Matched %s to %s"
-                                                (utils/summarize-request request)
-                                                verb-fn-sym)
-                                      (context-maintaining-handler request))]
-
-                (add-dispatch-entries dispatch-map method pathvec logging-handler))))
+                     (let [{:keys           [middleware-key route-params
+                                             verb-fn-sym arglist
+                                             metadata context]
+                            extra-resolvers :arg-resolvers}
+                           (get handlers handler-key)
+
+                           arglist-resolver (create-arglist-resolver
+                                              (if (:replace (meta extra-resolvers))
+                                                extra-resolvers
+                                                (merge
+                                                  arg-resolvers
+                                                  extra-resolvers))
+                                              (set route-params)
+                                              arglist)
+
+                           middleware (get middleware middleware-key)
+
+                           resource-handler-fn (eval verb-fn-sym)
+
+                           request-handler (fn [request]
+                                             (apply resource-handler-fn (arglist-resolver request)))
+
+
+                           request-handler (if (and async? (:sync metadata))
+                                             (internals/ring-handler->async-handler request-handler)
+                                             request-handler)
+
+                           middleware-applied (or (middleware request-handler metadata) request-handler)
+
+                           context-maintaining-handler (if context
+                                                         (fn [request]
+                                                           (-> request
+                                                               (update-in [:context] str context)
+                                                               middleware-applied))
+                                                         middleware-applied)
+
+                           logging-handler (fn [request]
+                                             (l/debugf "Matched %s to %s"
+                                                       (utils/summarize-request request)
+                                                       verb-fn-sym)
+                                             (context-maintaining-handler request))]
+
+                       (add-dispatch-entries dispatch-map method pathvec logging-handler))))
           {}
           routes))

@@ -652,21 +652,21 @@
        (if-not (find-ns ns-sym)
          (require ns-sym))
        (catch Exception e
-              (throw (ex-info "failed to require ns in namespace-dispatch-table"
-                              {:context-pathvec context-pathvec
-                               :ns              ns-sym
-                               :middleware      middleware}
-                              e))))
+         (throw (ex-info "failed to require ns in namespace-dispatch-table"
+                         {:context-pathvec context-pathvec
+                          :ns              ns-sym
+                          :middleware      middleware}
+                         e))))
      [(->> ns-sym
            ns-publics
            (keep (fn [[k v]]
                    (if (ifn? @v)
                      (t/track #(format "Building route mapping for `%s/%s'." ns-sym k)
-                       (if-let [route-spec (or (:route-spec (meta v))
-                                               (path-spec->route-spec
-                                                 (:path-spec (meta v)))
-                                               (get default-mappings k))]
-                         (conj route-spec (symbol (name ns-sym) (name k))))))))
+                              (if-let [route-spec (or (:route-spec (meta v))
+                                                      (path-spec->route-spec
+                                                        (:path-spec (meta v)))
+                                                      (get default-mappings k))]
+                                (conj route-spec (symbol (name ns-sym) (name k))))))))
            (list* context-pathvec middleware)
            vec)])))

@@ -675,31 +675,31 @@
   [outer-context-pathvec outer-middleware ns-specs]
   (mapcat (fn [[context-pathvec? ns-sym middleware? :as ns-spec]]
             (t/track (format "Parsing namespace specification `%s'." (pr-str ns-spec))
-              (let [context-pathvec (if (or (nil? context-pathvec?)
-                                            (vector? context-pathvec?))
-                                      (or context-pathvec? []))
-                    middleware (let [mw? (if context-pathvec
-                                           middleware?
-                                           ns-sym)]
-                                 (if-not (vector? mw?)
-                                   mw?))
-                    ns-sym (if context-pathvec
-                             ns-sym
-                             context-pathvec?)
-                    skip (reduce + 1
-                                 (map #(if % 1 0)
-                                      [context-pathvec middleware]))
-                    nested (drop skip ns-spec)]
-                (assert (symbol? ns-sym)
-                  (str "Malformed ns-spec: " (pr-str ns-sym)))
-                (concat
-                  [[(into outer-context-pathvec context-pathvec)
-                    ns-sym
-                    (or middleware outer-middleware)]]
-                  (canonicalize-ns-specs
-                    (into outer-context-pathvec context-pathvec)
-                    (or middleware outer-middleware)
-                    nested)))))
+                     (let [context-pathvec (if (or (nil? context-pathvec?)
+                                                   (vector? context-pathvec?))
+                                             (or context-pathvec? []))
+                           middleware (let [mw? (if context-pathvec
+                                                  middleware?
+                                                  ns-sym)]
+                                        (if-not (vector? mw?)
+                                          mw?))
+                           ns-sym (if context-pathvec
+                                    ns-sym
+                                    context-pathvec?)
+                           skip (reduce + 1
+                                        (map #(if % 1 0)
+                                             [context-pathvec middleware]))
+                           nested (drop skip ns-spec)]
+                       (assert (symbol? ns-sym)
+                               (str "Malformed ns-spec: " (pr-str ns-sym)))
+                       (concat
+                         [[(into outer-context-pathvec context-pathvec)
+                           ns-sym
+                           (or middleware outer-middleware)]]
+                         (canonicalize-ns-specs
+                           (into outer-context-pathvec context-pathvec)
+                           (or middleware outer-middleware)
+                           nested)))))
           ns-specs))

 (def ^:private default-opts
@@ -717,18 +717,20 @@
   entries such as

       [:get [\"api\" \"foo\"] 'example.foo/index ns-middleware]."
-  [options? & ns-specs]
-  (let [opts (merge default-opts (if (map? options?) options?))
-        {outer-context-pathvec :context-pathvec
-         default-middleware    :default-middleware} opts
-        ns-specs (canonicalize-ns-specs
-                   []
-                   default-middleware
-                   (if (map? options?)
-                     ns-specs
-                     (cons options? ns-specs)))]
-    [(reduce into [outer-context-pathvec default-middleware]
-             (map (fn [[context-pathvec ns-sym middleware]]
-                    (simple-namespace-dispatch-table
-                      context-pathvec ns-sym middleware))
-                  ns-specs))]))
+  {:arglists '([options ns-specs]
+               [ns-specs])}
+  [& arguments]
+  (consume arguments
+    [options map? :?
+     ns-specs :&]
+    (let [{outer-context-pathvec :context-pathvec
+           default-middleware    :default-middleware} (merge default-opts options)
+          ns-specs' (canonicalize-ns-specs
+                      []
+                      default-middleware
+                      ns-specs)]
+      [(reduce into [outer-context-pathvec default-middleware]
+               (map (fn [[context-pathvec ns-sym middleware]]
+                      (simple-namespace-dispatch-table
+                        context-pathvec ns-sym middleware))
+                    ns-specs'))])))


Fix bug in bootstrap namespace

Fix bug in bootstrap namespace

--- src/kixi/datastore/bootstrap.clj
+++ src/kixi/datastore/bootstrap.clj
@@ -13,9 +13,9 @@
         system (kixi.datastore.system/new-system config-profile)]
     (.addShutdownHook
      (Runtime/getRuntime)
-     (Thread. #(component/stop-system system))
+     (Thread. #(component/stop-system system)))
      (reset! application/system nil)
-     (reset! application/profile nil))
+     (reset! application/profile nil)
     (try
       (component/start-system system)
       (reset! application/system system)


remove with

remove with

--- tutorial/component_attributes.clj
+++ tutorial/component_attributes.clj
@@ -6,30 +6,32 @@
 ;   the terms of this license.
 ;   You must not remove this notice, or any other, from this software.

-(require '[datomic.client.api :as d])
+(require '[datomic.client.api :as d]
+         '[datomic.samples.repl :as repl])

-(def client (d/client {:server-type :dev-local :system "datomic-samples"}))
-(def conn (d/connect client {:db-name "social-news"}))
-(def db (d/with-db conn))
+(def client (d/client {:server-type :dev-local :system "day-of-datomic-cloud"}))
+(d/create-database client {:db-name "component-attributes"})
+(def conn (d/connect client {:db-name "component-attributes"}))
+(repl/transact-all conn (repl/resource "day-of-datomic-cloud/social-news.edn"))

 ;; create a story and some comments
 (def tx-result
-  (d/with db {:tx-data [{:db/id "story"
-                         :story/title "Getting Started"
-                         :story/url "http://docs.datomic.com/getting-started.html"}
-                        {:db/id "comment-1"
-                         :comment/body "It would be great to learn about component attributes."
-                         :_comments "story"}
-                        {:db/id "comment-2"
-                         :comment/body "I agree."
-                         :_comments "comment-1"}]}))
+  (d/transact conn {:tx-data [{:db/id "story"
+                               :story/title "Getting Started"
+                               :story/url "http://docs.datomic.com/getting-started.html"}
+                              {:db/id "comment-1"
+                               :comment/body "It would be great to learn about component attributes."
+                               :_comments "story"}
+                              {:db/id "comment-2"
+                               :comment/body "I agree."
+                               :_comments "comment-1"}]}))

 (def tempids (:tempids tx-result))
 (def story (get tempids "story"))
 (def comment-1 (get tempids "comment-1"))
 (def comment-2 (get tempids "comment-2"))

-(def db (:db-after tx-result))
+(def db (d/db conn))

 ;; component attributes are automatically pulled when you pull the parent
 (d/pull db '[*] story)
@@ -38,7 +40,7 @@
 (:db/doc (d/pull db '[:db/doc] :db/retractEntity))

 ;; retract the story
-(def retracted-es (->> (d/with db {:tx-data [[:db/retractEntity story]]})
+(def retracted-es (->> (d/transact conn {:tx-data [[:db/retractEntity story]]})
                        :tx-data
                        (remove :added)
                        (map :e)


Fixed field names

Fixed field names

--- src/clj/forma/hadoop/jobs/cdm.clj
+++ src/clj/forma/hadoop/jobs/cdm.clj
@@ -86,7 +86,7 @@
         start-period (date/datetime->period tres start)]
     (<- [?x ?y ?z ?p ?iso]
         (src ?sres ?modh ?modv ?s ?l ?prob-series)
-        (gadm-src ?s-res ?mod-h ?mod-v ?sample ?line _ ?gadm _ _ _)
+        (gadm-src ?sres ?modh ?modv ?s ?l _ ?gadm _ _ _)
         (gadm->iso ?gadm :> ?iso)
         (o/clean-probs ?prob-series nodata :> ?clean-series)
         (first-hit thresh ?clean-series :> ?first-hit-idx)
@@ -115,7 +115,7 @@
         start-period (date/datetime->period tres start)]
     (<- [?iso ?s-res ?modh ?modv ?s ?l ?p]
         (src ?sres ?modh ?modv ?s ?l ?prob-series)
-        (gadm-src ?s-res ?mod-h ?mod-v ?sample ?line _ ?gadm _ _ _)
+        (gadm-src ?sres ?modh ?modv ?s ?l _ ?gadm _ _ _)
         (gadm->iso ?gadm :> ?iso)
         (o/clean-probs ?prob-series nodata :> ?clean-series)
         (first-hit thresh ?clean-series :> ?first-hit-idx)
@@ -130,4 +130,3 @@
     (<- [?iso ?p ?ct]
         (spark-src ?iso _ _ _ _ _ ?p)
         (c/distinct-count ?p :> ?ct))))
-


Re-jigged Chronos to use :optional

Re-jigged Chronos to use :optional

--- src/clj/game/cards-identities.clj
+++ src/clj/game/cards-identities.clj
@@ -58,21 +58,21 @@

    "Chronos Protocol: Selective Mind-mapping"
    {:events {:pre-resolve-damage {:once :per-turn
-                          :effect (effect (system-msg "can choose first Net Damage by clicking on Chronos Protocol") (damage-defer :net (last targets)))
-                         }}
-
-    :abilities [{:msg "reveal the Runner's Grip and choose the card trashed for the first net damage this turn."
-                 :req (req (and (get-defer-damage state side :net nil) (> (get-defer-damage state side :net nil) 0)))
-                 :effect (req (resolve-ability
+                          :effect (effect (damage-defer :net (last targets))
+                                          (resolve-ability
+                                            { :optional {:prompt "Use Chronos Protocol: Selective Mind-mapping to reveal the Runner's grip to select the first card trashed?"
+                                            :yes-ability {:effect (req (resolve-ability
                                                state side
                                                {:prompt (msg "Choose a card to trash")
                                                 :choices (req (:hand runner))
-                                                :msg (msg "trash " (:title target) " and do " (- (get-defer-damage state side :net nil) 1) " more net damage.")
-                                                :effect (effect (trash target) (damage :net (- (get-defer-damage state side :net nil) 1) {:unpreventable true :card card}))} card nil))}
-
-                 {:msg "do all net damage without using ID ability"
-                 :req (req (and (get-defer-damage state side :net nil) (> (get-defer-damage state side :net nil) 0)))
-                 :effect (effect (damage :net (get-defer-damage state side :net nil) {:unpreventable true :card card}))}]}
+                                                :effect (effect (system-msg (str "trashes " (:title target) " by using Chronos Protocol: Selective Mind-mapping and does " (- (get-defer-damage state side :net nil) 1) " more net damage"))
+                                                                (trash target)
+                                                                (damage :net (- (get-defer-damage state side :net nil) 1) {:unpreventable true :card card}))} card nil))}
+                                            :no-ability {:effect (effect (damage :net (get-defer-damage state side :net nil) {:unpreventable true :card card}))}
+                                            }} card nil))
+                                    }
+                                }
+                       }

    "Cybernetics Division: Humanity Upgraded"
    {:effect (effect (lose :max-hand-size 1) (lose :runner :max-hand-size 1))}


return nested accounts as a vector

return nested accounts as a vector

--- src/clj_money/models/accounts.clj
+++ src/clj_money/models/accounts.clj
@@ -178,13 +178,13 @@
                       (map #(assoc % :path (:name %)))
                       (map #(append-children % all))
                       (group-by :type))]
-     (map #(hash-map :type % :accounts (or
-                                         (->> grouped
-                                              %
-                                              (sort-by :name)
-                                              vec)
-                                         []))
-          types))))
+     (mapv #(hash-map :type % :accounts (or
+                                          (->> grouped
+                                               %
+                                               (sort-by :name)
+                                               vec)
+                                          []))
+           types))))

 (def update
   (update-fn {:before-save before-save


Surround tables in pre.

Surround tables in pre.

--- src/cljs/onyx_dashboard/core.cljs
+++ src/cljs/onyx_dashboard/core.cljs
@@ -71,22 +71,24 @@
   (render [_]
           (let [num-displayed 100
                 start-id (max 0 (- (inc message-id-max) num-displayed))
-                displayed-msg-ids (range start-id (inc message-id-max))]
-            (table {:striped? true :bordered? true :condensed? true :hover? true}
-                   (dom/thead
+                displayed-msg-ids (range start-id (inc message-id-max))]
+            (dom/pre
+             (dom/h4 "Cluster Activity")
+             (table {:striped? true :bordered? true :condensed? true :hover? true}
+                    (dom/thead
                      (dom/tr
-                       (dom/th "ID")
-                       (dom/th "Time")
-                       (dom/th "fn")))
-                   (dom/tbody ;{:height "500px" :position "absolute" :overflow-y "scroll"}
-                              ; Entries may not exist if they have come in out of order from sente,
-                              ; thus we only keep the not nil entries
-                              (for [entry (keep entries (reverse displayed-msg-ids))]
-                                (dom/tr {:key (str "entry-" (:message-id entry))
-                                         :title (str (om/value entry))}
-                                        (dom/td (str (:id (:args entry))))
-                                        (dom/td (str (js/Date. (:created-at entry))))
-                                        (dom/td (str (:fn entry))))))))))
+                      (dom/th "ID")
+                      (dom/th "Time")
+                      (dom/th "fn")))
+                    (dom/tbody ;{:height "500px" :position "absolute" :overflow-y "scroll"}
+                                        ; Entries may not exist if they have come in out of order from sente,
+                                        ; thus we only keep the not nil entries
+                     (for [entry (keep entries (reverse displayed-msg-ids))]
+                       (dom/tr {:key (str "entry-" (:message-id entry))
+                                :title (str (om/value entry))}
+                               (dom/td (str (:id (:args entry))))
+                               (dom/td (str (js/Date. (:created-at entry))))
+                               (dom/td (str (:fn entry)))))))))))

 (defn select-job [id]
   (println "Selecting job " id)
@@ -94,21 +96,23 @@

 (defcomponent job-selector [{:keys [selected-job jobs]} owner]
   (render [_]
-          (table {:striped? true :bordered? true :condensed? true :hover? true}
-                 (dom/thead
+          (dom/pre
+           (dom/h4 "Jobs")
+           (table {:striped? true :bordered? true :condensed? true :hover? true}
+                  (dom/thead
                    (dom/tr
-                     (dom/th "ID")
-                     (dom/th "Time")))
-                 (dom/tbody
+                    (dom/th "ID")
+                    (dom/th "Time")))
+                  (dom/tbody
                    (for [job (reverse (sort-by :created-at (vals jobs)))]
                      (let [job-id (:id job)]
-                       (dom/tr {; make this a class
+                       (dom/tr {        ; make this a class
                                 :style {:background-color (if (= job-id selected-job)
                                                             "lightblue")}}
-                         (dom/td {:on-click (fn [_] (select-job job-id))}
-                                 (str job-id))
-                         (dom/td {}
-                                 (str (js/Date. (:created-at job)))))))))))
+                               (dom/td {:on-click (fn [_] (select-job job-id))}
+                                       (str job-id))
+                               (dom/td {}
+                                       (str (js/Date. (:created-at job))))))))))))

 (defcomponent catalog-view [catalog owner]
   (render [_]


refactor scoring

refactor scoring

--- src/cljs/triboard/ai/scoring.cljs
+++ src/cljs/triboard/ai/scoring.cljs
@@ -1,6 +1,5 @@
 (ns triboard.ai.scoring
   (:require
-    [cljs.spec :as s :include-macros true]
     [triboard.logic.constants :as cst]
     [triboard.logic.board :as board]
     ))
@@ -12,7 +11,7 @@

 (defn- neighbors-coordinates
   [[x y]]
-  (map (fn [[dx dy]] [(+ x dx) (+ y dy)]) cst/directions))
+  (for [[dx dy] cst/directions] [(+ x dx) (+ y dy)]))

 (defn- neighbouring-walls
   [board point]
@@ -27,8 +26,9 @@
 (defn- all-weights
   [board]
   (into {}
-    (map (fn [point] [point (cell-weight board point)]))
-    cst/all-positions))
+    (for [point cst/all-positions]
+      [point (cell-weight board point)]
+      )))

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


Switch pipeline to use :none encoding.

Switch pipeline to use :none encoding.

--- messaging/src/immutant/messaging/pipeline.clj
+++ messaging/src/immutant/messaging/pipeline.clj
@@ -162,7 +162,7 @@
                              (format "Timed out after %d ms when dereferencing the result of step %s"
                                timeout current-step)))
           (msg/publish pl m
-            :encoding :clojure
+            :encoding :none
             :properties {"step" next-step
                          correlation-property (get-correlation-property raw-message)}))))
     f))
@@ -233,7 +233,7 @@
           (throw (IllegalArgumentException.
                    (format "'%s' is not one of the available steps: %s" step (vec step-names)))))
         (msg/publish pl m
-          :encoding :clojure
+          :encoding :none
           :properties {"step" step, correlation-property id})
         (create-delay pl id keep-result?)))
     assoc
@@ -281,7 +281,7 @@
   (step
     (fn [m]
       (msg/publish pl (if m (.body m))
-        :encoding :clojure
+        :encoding :none
         :ttl ttl
         :properties {"result" true, correlation-property (get-correlation-property m)}))
     :decode? false))


Add fn to make ajax request and switch view

--- src/discuss/communication.cljs
+++ src/discuss/communication.cljs
@@ -30,7 +30,6 @@
 (defn ajax-get
   "Make ajax call to dialogue based argumentation system."
   ([url headers handler]
-   (debug/update-debug :last-api url)
    (lib/no-error!)
    (GET (make-url url)
         {:handler       handler
@@ -41,6 +40,12 @@
    (ajax-get url headers lib/update-all-states!))
   ([url]
    (ajax-get url {})))
+
+(defn ajax-get-and-change-view
+    "Make ajax call to jump right into the discussion and change to discussion view."
+    [url view]
+    (ajax-get url)
+    (lib/change-view! view))

 (defn success-handler
   "Generic success handler, which sets error handling and returns a cljs-compatible response."


Another reddit problem I started a bit ago

Not going to finish it now

--- meltdown/core.clj
+++ meltdown/core.clj
@@ -1,7 +1,15 @@
 (require '[clojure.string :as st])
+
+;; More interested in the hyperbinary problem than this one for the moment.
+;; I'll work on it when I get some time.

 (let [[x y] (st/split (read-line) #" ")]
   (for [line (repeatedly read-line) :while line]
-
-    ))
+    (loop [w (st/split line #".")]
+      (cond
+        (= (first w) '\n') nil ; '\n' is not a char
+        (not= (first w) '.') (do
+                               (println (first w))
+                               (recur (rest w)))
+      )))


remove redundunt call

remove redundunt call

Former-commit-id: 97eee14a4598f6e538d03eca4a5f44b99f69665a

--- src/messenger/android/login.cljs
+++ src/messenger/android/login.cljs
@@ -87,9 +87,6 @@
   static om/IQuery
   (query [this]
          '[:user-phone-number])
-  Object
-  (componentDidMount [this]
-                     (load-user-phone-number nil))
   (render [this]
           (let [{:keys [user-phone-number]} (om/props this)
                 {:keys [nav]} (om/get-computed this)]


Cleanup comments and dead code

Cleanup comments and dead code

--- src/onyx/peer/task_lifecycle.clj
+++ src/onyx/peer/task_lifecycle.clj
@@ -327,7 +327,6 @@
         subscriber (m/subscriber (get-messenger state))]
     (set-output-pipeline! state pipeline)
     (if advance?
-      ;(assert (not (empty? (sub/src-peers (m/subscriber messenger)))) (get-replica state))
       (cond-> (next-epoch! state)

         (and (sub/completed? subscriber)
@@ -483,18 +482,6 @@
 (defn new-task-information [peer task]
   (map->TaskInformation (select-keys (merge peer task) [:log :job-id :task-id :id])))

-;; Publisher heartbeats
-;; At the start of each cycle, set all publications to used? false
-;; Whenever you send a message / barrier / whatever to a publication, set used? true
-;; At the end of the cycle, send heartbeats to used? false publications
-;; Make all of this done by the messenger
-
-;; Subscriber heartbeats
-;; At the end of each cycle, check whether subscriber is still alive
-;; If it is not, do not send a message and consider re-establishing via log message / peer reboot
-;; If it is, then send a heartbeat in the backchannel to the publisher
-
-;; TODO, try to filter out lifecycles that are actually identity
 (defn filter-task-lifecycles
   [{:keys [onyx.core/task-map onyx.core/windows onyx.core/triggers] :as event}]
   (let [task-type (:onyx/type task-map)
@@ -560,8 +547,6 @@
                                                      :fn function/read-input-batch})
       (#{:function :output} task-type)        (conj {:lifecycle :lifecycle/read-batch
                                                      :fn function/read-function-batch})
-      ; (#{:input :function :output} task-type) (conj {:lifecycle :lifecycle/dead-peer-detection
-      ;                                                :fn dead-peer-detection})
       (#{:input :function :output} task-type) (conj {:lifecycle :lifecycle/after-read-batch
                                                      :fn (build-lifecycle-invoke-fn event :lifecycle/after-read-batch)})
       (#{:input :function :output} task-type) (conj {:lifecycle :lifecycle/apply-fn
@@ -637,8 +622,6 @@
         (do (set! last-heartbeat curr-time)
             (-> this
                 (send-heartbeats!)
-                ; FIXME FIXME FIXME CAN'T DETECT PEERS AS BEING DOWN IF WE HAVE BEEN BLOCKED
-                ;; AND NOT READING
                 (dead-peer-detection!)))
         this)))
   (print-state [this]
@@ -656,9 +639,6 @@
                 replica-version
                 :e
                 epoch
-                ; Replace with expected from subscriber itself
-                ;:n-subs
-                ;(count (m/subscriber messenger))
                 :n-pubs
                 (count (m/publishers messenger))
                 :batch
@@ -796,7 +776,6 @@
   (let [base-replica (onyx.log.replica/starting-replica opts)
         lifecycles (filter :fn (filter-task-lifecycles event))
         names (mapv :lifecycle lifecycles)
-        _ (info "NAMES" (:onyx.core/task event) names)
         arr #^"[Lclojure.lang.IFn;" (into-array clojure.lang.IFn (map :fn lifecycles))
         recover-idx (int 0)
         iteration-idx (int (lookup-lifecycle-idx lifecycles :lifecycle/next-iteration))
@@ -914,7 +893,6 @@
                                                      coordinator input-pipeline output-pipeline)
                     _ (info log-prefix "Enough peers are active, starting the task")
                     task-lifecycle-ch (start-task-lifecycle! initial-state ex-f)]
-                (info "EVENT IS " event)
                 (s/validate os/Event event)
                 (assoc component
                        :event event


Remove unnecessary merges in lifecycles (merges appear to already be performed by in the lifecycle calls)

--- src/onyx/peer/task_lifecycle.clj
+++ src/onyx/peer/task_lifecycle.clj
@@ -185,8 +185,7 @@
   event)

 (defn inject-batch-resources [compiled-before-batch-fn pipeline event]
-  (let [rets (-> event
-                 (merge (compiled-before-batch-fn event))
+  (let [rets (-> (compiled-before-batch-fn event)
                  (assoc :onyx.core/lifecycle-id (java.util.UUID/randomUUID)))]
     (taoensso.timbre/trace (format "[%s / %s] Started a new batch"
                                    (:onyx.core/id rets) (:onyx.core/lifecycle-id rets)))
@@ -310,7 +309,7 @@
     rets))

 (defn close-batch-resources [event]
-  (let [rets (merge event ((:onyx.core/compiled-after-batch-fn event) event))]
+  (let [rets ((:onyx.core/compiled-after-batch-fn event) event)]
     (taoensso.timbre/trace (format "[%s / %s] Closed batch plugin resources"
                                    (:onyx.core/id rets)
                                    (:onyx.core/lifecycle-id rets)))
@@ -657,7 +656,7 @@
                           (not (munge-start-lifecycle pipeline-data)))
                 (Thread/sleep (or (:onyx.peer/peer-not-ready-back-off opts) 2000)))

-            pipeline-data (merge pipeline-data ((:onyx.core/compiled-before-task-start-fn pipeline-data) pipeline-data))]
+            pipeline-data ((:onyx.core/compiled-before-task-start-fn pipeline-data) pipeline-data)]

         (clear-messenger-buffer! messenger-buffer)
         (>!! outbox-ch (entry/create-log-entry :signal-ready {:id id}))


Get matched event in header of panel

Get matched event in header of panel

--- src/day8/re_frame/trace/subs.cljs
+++ src/day8/re_frame/trace/subs.cljs
@@ -1,5 +1,6 @@
 (ns day8.re-frame.trace.subs
-  (:require [mranderson047.re-frame.v0v10v2.re-frame.core :as rf]))
+  (:require [mranderson047.re-frame.v0v10v2.re-frame.core :as rf]
+            [day8.re-frame.trace.metamorphic :as metam]))

 (rf/reg-sub
   :settings/root
@@ -146,7 +147,7 @@
     (let [matches (:matches epochs)
           current-index (:current-epoch-index epochs)
           match (nth matches (+ (count matches) (or current-index 0)) (last matches))
-          event (get-in (second match) [:tags :event])]
+          event (get-in (metam/matched-event match) [:tags :event])]
       event)))

 (rf/reg-sub


Implemented basic web interface

Implemented basic web interface

--- src/demogorgon/web.clj
+++ src/demogorgon/web.clj
@@ -1,13 +1,170 @@
 (ns demogorgon.web
-  (:use compojure.core, ring.adapter.jetty)
-  (:require [compojure.route :as route]))
+  (:import [java.io File]
+           [org.apache.log4j Logger])
+  (:use [compojure.core :only (defroutes GET)]
+        [ring.adapter.jetty :only (run-jetty)]
+        [ring.util.codec :only (url-encode url-decode)]
+        [hiccup.core :only (html escape-html)]
+        [hiccup.page-helpers :only (doctype link-to)])
+  (:require [compojure.route :as route]
+            [clojure.contrib.sql :as sql]))
+
+(def logger (Logger/getLogger "demogorgon.web"))
+
+(def db {:classname "org.sqlite.JDBC"
+                    :subprotocol "sqlite"
+                    :subname "/tmp/nh.db"
+                    :create true})
+
+(defn layout [content]
+  (html
+   (doctype :html5)
+   [:html
+    [:head
+     [:title "un.nethack.nu"]
+     [:style {:type "text/css"}
+      "body { font-family: verdana; font-size: 9px; }"
+      "table { width: 100%; font-size: 11px; }"
+      "th{ color: black; text-shadow:1px 1px 1px #bbb; }"
+      "tr:nth-child(odd) { color: black; background-color:#eee; }"
+      "tr:nth-child(even) { color: black; background-color:#fff; }"
+      "tr:hover { background-color: #ccc; }"]]
+    [:body
+     [:h1 "un.nethack.nu"]
+     [:div#menu
+      [:a {:href "/"} "last 25 games"] " | "
+      [:a {:href "/highscores"} "highscores"] " | "
+      [:a {:href "/users"} "users"] " | "
+      [:a {:href "/causes"} "causes"]]
+     [:br]
+     content]]))
+
+(defn make-dump-link [row]
+  (let [base (str "/user/" (:name row) "/dumps/" (:name row ) "." (:endtime row))
+        file-base (str "/srv/un.nethack.nu" base)
+        extension (if (.exists (File. (str file-base ".txt.html")))
+                    ".txt.html"
+                    (if (.exists (File. (str file-base ".txt")))
+                      ".txt"
+                      nil))]
+    (if extension
+      [:a {:href (str base extension)} "dump #" (:id row)]
+      [:div "No dump file for game " (:id row)])))
+
+(defn rs-to-table [rs]
+  [:table
+   [:tr
+    [:th "game"]
+    [:th "name"]
+    [:th "points"]
+    [:th "deathdate"]
+    [:th "death"]]
+   (map #'rs-row-to-tr rs)])
+
+(defn rs-row-to-tr [row]
+  [:tr
+   [:td [:a {:href (str "/game/" (:id row))} (:id row)]]
+   [:td [:a {:href (str "/user/" (:name row))} (:name row)]]
+   [:td (:points row)]
+   [:td (:deathdate row)]
+   [:td [:a {:href (str "/cause/" (url-encode (:death_uniq row)))} (:death row)]]])
+
+(defn game [id]
+  (sql/with-connection db
+    (sql/with-query-results
+      rs
+      ["select * from xlogfile where id = ?" id]
+      (let [row (first rs)]
+        (if (not row)
+          (page-not-found)
+          (layout (make-dump-link row)))))))
+
+(defn highscores
+  ([] (highscores 10))
+  ([limit]
+     (sql/with-connection db
+       (sql/with-query-results
+         rs
+         ["select * from xlogfile order by points desc limit ?" limit]
+         (layout
+          (rs-to-table rs))))))
+
+(defn cause [cause-str]
+  (sql/with-connection db
+    (sql/with-query-results
+      rs
+      ["select * from xlogfile where death_uniq = ? order by points desc" cause-str]
+      (layout
+       (rs-to-table rs)))))
+
+(defn last-games
+  ([] (last-games 10))
+  ([limit]
+     (sql/with-connection db
+       (sql/with-query-results
+         rs
+         ["select * from xlogfile order by endtime desc limit ?" limit]
+         (layout
+          (rs-to-table rs))))))
+
+(defn user [name]
+  (sql/with-connection db
+    (sql/with-query-results
+      rs
+      ["select count(*) as games_played, (select count(*) from xlogfile where name = ? and death = 'ascended') as ascensions from xlogfile where name = ?" name name]
+      (let [row (first rs)]
+        (if (not row)
+          (page-not-found)
+          (layout
+           [:div
+            [:h2 name]
+            [:p (:games_played row) " games played, " (:ascensions row) " ascensions."]
+            [:br]
+            [:a {:href (str "/user/" name "/dumps/")} "dumps"]
+            [:br]
+            [:a {:href (str "/user/" name "/ttyrecs/")} "ttyrecs"]]))))))
+
+(defn users []
+  (sql/with-connection db
+    (sql/with-query-results
+      rs
+      ["select distinct name from xlogfile order by name"]
+      (layout
+       [:div
+        (map (fn [row]
+               [:div [:a {:href (str "/user/" (:name row))} (:name row)]
+                [:br]])
+             rs)]))))
+
+(defn causes []
+  (sql/with-connection db
+    (sql/with-query-results
+      rs
+      ["select distinct death_uniq as death, count(*) as count from xlogfile group by death order by count desc"]
+      (layout
+       (map (fn [row]
+              [:div
+               (:count row) " " [:a {:href (str "/cause/" (url-encode (:death row)))} (:death row)]
+               [:br]])
+             rs)))))
+
+(defn page-not-found []
+  "
Page not found
")

 (defroutes main-routes
-  (GET "/" [] "
Hello World
")
-  (route/not-found "
Page not found
"))
+  (GET "/" [] (last-games 25))
+  (GET "/highscores" [] (highscores 25))
+  (GET "/game/:id" [id] (game id))
+  (GET "/user/:name" [name] (user name))
+  (GET "/user/:name/" [name] (user name))
+  (GET "/users" [] (users))
+  (GET "/causes" [] (causes))
+  (GET "/cause/:cause-str" [cause-str] (cause cause-str))
+  (GET "/highscores/:limit" [limit] (highscores limit))
+  (route/not-found (page-not-found)))

 (defn start-web []
-  (run-jetty main-routes {:port 8080 :join false}))
+  (run-jetty #'main-routes {:port 8080 :join false}))

 (defn stop-web [j]
   (.stop j))


Rename local var.

Rename local var.

--- src/dsbdp/data_processing_dsl.clj
+++ src/dsbdp/data_processing_dsl.clj
@@ -18,21 +18,21 @@
     '()
     (reverse
       (reduce
-        (fn [v data-processing-element]
+        (fn [v data-proc-def-element]
           (cond
             (or
-              (keyword? data-processing-element)
-              (symbol? data-processing-element)) (let [s (symbol (name data-processing-element))]
-                                                   (condp not= nil
-                                                     (ns-resolve 'clojure.core s)
-                                                       (conj v (ns-resolve 'clojure.core s))
-                                                     (ns-resolve 'dsbdp.byte-array-conversion s)
-                                                       (conj v (ns-resolve 'dsbdp.byte-array-conversion s) 'input)
-                                                     (do
-                                                       (println "Could not resolve keyword/symbol:" s)
-                                                        v)))
-            (list? data-processing-element) (conj v (into '() (reverse (create-data-processing-sub-fn data-processing-element input offset))))
-            :default (conj v data-processing-element)))
+              (keyword? data-proc-def-element)
+              (symbol? data-proc-def-element)) (let [s (symbol (name data-proc-def-element))]
+                                                 (condp not= nil
+                                                   (ns-resolve 'clojure.core s)
+                                                     (conj v (ns-resolve 'clojure.core s))
+                                                   (ns-resolve 'dsbdp.byte-array-conversion s)
+                                                     (conj v (ns-resolve 'dsbdp.byte-array-conversion s) 'input)
+                                                   (do
+                                                     (println "Could not resolve keyword/symbol:" s)
+                                                      v)))
+            (list? data-proc-def-element) (conj v (into '() (reverse (create-data-processing-sub-fn data-proc-def-element input offset))))
+            :default (conj v data-proc-def-element)))
         [] data-processing-definition))))

 (defn create-data-processing-fn-body-for-java-map-type


better response when hotloading

better response when hotloading

--- src/refactor_nrepl/artifacts.clj
+++ src/refactor_nrepl/artifacts.clj
@@ -107,8 +107,10 @@
         (throw (IllegalArgumentException. (str "Malformed dependency vector: "
                                                coordinates))))
       (add-dependencies :coordinates coords :repositories repos)
-      (transport/send transport (response-for msg :status :done
-                                              :dependency (first coords))))
+      (transport/send transport
+                      (response-for msg :status :done
+                                    :dependency
+                                    (apply str (interpose " " (first coords))))))
     (catch Exception e
       (transport/send transport (response-for msg :error (.getMessage e)
                                               :status :done)))))


Fix type hint.

Fix type hint.

--- src/fhofherr/clj_db_util/core.clj
+++ src/fhofherr/clj_db_util/core.clj
@@ -4,12 +4,13 @@
   (:import (javax.sql DataSource)
            (org.flywaydb.core Flyway)
            (com.zaxxer.hikari HikariDataSource HikariConfig)
-           (org.flywaydb.core.api MigrationInfoService)))
+           (org.flywaydb.core.api MigrationInfoService)
+           (clojure.lang Keyword)))

 (defrecord Database [^DataSource datasource
                      ^String db-resource-path
                      ^String schema
-                     ^String vendor
+                     ^Keyword vendor
                      ^Flyway migrator])

 (alter-meta! #'->Database assoc :no-doc true)


Add radians to degrees

Add radians to degrees

--- src/hydrofoil/core.clj
+++ src/hydrofoil/core.clj
@@ -14,7 +14,7 @@
   (hash-map :dencity dencity
             :velocity velocity
             :angle-of-attack angle-of-attack
-            :angle-of-attack-radiants (*(/ (Math/Pi) 180)) angle-of-attack))
+            :angle-of-attack-radians (*(/ (Math/PI) 180) angle-of-attack)))

 (defn -main [& args]
   (new-indv(NACA-design 50 50 50)))


Circle follows mouse.

Circle follows mouse.

Why do we have to turn off the keypresses for the 2nd circle? Probably
PEBCAK.

--- src/ldnclj_goose_201407/core.cljs
+++ src/ldnclj_goose_201407/core.cljs
@@ -7,6 +7,7 @@

 (defn draw []
   (let [[r g b] @bkgrnd-colour]
+    (println "circle-1" @circle-1)
     (q/background r g b)
     (q/fill b g r)
     (apply q/ellipse @circle-1)
@@ -15,15 +16,16 @@

 (defn key-press []
   (let [[r g b] @bkgrnd-colour
+        [x y w h] @circle-1
         circle-1-size (rand-int 800)
         circle-2-size 500
         key-pressed (q/key-as-keyword)]
     (println key-pressed)
     (reset! bkgrnd-colour [g b r])
-    (reset! circle-1 [(rand-int 1800)
-                      (rand-int 900)
-                      circle-1-size
-                      circle-1-size])
+    ;; (reset! circle-1 [(rand-int 1800)
+    ;;                   (rand-int 900)
+    ;;                   circle-1-size
+    ;;                   circle-1-size])
     (reset! circle-2 [(rand-int 1800)
                       (rand-int 900)
                       (cond
@@ -33,8 +35,16 @@
                        (= key-pressed :h) (* circle-2-size 4)
                        :else circle-2-size)])))

+(defn mouse-move []
+  (let [mx (q/mouse-x)
+        my (q/mouse-y)
+        [x y w h] @circle-1]
+    (println "x: " mx "y: " my)
+    (reset! circle-1 [mx my w h])))
+
 (q/defsketch ldnclj-goose-201407
 	:draw draw
 	:host "ldnclj-goose-201407"
 	:size [1920 1080]
-        :key-pressed key-press)
+        :key-pressed key-press
+        :mouse-moved mouse-move)


Set high max payload ws size.

Set high max payload ws size.

--- src/kabel/http_kit.clj
+++ src/kabel/http_kit.clj
@@ -58,10 +58,13 @@
                               (with-super super
                                 (try
                                   (when (> (count in-buffer) 100)
-                                    (error "incoming buffer for " url
-                                           " too full:" (count in-buffer))
-                                    (.close ws))
-                                  (debug "received byte message")
+                                    (.close ws)
+                                    (throw (ex-info
+                                            (str "incoming buffer for " url
+                                                 " too full:" (count in-buffer))
+                                            {:url url
+                                             :count (count in-buffer)})))
+                                  (debug "received byte message, buffer count:" (count in-buffer))
                                   (with-open [bais (ByteArrayInputStream. data)]
                                     (let [reader
                                           (transit/reader bais :json
@@ -154,10 +157,12 @@
                                                      host (:remote-addr request)]
                                                  (debug "received byte message")
                                                  (when (> (count in-buffer) 100)
-                                                   ;; TODO better throw
-                                                   (error "incoming buffer for " host
-                                                          " too full:" (count in-buffer))
-                                                   (close channel))
+                                                   (close channel)
+                                                   (throw (ex-info
+                                                           (str "incoming buffer for " (:remote-addr request)
+                                                                " too full:" (count in-buffer))
+                                                           {:url url
+                                                            :count (count in-buffer)})))
                                                  (try
                                                    (with-open [bais (ByteArrayInputStream. blob)]
                                                      (let [reader
@@ -190,7 +195,8 @@
                                            first
                                            second
                                            read-string)
-                                :max-body (* 512 1024 1024)}))
+                                :max-body (* 512 1024 1024)
+                                :max-ws (* 512 1024 1024)}))
     true))


Flush repl I/O in a separate thread; closes #71.

--- src/leiningen/repl.clj
+++ src/leiningen/repl.clj
@@ -20,10 +20,11 @@
                     [java.io ~'InputStreamReader ~'OutputStream
                      ~'OutputStreamWriter ~'PrintWriter]
                     [clojure.lang ~'LineNumberingPushbackReader]))
-           (try (require ['~'clojure.java.shell])
-                (require ['~'clojure.java.browse])
-                (catch Exception _#))
-           (use ['~'clojure.main :only ['~'repl]])
+         (try ;; transitive requires don't work for stuff on bootclasspath
+           (require ['~'clojure.java.shell])
+           (require ['~'clojure.java.browse])
+           (catch Exception _#))
+         (use ['~'clojure.main :only ['~'repl]])
          (let [server# (ServerSocket. ~port 0 (~'InetAddress/getByName ~host))
                acc# (fn [s#]
                       (let [ins# (.getInputStream s#)
@@ -49,15 +50,15 @@
              .start)
            (format "REPL started; server listening on %s:%s." ~host ~port)))))

-(defn- copy-out [reader]
-  (Thread/sleep 100)
-  (.write *out* (.read reader))
-  (while (.ready reader)
-    (.write *out* (.read reader)))
-  (flush))
+(defn- copy-out-loop [reader]
+  (let [buffer (make-array Character/TYPE 1000)]
+    (loop []
+      (.write *out* buffer 0 (.read reader buffer))
+      (flush)
+      (Thread/sleep 100)
+      (recur))))

 (defn repl-client [reader writer]
-  (copy-out reader)
   (let [eof (Object.)
         input (try (read *in* false eof)
                    (catch Exception e
@@ -68,8 +69,10 @@
       (recur reader writer))))

 (defn- connect-to-server [socket]
-  (repl-client (InputStreamReader. (.getInputStream socket))
-               (OutputStreamWriter. (.getOutputStream socket))))
+  (let [reader (InputStreamReader. (.getInputStream socket))
+        writer (OutputStreamWriter. (.getOutputStream socket))]
+    (.start (Thread. #(copy-out-loop reader)))
+    (repl-client reader writer)))

 (defn poll-repl-connection [port]
   (Thread/sleep 100)


Fix typos

Fix typos

--- src/leiningen/spec.clj
+++ src/leiningen/spec.clj
@@ -45,11 +45,11 @@
   "Speclj - pronounced \"speckle\": a TDD/BDD framework for Clojure.

 You're currently using Speclj's Leiningen plugin.  To get the Speclj's help
-documentation, as opposed to this message provided by Leinigen, try this:
+documentation, as opposed to this message provided by Leiningen, try this:

   lein spec --speclj

-That ough to do the trick."
+That ought to do the trick."
   [project & args]
   (prepare project)
   (let [speclj-args (cons "-c" args)


new definition to work with dimmers

new definition to work with dimmers

--- src/lights/my_show.clj
+++ src/lights/my_show.clj
@@ -28,7 +28,7 @@

 ; 2DO: understand how to pack dimmer and strobe into 1 function definition
-(defn my-rgbw
+(defn simple-rgbd
   "A simple RGB with dimmer"
   []
   {:channels [(chan/color 1 :red)
@@ -37,7 +37,9 @@
               (chan/functions :control 4
                 0 {:type :dimmer
                   :label "Dimmer from 0 to 189"
-                  :range :variable})]
+                  :range :variable}
+                190 {:type :strobe
+                  :label "Strobe from 190"})]
    :name "Simple RGB with dimmer"})

 (defn my-rgb
@@ -65,9 +67,9 @@
       ;;       to something descriptive and in your own style:
       (show/show :universes [1] :description "Deepower"))))

-  (show/patch-fixture! :rgbw-1 (my-rgbw) 1 1 :x 1)
-  (show/patch-fixture! :rgbw-2 (my-rgbw) 1 5 :x 2)
-  (show/patch-fixture! :rgbw-3 (my-rgbw) 1 9 :x 3)
+  (show/patch-fixture! :back-1 (simple-rgbd) 1 1 :x 1)
+  (show/patch-fixture! :back-2 (simple-rgbd) 1 5 :x 2)
+  (show/patch-fixture! :back-3 (simple-rgbd) 1 9 :x 3)
   (show/patch-fixture! :rgb-1 (my-rgb) 1 13  :x 3.5)

   ;; Return the show's symbol, rather than the actual map, which gets huge with


use migae/boot_gae intead of migae/templates

Signed-off-by: Gregg Reynolds <d0f77bc71a9867acdcb4f62f012b858edad79160@norc.org>

--- src/migae/boot_gae.clj
+++ src/migae/boot_gae.clj
@@ -416,7 +416,7 @@
          ;;(println "master config: " master-config)
          ;;(println "appengine-config-map 2: " appengine-config-map)
          (let [content (stencil/render-file
-                        "migae/templates/xml.appengine-web.mustache"
+                        "migae/boot_gae/xml.appengine-web.mustache"
                         appengine-config-map)]
            ;;(if verbose (println content))
            (if verbose (util/info "Configuring appengine-web.xml\n"))
@@ -661,17 +661,17 @@
             ;; in-file  (boot/tmp-file appengine-config-edn-f)
             ;; out-file (io/file workspace path)
             appengine-application-cfg (stencil/render-file
-                                       "migae/templates/appengine-application.mustache"
+                                       "migae/boot_gae/appengine-application.mustache"
                                        appengine-cfg)
             services-app-cfg (stencil/render-file
-                             "migae/templates/services-app.mustache"
+                             "migae/boot_gae/services-app.mustache"
                              (-> appengine-cfg
                                  (assoc-in [:services]
                                            (conj (seq (:services appengine-cfg))
                                                  {:name "default"}))))

             manifest-cfg (stencil/render-file
-                          "migae/templates/MANIFEST.MF.mustache"
+                          "migae/boot_gae/MANIFEST.MF.mustache"
                           appengine-cfg)]
         (if verbose
           (do (println appengine-application-cfg)
@@ -822,7 +822,7 @@
                      (spit boot-config-edn-out-file boot-config-edn-s))

                    ;; step 2: gen filters
-                   (let [gen-filters-content (stencil/render-file "migae/templates/gen-filters.mustache"
+                   (let [gen-filters-content (stencil/render-file "migae/boot_gae/gen-filters.mustache"
                                                                    (assoc filter-configs
                                                                           :gen-filters-ns
                                                                           gen-filters-ns))
@@ -1021,63 +1021,55 @@
   ;; (print-task "logging" *opts*)
   (fn middleware [next-handler]
     (fn handler [fileset]
+      (if verbose (util/info (format "Configuring logging for %s\n" (if jul "jul" "log4j"))))
       (let [workspace (boot/tmp-dir!)
             log4j-edn-files (->> fileset
                                  boot/input-files
                                  (boot/by-re [(re-pattern (str log4j-edn "$"))]))
             log4j-edn-f (condp = (count log4j-edn-files)
-                          0 (throw (Exception. (str appengine-edn " file not found")))
+                          0 (throw (Exception. (str log4j-edn " file not found")))
                           1 (first log4j-edn-files)
                           (throw (Exception.
-                                  (str "Only one " appengine-edn " file allowed; found "
+                                  (str "Only one " log4j-edn " file allowed; found "
                                        (count log4j-edn-files)))))
             log4j-cfg (-> (boot/tmp-file log4j-edn-f) slurp read-string)

             jul-edn-files (->> fileset
-                                 boot/input-files
-                                 (boot/by-re [(re-pattern (str jul-edn "$"))]))
+                               boot/input-files
+                               (boot/by-re [(re-pattern (str jul-edn "$"))]))
             jul-edn-f (condp = (count jul-edn-files)
-                          0 (throw (Exception. (str appengine-edn " file not found")))
-                          1 (first jul-edn-files)
-                          (throw (Exception.
-                                  (str "Only one " appengine-edn " file allowed; found "
-                                       (count jul-edn-files)))))
+                        0 (throw (Exception. (str jul-edn " file not found")))
+                        1 (first jul-edn-files)
+                        (throw (Exception.
+                                (str "Only one " jul-edn " file allowed; found "
+                                     (count jul-edn-files)))))
             jul-cfg (-> (boot/tmp-file jul-edn-f) slurp read-string)

             boot-config-edn-files (->> fileset
                                        boot/input-files
                                        (boot/by-re [(re-pattern (str boot-config-edn "$"))]))
-
-             boot-config-edn-f (condp = (count boot-config-edn-files)
-                                 0 (throw (Exception. (str boot-config-edn " file not found")))
-                                 ;; 0 (do (util/info (str "Creating " boot-config-edn "\n"))
-                                 ;;       (io/file boot-config-edn)) ;; this creates a java.io.File
-                                 1 (first boot-config-edn-files)  ;; this is a boot.tmpdir.TmpFile
-                                 (throw (Exception.
-                                         (str "only one _boot_config.edn file allowed, found "
-                                              (count boot-config-edn-files)))))
-             boot-config-edn-map (if (instance? boot.tmpdir.TmpFile boot-config-edn-f)
-                                   (-> (boot/tmp-file boot-config-edn-f) slurp read-string)
-                                   {})
+            boot-config-edn-f (condp = (count boot-config-edn-files)
+                                0 (throw (Exception. (str boot-config-edn " file not found")))
+                                ;; 0 (do (util/info (str "Creating " boot-config-edn "\n"))
+                                ;;       (io/file boot-config-edn)) ;; this creates a java.io.File
+                                1 (first boot-config-edn-files)  ;; this is a boot.tmpdir.TmpFile
+                                (throw (Exception.
+                                        (str "Only one " boot-config-edn " file allowed, found "
+                                             (count boot-config-edn-files)))))
+            boot-config-edn-map (if (instance? boot.tmpdir.TmpFile boot-config-edn-f)
+                                  (-> (boot/tmp-file boot-config-edn-f) slurp read-string)
+                                  {})

             content (stencil/render-file
                      (if jul
-                       "migae/templates/logging.properties.mustache"
-                       "migae/templates/log4j.properties.mustache")
+                       "migae/boot_gae/logging.properties.mustache"
+                       "migae/boot_gae/log4j.properties.mustache")
                      (merge boot-config-edn-map (if jul jul-cfg log4j-cfg)))

-            odir (if odir odir
-                     (if jul web-inf-dir classes-dir))
-            ;; (condp = log
-            ;;   :jul web-inf-dir
-            ;;   :log4j classes-dir
-            ;;   nil web-inf-dir
-            ;;   (throw (IllegalArgumentException. (str "Unrecognized :log value: " log)))))
+            odir (if odir odir (if jul web-inf-dir classes-dir))
+
             out-path (if jul "logging.properties" "log4j.properties")
-            #_(condp = log
-                :log4j "log4j.properties"
-                :jul "logging.properties"
-                nil  "logging.properties")
+
             mv-arg {(re-pattern out-path) (str odir "/$1")}

             target-middleware identity
@@ -1085,9 +1077,8 @@

             out-file (doto (io/file workspace (str odir "/" out-path)) io/make-parents)]

-         (spit out-file content)
-         (if verbose (util/info "Configuring logging...\n"))
-         (target-handler (-> fileset (boot/add-resource workspace) boot/commit!))))))
+        (spit out-file content)
+        (target-handler (-> fileset (boot/add-resource workspace) boot/commit!))))))

 (boot/deftask monitor
   "watch etc. for gae project"
@@ -1194,11 +1185,11 @@
                (io/make-parents boot-config-edn-out-file)
                (spit boot-config-edn-out-file boot-config-edn-s))

-             (let [reloader-impl-content (stencil/render-file "migae/templates/reloader-impl.mustache"
+             (let [reloader-impl-content (stencil/render-file "migae/boot_gae/reloader-impl.mustache"
                                                               {:reloader-ns reloader-impl-ns
                                                                :module module})

-                   gen-reloader-content (stencil/render-file "migae/templates/gen-reloader.mustache"
+                   gen-reloader-content (stencil/render-file "migae/boot_gae/gen-reloader.mustache"
                                                              {:gen-reloader-ns gen-reloader-ns
                                                               :reloader-impl-ns reloader-impl-ns})
                    ;; _ (if verbose (println "impl: " reloader-impl-path))
@@ -1417,7 +1408,7 @@
                                                          (boot/tmp-path boot-config-edn-f)
                                                          boot-config-edn-f))
                      ;; step 4: create servlet generator
-                     gen-servlets-content (stencil/render-file "migae/templates/gen-servlets.mustache"
+                     gen-servlets-content (stencil/render-file "migae/boot_gae/gen-servlets.mustache"
                                                                (assoc servlets-config-map
                                                                       :gen-servlets-ns
                                                                       gen-servlets-ns))
@@ -1509,9 +1500,8 @@
              ;; _ (println "master config: " master-config)

              content (stencil/render-file
-                      "migae/templates/xml.web.mustache"
+                      "migae/boot_gae/xml.web.mustache"
                       master-config)
-             ;; _ (println "web.xml content: " content)

              ;; step 3: create new master config file
              boot-config-edn-out-file (io/file workspace (boot/tmp-path boot-config-edn-f))
@@ -1528,7 +1518,6 @@
          (spit boot-config-edn-out-file master-config)
          (spit xml-out-file content))
       (-> fileset (boot/add-resource workspace) boot/commit!))))
-

 ;; (boot/deftask mods
 ;;   "modules"


[#84] Replace the usage of random for rand

--- priv/clojure/core.clj
+++ priv/clojure/core.clj
@@ -4597,7 +4597,7 @@
   n (default 1) (exclusive)."
   {:added "1.0"
    :static true}
-  ([] (random/uniform.e))
+  ([] (rand/uniform.e))
   ([n] (* n (rand))))

 (defn rand-int
@@ -6267,12 +6267,12 @@

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; helper files ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-;;(load "core_proxy")
+;; (load "core_proxy")
 (load "core_print")
-;;(load "genclass")
-;;(load "core_deftype")
-;;(load "core/protocols")
-;;(load "gvec")
+;; (load "genclass")
+;; (load "core_deftype")
+;; (load "core/protocols")
+;; (load "gvec")
 (load "instant")
 (load "uuid")


Update dependencies to match updates in compojure test

--- luminus/hello/project.clj
+++ luminus/hello/project.clj
@@ -4,16 +4,16 @@
   :dependencies
   [[org.clojure/clojure "1.5.1"]
    [lib-noir "0.6.6"]
-   [compojure "1.1.5"]
-   [ring-server "0.2.8"]
+   [compojure "1.1.6"]
+   [ring-server "0.3.1"]
    [selmer "0.4.0"]
    [com.taoensso/timbre "1.6.0"]
    [com.postspectacular/rotor "0.1.0"]
    [com.taoensso/tower "1.5.1"]
-   [markdown-clj "0.9.29"]
-   [org.clojure/java.jdbc "0.2.3"]
+   [markdown-clj "0.9.38"]
+   [org.clojure/java.jdbc "0.3.0-alpha1"]
    [mysql/mysql-connector-java "5.1.6"]
-   [korma "0.3.0-RC5"]
+   [korma "0.3.0-RC6"]
    [log4j
     "1.2.15"
     :exclusions
@@ -30,11 +30,11 @@
    {:ring
     {:open-browser? false, :stacktraces? false, :auto-reload? false}},
    :dev
-   {:dependencies [[ring-mock "0.1.3"] [ring/ring-devel "1.1.8"]]}}
+   {:dependencies [[ring-mock "0.1.5"] [ring/ring-devel "1.1.8"]]}}
   :url
   "http://example.com/FIXME"
   :plugins
-  [[lein-ring "0.8.5"]]
+  [[lein-ring "0.8.10"]]
   :description
   "FIXME: write description"
   :min-lein-version "2.0.0")


improve routing

improve routing

--- src/main/clj/wareblog/core.clj
+++ src/main/clj/wareblog/core.clj
@@ -44,12 +44,15 @@
   :handle-ok (fn [ctx] (let [id (get-in ctx [:request :route-params :id])]
                          (get-article (keyword id)))))

+(liberator/defresource home
+  :available-media-types ["text/html"]
+  :handle-ok (render-file "templates/home.html" {:name "World"}))
+
 (def handler
-  (bidi-ring/make-handler ["/" {"index.html" (liberator/resource :available-media-types ["text/html"]
-                                             :handle-ok (render-file "templates/home.html" {:name "World"})
-                                             )
-                      "articles/" {[:id] article
-                                   [:id "/comment"] comment-article}}]))
+  (bidi-ring/make-handler ["/" {"" home
+                                "index.html" home
+                                "articles/" {[:id] article
+                                             [:id "/comment"] comment-article}}]))

 (def wrap-handler
   (-> handler


Do not create messages editor div when there is no state transition.

Fixes #5.
IWillUpdate is called at regular intervals (by React?) on all the components in the DOM. If a message is being edited, we need to make sure we will not create a new edit DIV (as we already have one).

--- web-app/src/cljs/potato/core.cljs
+++ web-app/src/cljs/potato/core.cljs
@@ -860,7 +860,7 @@
         )
       om/IWillUpdate
       (will-update [_ next-props {:keys [editing]}]
-        (when editing
+        (when (and editing (not (om/get-render-state owner :editing)))
           (let [fieldset            (goog.dom/getElementByClass "chat-entry" (om/get-node owner))
                 keyboard-controller (om/get-shared owner :keyboard-control)
                 typing-chan         (om/get-shared owner :typing-chan)


Removed bullets from list on fetaures page in bootstrap-cover

--- lein-template/src/leiningen/new/modular/bootstrap-cover/website.clj
+++ lein-template/src/leiningen/new/modular/bootstrap-cover/website.clj
@@ -60,7 +60,7 @@
            [:div
             [:h1.cover-heading "Features"]
             [:p.lead "bootstrap-cover exhibits the following :-"]
-            [:ul.lead
+            [:ul.list-unstyled.lead
              [:li "A working Clojure-powered website using Stuart Sierra's 'reloaded' workflow and component library"]
              [:li "A fully-commented route-contributing website component"]
              [:li [:a {:href "https://github.com/juxt/bidi"} "Bidi"] " routing"]


rm unused code

rm unused code

--- src/neuseg/prepare.clj
+++ src/neuseg/prepare.clj
@@ -5,11 +5,7 @@
         [neuseg.db]
         [com.guokr.nlp.seg])
   (:import (com.guokr.neuseg.util NGram
-                                  Neighbors)
-           (com.googlecode.fannj Fann
-                                 Layer
-                                 Trainer
-                                 ActivationFunction)))
+                                  Neighbors)))

 (defn- mdot [vecs]
   (let [mid 4


query refactoring

query refactoring

--- src/tango/cljs/runtime/core.cljs
+++ src/tango/cljs/runtime/core.cljs
@@ -135,7 +135,7 @@
 (defui ScheduleView
   static om/IQuery
   (query [_]
-    [{:competition/activities (om/get-query ScheduleRow)}])
+    (into [] (om/get-query ScheduleRow)))
   Object
   (render
     [this]
@@ -266,13 +266,13 @@
 (defui ClassRow
   static om/IQuery
   (query [_]
-    [:class/position :class/name :class/remaining :class/starting :class/id
-     {:class/rounds
-      [{:round/status ['*]}
-       {:round/type ['*]}]}
+    '[:class/position :class/name :class/remaining :class/starting :class/id
+      {:class/rounds
+       [{:round/status [*]}
+       {:round/type [*]}]}
      {:class/adjudicator-panel
       [:adjudicator-panel/name]}
-     {:class/dances ['*]}])
+     {:class/dances [*]}])
   Object
   (render [this]
     ;(log "ClassRow")
@@ -296,7 +296,7 @@
 (defui ClassesView
   static om/IQuery
   (query [_]
-    (into [] (om/get-query ClassRow)))
+    `[~@(om/get-query ClassRow)])
   Object
   (render
     [this]
@@ -308,10 +308,16 @@
           (dom/button #js {:onClick #(om/transact! this `[(class/create {:class/name "New Class"
                                                                          :class/id ~(random-uuid)})
                                                           :app/selected-competition])} "New")
-          (dom/button #js {:onClick #(om/transact! this `[(app/select-page {:selected-page :create-class})
+          (dom/button #js {:className "btn btn-default"
+                           :onClick #(om/transact! this `[(app/select-page {:selected-page :create-class})
                                                           (app/select-class {:class/name "New Class"
                                                                              :class/id ~(random-uuid)})
-                                                          :app/selected-page])} "Newer"))
+                                                          :app/selected-page])}
+                      (dom/span #js {:className "glyphicon glyphicon-plus"}))
+
+          (dom/button #js {:className "btn btn-default"
+                           :onClick #()}
+                      (dom/span #js {:className "glyphicon glyphicon-trash"})))

         (dom/table
           #js {:className "table table-hover table-condensed"}
@@ -525,28 +531,27 @@
 (defui MainComponent
   static om/IQuery
   (query [_]
-    [{:app/selected-competition
-      (into [:competition/name :competition/location :competition/id
-             {:competition/classes (om/get-query ClassesView)}
-             {:competition/panels [:adjudicator-panel/name
-                                   {:adjudicator-panel/adjudicators
-                                    [:adjudicator/id
-                                     :adjudicator/name]}]}
-             {:competition/participants (om/get-query ParticipantsView)}
-             ]
-            (concat (om/get-query ScheduleView)))}
+    `[{:app/selected-competition
+       [:competition/name :competition/location :competition/id
+        {:competition/classes ~(om/get-query ClassesView)}
+        {:competition/panels [:adjudicator-panel/name
+                              {:adjudicator-panel/adjudicators
+                               [:adjudicator/id
+                                :adjudicator/name]}]}
+        {:competition/participants ~(om/get-query ParticipantsView)}
+        {:competition/activities ~(om/get-query ScheduleView)}]}

      ;; TODO - participants should come from the competition
-     {:app/participants (om/get-query ParticipantsView)}
+     {:app/participants ~(om/get-query ParticipantsView)}

      :app/status
      :app/selected-page

-     {:app/selected-class (om/get-query CreateClassView)}
+     {:app/selected-class ~(om/get-query CreateClassView)}

      {:app/selected-activities [:activity/id] }
      {:app/speaker-activities [:activity/id] }
-     {:app/clients (om/get-query ClientsView)}
+     {:app/clients ~(om/get-query ClientsView)}
      ])
   Object
   (render


Include file size in file data

Include file size in file data

--- src/bookshelf/core.clj
+++ src/bookshelf/core.clj
@@ -33,15 +33,17 @@
    (sql/drop-table-ddl :books)
    (sql/create-table-ddl :books
                          [:name :text]
-                         [:path :text]
-                         [:hash :text])))
+                         [:hash :text]
+                         [:size :float]
+                         [:path :text])))

 (defn populate-db []
   (for [file (library-files)]
     (sql/insert! db :books
                  {:name "name"
-                  :path (.getPath file)
-                  :hash (md5/md5-file file)})))
+                  :hash (md5/md5-file file)
+                  :size (.length file)
+                  :path (.getPath file)})))

 (defn library-files-html []
   (hiccup/html5
@@ -52,12 +54,14 @@
     [:thead
      [:tr
       [:td "Name"]
+      [:td "Size"]
       [:td "Hash"]
       [:td "Path"]]]
     [:tbody
      (for [row (sql/query db "SELECT * FROM books")]
        [:tr
         [:td (:name row)]
+        [:td (:size row)]
         [:td (:hash row)]
         [:td (:path row)]])]]))


Whitespace.

Whitespace.

--- src/task_tracker/server/core.clj
+++ src/task_tracker/server/core.clj
@@ -10,9 +10,10 @@
    :nrepl-server (nrepl/new-nrepl-server (:port nrepl))))

 (def system
-  (make-system {:db    {:port 1234
-                        :host "localhost"}
-                :nrepl {:port 5321}}))
+  (make-system
+   {:db    {:port 1234
+            :host "localhost"}
+    :nrepl {:port 5321}}))

 (defn init!
   []


Throw detailed error when header is wrong on jwe.

--- src/buddy/sign/jwe.clj
+++ src/buddy/sign/jwe.clj
@@ -166,11 +166,10 @@

 (defn- parse-header
   [^String header]
-  (let [header (codecs/safebase64->bytes header)
-        header (codecs/bytes->str header)
+  (let [header (codecs/safebase64->str header)
         {:keys [alg enc zip] :as header} (json/parse-string header true)]
     (when (or (nil? alg) (nil? enc))
-      (throw (IllegalArgumentException. "header must contain alg and enc keys.")))
+      (throw+ {:type :parse :cause :header :message "Missing `alg` or `enc` key in header."}))
     (merge {:alg (keyword (str/lower-case alg))
             :enc (keyword (str/lower-case enc))}
            (when zip


Map header names to lower case in locale-agnostic manner

--- ring-servlet/src/ring/util/servlet.clj
+++ ring-servlet/src/ring/util/servlet.clj
@@ -3,6 +3,7 @@
   (:require [clojure.java.io :as io]
             [clojure.string :as string])
   (:import (java.io File InputStream FileInputStream)
+           (java.util Locale)
            (javax.servlet.http HttpServlet
                                HttpServletRequest
                                HttpServletResponse)))
@@ -13,7 +14,7 @@
   (reduce
     (fn [headers, ^String name]
       (assoc headers
-        (.toLowerCase name)
+        (.toLowerCase name Locale/ENGLISH)
         (->> (.getHeaders request name)
              (enumeration-seq)
              (string/join ","))))
@@ -40,7 +41,7 @@
    :uri                (.getRequestURI request)
    :query-string       (.getQueryString request)
    :scheme             (keyword (.getScheme request))
-   :request-method     (keyword (.toLowerCase (.getMethod request)))
+   :request-method     (keyword (.toLowerCase (.getMethod request) Locale/ENGLISH))
    :headers            (get-headers request)
    :content-type       (.getContentType request)
    :content-length     (get-content-length request)


disable-grpc-test (#780)

disable-grpc-test (#780)

--- waiter/integration/waiter/grpc_test.clj
+++ waiter/integration/waiter/grpc_test.clj
@@ -45,7 +45,8 @@
   [length]
   (apply str (take length (repeatedly #(char (+ (rand 26) 65))))))

-(deftest ^:parallel ^:integration-fast test-basic-grpc-server
+;; setting to explicit because of temporary haproxy misconfiguration
+(deftest ^:parallel ^:integration-fast ^:explicit test-basic-grpc-server
   (testing-using-waiter-url
     (GrpcClient/setLogFunction (reify Function
                                  (apply [_ message]


Altered services paths, updated docstring.

--- src/capstone_demo_clj_api/routes/services.clj
+++ src/capstone_demo_clj_api/routes/services.clj
@@ -3,20 +3,21 @@
             [compojure.api.sweet :refer :all]
             [schema.core :as s]))

-(s/defschema Thingie {:id Long
-                      :hot Boolean
-                      :tag (s/enum :kikka :kukka)
-                      :chief [{:name String
-                               :type #{{:id String}}}]})
+;; (s/defschema Thingie {:id Long
+;;                       :hot Boolean
+;;                       :tag (s/enum :kikka :kukka)
+;;                       :chief [{:name String
+;;                                :type #{{:id String}}}]})
+;; unnecessary

 (defapi service-routes
   (ring.swagger.ui/swagger-ui
    "/swagger-ui")
   ;JSON docs available at the /swagger.json route
   (swagger-docs
-    {:info {:title "Sample api"}})
+    {:info {:title "Simple api"}})
   (context* "/api" []
-            :tags ["thingie"]
+            :tags ["JSON echo and path-based multiplication"]

             ;; (GET* "/plus" []
             ;;       :return       Long


Correct typo: :db/component -> :db/isComponent

--- src/datascript/core.cljc
+++ src/datascript/core.cljc
@@ -54,7 +54,7 @@
                  (:_ref (entity db 2)) ; => [{:db/id 1}]
                  (:ns/_ref (entity db 2)) ; => [{:db/id 1}]

-             Reverse reference lookup returns sequence of entities unless attribute is marked as `:db/component`:
+             Reverse reference lookup returns sequence of entities unless attribute is marked as `:db/isComponent`:

                  (:_component-ref (entity db 2)) ; => {:db/id 1}


Fix headers parsing on httpbasic backend.

--- src/clojure/buddy/auth/backends/httpbasic.clj
+++ src/clojure/buddy/auth/backends/httpbasic.clj
@@ -14,22 +14,23 @@

 (ns buddy.auth.backends.httpbasic
   (:require [buddy.auth.protocols :as proto]
+            [buddy.auth.utils :as utils]
             [buddy.auth :refer [authenticated?]]
             [buddy.core.codecs :refer [base64->str]]
-            [buddy.core.util :refer [maybe-let]]
-            [clojure.string :refer [split]]
+            [cuerdas.core :as str]
             [ring.util.response :refer [response response? header status]]))

 (defn parse-httpbasic-header
   "Given a request, try extract and parse
   http basic header."
   [request]
-  (maybe-let [headers-map (:headers request)
-              auth-header (get headers-map "authorization")
-              pattern     (re-pattern "^Basic (.+)$")
-              matches     (re-find pattern auth-header)
-              decoded     (base64->str (get matches 1))]
-    (let [[username, password] (split decoded #":")]
+  (let [headers (utils/lowercase-headers (:headers request))
+        pattern (re-pattern "^Basic (.+)$")
+        decoded (some->> (get headers "authorization")
+                         (re-find pattern)
+                         (second)
+                         (base64->str))]
+    (when-let [[username password] (str/split decoded #":")]
       {:username username :password password})))

 (defn http-basic-backend


Ditto

Ditto

--- src/clojure/clojurewerkz/cassaforte/debug.clj
+++ src/clojure/clojurewerkz/cassaforte/debug.clj
@@ -1,3 +1,12 @@
+;; Copyright (c) 2012-2014 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
+;;
+;; The use and distribution terms for this software are covered by the
+;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
+;; which can be found in the file epl-v10.html at the root of this distribution.
+;; By using this software in any fashion, you are agreeing to be bound by
+;; the terms of this license.
+;; You must not remove this notice, or any other, from this software.
+
 (ns clojurewerkz.cassaforte.debug
   "Debug utilities"
   (:require [clojure.stacktrace :refer :all]))


Wording

Wording

--- src/clojure/clojurewerkz/cassaforte/uuids.clj
+++ src/clojure/clojurewerkz/cassaforte/uuids.clj
@@ -1,5 +1,5 @@
 (ns clojurewerkz.cassaforte.uuids
-  "Provides utility methods to work with UUID."
+  "Provides utility functions for UUID generation."
   (:import [com.datastax.driver.core.utils UUIDs]
            [java.util UUID]))


functioning networking using hacked clj-http-lite

--- src/clojure/com/benbrittain/petrarch/main.clj
+++ src/clojure/com/benbrittain/petrarch/main.clj
@@ -3,24 +3,36 @@
               [neko.debug :refer [*a]]
               [neko.notify :refer [toast]]
               [neko.find-view :refer [find-view]]
-              [neko.threading :refer [on-ui]])
+              [neko.threading :refer [on-ui]]
+              [clojure.java.io :as io]
+              [clj-http.lite.client :as client])
   (:import com.benbrittain.petrarch.GPSbackground)
   (:import android.widget.TextView)
-  (:import [android.location LocationManager]
-           [android.content Context]))
+  (:import [android.content Context]))

+(defn send-chunk [a-chunk]
+  (let [body (pr-str (assoc {} :coords a-chunk))]
+    (def resp
+      (future (client/post "http://10.0.0.6:3000/api/routes/"
+                           {:body body
+                            :content-type :edn
+                            :socket-timeout 1000
+                            :conn-timeout 1000
+                            :accept :edn})))))

 (defn send-data [activity]
-  (let [^TextView input (.getText (find-view activity ::secret-key))]
-    (toast activity
-           (if (empty? input)
-             "Please enter the secret-key"
-             (str "secret key: " input))
-           :long)))
+  (let [^TextView input (.getText (find-view activity ::secret-key))
+        coords (read-gps-csv)]
+    (do
+      (doall
+        (map #(send-chunk %)
+             (partition-all 20 data)))
+      (toast activity
+             "sent data"
+             :long))))

 (defn start-background-gps [context activity]
   (let [^TextView input (.getText (find-view activity ::secret-key))
-        ^LocationManager location-manager (.getSystemService context Context/LOCATION_SERVICE)
         intent (android.content.Intent.)]
     (.setClassName intent context "com.benbrittain.petrarch.GPSbackground")
     (.startService context intent)