Fix merge conflicts

Fix merge conflicts

--- src/clojure/oxcart/emitter/jvm/emitter.clj
+++ src/clojure/oxcart/emitter/jvm/emitter.clj
@@ -59,7 +59,7 @@
   ([tag cast] (emit-cast tag cast false))
   ([tag cast unchecked?]
      (if (not (or (primitive? tag)
-                (primitive? cast)))
+                  (primitive? cast)))
        (when-not (#{Void Void/TYPE} cast)
          [[:check-cast cast]])
        (emit-box tag cast unchecked?))))
@@ -83,7 +83,7 @@
   Options
   -----------
   :debug? :- (Option bool)
-    Controls development debug level printing throughout code generation."
+  Controls development debug level printing throughout code generation."

   ([ast]
      (emit ast {}))
@@ -119,7 +119,7 @@
   Options
   -----------
   :debug :- (Option bool)
-    Controls developlent debug level printing throughout code generation."
+  Controls developlent debug level printing throughout code generation."

   ([ast]
      (emit-classes ast {}))
@@ -217,7 +217,7 @@
      [:invoke-virtual [(if (u/dynamic? var)
                          :clojure.lang.Var/get
                          :clojure.lang.Var/getRawRoot)] :java.lang.Object])))
-
+
 (defmethod -emit-set! :var
   [{:keys [target val] :as ast} frame]
   `[~@(emit-var target frame)
@@ -473,8 +473,8 @@
       ~@(emit (assoc instance :tag class) frame)
       ~@(mapcat #(emit % frame) args)
       ~@(when to-clear?
-           [[:insn :ACONST_NULL]
-            [:var-insn :clojure.lang.Object/ISTORE 0]])
+          [[:insn :ACONST_NULL]
+           [:var-insn :clojure.lang.Object/ISTORE 0]])
       [~(if (.isInterface class)
           :invoke-interface
           :invoke-virtual)
@@ -546,7 +546,7 @@
 (defmethod -emit :invoke
   [{:keys [fn args env to-clear?]} frame]
   (let [v       (-> fn :var)
-        static? (-> v meta :static)]
+        static? (-> v meta :oxcart.passes.fn-reduction/static)]
     ;; general invoke case
     [(emit fn frame)
      (when-not static? [:check-cast :clojure.lang.IFn])
@@ -820,7 +820,7 @@
                                      static?    :invokeStatic
                                      :else      :invoke)

-        attr                   (if static?
+        attr                   (if (and static? (not primitive?))
                                  #{:public :static}
                                  #{:public})

@@ -950,10 +950,10 @@
   [{:keys [target val env]} {:keys [class] :as frame}]
   (let [{:keys [o-tag name]} target]
     `[~@(emit-line-number env)
-     [:load-this]
-     ~@(emit (assoc val :tag Object) frame)
-     ~[:put-field class name Object]
-     ~@(-emit target frame)]))
+      [:load-this]
+      ~@(emit (assoc val :tag Object) frame)
+      ~[:put-field class name Object]
+      ~@(-emit target frame)]))

 (defmulti -emit-value (fn [type value] type))

@@ -1075,8 +1075,8 @@
   (let [sorted? (sorted? s)]
     (if (empty? s)
       [(if sorted?
-          [:get-static :clojure.lang.PersistentTreeSet/EMPTY :clojure.lang.PersistentTreeSet]
-          [:get-static :clojure.lang.PersistentHashSet/EMPTY :clojure.lang.PersistentHashSet])]
+         [:get-static :clojure.lang.PersistentTreeSet/EMPTY :clojure.lang.PersistentTreeSet]
+         [:get-static :clojure.lang.PersistentHashSet/EMPTY :clojure.lang.PersistentHashSet])]
       `[~@(emit-values-as-array s)
         ~@(if sorted?
             [[:invoke-static [:clojure.lang.RT/seq :java.lang.Object] :clojure.lang.ISeq]
@@ -1086,10 +1086,10 @@
 (defmethod -emit-value :seq [_ s]
   (if (empty? s)
     [[:get-static :clojure.lang.PersistentList/EMPTY :clojure.lang.PersistentList$EmptyList]]
-   `[~@(emit-values-as-array s)
-     [:invoke-static [:java.util.Arrays/asList :objects] :java.util.List]
-     [:invoke-static [:clojure.lang.PersistentList/create :java.util.List]
-      :clojure.lang.IPersistentList]]))
+    `[~@(emit-values-as-array s)
+      [:invoke-static [:java.util.Arrays/asList :objects] :java.util.List]
+      [:invoke-static [:clojure.lang.PersistentList/create :java.util.List]
+       :clojure.lang.IPersistentList]]))

 (defmethod -emit-value :char [_ c]
   [[:push c]
@@ -1416,13 +1416,15 @@
   (emit (-> init
             (assoc :var var))
         (-> frame
-            (assoc :static? (-> var clojure.core/meta :static)))))
+            (assoc :static? (-> var
+                                clojure.core/meta
+                                :oxcart.passes.fn-reduction/static)))))

 (defmethod -emit :fn
   [{:keys [var variadic? env] :as ast}
    {:keys [static?] :as frame}]
   (let [class-name (var->class var)
-        super      (cond variadic?
+        super      (cond variadic?
                          ,,:clojure.lang.RestFn

                          static?


wire up nav links

wire up nav links

--- src-cljs/frontend/components/landing.cljs
+++ src-cljs/frontend/components/landing.cljs
@@ -171,9 +171,9 @@
            [:div.our-claim
             [:div.navigation
              [:div.content
-              [:a {:role "button"} "Precursor"]
-              [:a {:role "button"} "Pricing"]
-              [:a {:role "button"} "Blog"]
+              [:a {:href "/home" :target "_self" :role "button"} "Precursor"]
+              [:a {:href "" :role "button"} "Pricing"]
+              [:a {:href "/blog" :target "_self" :role "button"} "Blog"]
               (common/google-login :small)]]
             [:div.our-philosphy-wrap
              [:div.our-philosphy.content
@@ -298,7 +298,8 @@
               [:p "Make working demos in just minutes using our simple target linking."]
               [:p
                [:a
-                {:role "button"}
+                {:href "/blog/interactive-layers"
+                 :role "button"}
                 "Read the tutorial"]
                "."]]
              [:div.featurette-media.reverse artwork-interactive]]
@@ -335,9 +336,9 @@
                 (om/build make-button (select-keys app [:document/id]))]]]
              [:div.navigation
               [:div.content
-               [:a {:role "button"} "Precursor"]
-               [:a {:role "button"} "Pricing"]
-               [:a {:role "button"} "Blog"]]]]])))))
+               [:a {:href "/home" :target "_self" :role "button"} "Precursor"]
+               [:a {:href "" :role "button"} "Pricing"]
+               [:a {:href "/blog" :target "_self" :role "button"} "Blog"]]]]])))))

 (defn landing [app owner]
   (reify


should be "auth-token" instead of just token

--- src-cljs/frontend/components/overlay.cljs
+++ src-cljs/frontend/components/overlay.cljs
@@ -685,7 +685,7 @@
               (om/build image-token-generator app)
               [:div.content.make (om/build share-input
                                            {:url (gstring/format "[![Precursor](%s)](%s)"
-                                                                 (urls/absolute-doc-svg doc :query {:token read-token})
+                                                                 (urls/absolute-doc-svg doc :query {:auth-token read-token})
                                                                  (urls/absolute-doc-url doc))
                                             ;; id that we can use to know if we should focus input
                                             ;; Should be set to a unique value


Fixed missing devices div.

Fixed missing devices div.

--- src-cljs/kixi/hecuba/tabs/programmes.cljs
+++ src-cljs/kixi/hecuba/tabs/programmes.cljs
@@ -443,7 +443,7 @@
       (let [{:keys [programmes projects properties devices active-components]} data
             history (om/get-shared owner :history)]
         (html
-         [:div.row#devices-id
+         [:div.row#devices-div
           [:div {:class (str "col-md-12 " (if (:property-id devices) "" "hidden"))}
            [:h2  "Devices"]
            [:ul {:class "breadcrumb"}


fixed typo

fixed typo

--- test/selmer/core_test.clj
+++ test/selmer/core_test.clj
@@ -73,7 +73,7 @@
       (= (fix-line-sep "\n{% block header %}\nB header\n\n
child-a header
\n<<\noriginal header\n>>\n\n{% endblock %}\n\n
{% block content %}\nSome content\n{% endblock %}
\n\n{% block footer %}\n
footer
\n{% endblock %}\n")
          (preprocess-template "templates/inheritance/child-b.html")))
     (is
-      (= "{%ifequal greeting|default:\"Hello!\" name|default:\"Jane Doe\"%} {{greeting|default:\"Hello!\"}} {{name|default:\"JaneDoe\"}} {%endifequal%}"
+      (= "{%ifequal greeting|default:\"Hello!\" name|default:\"Jane Doe\"%} {{greeting|default:\"Hello!\"}} {{name|default:\"Jane Doe\"}} {%endifequal%}"
          (preprocess-template "templates/inheritance/parent.html")))
     (is
       (= (fix-line-sep "\n    \n    \n        {% block hello %}\n\n            Hello \n         World\n{% endblock %}\n    \n")


Make subscription counts match visible pods

--- src/day8/re_frame/trace/subs.cljs
+++ src/day8/re_frame/trace/subs.cljs
@@ -361,29 +361,36 @@
       all-subs)))

 (rf/reg-sub
+  :subs/sub-counts
+  :<- [:subs/visible-subs]
+  (fn [subs _]
+    (->> subs
+         (map :type)
+         (frequencies))))
+
+(rf/reg-sub
   :subs/created-count
-  :<- [:subs/all-sub-traces]
-  (fn [traces]
-    (count (filter metam/subscription-created? traces))))
+  :<- [:subs/sub-counts]
+  (fn [counts]
+    (get counts :created 0)))

 (rf/reg-sub
   :subs/re-run-count
-  :<- [:subs/all-sub-traces]
-  ;; TODO: remove created subs that were re-run, they count as created only
-  (fn [traces]
-    (count (filter metam/subscription-re-run? traces))))
+  :<- [:subs/sub-counts]
+  (fn [counts]
+    (get counts :re-run 0)))

 (rf/reg-sub
   :subs/destroyed-count
-  :<- [:subs/all-sub-traces]
-  (fn [traces]
-    (count (filter metam/subscription-destroyed? traces))))
+  :<- [:subs/sub-counts]
+  (fn [counts]
+    (get counts :destroyed 0)))

 (rf/reg-sub
   :subs/not-run-count
-  :<- [:subs/all-sub-traces]
-  (fn [traces]
-    (count (filter metam/subscription-not-run? traces))))
+  :<- [:subs/sub-counts]
+  (fn [counts]
+    (get counts :not-run 0)))

 (rf/reg-sub
   :subs/unchanged-l2-subs-count


Name changes and authentication helpers

Name changes and authentication helpers

--- src/cylon/authentication.clj
+++ src/cylon/authentication.clj
@@ -19,7 +19,12 @@
    request :- Request]
   (p/authenticate component request))

-(defrecord DispatchingRequestAuthenticator [mappings]
+;; An authenticator that checks an authorization header. It takes a map,
+;; which maps Authorization token types to the local keywords of its
+;; dependencies that process them. Using declarations are automatically
+;; added.
+
+(defrecord AuthorizationHeaderRequestAuthenticator [mappings]
   p/RequestAuthenticator
   (authenticate [this request]
     (when-let [header (get-in request [:headers "authorization"])]
@@ -29,24 +34,42 @@
           (authenticate delegate-authenticator request)
           (debugf "Unrecognized token type (%s -> %s) in incoming Authorization header, with mappings as %s" token-type dependency mappings))))))

-(def new-dispatching-request-authenticator-schema
+(def new-authorization-header-request-authenticator-schema
   {:mappings {s/Str s/Keyword}})

-(defn new-dispatching-request-authenticator [& {:as opts}]
+(defn new-authorization-header-request-authenticator [& {:as opts}]
   (->> opts
        (merge {})
-       (s/validate new-dispatching-request-authenticator-schema)
-       (map->DispatchingRequestAuthenticator)
+       (s/validate new-authorization-header-request-authenticator-schema)
+       (map->AuthorizationHeaderRequestAuthenticator)
        (<- (using (-> opts :mappings vals vec)))))

-;; Utility
+;;

-;; TODO: It's possible that it would be useful to memoize authentication on each request
+;; Either - try multiple authenticators until one returns
+
+(defrecord EitherRequestAuthenticator []
+  p/RequestAuthenticator
+  (authenticate [this request]
+    (infof "Either: %s" (keys this))
+    (some (fn [a]
+            (when (satisfies? p/RequestAuthenticator a)
+              (let [res (authenticate a request)]
+                (when res (assoc res ::authenticator a)))))
+          (vals this))))
+
+(defn new-either-request-authenticator [& {:as opts}]
+  (->> opts
+       (merge {})
+       (map->EitherRequestAuthenticator)))
+
+;; Utility functions
+
+;; TODO: It's possible that it would be useful to memoize authentication
+;; on each request

 (defn get-subject-identifier [authenticator req]
   (:cylon/subject-identifier (authenticate authenticator req)))
-
-;; AuthenticationHandshake

 (s/defn initiate-authentication-handshake :- Response
   [component :- (s/protocol p/AuthenticationHandshake)


Use a default get value for panel-width-ratio ls

--- src/day8/re_frame/trace.cljs
+++ src/day8/re_frame/trace.cljs
@@ -270,8 +270,7 @@
   ;; Add clear button
   ;; Filter out different trace types
   (let [position          (r/atom :right)
-        panel-width-ratio (r/atom (or (localstorage/get "panel-width-ratio")
-                                      0.35))
+        panel-width-ratio (r/atom (localstorage/get "panel-width-ratio" 0.35))
         showing?          (r/atom false)
         dragging?         (r/atom false)
         pin-to-bottom?    (r/atom true)


Formatting.

Formatting.

--- test/test/datascript.cljs
+++ test/test/datascript.cljs
@@ -21,8 +21,8 @@
     (d/q '[:find ?w
           :where [?w "name"]] (fn [result]
                                 (is (= result #{[1] [2] [3]}))) db)
-   (d/q '[:find  ?e ?v
-           :where [?e "name" "Ivan"]
+    (d/q '[:find  ?e ?v
+          :where  [?e "name" "Ivan"]
                   [?e "age" ?v]] (fn [result]
                          (is (= result #{[1 15] [3 37]}))) db)
     ))


Respect proportion of icon or image when is added/imported to workspace.

--- src/uxbox/main/ui/workspace/drawarea.cljs
+++ src/uxbox/main/ui/workspace/drawarea.cljs
@@ -110,6 +110,7 @@
   (when-let [shape (:drawing @wb/workspace-ref)]
     (case (:type shape)
       :icon (on-init-draw-icon shape)
+      :image (on-init-draw-icon shape)
       :path (if (:free shape)
               (on-init-draw-free-path shape)
               (on-init-draw-path shape))
@@ -118,9 +119,14 @@
 ;; --- Icon Drawing

 (defn- on-init-draw-icon
-  [shape]
+  [{:keys [metadata] :as shape}]
   (let [{:keys [x y]} (gpt/divide @wb/mouse-canvas-a @wb/zoom-ref)
-        props {:x1 x :y1 y :x2 (+ x 100) :y2 (+ y 100)}
+        {:keys [width height]} metadata
+        proportion (/ width height)
+        props {:x1 x
+               :y1 y
+               :x2 (+ x 200)
+               :y2 (+ y (/ 200 proportion))}
         shape (geom/setup shape props)]
     (rs/emit! (uds/add-shape shape)
               (udw/select-for-drawing nil)


Clean up and add todo.

Clean up and add todo.

--- src/dsbdp/data_processing_dsl.clj
+++ src/dsbdp/data_processing_dsl.clj
@@ -35,6 +35,9 @@
             :default (conj v data-proc-def-element)))
         [] data-processing-definition))))

+;;; TODO: This function only supports byte array based functions yet.
+;;; This will become problematic once other input data types,
+;;; such as vectors or maps shall be processed to, e.g., CSV string format.
 (defn get-data-processing-sub-fn-ret-type
   "Get the return type of a data processing sub-function data-proc-sub-fn.
    For determining the type, this function calls data-proc-sub-fn with a 1530 byte dummy byte-array filled with 0."
@@ -90,7 +93,6 @@
                         "java-map" (create-data-processing-fn-body-for-java-map-output-type input-sym offset-sym rules)
                         "clj-map" (create-data-processing-fn-body-for-clj-map-output-type input-sym offset-sym rules)
                         "csv-str" (create-data-processing-fn-body-for-csv-str-output-type input-sym offset-sym rules)
-;                        "csv-str" (create-data-processing-fn-body-for-csv-str-type input-sym offset-sym rules)
 ;                        "json-str" (create-data-processing-fn-body-for-json-str-type input-sym offset-sym rules)
                         (do
                           (println "Unknown output type:" output-type)


Begin to refactor DSL code generation.

Begin to refactor DSL code generation.

--- src/dsbdp/data_processing_dsl.clj
+++ src/dsbdp/data_processing_dsl.clj
@@ -50,23 +50,27 @@
   [input rules nesting-level]
   (reduce
     (fn [v rule]
-      (cond
-        (list? (second rule)) (conj v
+      (let [rule-name (first rule)
+            rule-expression (second rule)]
+        (cond
+          (list? rule-expression) (conj v
                                     (if (> 1 nesting-level)
                                       (first rule)
-                                      (symbol (str "__" nesting-level "_" (first rule))))
-                                    (create-proc-sub-fn (second rule) input))
-        (vector? (second rule)) (do
-                                  ;(println "Binding: Got a VECTOR..." (first rule) (second rule))
-                                  (into
-                                    (conj v
-                                          (first rule)
-                                          nil)
-                                    (create-bindings-vector
-                                      input
-                                      (second rule)
-                                      (inc nesting-level))))
-        :default (println "Binding: unknown element for rule:" (str rule))))
+                                      (symbol (str "__" nesting-level "_" rule-name)))
+                                    (create-proc-sub-fn rule-expression input))
+          (and
+            (vector? rule-expression)
+            (every? vector? rule-expression)) (do
+                                                ;(println "Binding: Got a VECTOR..." (first rule) (second rule))
+                                                (into
+                                                  (conj v
+                                                        rule-name
+                                                        nil)
+                                                  (create-bindings-vector
+                                                    input
+                                                    rule-expression
+                                                    (inc nesting-level))))
+          :default (println "Binding: unknown element for rule:" (str rule)))))
     []
     rules))


Add a test for construct.

Add a test for construct.

--- test/useful/java_test.clj
+++ test/useful/java_test.clj
@@ -4,3 +4,6 @@
 (deftest test-rescue
   (is (= nil (rescue (/ 9 0) nil)))
   (is (= 3   (rescue (/ 9 3) nil))))
+
+(deftest test-construct
+  (is (= "test" (construct String "test"))))


Clean up the Swagger tests, reduce to minimal assurances

--- spec/rook/swagger_spec.clj
+++ spec/rook/swagger_spec.clj
@@ -15,7 +15,8 @@
             [io.aviso.tracker :as t]
             [clojure.tools.logging :as l]
             [io.aviso.rook.server :as server])
-  (:import [org.eclipse.jetty.server Server]))
+  (:import [org.eclipse.jetty.server Server]
+           [javax.servlet.http HttpServletResponse]))

 (defn- swagger-object
   [rook-options swagger-options & ns-specs]
@@ -26,9 +27,7 @@
   [path]
   (client/get (str "http://localhost:8192" path)
               {:throw-exceptions false
-               :content-type     :edn
-               :accept           :edn
-               :as               :clojure}))
+               :accept           :json}))

 (defmacro should-have-status
   [expected-status response]
@@ -40,20 +39,12 @@
                       expected-status#
                       (pretty-print response#))))))

-(defn tap
-  [message data]
-  (l/debugf "%s: %s" message (pretty-print data))
-  data)
-
-(def expected-swagger-data
-  {})
-

 (def swagger-options (-> rs/default-swagger-options
                          (assoc-in [:template :info :title] "Hotels and Rooms API")
                          (assoc-in [:template :info :version] "Pre-Alpha")))

-(binding [t/*log-trace-level* :info]
+#_ (binding [t/*log-trace-level* :info]
   (-> (swagger-object nil swagger-options
                       ["hotels" 'hotels
                        [[:hotel-id "rooms"] 'rooms]])
@@ -71,18 +62,17 @@
                                        :port         8192})]
     #(.stop server)))

-#_
 (describe "io.aviso.rook.swagger"

   (it "can construct swagger data"
-      (let [data (swagger-object nil nil
-                                 ["hotels" 'hotels
-                                  [[:hotel-id "rooms"] 'rooms]])]
-        #_ (should= expected-swagger-data data)))
+      (should-not-be-nil (swagger-object nil swagger-options
+                                         ["hotels" 'hotels
+                                          [[:hotel-id "rooms"]
+                                           'rooms]])))

   (context "end-to-end (synchronous)"

-    (with-all handler (-> (rook/namespace-handler {:swagger true}
+    (with-all handler (-> (rook/namespace-handler {:swagger-options swagger-options}
                                                   ["hotels" 'hotels
                                                    [[:hotel-id "rooms"] 'rooms]])
                           rook/wrap-with-standard-middleware))
@@ -99,14 +89,8 @@

     (it "can expose the resource listing"

-        (->> (get* "/swagger")
-             (should-have-status HttpServletResponse/SC_OK)
-             #_ (tap "response")
-             :body
-             :apis
-             (map :path)
-             sort
-             ;; This is wrong and a fix is coming:
-             (should= ["/hotels" "/hotels/{hotel-id}/rooms"])))))
+        ;; The result is so large and complex, there isn't much we can do to check it here.
+        (->> (get* "/swagger.json")
+             (should-have-status HttpServletResponse/SC_OK)))))

-#_ (run-specs)
+(run-specs)


Minor change to `stroke` snippet in order to display everything inside the canvas.

--- src/cljc/quil/snippets/color/setting.cljc
+++ src/cljc/quil/snippets/color/setting.cljc
@@ -109,19 +109,19 @@

   (comment "grey")
   (q/stroke 120)
-  (q/rect 0 0 100 100)
+  (q/rect 10 10 100 100)

   (comment "semitransparent light grey")
   (q/stroke 80 120)
-  (q/rect 70 70 100 100)
+  (q/rect 80 80 100 100)

   (comment "green")
   (q/stroke 0 255 0)
-  (q/rect 140 140 100 100)
+  (q/rect 150 150 100 100)

   (comment "semitransparent red")
   (q/stroke 255 0 0 120)
-  (q/rect 210 210 100 100))
+  (q/rect 220 220 100 100))

 (defsnippet clear
   "clear"


Added associated-difs to keyword field

Added associated-difs to keyword field

--- src/cmr/indexer/data/concepts/keyword.clj
+++ src/cmr/indexer/data/concepts/keyword.clj
@@ -60,6 +60,7 @@
                                   attrib-keywords
                                   spatial-keywords
                                   temporal-keywords
+                                  associated-difs
                                   platform-short-names
                                   platform-long-names
                                   instrument-short-names


deref-workspace! - check for atom before deref

--- src/com/billpiel/mem_tracer/workspace.clj
+++ src/com/billpiel/mem_tracer/workspace.clj
@@ -1,5 +1,9 @@
 (ns com.billpiel.mem-tracer.workspace
   (:require [com.billpiel.mem-tracer.trace :as trace]))
+
+(defn atom?
+  [v]
+  (instance? clojure.lang.Atom v))

 (defn default-workspace
   [& {:as m}]
@@ -49,9 +53,12 @@

 (defn deref-workspace!
   [ws]
-  (clojure.walk/prewalk #(if (-> %
-                                 meta
-                                 ::trace/entry)
+  (clojure.walk/prewalk #(if (and (-> %
+                                      meta
+                                      ::trace/entry)
+                                  (-> %
+                                      :children
+                                      atom?))
                            (update-in % [:children] deref)
                            %)
                         @ws))


Jump straight to the interesting bits when displaying a problem

--- src/foreclojure/problems.clj
+++ src/foreclojure/problems.clj
@@ -45,7 +45,7 @@
                         (first not-yet-tried)]))))

 (letfn [(problem-link [{id :_id title :title}]
-          (str "" title ""))]
+          (str "" title ""))]
   (defn suggest-problems
     ([] "You've solved them all! Come back later for more!")
     ([problem]
@@ -177,7 +177,8 @@
         [(.getMessage e) *url*]))))

 (defn static-run-code [id raw-code]
-  (apply flash-msg (run-code id raw-code)))
+  (binding [*url* (str *url* "#prob-desc")]
+    (apply flash-msg (run-code id raw-code))))

 (defn render-test-cases [tests]
   [:table {:class "testcases"}


Renamed return-value to result.

Renamed return-value to result.

--- project/analyze-data/test/analyze_data/corpus_to_tf_idf_test.clj
+++ project/analyze-data/test/analyze_data/corpus_to_tf_idf_test.clj
@@ -5,12 +5,12 @@
 (deftest corpus-to-tf-idf-data-test
   (let [corpus [{"item-name" "foo" "item-text" "my dog rover"}
                 {"item-name" "bar" "item-text" "my dog spot"}]
-        return-value (test-ns/corpus-to-tf-idf-data corpus)
-        first-row (first return-value)
-        second-row (second return-value)]
-    (is (sequential? return-value)
+        result (test-ns/corpus-to-tf-idf-data corpus)
+        first-row (first result)
+        second-row (second result)]
+    (is (sequential? result)
         "returns a sequence")
-    (is (= 3 (count return-value))
+    (is (= 3 (count result))
         "contains same number of rows as input plus one header row")
     (is (= ["item-name" "dog" "dog rover" "dog spot" "rover" "spot"]
            first-row)


<label for=> etc.

<label for=> etc.

--- src/golden_kestrel/core.cljs
+++ src/golden_kestrel/core.cljs
@@ -45,8 +45,9 @@
       nil
       (dom/fieldset
         nil
-        (dom/label nil "Badge type")
+        (dom/label #js {:htmlFor "kestrel-badge-type"} "Badge type")
         (dom/select #js {:ref "badgeType"
+                         :id "kestrel-badge-type"
                          :value (:badge-type data)
                          :defaultValue (:badge-type data)
                          :onChange (partial change-data :badge-type)}
@@ -56,8 +57,9 @@
                     (dom/option #js {:value "donut"} "Donut")
                     (dom/option #js {:value "medium-donut"} "Medium donut")
                     (dom/option #js {:value "large-donut"} "Large donut"))
-        (dom/label nil "Popover")
+        (dom/label #js {:htmlFor "kestrel-popover"} "Popover")
         (dom/select #js {:ref "popover"
+                         :id "kestrel-popover"
                          :value (:popover data)
                          :defaultValue (if (= "" (:badge-details data))
                                          (:popover data)
@@ -68,8 +70,9 @@
                     (dom/option #js {:value "right"} "Right")
                     (dom/option #js {:value "bottom"} "Bottom")
                     (dom/option #js {:value "left"} "Left"))
-        (dom/label nil "Details")
+        (dom/label #js {:htmlFor "kestrel-details"} "Details")
         (dom/select #js {:ref "details"
+                         :id "kestrel-details"
                          :value (:badge-details data)
                          :defaultValue (if (= "" (:popover data))
                                          (:badge-details data)
@@ -77,14 +80,16 @@
                          :onChange (partial change-data :badge-details)}
                     (dom/option #js {:value ""} "None")
                     (dom/option #js {:value "right"} "Right"))
-        (dom/label nil "Hide no mentions?")
         (dom/input #js {:ref "hideNoMentions"
+                        :id "kestrel-no-mentions"
                         :type "checkbox"
                         :checked (:hide-no-mentions data)
                         :onChange (partial change-data :hide-no-mentions)}
                    nil)
-        (dom/label nil "DOI")
+        (dom/label #js {:htmlFor "kestrel-no-mentions"} "Hide no mentions?")
+        (dom/label #js {:htmlFor "kestrel-doi"} "DOI")
         (dom/input #js {:ref "doi"
+                        :id "kestrel-doi"
                         :type "text"
                         :size "40"
                         :defaultValue (:doi data)


Rearrange declarations.

Rearrange declarations.

--- src/overtunes/songs/canone_alla_quarta.clj
+++ src/overtunes/songs/canone_alla_quarta.clj
@@ -45,8 +45,6 @@
 ;; Melody                                       ;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(defn sums [series] (map (partial sum-n series) (range (count series))))
-(def repeats (partial mapcat (partial apply repeat)))
 (defn run [[a & bs]]
   (let [up-or-down
           #(if (<= %1 %2)
@@ -57,6 +55,9 @@
         (up-or-down a (first bs))
         (run bs))
       [a])))
+
+(defn sums [series] (map (partial sum-n series) (range (count series))))
+(def repeats (partial mapcat (partial apply repeat)))
 (def runs (partial mapcat run))

 ;(demo# (map g-major


Revert "Control visibility of tabs"

Revert "Control visibility of tabs"

This reverts commit dadfcfd3721fab9f0a07e66647aaa016c7802fb1.

--- src/day8/re_frame_10x/view/container.cljs
+++ src/day8/re_frame_10x/view/container.cljs
@@ -240,48 +240,19 @@
                    [rc/hyperlink
                     :label "Dismiss"
                     :on-click #(rf/dispatch [:errors/dismiss-popup-failed])]])
-                [rc/h-box
+                [rc/box
                  :v-scroll :on
                  :height "100%"
                  :style {:margin-left common/gs-19s}
-                 :children
-                 [[rc/box
-                   :size "1"
-                   :style (tab-styles @selected-tab :event)
-                   :child [event/render]]
-                  [rc/box
-                   :size "1"
-                   :style (tab-styles @selected-tab :fx)
-                   :child [fx/render]]
-                  [rc/box
-                   :size "1"
-                   :style (tab-styles @selected-tab :app-db)
-                   :child [app-db/render db/app-db]]
-                  [rc/box
-                   :size "1"
-                   :style (tab-styles @selected-tab :subs)
-                   :child [subs/render]]
-                  [rc/box
-                   :size "1"
-                   :style (tab-styles @selected-tab :views)
-                   :child [views/render]]
-                  [rc/box
-                   :size "1"
-                   :style (tab-styles @selected-tab :parts)
-                   :child [parts/render]]
-                  [rc/box
-                   :size "1"
-                   :style (tab-styles @selected-tab :timing)
-                   :child [timing/render]]
-                  [rc/box
-                   :size "1"
-                   :style (tab-styles @selected-tab :traces)
-                   :child [traces/render]]
-                  [rc/box
-                   :size "1"
-                   :style (tab-styles @selected-tab :debug)
-                   :child [debug/render]]
-                  [rc/box
-                   :size "1"
-                   :style (tab-styles @selected-tab :settings)
-                   :child [settings/render]]]]]]))
+                 :child (case @selected-tab
+                          :event [event/render]
+                          :fx [fx/render]
+                          :app-db [app-db/render db/app-db]
+                          :subs [subs/render]
+                          :views [views/render]
+                          :parts [parts/render]
+                          :timing [timing/render]
+                          :traces [traces/render]
+                          :debug [debug/render]
+                          :settings [settings/render]
+                          [app-db/render db/app-db])]]]))


Low-priority default :responses in Swagger spec

According to meta-merge documentation, ^:displace is a good solution
for default values. This is still inside the meta-merge, as I don't
see where else I could put it. Perhaps a better solution is available.

--- modules/reitit-swagger/src/reitit/swagger.cljc
+++ modules/reitit-swagger/src/reitit/swagger.cljc
@@ -82,17 +82,18 @@
                                 :x-id ids}))
            accept-route (fn [route]
                           (-> route second :swagger :id (or ::default) (trie/into-set) (set/intersection ids) seq))
+           base-swagger-spec {:responses ^:displace {:default {:description ""}}}
            transform-endpoint (fn [[method {{:keys [coercion no-doc swagger] :as data} :data
                                             middleware :middleware
                                             interceptors :interceptors}]]
                                 (if (and data (not no-doc))
                                   [method
                                    (meta-merge
+                                     base-swagger-spec
                                      (apply meta-merge (keep (comp :swagger :data) middleware))
                                      (apply meta-merge (keep (comp :swagger :data) interceptors))
                                      (if coercion
                                        (coercion/get-apidocs coercion :swagger data))
-                                     (when-not (:responses data) {:responses {:default {:description ""}}})
                                      (select-keys data [:tags :summary :description])
                                      (strip-top-level-keys swagger))]))
            transform-path (fn [[p _ c]]


EDITED EQ of beat

EDITED EQ of beat

--- src/leap_step/example/popular.clj
+++ src/leap_step/example/popular.clj
@@ -2,7 +2,7 @@
   (:use [overtone.core]
         [overtone.synth.stringed]))

-(defsynth dubstep [rootNote 34 bpm 120 wobble 8 note 34 snare-vol 1 kick-vol 1 hihat-vol 1 v 1 chord-vol 0 wob-vol 0 wob4-vol 0 out-bus 0]
+(defsynth dubstep [rootNote 34 bpm 120 wobble 8 note 34 snare-vol 0.7 kick-vol 0.7 hihat-vol 0.7 v 0.7 chord-vol 0 wob-vol 0 wob4-vol 0 out-bus 0]

   (defn wub [offset b-freq roomsize]
     (let [trig-i (impulse:kr (/ bpm 120))


removed unbalanced bracket

removed unbalanced bracket

--- src/leiningen/new/fwrum/core.cljs
+++ src/leiningen/new/fwrum/core.cljs
@@ -48,8 +48,7 @@
        [:tr [:td "Michelle"]
         [:td "42"]]
        [:tr [:td "Frank"]
-        [:td "46"]]]]]]
-   ])
+        [:td "46"]]]]]])

 ;;
 ;; Put the app/game in here


Attempting to solve 5.11, 5.12... committing so I can go on at home

--- src/fpinscala/strictness_and_laziness.clj
+++ src/fpinscala/strictness_and_laziness.clj
@@ -183,7 +183,7 @@
   "Fibonacci sequence"
   []
   (letfn [(go [x0, x1]
-            (cons x0 (lazy-seq (go x1, (+ x0 x1)))))]
+              (cons x0 (lazy-seq (go x1, (+ x0 x1)))))]
     (stream-cons 0 (go 1 1))))
 ;fpins
 (defn fibs-fpins                                            ; well :) I should have seen it... there is unnecessary stream-cons :)
@@ -194,3 +194,20 @@
     (go 0 1)))
 ;-----------------------------------------------------------------------

+;5.11
+;mine
+(defn unfold
+  "Unfold for exercise 5.11"
+  [z f]                                                     ;f produces both next value and next state
+  (let [val (f z)]
+    (when val
+      (cons val (lazy-seq (unfold val f))))))
+;fpins
+;-----------------------------------------------------------------------
+
+;5.12
+(defn fibs-via-unfold
+  "Fibonacci sequence via unfold"
+  []
+  (cons 0 (map first (unfold [0 1] #(let [x0 (first %) x1 (second %)]
+                                     [x1 (+ x0 x1)])))))


Fix a test

Fix a test

--- test/circle/backend/build/test_run_build.clj
+++ test/circle/backend/build/test_run_build.clj
@@ -71,9 +71,8 @@
 (fact "running an inferred build with zero actions marks the project disabled"
   (let [build (minimal-build :actions [])]
     (dosync
-     (alter build assoc :_project_id (-> test-project :_id))) => anything
      (run-build build) => anything
-     (-> (mongo/fetch-one :projects :where {:_id (-> test-project :_id)}) :state) => "disabled"))
+     (-> (mongo/fetch-one :projects :where {:vcs_url (-> test-project :vcs_url)}) :state) => "disabled")))

 (fact "running a disabled build"
   (let [build (minimal-build :actions [])


Added missing slashes in pr namespaces

Added missing slashes in pr namespaces

--- src/kabob/core/namespace.clj
+++ src/kabob/core/namespace.clj
@@ -36,16 +36,16 @@
         ;; be removed once the 'http:/' bug is resolved.
         ;; ---------------------------------------------------------------------------
         ("bnode" "http://ccp.ucdenver.edu/bnode/")
-        ("bird_pr","http:/birdgenenames.org/cgnc/GeneReport?id=")
-        ("rgd_pr","http:/rgd.mcw.edu/rgdweb/report/gene/main.html?id=")
-        ("tair_pr","http:/www.arabidopsis.org/servlets/TairObject?type=")
-        ("hgnc_pr","http:/www.genenames.org/cgi-bin/gene_symbol_report?hgnc_id=")
-        ("yeast_pr","http:/www.yeastgenome.org/cgi-bin/locus.fpl?dbid=")
-        ("flybase_pr","http:/flybase.org/reports/")
-        ("eco_pr","http:/www.ecogene.org/gene/")
-        ("pombase_pr","http:/www.pombase.org/spombe/result/")
-        ("wormbase_pr","http:/www.wormbase.org/species/c_elegans/gene/")
-        ("zfin_pr","http:/zfin.org/action/marker/view/")
+        ("bird_pr","http://birdgenenames.org/cgnc/GeneReport?id=")
+        ("rgd_pr","http://rgd.mcw.edu/rgdweb/report/gene/main.html?id=")
+        ("tair_pr","http://www.arabidopsis.org/servlets/TairObject?type=")
+        ("hgnc_pr","http://www.genenames.org/cgi-bin/gene_symbol_report?hgnc_id=")
+        ("yeast_pr","http://www.yeastgenome.org/cgi-bin/locus.fpl?dbid=")
+        ("flybase_pr","http://flybase.org/reports/")
+        ("eco_pr","http://www.ecogene.org/gene/")
+        ("pombase_pr","http://www.pombase.org/spombe/result/")
+        ("wormbase_pr","http://www.wormbase.org/species/c_elegans/gene/")
+        ("zfin_pr","http://zfin.org/action/marker/view/")
         ;; ---------------------------------------------------------------------------

        ("kiao" "http://kabob.ucdenver.edu/iao/")


avoid writing to stdout when possible in npm cli script

fixes #925

--- src/main/shadow/cljs/npm/cli.cljs
+++ src/main/shadow/cljs/npm/cli.cljs
@@ -68,7 +68,7 @@
 (defn run! [project-root cmd args proc-opts]
   (let [executable (which/sync cmd #js {:nothrow true})]
     (if-not executable
-      (do (println (str "Executable '" cmd "' not found on system path."))
+      (do (log (str "Executable '" cmd "' not found on system path."))
           (js/process.exit 1))

       (let [spawn-opts
@@ -780,15 +780,15 @@
                        (or (get-in pjson ["devDependencies" "shadow-cljs"])
                            (get-in pjson ["dependencies" "shadow-cljs"]))))

-        (println "------------------------------------------------------------------------------")
-        (println)
-        (println "   WARNING: shadow-cljs not installed in project.")
-        (println "   See https://shadow-cljs.github.io/docs/UsersGuide.html#project-install")
-        (println)
-        (println "------------------------------------------------------------------------------")))
+        (log "------------------------------------------------------------------------------")
+        (log)
+        (log "   WARNING: shadow-cljs not installed in project.")
+        (log "   See https://shadow-cljs.github.io/docs/UsersGuide.html#project-install")
+        (log)
+        (log "------------------------------------------------------------------------------")))

     (catch :default e
-      (println "WARNING: package.json not found. See https://shadow-cljs.github.io/docs/UsersGuide.html#project-install"))))
+      (log "WARNING: package.json not found. See https://shadow-cljs.github.io/docs/UsersGuide.html#project-install"))))

 (defn main [args]

@@ -807,9 +807,9 @@
         :else
         (let [config-path (ensure-config)]
           (if-not config-path
-            (do (println "Could not find shadow-cljs.edn config file.")
-                (println "To create one run:")
-                (println "  shadow-cljs init"))
+            (do (log "Could not find shadow-cljs.edn config file.")
+                (log "To create one run:")
+                (log "  shadow-cljs init"))

             (let [project-root
                   (path/dirname config-path)


add-user! so you don't have to insert directly.

--- src/kixi/hecuba/security.clj
+++ src/kixi/hecuba/security.clj
@@ -13,6 +13,24 @@
 (derive ::programme-manager ::project-manager)
 (derive ::admin ::programme-manager)
 (derive ::super-admin ::admin)
+
+(defn add-user!
+  ([store username password roles programmes projects]
+     (db/with-session [session (:hecuba-session store)]
+       (db/execute
+        session
+        (hayt/update :users
+                     (hayt/set-columns
+                      {:username username
+                       :password (creds/hash-bcrypt password)
+                       :data     (pr-str {:roles      (set roles)
+                                          :programmes (set programmes)
+                                          :projects   (set projects)})})
+                     (hayt/where [[= :id username]])))))
+  ([store username password roles]
+     (add-user! store username password roles #{} #{})))
+
+;; (kixi.hecuba.security/add-user! (:store system) "support@example.com" "<password>" #{:kixi.hecuba.security/super-admin})

 (defn get-user [store]
   (fn [username]


Add async test for connect mutation

Add async test for connect mutation

--- test/com/wsscode/pathom/connect_test.cljc
+++ test/com/wsscode/pathom/connect_test.cljc
@@ -268,15 +268,15 @@
 (def parser
   (p/parser {:mutate pc/mutate
              ::p/plugins
-             [(p/env-wrap-plugin #(assoc % ::pc/indexes @base-indexes))
-              (p/env-plugin {::p/reader             [{:cache (comp deref ::p/request-cache)}
-                                                     p/map-reader
-                                                     {::env #(p/join % %)}
-                                                     pc/all-readers
-                                                     (p/placeholder-reader ">")]
-                             ::pc/resolver-dispatch resolver-fn
-                             ::pc/mutate-dispatch   mutate-fn})
-              p/request-cache-plugin]}))
+                     [(p/env-wrap-plugin #(assoc % ::pc/indexes @base-indexes))
+                      (p/env-plugin {::p/reader             [{:cache (comp deref ::p/request-cache)}
+                                                             p/map-reader
+                                                             {::env #(p/join % %)}
+                                                             pc/all-readers
+                                                             (p/placeholder-reader ">")]
+                                     ::pc/resolver-dispatch resolver-fn
+                                     ::pc/mutate-dispatch   mutate-fn})
+                      p/request-cache-plugin]}))

 (deftest test-reader
   (testing "reading root entity"
@@ -368,7 +368,7 @@
       (is (= 1 @counter)))))

 (defmutation 'call/op
-  {}
+  {::pc/output [:user/id]}
   (fn [env input]
     {:user/id 1}))

@@ -397,11 +397,21 @@
   (fn [_ {:keys [color-async]}]
     {:color-async2 (str color-async "-derived")}))

+(defmutation 'call/op-async
+  {::pc/output [:user/id]}
+  (fn [env input]
+    (go
+      {:user/id 1})))
+
 (def async-parser
-  (p/async-parser {::p/plugins
-                   [(p/env-plugin {::p/reader             [p/map-reader pc/all-async-readers]
+  (p/async-parser {:mutate
+                   pc/mutate
+
+                   ::p/plugins
+                   [(p/env-wrap-plugin #(assoc % ::pc/indexes @base-indexes))
+                    (p/env-plugin {::p/reader             [p/map-reader pc/all-async-readers]
                                    ::pc/resolver-dispatch resolver-fn
-                                   ::pc/indexes           @base-indexes})
+                                   ::pc/mutate-dispatch   mutate-fn})
                     p/request-cache-plugin]}))

 #?(:clj
@@ -418,6 +428,12 @@
                                         {:async-thing-value "b"}
                                         {:async-thing-value "c"}]}))
          (is (= 1 @counter))))))
+
+#?(:clj
+   (deftest test-mutate-async
+     (testing "call mutation and parse response"
+       (is (= (<!! (async-parser {} [{'(call/op {}) [:user/id :user/name]}]))
+              {'call/op {:user/id 1, :user/name "Mel"}})))))

 (def index
   #::pc{:index-io {#{:customer/id}                                         #:customer{:external-ids  {}


This verison did it

This verison did it

--- src/plugins/Scripts/Funimage/Morphology/Branch_Point_Counter.clj
+++ src/plugins/Scripts/Funimage/Morphology/Branch_Point_Counter.clj
@@ -3,6 +3,8 @@
 ; @OUTPUT ImagePlus imp

 ;(require '[funimage.imp :as ij1])
+
+(ij.IJ/run "Options..." "iterations=1 count=1 black")

 (def orig-name (.getTitle imp))
 (def directory (ij.IJ/getDirectory "image"))


Improve strobe cue flashing.

Improve strobe cue flashing.

--- src/afterglow/examples.clj
+++ src/afterglow/examples.clj
@@ -337,12 +337,11 @@
                            (fn [var-map] (fun/strobe-2 (str "Strobe " name) fixtures
                                                        (:level var-map 50) (:lightness var-map 100)))
                            :color :purple
-                           :color-fn (fn [cue active show _]
-                                       (let [base-color (or (show/get-variable :strobe-color)
-                                                            (:color cue))]
-                                         (if (> (mod (System/currentTimeMillis) 500) 400)
-                                           white
-                                           base-color)))
+                           :color-fn (fn [cue active show snapshot]
+                                       (if (> (rhythm/snapshot-beat-phase snapshot 0.5) 0.7)
+                                         white
+                                         (or (show/get-variable :strobe-color)
+                                             (:color cue))))
                            :held true
                            :priority 100
                            :variables [{:key "level" :min 0 :max 100 :start 100 :name "Level"}


Fix timeouts

Fix timeouts

--- src/airhead_cljs/core.cljs
+++ src/airhead_cljs/core.cljs
@@ -26,8 +26,8 @@
   (let [current-track (atom {})
         reset         #(reset! current-track (% "track"))
         get-track     #(get-json "/api/queue/current" reset)]
-    (js/setTimeout get-track 1000)
     (fn []
+      (js/setTimeout get-track 1000)
       [:div
        [track-span @current-track]])))

@@ -35,8 +35,8 @@
   (let [playlist     (atom [])
         reset        #(reset! playlist (% "items"))
         get-playlist #(get-json "/api/queue" reset)]
-    (js/setTimeout get-playlist 1000)
     (fn []
+      (js/setTimeout get-playlist 1000)
       [:div
        [:h2 "Playlist"]
        [:ul (for [track @playlist]


- Changed the ClassLoader passed to the JavaReflector in clara.rules.compiler to be a new DynamicClassLoader via clojure.lang.RT/makeClassLoader, to allow for dynamically added types to be reflected on, even if the compile-time "base" loader for clara is not a DynamicClassLoader

--- src/main/clojure/clara/rules/compiler.clj
+++ src/main/clojure/clara/rules/compiler.clj
@@ -12,9 +12,9 @@

 (def ^:private reflector
   "For some reason (bug?) the default reflector doesn't use the
-  Clojure dynamic class loader, which prevents reflecting on
+   Clojure dynamic class loader, which prevents reflecting on
   `defrecords`.  Work around by supplying our own which does."
-  (clojure.reflect.JavaReflector. (clojure.lang.RT/baseLoader)))
+  (clojure.reflect.JavaReflector. (clojure.lang.RT/makeClassLoader)))

 ;; This technique borrowed from Prismatic's schema library.
 (defn compiling-cljs?


lose make-metadata

lose make-metadata

--- src/main/clojure/org/dada/demo/whales.clj
+++ src/main/clojure/org/dada/demo/whales.clj
@@ -132,22 +132,6 @@
 (import org.dada.core.AggregatedModelView$Aggregator)

 ;; make a class to hold key, version and aggregate value...
-
-(defn make-metadata [classname pktype pkname fieldtype fieldname]
-  (let [properties (list [pktype pkname] [(Integer/TYPE) "version"] [fieldtype fieldname])
-	class (apply make-class classname Object properties)]
-  (new GetterMetadata
-       (proxy [Creator] [] (create [args] (apply make-instance class args)))
-       (collection pkname "version")
-       (map first properties)
-       (map second properties)
-       (map
-	(fn [property]
-	    (make-proxy-getter
-	     class
-	     (first property)
-	     (second property)))
-	properties))))

 (def aggregator-initial-values
      {
@@ -282,7 +266,6 @@
 ;; initial-value - (new Float "0")
 ;; accessor - .getLength

-;; make-metadata [classname pktype pkname fieldtype fieldname]
 ;; make-aggregator [metadata modelname pkval initial-value fieldname]
 (def
  sum-aggregator


restrict generation to make test more precise

--- test/babel/test/en.cljc
+++ test/babel/test/en.cljc
@@ -143,12 +143,12 @@
   (let [result
         (generate {:synsem {:cat :noun
                             :sem {:number :sing
+                                  :mod '()
                                   :spec {:pred :of
                                          :of {:pred :Juana}}
                                   :pred :cane}}})]
     (is (not (nil? result)))
-    (is (= :cane
-           (get-in result [:synsem :sem :pred])))))
+    (is (= "Juana's dog" (fo result)))))

 (deftest generate-with-possessive-2
   (let [result


paste the clip when you click on it

paste the clip when you click on it

--- src-cljs/frontend/components/clip_viewer.cljs
+++ src-cljs/frontend/components/clip_viewer.cljs
@@ -48,7 +48,7 @@
           (for [clip (reverse (sort-by #(some-> % :clip/uuid d/squuid-time-millis) clips))]
             (html
              [:div.clip
-              [:a.recent-doc.make {:href (:clip/s3-url clip)}
+              [:a.recent-doc.make {:on-click #(cast! :clip-pasted clip)}
                [:object {:data (:clip/s3-url clip) :type "image/svg+xml"}]
                [:i.loading-ellipses
                 [:i "."]
@@ -56,13 +56,16 @@
                 [:i "."]]
                (if (:clip/important? clip)
                  [:a.clip-tag {:role "button"
-                               :on-click #(cast! :unimportant-clip-marked {:clip/uuid (:clip/uuid clip)})}
+                               :on-click #(do (cast! :unimportant-clip-marked {:clip/uuid (:clip/uuid clip)})
+                                              (utils/stop-event %))}
                   (common/icon :starred)]
                  [:a.clip-tag {:role "button"
-                               :on-click #(cast! :important-clip-marked {:clip/uuid (:clip/uuid clip)})}
+                               :on-click #(do (cast! :important-clip-marked {:clip/uuid (:clip/uuid clip)})
+                                              (utils/stop-event %))}
                   (common/icon :star)])
                [:a.clip-delete {:role "button"
-                                :on-click #(cast! :delete-clip-clicked {:clip/uuid (:clip/uuid clip)})}
+                                :on-click #(do (cast! :delete-clip-clicked {:clip/uuid (:clip/uuid clip)})
+                                               (utils/stop-event %))}
                 (common/icon :times)]]]))])))))

 (defn clip-viewer* [app owner]


Extract fn for clarity.

Extract fn for clarity.

--- test/kolmogorov_music/test/kolmogorov.clj
+++ test/kolmogorov_music/test/kolmogorov.clj
@@ -31,14 +31,14 @@
        (drop-while (complement applies?))
        first))

-(first-that #(< 10 %) (range))
+(defn more-complex-than? [n limit]
+  (< limit (minimal-complexity n)))

 (defn enterprise*
   "Find the first natural number with a complexity greater than f."
   [expr ns]
-  (let [lower-limit (kolmogorov/complexity* expr ns)]
-    (->> (range)
-         (first-that (fn [n] (< lower-limit (minimal-complexity n)))))))
+  (->> (range)
+       (first-that #(more-complex-than? % (kolmogorov/complexity* expr ns)))))

 (defmacro enterprise
   [expr]


Fail / warn on invalid flags to the template generator

Fail / warn on invalid flags to the template generator

--- edge-app-template/src/clj/new/edge_app_template.clj
+++ edge-app-template/src/clj/new/edge_app_template.clj
@@ -17,54 +17,107 @@
       [(format "%d%d" dd-port dd-port)
        (format "%d00" dd-port)])))

+
+(def supported-flags ["sass" "cljs" "reframe"])
+
+(def flags-opts (set (map #(str "--" %) supported-flags)))
+
+;;The following functions involving the flags validation are taken from:
+;;https://github.com/bhauman/figwheel-main-template/blob/master/src/leiningen/new/figwheel_main.clj
+
+(defn- next-row
+  [previous current other-seq]
+  (reduce
+    (fn [row [diagonal above other]]
+      (let [update-val (if (= other current)
+                          diagonal
+                          (inc (min diagonal above (peek row))))]
+        (conj row update-val)))
+    [(inc (first previous))]
+    (map vector previous (next previous) other-seq)))
+
+(defn- levenshtein
+  [sequence1 sequence2]
+  (peek
+    (reduce (fn [previous current] (next-row previous current sequence2))
+            (map #(identity %2) (cons nil sequence2) (range))
+            sequence1)))
+
+(defn- similar [ky ky2]
+  (let [dist (levenshtein (str ky) (str ky2))]
+    (when (<= dist 2) dist)))
+
+(defn similar-options [opt]
+  (second (first (sort-by first
+                          (filter first (map (juxt (partial similar opt) identity)
+                                             flags-opts))))))
+(defn parse-opts [opts]
+  (reduce (fn [accum opt]
+            (cond
+              (flags-opts opt) (conj accum (keyword (subs opt 2)))
+              :else
+              (let [suggestion (similar-options opt)]
+                (reduced
+                 {:error
+                  (format
+                   "Unknown option '%s' %s" opt
+                   (str
+                    (when suggestion
+                      (format
+                       "\n --> Perhaps you intended to use the '%s' option?" suggestion))))}))))
+          #{} opts))
+
 (defn edge-app-template
   "FIXME: write documentation"
   [name & opts]
   (binding [*dir* (sanitize-ns name)]
-    (let [opts (set (map #(keyword (subs % 2)) opts))
-          cljs? (contains? opts :cljs)
-          sass? (contains? opts :sass)
-          reframe? (contains? opts :reframe)
-          data {:name (project-name name)
-                :sanitized (name-to-path name)
-                :root-ns (multi-segment (sanitize-ns name))
-                :sass sass?
-                :cljs (or cljs? reframe?)
-                :reframe reframe?
-                :kick (or sass?
-                          reframe?
-                          cljs?)
-                :server-port (generate-port)
-                :figwheel-port (generate-port)}]
-      (println (str "Generating fresh 'clj new' edge.app-template project into " *dir* "."))
-      (->files data
-               ["deps.edn" (render "deps.edn" data)]
-               ["src/{{sanitized}}/foo.clj" (render "foo.clj" data)]
-               ["src/config.edn" (render "config.edn" data)]
-               ["dev/dev.clj" (render "dev.clj" data)]
-               ["dev/log_dev_app.properties" (render "log_dev_app.properties" data)]
-               [".dir-locals.el" (render "dir-locals.el" data)])
-      (binding [*force?* true]
-        (when (:kick data)
+    (let [parsed-opts (parse-opts opts)]
+      (if (:error parsed-opts)
+        (do (println (:error parsed-opts))
+            (System/exit 1))
+        (let [cljs? (contains? parsed-opts :cljs)
+              sass? (contains? parsed-opts :sass)
+              reframe? (contains? parsed-opts :reframe)
+              data {:name (project-name name)
+                    :sanitized (name-to-path name)
+                    :root-ns (multi-segment (sanitize-ns name))
+                    :sass sass?
+                    :cljs (or cljs? reframe?)
+                    :reframe reframe?
+                    :kick (or sass?
+                              reframe?
+                              cljs?)
+                    :server-port (generate-port)
+                    :figwheel-port (generate-port)}]
+          (println (str "Generating fresh 'clj new' edge.app-template project into " *dir* "."))
           (->files data
-                   ["src/index.html" (render "index.html" data)]
-                   ["target/dev/.gitkeep" ""]
-                   ["target/prod/.gitkeep" ""]))
-        (if (:sass data)
-          (->files data
-                   ["src/{{name}}.scss" (render "app.css" data)])
-          (->files data
-                   ["src/public/{{name}}.css" (render "app.css" data)]))
-        (when (:cljs data)
-          (->files data
-                   ["src/{{sanitized}}/frontend/main.cljs"
-                    (render (cond
-                              reframe? "reframe/main.cljs"
-                              cljs? "main.cljs")
-                            data)]))
-        (when (:reframe data)
-          (->files data
-                   ["src/{{sanitized}}/frontend/views.cljs" (render "reframe/views.cljs" data)]
-                   ["src/{{sanitized}}/frontend/db.cljs" (render "reframe/db.cljs" data)]
-                   ["src/{{sanitized}}/frontend/handlers.cljs" (render "reframe/handlers.cljs" data)]
-                   ["src/{{sanitized}}/frontend/subs.cljs" (render "reframe/subs.cljs" data)]))))))
+                   ["deps.edn" (render "deps.edn" data)]
+                   ["src/{{sanitized}}/foo.clj" (render "foo.clj" data)]
+                   ["src/config.edn" (render "config.edn" data)]
+                   ["dev/dev.clj" (render "dev.clj" data)]
+                   ["dev/log_dev_app.properties" (render "log_dev_app.properties" data)]
+                   [".dir-locals.el" (render "dir-locals.el" data)])
+          (binding [*force?* true]
+            (when (:kick data)
+              (->files data
+                       ["src/index.html" (render "index.html" data)]
+                       ["target/dev/.gitkeep" ""]
+                       ["target/prod/.gitkeep" ""]))
+            (if (:sass data)
+              (->files data
+                       ["src/{{name}}.scss" (render "app.css" data)])
+              (->files data
+                       ["src/public/{{name}}.css" (render "app.css" data)]))
+            (when (:cljs data)
+              (->files data
+                       ["src/{{sanitized}}/frontend/main.cljs"
+                        (render (cond
+                                  reframe? "reframe/main.cljs"
+                                  cljs? "main.cljs")
+                                data)]))
+            (when (:reframe data)
+              (->files data
+                       ["src/{{sanitized}}/frontend/views.cljs" (render "reframe/views.cljs" data)]
+                       ["src/{{sanitized}}/frontend/db.cljs" (render "reframe/db.cljs" data)]
+                       ["src/{{sanitized}}/frontend/handlers.cljs" (render "reframe/handlers.cljs" data)]
+                       ["src/{{sanitized}}/frontend/subs.cljs" (render "reframe/subs.cljs" data)]))))))))


Actually, use StandardAnalyzer for queries

Otherwise from:dishevelled.net matches every "net" address :)  Just use
the new analyzer at index time to build up the right terms.

--- src/net/dishevelled/mailindex.clj
+++ src/net/dishevelled/mailindex.clj
@@ -472,7 +472,7 @@
         all-fields (expand-query
                     (.rewrite (.parse (doto (MultiFieldQueryParser.
                                              (into-array search-fields)
-                                             (doto (MailindexAnalyzer.)
+                                             (doto (StandardAnalyzer.)
                                                (.setVersion Version/LUCENE_6_1_0)))
                                         (.setDefaultOperator QueryParser$Operator/AND))
                                       (normalcase querystr))


Add also a complete-follow-ups parameter to the migration script, small fixes.

--- src/oc/storage/util/migrate_bookmarks.clj
+++ src/oc/storage/util/migrate_bookmarks.clj
@@ -2,11 +2,11 @@
   "Get all the existing uncompleted follow-ups and create a bookmark for every one of them.
    To perform a dry run and simulate the update use:

-  lein run -m oc.storage.util.migrate-bookmark
+  lein run -m oc.storage.util.migrate-bookmarks

   To actually update the entries:

-  lein run -m oc.storage.util.migrate-bookmark -f
+  lein run -m oc.storage.util.migrate-bookmarks -f

   Use -s/--self-only to create bookmarks only for self created follow-ups."

@@ -54,7 +54,7 @@
       (f (first items)) idx
       :else (recur (inc idx) (rest items)))))

-(defn- migrate-follow-ups-for-entry [conn e self-only? dry-run?]
+(defn- migrate-follow-ups-for-entry [conn e self-only? dry-run? complete-follow-ups?]
   (let [follow-ups (:follow-ups e)
         new-bookmarks (remove nil? (mapv #(when (and (not (:completed? %))
                                            (or (not self-only?)
@@ -63,22 +63,27 @@
                                     (:assignee %))
                             follow-ups))
         updated-bookmarks (clojure.set/union (set (map :user-id new-bookmarks)) (:bookmarks e))
-        updated-follow-ups (mapv #(if (and (not (:completed? %))
-                                             (or (not self-only?)
-                                                 (and self-only?
-                                                      (= (-> % :assignee :user-id) (-> % :author :user-id)))))
-                                      (assoc % :completed? true)
-                                      %)
-                              follow-ups)]
+        updated-follow-ups (when complete-follow-ups?
+                             (mapv #(if (and (not (:completed? %))
+                                               (or (not self-only?)
+                                                   (and self-only?
+                                                        (= (-> % :assignee :user-id) (-> % :author :user-id)))))
+                                        (assoc % :completed? true)
+                                        %)
+                                follow-ups))]
     (println "  Updating entry:" (:uuid e))
     (println "    Adding bookmarks for:" updated-bookmarks)
     (println "    Updating follow-ups:")
     (doseq [f updated-follow-ups]
       (println "     -" (:uuid f) "completed?" (:completed? f) "self?" (= (-> f :assignee :user-id) (-> f :author :user-id))))
     (when-not dry-run?
-      (println "  Actually updating entry:" (:uuid e))
-      (entry/update-entry-no-user! conn (:uuid e) (merge e {:follow-ups updated-follow-ups
-                                                            :bookmarks updated-bookmarks})))))
+      (if complete-follow-ups?
+        (println "  Actually updating entry's bookmarks and follow-ups:" (:uuid e))
+        (println "  Actually updating entry's bookmarks:" (:uuid e)))
+      (entry/update-entry-no-user! conn (:uuid e) (merge e (if complete-follow-ups?
+                                                             {:follow-ups updated-follow-ups
+                                                              :bookmarks updated-bookmarks}
+                                                             {:bookmarks updated-bookmarks}))))))

 (defn- exit [status msg]
   (println msg)
@@ -86,11 +91,14 @@

 (def cli-options
   [["-f" "--force-update"]
+   ["-c" "--complete-follow-ups"] ;; Use with -f
    ["-s" "--self-only"]])

 (defn -main [& args]
   (let [{:keys [options arguments errors summary]} (parse-opts args cli-options)]
-    (println "Running bookmarks migration with options: dry-run" (not (:force-update options)) "self-only" (:self-only options))
+    (println "Running bookmarks migration with options: dry-run" (not (:force-update options))
+      "self-only" (:self-only options)
+      "complete-follow-ups" (:complete-follow-ups options))
     (let [conn (db/init-conn c/db-options)]
       (try
         (create-temp-index conn)
@@ -99,11 +107,16 @@
             (let [entries (entries-for-org conn (:uuid o))]
               (println "Org:" (:uuid o) "-" (:name o))
               (doseq [e entries]
-                (migrate-follow-ups-for-entry conn e (:self-only options) (not (:force-update options)))))))
+                (migrate-follow-ups-for-entry conn e
+                 (:self-only options)                 ; Only self created follow-ups
+                 (not (:force-update options))        ; Make changes in DB, no dry-run
+                 (and (:force-update options)         ; Complete the relative follow-up,
+                      (:complete-follow-ups options)) ; use this to keep them to re-run the import
+                 )))))
         (delete-temp-index conn)
         (exit 0 "\n")

         (catch Exception e
           (println e)
           (delete-temp-index conn)
-          (exit 1 "Bookmark migration exception."))))))+          (exit 1 "Bookmark migration exception."))))))


page.connections-test: rename fact for clarity

--- test/busa_server/page/connections_test.clj
+++ test/busa_server/page/connections_test.clj
@@ -15,7 +15,7 @@
   (connections-page/url connection-page-details) =>
     "https://liput.matkahuolto.fi/connectionlist?lang=fi&arrivalPlaceId=10&departurePlaceId=20&departureDate=2016-01-01")

-(fact "should return departure dates from connections page"
+(fact "should return departure times from connections page"
   (connections-page/departure-times connection-page-details) => (has-prefix ["00:00" "01:10" "06:45" "07:15"])
   (provided
     (driver/fetch anything) => (slurp "connections.html")))


working player select

working player select

--- src/cljs/foosball/locations/report_match.cljs
+++ src/cljs/foosball/locations/report_match.cljs
@@ -28,31 +28,13 @@
         (loc/set-location app (:id v)))
       (.back js/history))))

-(defn selected-players [report-match]
-  (let [paths (for [team   [:team1 :team2]
-                    player [:player1 :player2]]
-                [team player])]
-    (->> paths
-         (map (fn [p] (get-in report-match p)))
+(defn selected-players [team other-team]
+  (let [players (for [t      [team other-team]
+                      player [:player1 :player2]]
+                  (get t player))]
+    (->> players
          (filter identity)
          set)))
-
-(defn- render-players-select [report-match players selected-player-path change-ch]
-  (let [selected-player  (get-in report-match selected-player-path)
-        other-selected   (disj (selected-players report-match) selected-player)
-        player-lookup    (group-by :id players)
-        possible-options (->> players
-                              (filter (complement (partial contains? other-selected))))]
-    [:select.form-control
-     {:value     (or (:id selected-player) "nil")
-      :on-change (fn [e]
-                   (let [player-id (-> e .-target .-value uuid/make-uuid-from)
-                         player    (first (get player-lookup player-id))]
-                     (put! change-ch player)))}
-     [:option {:value "nil" :disabled "disabled"} "Pick a player"]
-     (map (fn [{:keys [id name]}]
-            [:option {:value id} name])
-          possible-options)]))

 (defn team-score-component [team owner {:keys [score-ch]}]
   (reify
@@ -67,7 +49,28 @@
                                            :placeholder "0"
                                            :input-props {:type "number"}}})]]))))

-(defn team-player-component [{:keys [active-players player-num] :as team} owner {:keys [change-ch]}]
+(defn- render-players-select [{:keys [team other-team active-players]}
+                              selected-player-path
+                              change-ch]
+  (let [selected-player  (get-in team selected-player-path)
+        other-selected   (disj (selected-players team other-team) selected-player)
+        possible-options (->> active-players
+                              (filter (complement (partial contains? other-selected))))]
+    [:select.form-control
+     {:value     (or (:id selected-player) "nil")
+      :on-change (fn [e]
+                   (let [player-lookup (group-by :id active-players)
+                         player-id     (-> e .-target .-value uuid/make-uuid-from)
+                         player        (first (get player-lookup player-id))]
+                     (put! change-ch player)))}
+     [:option {:value "nil" :disabled "disabled"} "Pick a player"]
+     (map (fn [{:keys [id name]}]
+            [:option {:value id} name])
+          possible-options)]))
+
+(defn team-player-component [{:keys [team other-team active-players player-num] :as teams}
+                             owner
+                             {:keys [change-ch]}]
   (reify
     om/IRender
     (render [_]
@@ -76,22 +79,29 @@
          [:div.form-group
           [:label.control-label.col-lg-4 (str "Player " player-num)]
           [:div.controls.col-lg-8
-           (render-players-select team active-players [player-selector] change-ch)]])))))
+           (render-players-select teams [player-selector] change-ch)]])))))

 (defn team-selector [team-num]
   (keyword (str "team" team-num)))
+
+(defn other-team [this-team]
+  (let [difference (disj #{:team1 :team2} this-team)]
+    (when (= 1 (count difference))
+      (first difference))))

 (defn- render-team-controls [{:keys [report-match active-players] :as app}
                              team-num
                              {:keys [score player1 player2] :as chans}]
-  (let [team          ((team-selector team-num) report-match)
-        render-player (fn [num change-ch]
-                        (om/build team-player-component team
-                                  {:opts      {:change-ch change-ch}
-                                   :react-key (str team-selector "-" num)
-                                   :fn        (fn [t] (merge t {:active-players active-players
-                                                               :player-num num}))}))]
-    (debug "render team" team)
+  (let [team-sel       (team-selector team-num)
+        other-team-sel (other-team team-sel)
+        render-player  (fn [num change-ch]
+                         (om/build team-player-component (team-sel report-match)
+                                   {:opts      {:change-ch change-ch}
+                                    :react-key (str team-selector "-" num)
+                                    :fn        (fn [t] {:team t
+                                                       :other-team (other-team-sel report-match)
+                                                       :active-players active-players
+                                                       :player-num num})}))]
     [:div.col-lg-5.well.well-lg
      [:h2 (str "Team " team-num ":")]
      (render-player 1 player1)
@@ -110,11 +120,6 @@
                                           :type "date"
                                           :value formated-date}]]]]))

-(defn other-team [this-team]
-  (let [difference (disj #{:team1 :team2} this-team)]
-    (when (= 1 (count difference))
-      (first difference))))
-
 (defn valid-score? [this other]
   (:team1score (vm/validate-scores [this other])))

@@ -134,8 +139,7 @@
           (update-score! report-match other other-score score))))))

 (defn handle-player-update [report-match path player]
-  (debug "handle update" path player)
-  (om/update! @report-match path player))
+  (om/update! report-match path player))

 (defn report-match-component [{:keys [active-players report-match] :as app} owner]
   (reify
@@ -144,8 +148,8 @@
       (letfn [(team-chans-fact [] {:score (chan)
                                    :player1 (chan)
                                    :player2 (chan)})]
-              {:team1 (team-chans-fact)
-               :team2 (team-chans-fact)}))
+        {:team1 (team-chans-fact)
+         :team2 (team-chans-fact)}))

     om/IWillMount
     (will-mount [_]
@@ -156,14 +160,17 @@
         (go-loop []
           (let [[v c] (alts! (keys chan-to-path-map))
                 path (get chan-to-path-map c)]
-            (condp = (second path)
-              :score   (handle-score-update report-match path v)
-              (handle-player-update report-match path v))
+            (condp some (-> path)
+              #{:score}   (handle-score-update report-match path v)
+              #{:player1
+                :player2} (handle-player-update report-match path v)
+              nil)
             (recur)))))

     om/IRenderState
     (render-state [_ {:keys [team1 team2]}]
-      (let [_  (debug (map (fn [p]  (str "'" (:name p) "'")) (selected-players report-match)))
+      (let [_  (debug (map (fn [p]  (str "'" (:name p) "'")) (selected-players (:team1 report-match)
+                                                                              (:team2 report-match))))
             __ (debug (map (fn [kw] (get-in report-match [kw :score])) [:team1 :team2]))
             render-team (partial render-team-controls app)]
         (html


Fix typo.

Fix typo.

--- src/clojure/uncomplicate/neanderthal/core.clj
+++ src/clojure/uncomplicate/neanderthal/core.clj
@@ -419,7 +419,7 @@
    (if (and (or (= 0 kl m) (< -1 (long kl) (long m))) (or (= 0 ku n) (< -1 (long ku) (long n))))
      (let-release [res (api/create-gb (api/factory factory) m n kl ku
                                       (api/options-column? options) (not (:raw options)))]
-       (if source (transfer! source res) rnes))
+       (if source (transfer! source res) res))
      (dragan-says-ex "GB matrix cannot have a negative dimension nor overflow diagonals."
                      {:m m :n n :kl kl :ku ku})))
   ([factory m n kl ku arg]


lower pool limit

lower pool limit

--- kafka-clj/src/kafka_clj/pool/atom.clj
+++ kafka-clj/src/kafka_clj/pool/atom.clj
@@ -36,7 +36,7 @@
   "create-f when called should create a valid object called as (create-f ctx),
    validate-f is called before poll returns, called (validate-f ctx v)
    destroy-f  is called to destroy an object (destroy-f ctx v)
-   sem is a semaphore setting up the limit = (get ctx :pool-limit 100)"
+   sem is a semaphore setting up the limit = (get ctx :pool-limit 20)"
   [ctx create-f validate-f destroy-f]
   {:pre [(every? fn? [create-f validate-f destroy-f])]}
   (->AtomPool
@@ -45,7 +45,7 @@
     create-f
     validate-f
     destroy-f
-    (Semaphore. (int (get ctx :pool-limit 100)))
+    (Semaphore. (int (get ctx :pool-limit 20)))
     (AtomicBoolean. false)))

 (defn a-destroy


load or generate wallet keypair on start

--- src/block_chain/wallet.clj
+++ src/block_chain/wallet.clj
@@ -1,6 +1,7 @@
 (ns block-chain.wallet
   (:require [clojure.java.io :as io]
             [clojure.string :refer [join split]]
+            [block-chain.pem :as pem]
             [block-chain.encoding :refer :all]))

 ;; Thanks to http://nakkaya.com/2012/10/28/public-key-cryptography/
@@ -55,4 +56,22 @@
     (.verify sig signature)))

+(def wallet-path (str (System/getProperty "user.home") "/.wallet.pem"))
+
+(defn wallet-exists? [] (.exists (io/as-file wallet-path)))
+
+(defn load-or-generate-keys!
+  "Looks for wallet keypair to exist at ~/.wallet.pem. If found, loads
+   that keypair to use as our wallet. If not, generates a new keypair and
+   saves it in that location for future use."
+  []
+  (if (wallet-exists?)
+    (pem/pem-file->key-pair wallet-path)
+    (let [kp (generate-keypair)]
+      (spit wallet-path
+            (pem/private-key->pem-string (.getPrivate kp)))
+      kp)))
+
+(def keypair (load-or-generate-keys!))
+
 (defn sign-txn [txn])


Add clean option to test-block-store.

Add clean option to test-block-store.

--- src/blocks/store/tests.clj
+++ src/blocks/store/tests.clj
@@ -105,12 +105,14 @@
                           (sort)
                           (take limit))]
         (is (= expected (map :id stats))
-            "list should return the expected ids in sorted order")))))
+            (str "list should return the expected ids in sorted order for: "
+                 (pr-str {:after after, :limit limit})))))))

 (defn test-block-store
   "Tests a block store implementation."
-  [label store & {:keys [blocks max-size], :or {blocks 10, max-size 1024}}]
+  [label store & {:keys [blocks max-size clean]
+                  :or {blocks 10, max-size 1024, clean true}}]
   (println "  *" label)
   (is (empty? (block/list store)) "starts empty")
   (testing (.getSimpleName (class store))
@@ -123,11 +125,12 @@
               "enumerates all ids in sorted order")
           (is (every? #(= (:size %) (count (get stored-content (:id %)))) stats)
               "returns correct size for all blocks"))
-        (test-list-stats store (keys stored-content) 100))
+        (test-list-stats store (keys stored-content) 10))
       (doseq [[id content] stored-content]
         (test-block store id content))
       (let [[id content] (first (seq stored-content))]
         (test-restore-block store id content))
-      (doseq [id (keys stored-content)]
-        (is (true? (block/delete! store id))))
-      (is (empty? (block/list store)) "ends empty"))))
+      (when clean
+        (doseq [id (keys stored-content)]
+          (is (true? (block/delete! store id))))
+        (is (empty? (block/list store)) "ends empty")))))


Disallow punctuation.

Disallow punctuation.

--- src/mash_commander/core.cljs
+++ src/mash_commander/core.cljs
@@ -19,7 +19,7 @@
 (defonce valid-words #{"hello" "world"})
 (defonce valid-letters (set (concat (str/split "abcdefghijklmnopqrstuvwxyz" "")
                                     (str/split "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "")
-                                    (str/split "1234567890.?" ""))))
+                                    (str/split "1234567890" ""))))

 (defn recognize? [letters]
   (let [last-word (str/join (reverse (take-while #(not= " " %) letters)))]


Fix comment formatting

Fix comment formatting

--- src/braid/search/core.cljc
+++ src/braid/search/core.cljc
@@ -115,7 +115,7 @@
        (core/register-server-message-handlers!
          {::search-ws
           (fn [{:as ev-msg :keys [?data ?reply-fn user-id]}]
-            ; this can take a while, so move it to a future
+            ;; this can take a while, so move it to a future
             (future
               (let [user-tags (tag/tag-ids-for-user user-id)
                     filter-tags (fn [t] (update-in t [:tag-ids] (partial into #{} (filter user-tags))))


RS & RP | 131 | Refactor create-account view tests

--- test/mooncake/test/view/create_account.clj
+++ test/mooncake/test/view/create_account.clj
@@ -44,63 +44,3 @@
   :invalid-format   "invalid@-!*"                 "content:create-account/username-invalid-format-validation-message"
   :duplicate        "duplicate_user"              "content:create-account/username-duplicate-validation-message"
   :some-other-one   "some_username"               "content:create-account/username-default-validation-message")
-
-
-
-
-  (facts "when username is blank"
-         (let [error-m {:username :blank}
-               params {:username ""}
-               page (ca/create-account {:params params :context {:error-m error-m}})]
-           (fact "the class for styling errors is added"
-                 (html/select page [[:.clj--username :.form-row--validation-error]]) =not=> empty?)
-           (fact "username validation element is present"
-                 (html/select page [:.clj--username__validation]) =not=> empty?)
-           (fact "correct error message is displayed"
-                 (first (html/select page [:.clj--username__validation]))
-                 => (contains {:attrs (contains {:data-l8n "content:create-account/username-blank-validation-message"})}))))
-
-  (facts "when username is too long"
-         (let [error-m {:username :too-long}
-               params {:username "this_username_is_too_long"}
-               page (ca/create-account {:context {:params params :error-m error-m}})]
-           (fact "the class for styling errors is added"
-                 (html/select page [[:.clj--username :.form-row--validation-error]]) =not=> empty?)
-           (fact "username validation element is present"
-                 (html/select page [:.clj--username__validation]) =not=> empty?)
-           (fact "input is retained"
-                 (first (html/select page [:.clj--username__input])) =>
-                 (contains {:attrs (contains {:value "this_username_is_too_long"})}))
-           (fact "correct error message is displayed"
-                 (first (html/select page [:.clj--username__validation]))
-                 => (contains {:attrs (contains {:data-l8n "content:create-account/username-too-long-validation-message"})}))))
-
-  (facts "when username has invalid-format"
-         (let [error-m {:username :invalid-format}
-               params {:username "invalid@-!"}
-               page (ca/create-account {:context {:params params :error-m error-m}})]
-           (fact "the class for styling errors is added"
-                 (html/select page [[:.clj--username :.form-row--validation-error]]) =not=> empty?)
-           (fact "username validation element is present"
-                 (html/select page [:.clj--username__validation]) =not=> empty?)
-           (fact "input is retained"
-                 (first (html/select page [:.clj--username__input])) =>
-                 (contains {:attrs (contains {:value "invalid@-!"})}))
-           (fact "correct error message is displayed"
-                 (first (html/select page [:.clj--username__validation]))
-                 => (contains {:attrs (contains {:data-l8n "content:create-account/username-invalid-format-validation-message"})}))))
-
-  (facts "when username is already taken"
-         (let [error-m {:username :duplicate}
-               params {:username "duplicate_user"}
-               page (ca/create-account {:context {:params params :error-m error-m}})]
-           (fact "the class for styling errors is added"
-                 (html/select page [[:.clj--username :.form-row--validation-error]]) =not=> empty?)
-           (fact "username validation element is present"
-                 (html/select page [:.clj--username__validation]) =not=> empty?)
-           (fact "input is retained"
-                 (first (html/select page [:.clj--username__input])) =>
-                 (contains {:attrs (contains {:value "duplicate_user"})}))
-           (fact "correct error message is displayed"
-                 (first (html/select page [:.clj--username__validation]))
-                 => (contains {:attrs (contains {:data-l8n "content:create-account/username-duplicate-validation-message"})}))))


fix up test that had been TODO for a bit

--- test/block_chain/message_handlers_test.clj
+++ test/block_chain/message_handlers_test.clj
@@ -126,20 +126,24 @@
                              @db/db)))
     (is (= 25 (bc/balance-db (:address key-b) @db/db)))))

-;; TODO
-#_(deftest test-submitting-transaction-with-txn-fee
+(deftest test-submitting-transaction-with-txn-fee
   (let [key-b (wallet/generate-keypair 512)]
-    (is (= 0 (bc/balance-db (:address wallet/keypair) @db/db)))
-    (miner/mine-and-commit-db!)
-    (let [payment (miner/generate-payment wallet/keypair (:address key-b) 24 (q/longest-chain @db/db) 1)]
-      (handler {:message "submit_transaction" :payload payment} sock-info)
+    (is (= 1 (q/chain-length @db/db)))
+    (is (= 25 (q/balance (:address wallet/keypair) @db/db)))
+    (let [payment (txn/payment wallet/keypair
+                               (:address key-b)
+                               24
+                               @db/db
+                               1)]
+      (handler {:message "submit_transaction"
+                :payload payment}
+               sock-info)
       (miner/mine-and-commit-db!)
       ;; miner should have 25 from coinbase and 1 from allotted txn fee
-      (is (= 2 (q/block-height @db/db)))
-      (is (= 1 ()))
-      (is (= 26 (bc/balance-db (:address wallet/keypair) @db/db)))
+      (is (= 2 (q/chain-length @db/db)))
+      (is (= 26 (q/balance (:address wallet/keypair) @db/db)))
       ;; B should have 24 from the payment
-      (is (= 24 (bc/balance-db (:address key-b) @db/db))))))
+      (is (= 24 (q/balance (:address key-b) @db/db))))))

 (deftest test-only-forwards-new-transactions
   (miner/mine-and-commit-db!)


Fix bug with report generation on fresh conv

--- src/polismath/conv_man.clj
+++ src/polismath/conv_man.clj
@@ -370,8 +370,8 @@
                            (conv/mod-update conv moderation)
                            conv)
                     ;; Note that we run the update here if there are either new votes or changes in moderation; conv update
-                    ;; should work on nil vote seq
-                    conv (if (or moderation votes)
+                    ;; should work on nil vote seq; we also run if we get a report gen request but haven't built the reating mat
+                    conv (if (or moderation votes (not (:rating-mat conv)))
                            (conv-update conv-man conv votes error-handler)
                            conv)]
                 (log/info "Completed computing conversation zid:" zid)


Rename nom to om

Rename nom to om

--- src/discuss/components/search/statements.cljs
+++ src/discuss/components/search/statements.cljs
@@ -1,6 +1,6 @@
 (ns discuss.components.search.statements
   (:require [sablono.core :as html :refer-macros [html]]
-            [om.next :as nom :refer-macros [defui]]
+            [om.next :as om :refer-macros [defui]]
             [clojure.walk :refer [keywordize-keys]]
             [cljs.spec.alpha :as s]
             [ajax.core :refer [GET]]
@@ -65,12 +65,12 @@
 (defn set-search-results!
   "Store the search results into the app-state."
   [statements]
-  (nom/transact! parser/reconciler `[(search/results {:value ~statements})]))
+  (om/transact! parser/reconciler `[(search/results {:value ~statements})]))

 (defn remove-search-results!
   "Reset the search results."
   []
-  (set-search-results! {}))
+  (set-search-results! []))

 (defn- handle-search-results
   "Handler which is called with the results from ElasticSearch. Extract statements
@@ -95,7 +95,7 @@
 (defui Result
   Object
   (render [this]
-          (let [{:keys [text issue author]} (nom/props this)]
+          (let [{:keys [text issue author]} (om/props this)]
             (html [:div.bs-callout.bs-callout-info
                    [:div.row
                     [:div.col-sm-8
@@ -110,18 +110,18 @@
                       [:br]
                       [:span.label.label-default
                        (str (t :search :author) ": " (:nickname author))]]]]]))))
-(def ^:private result (nom/factory Result))
+(def ^:private result (om/factory Result))

 (defui Results
-  static nom/IQuery
+  static om/IQuery
   (query [this] [:search/results])
   Object
   (render [this]
-          (let [{:keys [search/results]} (nom/props this)]
+          (let [{:keys [search/results]} (om/props this)]
             (html [:div.results
                    (take 5
                          (map #(result (merge (lib/unique-react-key-dict) %)) results))]))))
-(def results (nom/factory Results))
+(def results (om/factory Results))

 ;; -----------------------------------------------------------------------------
@@ -134,4 +134,4 @@
                   [:div.form-group
                    [:input.form-control {:type "text"
                                          :on-change #(search (.. % -target -value))}]]]])))
-(def search-query (nom/factory SearchQuery))
+(def search-query (om/factory SearchQuery))


remove duplicate key

remove duplicate key

--- src/overtone/music/pitch.clj
+++ src/overtone/music/pitch.clj
@@ -284,7 +284,6 @@
      :hindu              [2 2 1 2 1 2 2]
      :iwato              [1 4 1 4 2]
      :melodic-minor      [2 1 2 2 2 2 1]
-     :harmonic-minor     [2 1 2 2 1 3 1]
      :diminished2        [2 1 2 1 2 1 2 1]
      :marva              [1 3 2 1 2 2 1]
      :melodic-major      [2 2 1 2 1 2 2]


fix redirect after register

fix redirect after register

--- src/chat/server/routes.clj
+++ src/chat/server/routes.clj
@@ -123,13 +123,15 @@
                                                        :email email
                                                        :avatar avatar-url
                                                        :nickname nickname
-                                                       :password password}))]
+                                                       :password password}))
+                  referer (get-in req [:headers "referer"] (env :site-url))
+                  [proto _ referrer-domain] (string/split referer #"/")]
               (db/with-conn
                 (db/user-add-to-group! (user :id) (invite :group-id))
                 (db/user-subscribe-to-group-tags! (user :id) (invite :group-id))
                 (db/retract-invitation! (invite :id)))
               (sync/broadcast-user-change (user :id) [:chat/new-user user])
-              {:status 302 :headers {"Location" "/"}
+              {:status 302 :headers {"Location" (str proto "//" referrer-domain)}
                :session (assoc (req :session) :user-id (user :id))
                :body ""}))))))

@@ -224,8 +226,7 @@
          :body (pr-str {:error "No S3 secret for upload"})})
       {:status 403
        :headers {"Content-Type" "application/edn"}
-       :body (pr-str {:error "Unauthorized"})}))
-  )
+       :body (pr-str {:error "Unauthorized"})})))

 (defroutes resource-routes
   (resources "/"))


[util] Working around an exception coming from core.matrix: (#32)

https://github.com/mikera/core.matrix/issues/302

--- cortex/src/cortex/util.cljc
+++ cortex/src/cortex/util.cljc
@@ -622,7 +622,10 @@
                                                          n-input
                                                          rand-gaussian)))
                                                   mean variance))))))
-  ([^long n-output ^long n-input] (weight-matrix n-output n-input :xavier)))
+  ([^long n-output ^long n-input]
+   (if (= 1 n-output n-input)
+     (b/array [[0]])
+     (weight-matrix n-output n-input :xavier))))

 (defn identity-matrix


loosen restrictions on Clairvoyant Monitor targets

--- src/clj/game/cards-ice.clj
+++ src/clj/game/cards-ice.clj
@@ -119,7 +119,7 @@
                                    :prompt "Choose a target for Clairvoyant Monitor"
                                    :msg (msg "place 1 advancement token on "
                                              (if (:rezzed target) (:title target) "a card") " and end the run")
-                                   :choices {:req #(or (= (:type %) "Agenda") (:advanceable %))}
+                                   :choices {:req #(= (first (:zone %)) :servers)}
                                    :effect (effect (add-prop target :advance-counter 1) (end-run))}}}]}

    "Chum"


replaced make-word-cloud with filtered-weighted

--- src/clj/gitomic/trello.clj
+++ src/clj/gitomic/trello.clj
@@ -26,14 +26,12 @@
 (defn word-cloud [word-counts]
   (string/join " " (mapcat (fn [[x n]] (repeat n x)) word-counts)))

-(defn make-word-cloud [strs contains remove top-n]
+(defn filtered-weighted [strs remove top-n]
   (as-> strs xs
-        (filter #(if contains (.contains % contains) true) xs)
         (words xs)
         (apply dissoc xs remove)
         (vec (reverse (sort-by second xs)))
-        (take (or top-n (count xs)) xs)
-        (word-cloud xs)))
+        (take (or top-n (count xs)) xs)))

 [{:subscribed [:subscribed
                :labels


Allow `lein spec --help` in lein 2.4+

Allow `lein spec --help` in lein 2.4+

--- src/clj/leiningen/spec.clj
+++ src/clj/leiningen/spec.clj
@@ -24,13 +24,15 @@
     (with-paths project)
     vec))

-(defn spec
+(defn ^:pass-through-help spec
   "Speclj - pronounced \"speckle\": a TDD/BDD framework for Clojure.

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

-  lein spec --speclj
+  lein spec --help
+
+  (or lein spec --speclj if you're on leiningen 2.3.x or lower)

 That ought to do the trick."
   [project & args]
@@ -38,4 +40,4 @@
         speclj-args (build-args project args)
         run-form (make-run-form project speclj-args)
         init-form '(require 'speclj.cli)]
-      (eval-in-project project run-form init-form)))+      (eval-in-project project run-form init-form)))


add DISABLE_RENAMED_FILES_HISTORY

add DISABLE_RENAMED_FILES_HISTORY

--- src/clj_opengrok/index.clj
+++ src/clj_opengrok/index.clj
@@ -41,6 +41,7 @@
                  "-d" data-root
                  "-H"
                  "-q"
+                 "-D"
                  "-e"
                  project
                  ignore)))


Added pentatonic major

Added pentatonic major

--- src/cljs/guitar1/neck.cljs
+++ src/cljs/guitar1/neck.cljs
@@ -37,6 +37,8 @@
   '(true false true false true true false true false true false true))
 (def pentatonic-minor
   '(true false false true false true false true false false true false))
+(def pentatonic-major
+  '(true false true false true false false true false true false false))
 (def mode-names [:Ionian :Dorian :Phrygian :Lydian :Mixolydian :Aeolian :Locrian])
 (defn mode
   [mode-name]
@@ -86,6 +88,7 @@
   [key scale]
   [:div.neck
    [:button {:on-click #(set-scale pentatonic-minor)} "Pentatonic Minor"]
+   [:button {:on-click #(set-scale pentatonic-major)} "Pentatonic Major"]
    (map (fn [mode] [:button {:on-click #(set-scale (mode modes))} (name mode)]) (keys modes))
    (conj (map build-string (reverse strings))
          [:ul.string.frets (map #(vector :li %) (into [] (range 24)))])])


Fix bug

Fix bug

--- src/cljx/transom/core.cljx
+++ src/cljx/transom/core.cljx
@@ -92,7 +92,8 @@

 (defn compose
   ([doc old new]
-    (let [old' (rebase-paths doc old new)]
+    (let [doc (patch doc old)
+          old (rebase-paths doc old new)]
       (reduce
         (fn [old [new-path new-edit]]
           (if-some [old-edit (get old new-path)]
@@ -100,7 +101,7 @@
                   composed-edit (impl/compose state old-edit new-edit)]
               (assoc old new-path composed-edit))
             (assoc old new-path new-edit)))
-        old'
+        old
         new)))
   ([doc old new & more]
     (reduce (partial compose doc) (compose doc old new) more)))


Update json-file and json-rdd to Spark 2.0

--- src/clojure/flambo/sql.clj
+++ src/clojure/flambo/sql.clj
@@ -40,7 +40,7 @@
 (defn json-file
   "Loads a JSON file (one object per line), returning the result as a DataFrame."
   [sql-context path]
-  (.jsonFile sql-context path))
+  (-> sql-context .read (.format "json") (.load path)))

 ;; Since 1.3 the SparkSQL data sources API is recommended for load & save operations.
 (defn load
@@ -77,7 +77,7 @@
 (defn json-rdd
   "Load an RDD of JSON strings (one object per line), inferring the schema, and returning a DataFrame"
   [sql-context json-rdd]
-  (.jsonRDD sql-context json-rdd))
+  (-> sql-context .read (.json json-rdd)))

 (defn uncache-table
   "Removes the specified table from the in-memory cache."


[n.debug] Explicitly return false if safe-for-ui failed

--- src/clojure/neko/debug.clj
+++ src/clojure/neko/debug.clj
@@ -47,7 +47,8 @@
   (if (:neko.init/release-build *compiler-options*)
     `(do ~@body)
     `(try ~@body
-          (catch Throwable e# (handle-exception-from-ui-thread e#)))))
+          (catch Throwable e# (handle-exception-from-ui-thread e#)
+                 false))))

 (defn safe-for-ui*
   "Wraps the given zero-argument function in `safe-for-ui` call and returns it,


Add lein-nevam for pom.xml to project.clj

--- clojure/profiles.clj
+++ clojure/profiles.clj
@@ -1,2 +1,5 @@
 {:user {:plugins [[lein-localrepo "0.5.3"]
-                  [lein-try "0.4.3"]]}}
+                  [lein-try "0.4.3"]
+                  ;; Convert pom.xml to project.clj
+                  ;; Note: from https://github.com/thickey/lein-nevam
+                  [lein-nevam "0.1.2"]]}}