Rework handling of Repl binding

Rework handling of Repl binding

Also add *unchecked-math* for 1.3

--- server/src/main/clojure/vimclojure/repl.clj
+++ server/src/main/clojure/vimclojure/repl.clj
@@ -24,9 +24,12 @@
   (:require
     clojure.test)
   (:use
-     [vimclojure.util :only (stream->seq pretty-print pretty-print-causetrace)])
+    [vimclojure.util :only [safe-var-get stream->seq
+                            pretty-print pretty-print-causetrace]])
   (:import
-     (clojure.lang Var Compiler LineNumberingPushbackReader)))
+    clojure.lang.Var
+    clojure.lang.Compiler
+    clojure.lang.LineNumberingPushbackReader))

 (def
   ^{:dynamic true :doc
@@ -47,37 +50,31 @@
   *print-pretty*
   false)

-(defstruct
-  #^{:doc
-  "The structure for the Repl interface. Holds the state of a Repl between
-  invokations. The members correspond to the Vars as bound be with-binding."}
-  repl
-  :id :ns :warn-on-reflection :print-meta :print-length :print-level
-  :compile-path :command-line-args :expr1 :expr2 :expr3 :exception :test-out
-  :line)
+(defn add-binding
+  [bindings sym]
+  (if-let [v (resolve sym)]
+    (assoc bindings v (safe-var-get v))
+    bindings))
+
+(def bindable-vars
+  `[*warn-on-reflection* *print-meta* *print-length*
+    *print-level* *compile-path* *command-line-args*
+    *unchecked-math* *1 *2 *3 *e
+    ; VimClojure specific.
+    *print-pretty*])

 (defn make-repl
   "Create a new Repl."
   ([id] (make-repl id (the-ns 'user)))
   ([id namespace]
-   (struct-map repl
-               :id                 id
-               :ns                 namespace
-               :warn-on-reflection *warn-on-reflection*
-               :print-meta         *print-meta*
-               :print-length       *print-length*
-               :print-level        *print-level*
-               :compile-path       (System/getProperty
-                                     "clojure.compile.path"
-                                     "classes")
-               :command-line-args  nil
-               :expr1              nil
-               :expr2              nil
-               :expr3              nil
-               :exception          nil
-               :print-pretty       vimclojure.repl/*print-pretty*
-               :test-out           nil
-               :line               0)))
+   {:id        id
+    :ns        namespace
+    :test-out  nil
+    :line      1
+    :bindings  (-> (reduce add-binding {} bindable-vars)
+                 (assoc #'*compile-path* (System/getProperty
+                                           "clojure.compile.path"
+                                           "classes")))}))

 (defn start
   "Start a new Repl and register it in the system."
@@ -126,49 +123,28 @@
                    (the-repl :line)
                    line)]
     (with-bindings
-      {Compiler/LINE          (Integer. (.intValue line)) ; #64: Unbox to ensure int.
-       Compiler/SOURCE        (.getName (java.io.File. file))
-       Compiler/SOURCE_PATH   file
-       #'*in*                 (make-reader *in* line)
-       #'*ns*                 (if nspace nspace (the-repl :ns))
-       #'*warn-on-reflection* (the-repl :warn-on-reflection)
-       #'*print-meta*         (the-repl :print-meta)
-       #'*print-length*       (the-repl :print-length)
-       #'*print-level*        (the-repl :print-level)
-       #'*compile-path*       (the-repl :compile-path)
-       #'*command-line-args*  (the-repl :command-line-args)
-       #'*1                   (the-repl :expr1)
-       #'*2                   (the-repl :expr2)
-       #'*3                   (the-repl :expr3)
-       #'*e                   (the-repl :exception)
-       #'vimclojure.repl/*print-pretty* (the-repl :print-pretty)
-       #'clojure.test/*test-out* (if-let [test-out (the-repl :test-out)]
-                                   test-out
-                                   *out*)}
+      (merge (:bindings the-repl)
+             ; #64: Unbox to ensure int.
+             {Compiler/LINE        (Integer. (.intValue line))
+              Compiler/SOURCE      (.getName (java.io.File. file))
+              Compiler/SOURCE_PATH file
+              #'*in*               (make-reader *in* line)
+              #'*ns*               (if nspace nspace (:ns the-repl))
+              #'clojure.test/*test-out* (if-let [test-out (the-repl :test-out)]
+                                          test-out
+                                          *out*)})
       (try
         (thunk)
         (finally
           (when (not= id -1)
             (swap! *repls* assoc id
-                   (struct-map
-                     repl
-                     :id                 id
-                     :ns                 *ns*
-                     :warn-on-reflection *warn-on-reflection*
-                     :print-meta         *print-meta*
-                     :print-length       *print-length*
-                     :print-level        *print-level*
-                     :compile-path       *compile-path*
-                     :command-line-args  *command-line-args*
-                     :expr1              *1
-                     :expr2              *2
-                     :expr3              *3
-                     :exception          *e
-                     :print-pretty       vimclojure.repl/*print-pretty*
-                     :test-out           (let [test-out clojure.test/*test-out*]
-                                           (when-not (identical? test-out *out*)
-                                             test-out))
-                     :line               (dec (.getLineNumber *in*))))))))))
+                   {:id        id
+                    :ns        *ns*
+                    :test-out  (let [test-out clojure.test/*test-out*]
+                                 (when-not (identical? test-out *out*)
+                                   test-out))
+                    :line      (dec (.getLineNumber *in*))
+                    :bindings  (reduce add-binding {} bindable-vars)})))))))

 (defmacro with-repl
   "Executes body in the context of the Repl with the given id. id may be -1


CMR-3158 Remove unnecessary namespaces

CMR-3158 Remove unnecessary namespaces

--- umm-spec-lib/test/cmr/umm_spec/test/xml_to_umm_mappings/echo10.clj
+++ umm-spec-lib/test/cmr/umm_spec/test/xml_to_umm_mappings/echo10.clj
@@ -1,6 +1,5 @@
 (ns cmr.umm-spec.test.xml-to-umm-mappings.echo10
   (:require
-   [clj-time.core :as t]
    [clojure.test :refer :all]
    [cmr.umm-spec.xml-to-umm-mappings.echo10.data-contact :as contact]))


fixing

fixing

--- test/celestial/test/jobs.clj
+++ test/celestial/test/jobs.clj
@@ -18,5 +18,5 @@

 (scenario
   (expect AssertionError (job-exec identity {:machine {:host nil}}))
-  (job-exec identity {:machine {:host "red1"}})
+  (job-exec identity {:machine {:hostname "red1"}})
   (expect (interaction (with-lock "red1" anything {:expiry half-hour :wait-time minute}))))


om links tutorial works

om links tutorial works

--- test/cellophane/dom_test.clj
+++ test/cellophane/dom_test.clj
@@ -275,6 +275,61 @@
                       More text

")))

+;; Om Links tutorial
+
+(defui LinksItem
+  static cellophane/Ident
+  (ident [_ {:keys [id]}]
+    [:item/by-id id])
+  static cellophane/IQuery
+  (query [_]
+    '[:id :title [:current-user _]])
+  Object
+  (render [this]
+    (let [{:keys [title current-user]} (cellophane/props this)]
+      (dom/li nil
+        (dom/div nil title)
+        (dom/div nil (:email current-user))))))
+
+(def links-item (cellophane/factory LinksItem))
+
+(defui LinksSomeList
+  static cellophane/IQuery
+  (query [_]
+    [{:items (cellophane/get-query LinksItem)}])
+  Object
+  (render [this]
+    (dom/div nil
+      (dom/h2 nil "A List!")
+      (dom/ul nil
+        (map links-item (-> this cellophane/props :items))))))
+
+;; TODO: this is not actually the real init data, but the result of parsing
+(def links-init-data
+  {:items [{:id 0 :title "Foo" :current-user {:email "bob.smith@gmail.com"}}
+           {:id 1 :title "Bar" :current-user {:email "bob.smith@gmail.com"}}
+           {:id 2 :title "Baz" :current-user {:email "bob.smith@gmail.com"}}]})
+
+(deftest test-render-links-tutorial
+  (let [ctor (cellophane/factory LinksSomeList)]
+    (is (= (dom/render-to-str (ctor links-init-data))
+          (remove-whitespace "

+
A List!

+

+

+
Foo

+
bob.smith@gmail.com

+

+

+
Bar

+
bob.smith@gmail.com

+

+

+
Baz

+
bob.smith@gmail.com

+

+

+
")))))
 ;; ===================================================================
 ;; Checksums, react-ids


Loops in tests are tricky

Loops in tests are tricky

--- test/littlepot/core_test.clj
+++ test/littlepot/core_test.clj
@@ -70,12 +70,13 @@
         (Thread/sleep 500)
         (is (= (range 10) (take 10 (repeatedly #(cook pot)))))
         ;; next portion is unavailable
-        (Thread/sleep 200)
         (if (< batch-num 2)
           (is (every? #(= % :no-data)
                       (take 20 (repeatedly #(cook pot)))))
-          (is (every? #(= % :exhausted)
-                      (take 20 (repeatedly #(cook pot)))))
+          (do
+            (Thread/sleep 200)
+            (is (every? #(= % :exhausted)
+                        (take 20 (repeatedly #(cook pot))))))
           )))))

 (deftest test-error-no-batches


Adapt tests.

Adapt tests.

--- test/promesa/core_tests.cljs
+++ test/promesa/core_tests.cljs
@@ -5,33 +5,17 @@

 (enable-console-print!)

-(t/deftest promise-constructor
-  ;; Constructor with value
+(t/deftest promise-from-value
   (let [p1 (p/promise 1)]
     (t/is (p/fulfilled? p1))
-    (t/is (= (m/extract p1) 1)))
+    (t/is (= (m/extract p1) 1))))

-  ;; Constructor with callable
+(t/deftest promise-from-factory
   (let [p1 (p/promise (fn [resolve] (resolve 1)))]
     (t/is (p/fulfilled? p1))
-    (t/is (= (m/extract p1) 1)))
+    (t/is (= (m/extract p1) 1))))

-  (let [p1 (p/promise (ex-info "foo" 1))]
-    (t/is (p/rejected? p1))
-    (p/catch p1 (fn [x] x)))
-
-  (let [p1 (p/resolved 1)]
-    (t/is (p/fulfilled? p1)))
-
-  (let [p1 (p/rejected 1)]
-    (t/is (p/rejected? p1))
-    (p/catch p1 (fn [x] x)))
-
-  (let [p1 (p/promise (fn [_ _] 1))]
-    (t/is (p/pending? p1)))
-)
-
-(t/deftest promise-async-constructor-async
+(t/deftest promise-async-factory
   (t/async done
     (let [p1 (p/promise (fn [resolve]
                           (js/setTimeout (partial resolve 1) 0)))]
@@ -40,23 +24,38 @@
                    (t/is (= (m/extract p1)  1))
                    (done))))))

-(t/deftest spread-all-chain
+(t/deftest promise-from-exception
+  (let [p1 (p/promise (ex-info "foo" 1))]
+    (t/is (p/rejected? p1))
+    (p/catch p1 (fn [x] x))))
+
+(t/deftest promise-rejected
+  (let [p1 (p/rejected 1)]
+    (t/is (p/rejected? p1))
+    (p/catch p1 (fn [x] x))))
+
+(t/deftest promise-from-promise
+  (let [p1 (p/promise 1)
+        p2 (p/promise p1)]
+    (t/is (identical? p1 p2))))
+
+(t/deftest syncrhonize-promises
   (let [p1 (-> (p/all [(p/promise 1) (p/promise 2)])
-               (p/spread (fn [x y]
-                           (t/is (= x 1))
-                           (t/is (= y 2))
-                           (+ x y))))]
+               (p/then (fn [[x y]]
+                         (t/is (= x 1))
+                         (t/is (= y 2))
+                         (+ x y))))]
     (p/then p1 (fn [v]
                  (t/is (= v 3))))))

-(t/deftest any-with-delay-chain
+(t/deftest arbitrary-choice
   (t/async done
     (let [p1 (p/any [(p/delay 300 1) (p/delay 200 2)])]
       (p/then p1 (fn [v]
                    (t/is (= v 2))
                    (done))))))

-(t/deftest any-with-timeout-catch
+(t/deftest catch-timeout
   (t/async done
     (let [p1 (-> (p/delay 300 1)
                  (p/timeout 200))]
@@ -64,24 +63,6 @@
                              (t/is (instance? js/Error v))
                              (t/is (p/rejected? p1))
                              (done))))))
-
-(t/deftest timeout-with-finally
-  (t/async done
-    (let [p1 (-> (p/delay 300 1)
-                 (p/timeout 200 1))]
-      (-> p1
-          (p/catch #(t/is (instance? js/Error %)))
-          (p/finally (fn [v]
-                       (t/is (= v nil))
-                       (done)))))))
-
-(t/deftest rejected-promise
-  (t/async done
-    (let [p1 (p/rejected 1)]
-      (t/is (p/rejected? p1))
-      (p/catch p1 (fn [v]
-                    (t/is (= v 1))
-                    (done))))))

 (t/deftest promise-as-functor
   (t/async done
@@ -104,7 +85,6 @@
                    (t/is (= v 3))
                    (done))))))

-
 (t/deftest promisify
   (t/async done
     (let [func1 (fn [x cb] (cb (inc x)))


reorder tests

reorder tests

--- test/snap_spot/trip_test.clj
+++ test/snap_spot/trip_test.clj
@@ -6,6 +6,10 @@
              (position :as position)
              (trip :as trip)]
             [clojure.data.json :as json]))
+
+(deftest test-params->trip
+  (testing "params->trip"
+    (is (= 1M (:duration (trip/params->trip {:id "1" :duration "1"}))))))

 (deftest test-create
   (testing "trip/create test"
@@ -22,10 +26,6 @@
     (def error (json/read-str (trip/create {:params {:id 5}})))
     (is (contains? error "error"))))

-(deftest test-params->trip
-  (testing "params->trip"
-    (is (= 1M (:duration (trip/params->trip {:id "1" :duration "1"}))))))
-
 (deftest test-update
   (testing "trip/update duration error test"
     (def error (json/read-str (trip/create {:params {:id 5}})))


Fix Space

Fix Space

--- src-cljs/frontend/components/build_head.cljs
+++ src-cljs/frontend/components/build_head.cljs
@@ -354,8 +354,7 @@
            "JavaScript" "/docs/test-metadata#js"
            "Python" "/docs/test-metadata#python"
            "Java" "/docs/test-metadata#java-junit-results-with-maven-surefire-plugin"
-           "/docs/test-metadata#metadata-collection-in-custom-test-steps"
-           )
+           "/docs/test-metadata#metadata-collection-in-custom-test-steps")
             :on-mouse-up #(analytics/track-build-tests-ad-click language)}
         "Set up your test runner to output in JUnit-style XML"] ", so we can:"
        [:ul


Fixes #244 - error markers disappeared

Fixes #244 - error markers disappeared

--- ccw.core/src/ccw/debug/serverrepl.clj
+++ ccw.core/src/ccw/debug/serverrepl.clj
@@ -21,19 +21,19 @@
          v []]
     (if-not e
       v
-      (let [stack-traces (.getStackTrace e)
-            first-stack (aget stack-traces 0)
-            file-name (.getFileName first-stack)
-            line-number (.getLineNumber first-stack)
-            message (.getMessage e)]
+      (let [stack-traces (.getStackTrace e)]
         (recur (.getCause e)
-          (conj v (if (> (.length stack-traces) 0)
-                    {"file-name" file-name
-                     "line-number" line-number
-                     "message" message}
-                    {"file-name" "<none>"
-                     "line-number" 0
-                     "message" "<none>"})))))))
+               (conj v (if (> (alength stack-traces) 0)
+                         (let [first-stack (aget stack-traces 0)
+                               file-name (.getFileName first-stack)
+                               line-number (.getLineNumber first-stack)
+                               message (.getMessage e)]
+                           {"file-name" file-name
+                            "line-number" line-number
+                            "message" message})
+                         {"file-name" "<none>"
+                          "line-number" 0
+                          "message" "<none>"})))))))

 (defmacro with-exception-serialization
   [& body]


finding percolation matches

finding percolation matches

--- Clojure-Websockets/src/clj/birdwatch/main.clj
+++ Clojure-Websockets/src/clj/birdwatch/main.clj
@@ -183,6 +183,10 @@
  (while true
    (let [t (<! tweets-chan)]

+     (let [response (perc/percolate conn "percolator" "tweet" :doc t)
+           matches (vec (map #(:_id %1) (esrsp/matches-from response)))]
+       (log/info "esrsp/matches-from" matches))
+
      (doseq [uid (:any @connected-uids)]
        (chsk-send! uid [:tweet/new t]))


CMR-4369 - Added test for unsupported content types and refactored tests.

--- system-int-test/test/cmr/system_int_test/search/variable/concept_retrieval_test.clj
+++ system-int-test/test/cmr/system_int_test/search/variable/concept_retrieval_test.clj
@@ -26,19 +26,47 @@

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;
+;; Helper constants and utility functions
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(def var1-name "variable1")
+(def var1-name-new "variable1-new")
+(def del-var-name "deleted-variable")
+(def user-name "user1")
+
+(defn- get-tokens
+  "A minimal utility function for tokens used by the tests."
+  []
+  [(e/login-guest (s/context))
+   (e/login (s/context) user-name)])
+
+(defn- get-var
+  "Ingest a single var given a var-name."
+  [var-name]
+  (variable/ingest-variable-with-attrs {:Name var-name}))
+
+(defn- get-updated-var
+  "Update (re-ingest) an existing (old) variable with new data."
+  [old-var data]
+  (index/wait-until-indexed)
+  (variable/ingest-variable-with-attrs
+   (merge data
+          {:native-id (:native-id old-var)})))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
 ;; Retrieve by concept-id - general test
 ;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (deftest retrieve-variable-by-concept-id-any-accept-header
-  (let [var1-name "variable1"
-        var1-v1 (variable/ingest-variable-with-attrs {:Name var1-name})
-        del-var (variable/ingest-variable-with-attrs {:Name "deleted-variable"})
+  (let [var1-v1 (get-var var1-name)
+        del-var (get-var del-var-name)
         _ (index/wait-until-indexed)
         del-concept (mdb/get-concept (:concept-id del-var))
         ;; tokens
-        guest-token (e/login-guest (s/context))
-        user1-token (e/login (s/context) "user1")]
+        [guest-token user1-token] (get-tokens)]
     (ingest/delete-concept del-concept (variable/token-opts user1-token))
     (index/wait-until-indexed)
     (testing "retrieval of a deleted variable results in a 404"
@@ -53,10 +81,7 @@
         (is (= [(format "Concept with concept-id [%s] could not be found."
                         (:concept-id del-var))]
                errors))))
-    (let [var1-name-new "variable1-new"
-          var1-v2 (variable/ingest-variable-with-attrs
-                   {:Name var1-name-new
-                    :native-id (:native-id var1-v1)})]
+    (let [var1-v2 (get-updated-var var1-v1 {:Name var1-name-new})]
       (testing (str "Sanity check that the test variable got updated and its "
                     "revision id was incremented.")
         (is (= 2
@@ -119,17 +144,11 @@
                errors))))))

 (deftest retrieve-variable-by-concept-id-umm-json-accept-header
-  (let [var1-name "variable1"
-        var1-name-new "variable1-new"
-        var1-v1 (variable/ingest-variable-with-attrs {:Name var1-name})
-        _ (index/wait-until-indexed)
-        var1-v2 (variable/ingest-variable-with-attrs
-                 {:Name var1-name-new
-                  :native-id (:native-id var1-v1)})
+  (let [var1-v1 (get-var var1-name)
+        var1-v2 (get-updated-var var1-v1 {:Name var1-name-new})
         ;; tokens
-        guest-token (e/login-guest (s/context))
-        user1-token (e/login (s/context) "user1")
-
+        [guest-token user1-token] (get-tokens)
+        ;; responses
         response (search/retrieve-concept
                   (:concept-id var1-v1)
                   nil
@@ -167,4 +186,18 @@
                              "does not exist.")
                         (:concept-id var1-v1)
                         no-rev)]
+               errors))))
+    (testing "unsupported content types return an error"
+      (let [unsupported-mt "unsupported/mime-type"
+            {:keys [status errors]} (search/get-search-failure-xml-data
+                                     (search/retrieve-concept
+                                      (:concept-id var1-v1)
+                                      nil
+                                      {:accept unsupported-mt
+                                       :throw-exceptions true
+                                       :headers {transmit-config/token-header user1-token}}))]
+        (is (= 400 status))
+        (is (= [(format (str "The mime types specified in the accept header "
+                             "[%s] are not supported.")
+                        unsupported-mt)]
                errors))))))


query-params break fragments

query-params break fragments

--- frontend/components/jobs.cljs
+++ frontend/components/jobs.cljs
@@ -127,7 +127,7 @@
              "Experience building fat JS apps, stateful HTML5 apps, and data visualizations."]
             [:li "Good product and user experience sensibilities."]]
            [:a
-            {:role "button", :href "/jobs?role=engineering#apply"}
+            {:role "button", :href "/jobs#apply"}
             [:span "Apply for Engineering roles"]]]

           [:div#designer
@@ -174,7 +174,7 @@
             [:li
              "Most importantly, relate to our customers; primarily developers."]]
            [:a
-            {:role "button", :href "/jobs?role=design#apply"}
+            {:role "button", :href "/jobs#apply"}
             [:span "Apply for Design roles"]]]

           [:div#business
@@ -220,7 +220,7 @@
             [:li "Are supremely organized and resourceful."]
             [:li "Have reasonable to strong coding ability."]]
            [:a
-            {:role "button", :href "/jobs?role=business#apply"}
+            {:role "button", :href "/jobs#apply"}
             [:span "Apply for Business roles"]]]]

          [:div.jobs-how


Order Enterprise form fields in email

Order Enterprise form fields in email

--- src-cljs/frontend/components/enterprise.cljs
+++ src-cljs/frontend/components/enterprise.cljs
@@ -45,17 +45,19 @@
    {:params-filter (fn [{:strs [name email company phone developer-count]}]
                      {:name name
                       :email email
-                      :message (->> {"Company" company
-                                     "Phone" phone
-                                     "Developer count" developer-count
-                                     "Form URL" js/location.href
-                                     "Initial referrer" (mixpanel/get-property "$initial_referrer")
-                                     "UTM medium" (mixpanel/get-property "utm_medium")
-                                     "UTM source" (mixpanel/get-property "utm_source")
-                                     "UTM campaign" (mixpanel/get-property "utm_campaign")
-                                     "UTM content" (mixpanel/get-property "utm_content")
-                                     "UTM term" (mixpanel/get-property "utm_term")}
-                                    (map (fn [[k v]] (gstr/format "%s: %s" k (or v "not set"))))
+                      :message (->> [["Company" company]
+                                     ["Phone" phone]
+                                     ["Developer count" developer-count]
+                                     []
+                                     ["Form URL" js/location.href]
+                                     ["Initial referrer" (mixpanel/get-property "$initial_referrer")]
+                                     []
+                                     ["UTM medium" (mixpanel/get-property "utm_medium")]
+                                     ["UTM source" (mixpanel/get-property "utm_source")]
+                                     ["UTM campaign" (mixpanel/get-property "utm_campaign")]
+                                     ["UTM content" (mixpanel/get-property "utm_content")]
+                                     ["UTM term" (mixpanel/get-property "utm_term")]]
+                                    (map (fn [[k v]] (if k (gstr/format "%s: %s" k (or v "not set")) "")))
                                     (str/join "\n"))
                       :enterprise true})
     :success-hook (fn [{:keys [email]}]


add test for split-map-values-at

add test for split-map-values-at

--- test-cljs/frontend/utils_test.cljs
+++ test-cljs/frontend/utils_test.cljs
@@ -52,3 +52,13 @@
     (is (contains? #{"https://secure.gravatar.com/avatar/bar?d=https%3A%2F%2Fidenticons.github.com%2Ffoo.png&s=200"
                      "https://secure.gravatar.com/avatar/bar?s=200&d=https%3A%2F%2Fidenticons.github.com%2Ffoo.png"}
                    (gh-utils/make-avatar-url {:login "foo" :gravatar_id "bar"})))))
+
+
+(deftest split-map-values-at-works
+  (let [orig (into (sorted-map) [[:a [1 2 3]], [:b [4 5 6]]])]
+    (testing "split spill over to bottom"
+      (is (= [{:a [1 2]} {:a [3] :b [4 5 6]}]
+             (utils/split-map-values-at orig 2))))
+    (testing "even split"
+      (is (= [{:a [1 2 3]} {:b [4 5 6]}]
+             (utils/split-map-values-at orig 3))))))


no need for another require

no need for another require

--- test/celestial/integration/aws.clj
+++ test/celestial/integration/aws.clj
@@ -1,6 +1,5 @@
 (ns celestial.integration.aws
   "Tests ec2, requires access key and secret key to be defined in ~/.celestial.edn"
-  (:require aws.provider)
   (:import clojure.lang.ExceptionInfo)
   (:require
     [celestial.persistency.systems :as s]


Fix GitHub sign-in button

Fix GitHub sign-in button

--- frontend/components/landing.cljs
+++ frontend/components/landing.cljs
@@ -32,7 +32,7 @@

 (defn home-button
   [{:keys [source]}]
-  [:a.btn.btn-primary.bold-btn {:href XXXXX
+  [:a.btn.btn-primary.bold-btn {:href (auth-url)
                                 :title "Sign up with GitHub"
                                 ;; XXXXX on click track auth event
                                 }
@@ -464,7 +464,7 @@
         "All plans include a "
         [:strong [:i "Free 14 Day Trial."]]]]]]]])

-(utils/defrender home
+(defrender home
   []
   (let [ab-tests nil]
     (html [:div.landing.page


fix sample template

fix sample template

--- sample/_template/_posts/2011-01-01-post1.html.clj
+++ sample/_template/_posts/2011-01-01-post1.html.clj
@@ -54,6 +54,14 @@
   (println "hello," msg))
 CLJ

+(h2 "Paragraph")
+#-CLJ
+(p "hello, world")
+(p "paragraph with `inline` code")
+CLJ
+(p "hello, world")
+(p "paragraph with `inline` code")
+
 (h2 "JavaScript")
 #-CLJ
 (js "a.js" "b.js")


Use a better icon for the recorded button

--- src/cljs/mdr2/productions/in_production.cljs
+++ src/cljs/mdr2/productions/in_production.cljs
@@ -242,7 +242,7 @@
          [:button.button
           {:on-click (fn [e] (rf/dispatch [::recorded-production uuid]))}
           [:span.icon.is-small
-           [:span.material-icons "mic"]]]))
+           [:span.material-icons "record_voice_over"]]]))
      ;; show the "Split" button if the next state is "split" and the user is
      ;; authorized
      (when (and (seq (set/intersection #{"madras2.it" "madras2.admin"} roles))


tags input stylo

tags input stylo

--- src/cljs/re_form/inputs/tags_input_impl.cljs
+++ src/cljs/re_form/inputs/tags_input_impl.cljs
@@ -10,10 +10,12 @@
    {:display "inline-block"
      :min-width "30em"
      :background-color :white
+     :padding [[(u/px 3) (u/px 12)]]
      :border-radius (u/px 2)
-     :padding [[(u/px 2) (u/px 12)]]
      :line-height (u/px h2)
     :border border}
+   [:&.empty-tags
+    {:padding [[(u/px 4) (u/px 12)]]}]
    [:input {:border :none
             :width (u/px 100)
             :outline :none}]
@@ -75,7 +77,9 @@
       :reagent-render
       (fn [{:keys [value on-change]}]
         (reset! inner-value (set value))
-        [:div.re-tags-container {:ref (fn [this] (swap! nodes assoc :root-node this))}
+        [:div.re-tags-container
+         {:class (when (empty? value) :empty-tags)
+          :ref (fn [this] (swap! nodes assoc :root-node this))}
          (for [v value] ^{:key v}
            [tag v #(on-change (s/difference (set value) (setgen v)))])
          [:input.new-tag {:type :text


fix ws

fix ws

--- src/cljs/wombats_web_client/events/user.cljs
+++ src/cljs/wombats_web_client/events/user.cljs
@@ -130,7 +130,7 @@
  :update-user
  (fn [db [_ current-user]]
    (print current-user)
-   (ws/add-user-token (:access-token current-user))
+   (ws/add-user-token (:user/access-token current-user))
    (assoc db :current-user current-user)))

 (re-frame/reg-event-db


Base sending on queue pointer, instead of nil

Original checks for "should I send from this queue next?" returned nil
for the state, if it wasn't appropriate to send.

Just don't set the field that holds the pointer to that queue instead.

This may be a performance hit (since I have to do a nested map
destructuring/lookup), but it seems cleaner/safer.

--- src/clojure/frereth_cp/message/to_parent.clj
+++ src/clojure/frereth_cp/message/to_parent.clj
@@ -329,9 +329,9 @@

 (s/fdef check-for-previous-block-to-resend
         :args ::specs/state
-        :ret (s/nilable ::specs/state))
+        :ret ::specs/state)
 (defn check-for-previous-block-to-resend
-  "Returns a modified state to resend, or nil if it's safe to move on to something fresh
+  "Return value includes next-block-queue, if we should resend
 ;;;  339-356: Try re-sending an old block: (DJB)
 ;;;           Picks out the oldest block that's waiting for an ACK
 ;;;           If it's older than (+ lastpanic (* 4 rtt_timeout))
@@ -374,17 +374,17 @@
       ;; It finds the first block that matches earliest-time
       ;; It's going to re-send that block (it *does* exist...right?)
       (let [block (first un-ackd-blocks)
-            state (assoc-in state [::specs/outgoing ::specs/next-block-queue] ::specs/un-ackd-blocks)]
+            state' (assoc-in state [::specs/outgoing ::specs/next-block-queue] ::specs/un-ackd-blocks)]
         ;; But first, it might adjust some of the globals.
         (if (> recent (+ last-panic (* 4 rtt-timeout)))
           ;; Need to update some of the related flow-control fields
-          (-> state
+          (-> state'
               (update-in [::specs/flow-control ::specs/n-sec-per-block] * 2)
               (assoc-in [::specs/outgoing ::specs/last-panic] recent)
               (assoc-in [::specs/flow-control ::specs/last-edge] recent))
           ;; We haven't had another timeout since the last-panic.
           ;; Don't adjust those dials.
-          state)))
+          state')))
     (do
       ;; Honestly, it makes more sense to consolidate the
       ;; gap-buffer with any ACKs in this message before
@@ -392,8 +392,8 @@
       ;; TODO: That instead.
       (log/debug (cl-format nil
                             (str
-                             "~a (~a): Hasn't been long enough to"
-                             " justify resending any of our ~d previously "
+                             "~a (~a): Conditions wrong"
+                             " for resending any of our ~d previously "
                              "sent un-ack'd blocks, based on"
                              "\nEarliest time: ~:d"
                              "\nnanoseconds per block: ~:d"
@@ -406,7 +406,7 @@
                             n-sec-per-block
                             rtt-timeout
                             recent))
-      nil)))
+      state)))

 (s/fdef ok-to-send-new?
         :args (s/cat :state ::specs/state)
@@ -478,7 +478,7 @@

 (s/fdef check-for-new-block-to-send
         :args (s/cat :state ::specs/state)
-        :ret (s/nilable ::specs/state))
+        :ret ::specs/state)
 (defn check-for-new-block-to-send
   "Q: Is there a new block ready to send?

@@ -500,7 +500,7 @@
                     ": Does it make sense to try to send any of our "
                     block-count
                     " unsent blocks?"))
-    (when (< 0 block-count)
+    (if (< 0 block-count)
       (if (ok-to-send-new? state)
         ;; XXX: if any Nagle-type processing is desired, do it here (--DJB)
         ;; Consolidating smaller blocks *would* be a good idea -- JRG
@@ -522,11 +522,8 @@
           (assoc-in state
                     [::specs/outgoing ::specs/next-block-queue]
                     ::specs/un-sent-blocks))
-        (do
-          ;; Be explicit about this
-          ;; TODO: Avoid extra hoops. Make the caller smarter/less complex.
-          ;; Just set the cursor to nil here.
-          nil)))))
+        ;; Leave it as-is
+        state))))

 (s/fdef pick-next-block-to-send
         :args (s/cat :state ::specs/state)
@@ -536,11 +533,13 @@
   ;; TODO: Instead of returning nil on nothing to do, just
   ;; do something like setting a nil cursor.
   ;; That should simplify the caller.
-  (or (check-for-previous-block-to-resend state)
+  (let [found? (check-for-previous-block-to-resend state)]
+    (if (get-in found? [::specs/outbound ::specs/next-block-queue])
+      found?)
 ;;;       357-410: Try sending a new block: (-- DJB)
-                  ;; There's goto-fun overlap with resending
-                  ;; a previous block -- JRG
-      (check-for-new-block-to-send state)))
+     ;; There's goto-fun overlap with resending
+     ;; a previous block -- JRG
+    (check-for-new-block-to-send state)))

 (s/fdef block->parent!
         :args (s/cat :send-buf ::specs/buf)
@@ -580,29 +579,34 @@
   ;; of having it return nil like this.
   ;; That seems like a better API.
   ;; TODO: Make that so.
-  (if-let [state' (pick-next-block-to-send state)]
-    (let [{{:keys [::specs/->parent
-                   ::specs/send-buf
-                   ::specs/un-ackd-blocks]} ::specs/outgoing
-           :as state''} (pre-calculate-state-after-send state')]
-      (log/debug (str message-loop-name
-                      ": Sending "
-                      (count send-buf)
-                      " bytes to parent"))
-      ;; Note that this winds up doing a send to the message
-      ;; loop's agent.
-      (block->parent! ->parent send-buf)
-      (log/debug (utils/pre-log message-loop-name)
-                 (str "Calculating earliest time among "
-                      (count un-ackd-blocks)
-                      " blocks\nthat have not been ACK'd in a "
-                      (class un-ackd-blocks)
-                      ".\nThis is very distinct from the "
-                      (count (get-in state'' [::specs/outgoing ::specs/un-sent-blocks]))
-                      " that is/are left in un-sent-blocks"))
+  (let [state' (pick-next-block-to-send state)
+        {{:keys [::specs/->parent
+                 ::specs/next-block-queue
+                 ::specs/send-buf
+                 ::specs/un-ackd-blocks]} ::specs/outgoing
+         :as state''} (pre-calculate-state-after-send state')]
+    (if next-block-queue
+      (do
+        (log/debug (str message-loop-name
+                        ": Sending "
+                        (count send-buf)
+                        " bytes to parent"))
+        ;; Note that this winds up doing a send to the message
+        ;; loop's agent.
+
+        (block->parent! ->parent send-buf)
+        (log/debug (utils/pre-log message-loop-name)
+                   (str "Calculating earliest time among "
+                        (count un-ackd-blocks)
+                        " blocks\nthat have not been ACK'd in a "
+                        (class un-ackd-blocks)
+                        ".\nThis is very distinct from the "
+                        (count (get-in state'' [::specs/outgoing ::specs/un-sent-blocks]))
+                        " that is/are left in un-sent-blocks"))
 ;;;      408: earliestblocktime_compute()
-      (-> state''
-          (assoc-in [::specs/outgoing ::specs/earliest-time]
-                    (help/earliest-block-time message-loop-name un-ackd-blocks))
-          (update ::specs/outgoing dissoc ::specs/next-block-queue)))
-    state))
+
+        (-> state''
+            (assoc-in [::specs/outgoing ::specs/earliest-time]
+                      (help/earliest-block-time message-loop-name un-ackd-blocks))
+            (update ::specs/outgoing dissoc ::specs/next-block-queue)))
+      state)))


Add spacing between elements on the grid

--- src/clojure/org/bytopia/foreclojure/main.clj
+++ src/clojure/org/bytopia/foreclojure/main.clj
@@ -112,6 +112,7 @@
                         context
                         [:relative-layout {:layout-height [160 :dp]
                                            :id-holder true
+                                           :background-color (android.graphics.Color/WHITE)
                                            :padding [5 :dp]}
                          [:text-view {:id ::title-tv
                                       :text-size [20 :sp]
@@ -161,7 +162,6 @@
   :key :main
   :on-create
   (fn [this bundle]
-    (neko.log/d "onCreate()" this)
     (neko.activity/request-window-features! this :indeterminate-progress)
     ;; (.addFlags (.getWindow this) android.view.WindowManager$LayoutParams/FLAG_KEEP_SCREEN_ON)
     (safe-for-ui
@@ -175,7 +175,12 @@
            [:grid-view {:id ::problems-gv
                         :column-width (traits/to-dimension this [160 :dp])
                         :num-columns :auto-fit
-                        :stretch-mode :stretch-spacing-uniform
+                        :stretch-mode :stretch-column-width
+                        :background-color (android.graphics.Color/rgb 229 229 229)
+                        :horizontal-spacing (traits/to-dimension this [8 :dp])
+                        :vertical-spacing (traits/to-dimension this [8 :dp])
+                        :padding [8 :dp]
+                        :clip-to-padding false
                         :adapter (make-problem-adapter this user)
                         :on-item-click (fn [parent _ position __]
                                          (let [id (-> (.getAdapter parent)


Left and right align working when browser window smaller than left/right edge of tooltip

--- cljs-cheatsheet/cljs_cheatsheet/tooltips.cljs
+++ cljs-cheatsheet/cljs_cheatsheet/tooltips.cljs
@@ -16,6 +16,8 @@
 (def left-arrow-class "left-arr-42ea1")
 (def right-arrow-class "right-arr-d3345")
 (def arrow-classes (str left-arrow-class " " right-arrow-class))
+
+(def min-brwsr-wdth--tt-algn 1460)

 (def fade-speed 100)

@@ -121,23 +123,32 @@
         tooltip-width (.outerWidth $tooltip-el)
         tt-width-half (half tooltip-width)
         tooltip-left (- (+ link-x (half link-width)) (half tooltip-width))
+        tooltip-right (+ (+ link-x (half link-width)) (half tooltip-width))
         tooltip-top (+ link-y link-height 4)
-        right-column-align (- $innerWidth (+ tooltip-left tt-width-half))]
-
-    ;; position el to align with edge of browser (plus padding) for
-    ;; responsive sizes
-    (if (<= tooltip-left 200)
+        right-align-amt (- (- $innerWidth tooltip-right))
+        right-align-position (- (- (- tooltip-right right-align-amt)
+          tooltip-width) 26)]
+
+    ;; position the el
+    (.css $tooltip-el (js-obj
+        "left" tooltip-left
+        "top" tooltip-top))
+
+    ;; position el to align with left edge of browser (plus padding) or
+    ;; center on link if not on edge
+    (when (and (<= tooltip-left 200)
+               (< $innerWidth min-brwsr-wdth--tt-algn))
       (.css $tooltip-el (js-obj
         "left" 10
-        "top" tooltip-top))
+        "top" tooltip-top)))
+
+    ;; position el to align with right edge of browser (plus padding) or
+    ;; center on link if not on edge
+    (when (and (>= tooltip-right (- $innerWidth 25))
+               (< $innerWidth min-brwsr-wdth--tt-algn))
       (.css $tooltip-el (js-obj
-        "left" tooltip-left
+        "left" right-align-position
         "top" tooltip-top)))
-
-        ;;on right column, if innerWidth - (tooltip-left + tooltip-width/2) >= (tooltip-width/2) : window.innerWidth - tooltip-left - toolip-width/2 = amt to adjust to the left
-
-    (log link-x)
-    (log tooltip-left)

     ;; save the bounds of the tooltip and link elements
     ;; NOTE: these numbers allow for a smidge of padding on the outside of the


Fix timing out code.

Fix timing out code.

--- src/pomo/core.cljs
+++ src/pomo/core.cljs
@@ -34,7 +34,7 @@
                                          [notification-title next-state] ((:state n) copy)
                                          ]
                                      (notify notification-title)
-                                     (swap! app-state assoc :state next-state)
+                                     (swap! app-state (comp (model/fns next-state) #(assoc % :already 0)))
                                      )
                                    )))


Add test for update-page-metadata functionality.

--- test/uxbox/tests/test_projects.clj
+++ test/uxbox/tests/test_projects.clj
@@ -126,12 +126,38 @@
         (let [uri (str +base-url (str "/api/pages/" (:id page)))
               params {:body (assoc page :data [:test1 :test2])}
               [status page'] (th/http-put user uri params)]
-          (println "RESPONSE:" status page')
+          ;; (println "RESPONSE:" status page')
           (t/is (= 200 status))
           (t/is (= [:test1 :test2] (:data page')))
           (t/is (= 1 (:version page')))
           (t/is (= (:user page') (:id user)))
           (t/is (= (:name data) "page1")))))))
+
+(t/deftest test-http-page-update-metadata
+  (with-open [conn (up/get-conn)]
+    (let [user (create-user conn 1)
+          proj (usp/create-project conn {:user (:id user) :name "proj1"})
+          data {:id (uuid/v4)
+                :user (:id user)
+                :project (:id proj)
+                :version 0
+                :data (data-encode [:test1])
+                :name "page1"
+                :width 200
+                :height 200
+                :layout "mobil"}
+          page (usp/create-page conn data)]
+      (with-server {:handler (urt/app)}
+        (let [uri (str +base-url (str "/api/pages/" (:id page) "/metadata"))
+              params {:body (assoc page :data [:test1 :test2])}
+              [status page'] (th/http-put user uri params)]
+          ;; (println "RESPONSE:" status page')
+          (t/is (= 200 status))
+          (t/is (= [:test1] (:data page')))
+          (t/is (= 1 (:version page')))
+          (t/is (= (:user page') (:id user)))
+          (t/is (= (:name data) "page1")))))))
+

 (t/deftest test-http-page-delete
   (with-open [conn (up/get-conn)]


Progress on team creation

Progress on team creation

--- webapp/src/org/teamweek/webapp/endpoint/team.clj
+++ webapp/src/org/teamweek/webapp/endpoint/team.clj
@@ -28,31 +28,34 @@

 (defn create-team
   "Creates a team based on a token"
-  [req]
-  (if-let [token (get (:form-params req) "token")]
-    (let [conn (:conn req)
-          team-data (get-team-data token)
-          team-id (d/tempid :db.part/user)
-          team-tx {:db/id team-id
-                   :team/domain (:domain team-data)
-                   :team/name (:name team-data)
-                   :team/schedule "0 0 13 ? * FRI *" ; every FRI at 13:00
-                   :team/members (for [{:keys [email name]} (:members team-data)]
-                                   {:member/name name
-                                    :member/email email})
-                   :team/questions [{:question/text "What have you accomplished this week?"
-                                     :question/order 1}
-                                    {:question/text "What you commit to do next week?"
-                                     :question/order 2}]}
-          ]
-      @(d/transact conn [team-tx]))
-    {:status 400}))
+  [conn token]
+  (let [team-data (get-team-data token)
+        team-id (d/tempid :db.part/user)
+        team-tx {:db/id team-id
+                 :team/domain (:domain team-data)
+                 :team/token token
+                 :team/name (:name team-data)
+                 :team/schedule "0 0 13 ? * FRI *" ; every FRI at 13:00
+                 :team/members (for [{:keys [email name]} (:members team-data)]
+                                 {:member/name name
+                                  :member/email email})
+                 :team/questions [{:question/text "What have you accomplished this week?"
+                                   :question/order 1}
+                                  {:question/text "What you commit to do next week?"
+                                   :question/order 2}]}
+        ]
+    @(d/transact conn [team-tx])))

 (defn team-endpoint [config]
   (context "/team" []
    (GET "/" req
      (str ring.middleware.anti-forgery/*anti-forgery-token*))
    (POST "/" req
-     (let [t (create-team req)]
-       (clojure.pprint/pprint t))
-     "Hola")))
+     (if-let [token (get (:form-params req) "token")]
+       (let [db (:db req)
+             conn (:conn req)
+             team (ffirst (d/q '[:find ?e :in $ ?t :where [?e :team/token ?t]] db token))]
+         (if team
+           (pr-str (d/touch (d/entity db team)))
+           (create-team conn token)))
+       {:status 400}))))


refine price select

refine price select

--- src/clj_money/models/storage/sql_storage.clj
+++ src/clj_money/models/storage/sql_storage.clj
@@ -218,34 +218,42 @@
 (defn- merge-where-range
   [sql field-key [start end]]
   (if (and start end)
-    (h/merge-where (if (= start end)
-                     [:= field-key start]
-                     [:and
-                      [:>= field-key start]
-                      [:<= field-key end]]))
+    (h/merge-where sql (if (= start end)
+                         [:= field-key start]
+                         [:and
+                          [:>= field-key start]
+                          [:<= field-key end]]))
     sql))
+
+(defn- descending-sort?
+  "Returns a boolean value indicating whether or not
+  the first segment of the sort expression specified
+  descending order"
+  [[sort-exp]]
+  (when (and sort-exp (sequential? sort-exp))
+    (= :desc (second sort-exp))))

 ; TODO: maybe extract the sql parts and move this to the partitioning namespace?
 (defmacro with-partitioning
-  [storage table-name d-range options bindings & body]
-  (let [[start# end#] ~d-range
-        tables# (tables-for-range start#
-                                  end#
-                                  ~table-name
-                                  {:descending? (descending-sort?
-                                                  (:sort ~options))})
-        sql-fn# (fn [~(first ~bindings)]
-                  ~@body)]
-    (->> tables#
-         (map keyword)
-         (reduce (fn [records# table#]
-                   (let [sql# (sql-fn# table#)
-                         updated-records# (concat records# (query ~storage sql#))]
-                     (if (and (= 1 (:limit ~options))
-                              (seq updated-records#))
-                       (reduced updated-records#)
-                       updated-records#)))
-                 []))))
+  [db-spec table-name d-range options bindings & body]
+  `(let [tables# (tables-for-range (first ~d-range)
+                                   (second ~d-range)
+                                   ~table-name
+                                   {:descending? (descending-sort?
+                                                   (:sort ~options))})
+         sql-fn# (fn* [~(first bindings)] ~@body)]
+     (->> tables#
+          (map keyword)
+          (reduce (fn [records# table#]
+                    (let [sql# (-> table#
+                                   sql-fn#
+                                   sql/format)
+                          updated-records# (concat records# (query ~db-spec sql#))]
+                      (if (and (= 1 (:limit ~options))
+                               (seq updated-records#))
+                        (reduced updated-records#)
+                        updated-records#)))
+                  []))))

 (defn- append-sort
   [sql options]
@@ -345,16 +353,8 @@
         rest
         (update-in [0] #(or % (.get-setting storage
                                             "earliest-partition-date"
-                                            (fnil read-string "#local-date \"2000-01-01\""))))
-        [range-value range-value])))
-
-(defn- descending-sort?
-  "Returns a boolean value indicating whether or not
-  the first segment of the sort expression specified
-  descending order"
-  [[sort-exp]]
-  (when (and sort-exp (sequential? sort-exp))
-    (= :desc (second sort-exp))))
+                                            (fnil read-string "#local-date \"2000-01-01\"")))))
+    [range-value range-value]))

 (deftype SqlStorage [db-spec]
   Storage
@@ -581,10 +581,9 @@
     [this criteria options]
     (validate-criteria criteria ::price-criteria)
     (let [d-range (date-range this (:trade-date criteria))]
-      (with-partitioning storage :prices d-range options [table]
+      (with-partitioning db-spec :prices d-range options [table]
         (-> (h/select :p.*)
             (h/from [table :p])
-            (h/join [:commodities :c] [:= :c.id :p.commodity_id])
             (append-where (dissoc criteria :trade-date) {:prefix "p"})
             (merge-where-range :trade-date d-range)
             (append-sort options)


fix deselect node deselect bug

fix deselect node deselect bug

--- src/cljs/flow_editor/views/graph_viewer.cljs
+++ src/cljs/flow_editor/views/graph_viewer.cljs
@@ -172,8 +172,8 @@

   (.on net "deselectNode"
     (fn [e]
-      (when (= 0 (.-length (aget e "nodes"))))
-      (dispatch [:graph-ui/set-active-node nil]))))
+      (when (= 0 (.-length (aget e "nodes")))
+        (dispatch [:graph-ui/set-active-node nil])))))

 (defn add-node-menu


fix textinput error-paths

fix textinput error-paths

--- src/cljs/re_form/inputs/text_input_impl.cljs
+++ src/cljs/re_form/inputs/text_input_impl.cljs
@@ -21,7 +21,7 @@
   (let [my-onchange (fn [event on-change] (on-change (.. event -target -value)))]
     (fn [{:keys [value on-change errors] :as props}]
       [:div.re-input-wrap
-       [:input.re-input (merge (dissoc props :errors)
+       [:input.re-input (merge (dissoc props :errors :error-paths)
                                {:type (or (:type props) "text")
                                 :class (when-not (empty? errors) :error)
                                 :on-change #(my-onchange % on-change)


Select input content on load

Select input content on load

--- src/cljs/subman/components/search_input.cljs
+++ src/cljs/subman/components/search_input.cljs
@@ -61,7 +61,8 @@
                (input-field-part app owner)))
     om/IDidMount
     (did-mount [_]
-      (let [input (.find ($ (om/get-node owner)) "input.search-input")]
+      (let [input (.find ($ (om/get-node owner))
+                         "input.search-input")]
         (.typeahead input
                     #js {:highlight true}
                     #js {:source #(completion-source
@@ -69,4 +70,6 @@
                                    (get-in @app [:options :source :options])
                                    %1 %2)})
         (.on input "typeahead:closed"
-             #(handle-search-input app owner (.val input)))))))
+             #(handle-search-input app owner (.val input)))
+        (.focus input)
+        (.select input)))))


Moved method details to bottom, removed old view, added loading indicator

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/method_configs/method_config_editor.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/method_configs/method_config_editor.cljs
@@ -60,32 +60,13 @@
                                           (js/alert (str "Exception:\n" (.-statusText xhr)))))})))))})))

-(defn- render-top-bar-config [config]
-  [:div {:style {:backgroundColor (:background-gray style/colors)
-                 :borderRadius 8 :border (str "1px solid " (:line-gray style/colors))
-                 :padding "1em"}}
-   [:div {:style {:float "left" :width "33.33%" :textAlign "left"}}
-    [:span {:style {:fontWeight 500 :padding "0 0.5em"}} "Method Namespace:"]
-    [:span {} (get-in config ["methodRepoMethod" "methodNamespace"])]]
-   [:div {:style {:float "left" :width "33.33%" :textAlign "center"}}
-    [:span {:style {:fontWeight 500 :padding "0 0.5em"}} "Method Name:"]
-    [:span {} (get-in config ["methodRepoMethod" "methodName"])]]
-   [:div {:style {:float "left" :width "33.33%" :textAlign "right"}}
-    [:span {:style {:fontWeight 500 :padding "0 0.5em"}} "Method Version:"]
-    [:span {} (get-in config ["methodRepoMethod" "methodVersion"])]]
-   (clear-both)])
-
-
 (react/defc MethodDetailsViewer
   {:render
    (fn [{:keys [props state]}]
-     [:div {:style {:marginRight "20%"}}
-      (cond
-        (:loaded-method @state)
-        [:div {}
-         [comps/EntityDetails
-          {:entity (:loaded-method @state)}]]
-        :else (render-top-bar-config (:config props)))])
+     (cond
+       (:loaded-method @state) [comps/EntityDetails {:entity (:loaded-method @state)}]
+       (:error @state) (style/create-server-error-message (:error @state))
+       :else [comps/Spinner {:text "Loading details..."}]))
    :component-did-mount
    (fn [{:keys [props state]}]
      (endpoints/call-ajax-orch
@@ -98,13 +79,6 @@
                    (if success?
                      (swap! state assoc :loaded-method (get-parsed-response))
                      (swap! state assoc :error status-text)))}))})
-
-(defn- render-top-bar-method [config]
-  [MethodDetailsViewer
-   {:name (get-in config ["methodRepoMethod" "methodName"])
-    :namespace (get-in config ["methodRepoMethod" "methodNamespace"])
-    :snapshotId (get-in config ["methodRepoMethod" "methodVersion"])
-    :config config}])

 (defn- render-side-bar [state refs config editing? props]
@@ -196,7 +170,13 @@
      (create-section-header "Inputs")
      (input-output-list config "inputs" invalid-inputs editing?)
      (create-section-header "Outputs")
-     (input-output-list config "outputs" invalid-outputs editing?)]))
+     (input-output-list config "outputs" invalid-outputs editing?)
+     (create-section-header "Referenced Method")
+     (create-section [MethodDetailsViewer
+                      {:name (get-in config ["methodRepoMethod" "methodName"])
+                       :namespace (get-in config ["methodRepoMethod" "methodNamespace"])
+                       :snapshotId (get-in config ["methodRepoMethod" "methodVersion"])
+                       :config config}])]))

 (defn- render-display [state refs wrapped-config editing? props]
   (let [config (get-in wrapped-config ["methodConfiguration"])]
@@ -212,19 +192,17 @@
                              :after-delete (:after-delete props)}])

      [comps/Blocker {:banner (:blocker @state)}]
-     [:div {:style {:padding "0em 2em"}}
-      (render-top-bar-method config)
-      [:div {:style {:padding "1em 0em"}}
-       (render-side-bar state refs config editing? props)
-       (when-not editing?
-         [:div {:style {:float "right"}}
-          (launch/render-button {:workspace-id (:workspace-id props)
-                                 :config-id {:namespace (config "namespace") :name (config "name")}
-                                 :root-entity-type (config "rootEntityType")
-                                 :disabled? (:locked? @state)
-                                 :on-success (:on-submission-success props)})])
-       (render-main-display wrapped-config editing?)
-       (clear-both)]]]))
+     [:div {:style {:padding "1em 2em"}}
+      (render-side-bar state refs config editing? props)
+      (when-not editing?
+        [:div {:style {:float "right"}}
+         (launch/render-button {:workspace-id (:workspace-id props)
+                                :config-id {:namespace (config "namespace") :name (config "name")}
+                                :root-entity-type (config "rootEntityType")
+                                :disabled? (:locked? @state)
+                                :on-success (:on-submission-success props)})])
+      (render-main-display wrapped-config editing?)
+      (clear-both)]]))

 (react/defc MethodConfigEditor
   {:get-initial-state


Turn off parallel build

Turn off parallel build

Not really needed and can cause
rare failures on dual hexacore.

--- planck-cljs/script/build.clj
+++ planck-cljs/script/build.clj
@@ -25,7 +25,7 @@
      :static-fns         true
      :optimize-constants false
      :dump-core          false
-     :parallel-build     true}))
+     :parallel-build     false}))

 (defn copy-source
   [filename]


* benchmark/cljs/benchmark_runner.cljs: add instance? to benchmarks


Fixed logging statement so it sends a single argument

--- src/layzee/adapters/twitter/nice_twitter.clj
+++ src/layzee/adapters/twitter/nice_twitter.clj
@@ -20,11 +20,11 @@
   #(or
     (let [log (:log opts)]
       (when-let [cached (db/get amazon-credential simple-db-domain %)]
-        (apply log ["HIT: " %])
+        (apply log [(format "HIT: " %)])
         cached)
       (do
         (let [fresh-value (simplify (api/get-tweet oauth-credential %))]
           (swap! api-hit-count inc)
-          (apply log ["MISS: " fresh-value])
+          (apply log [(format "MISS: " fresh-value)])
           (db/set amazon-credential simple-db-domain % fresh-value) ;; [!] Can only store 1024 bytes
           fresh-value))))))


Added ability to scale using by a complex number

--- src/main/clj/clojure/core/matrix/complex.clj
+++ src/main/clj/clojure/core/matrix/complex.clj
@@ -19,7 +19,7 @@

 (deftype ComplexArray [real imag]
   mp/PImplementation
-  (implementation-key [m]  ;; in this case, 'm' takes the place of the more typical 'this'
+  (implementation-key [m]                                   ;; in this case, 'm' takes the place of the more typical 'this'
     :complex-array)
   (meta-info [m]
     {:doc "Implementation for complex arrays"})
@@ -110,6 +110,10 @@
     (cond
       (number? a) (ComplexArray. (mp/scale (clojure.core.matrix.complex/real m) a)
                                  (mp/scale (clojure.core.matrix.complex/imag m) a))
+      (instance? Complex a) (ComplexArray. (mp/scale (clojure.core.matrix.complex/real m)
+                                                     (c/real-part a))
+                                           (mp/scale (clojure.core.matrix.complex/imag m)
+                                                     (c/imaginary-part a)))
       :else (error "Unable to multiply " (class a) " with a Complex value")))
   (pre-scale [m a]
     (cond
@@ -180,12 +184,16 @@

 (defn complex
   "Function to coerce a value to a complex scalar or array"
-  ([a]
-   (cond
-     (complex? a) a
-     (number? a) (c/complex-number a)
-     (mp/get-shape a) (complex-array a)
-     :else (error "Unable to coerce to complex value: " a))))
+  ([r]
+   (cond
+     (complex? r) r
+     (number? r) (c/complex-number r)
+     (mp/get-shape r) (complex-array r)
+     :else (error "Unable to coerce to complex value: " r)))
+  ([r i]
+   (cond
+     (and  (number? r) (number? i)) (c/complex-number r i)
+     :else (error "Unable to coerce to complex value: " r i))))

 (defn complex?
   "Predicate to test whether a value is a complex number or array supported by core.matrix.complex"


more on warehouse

more on warehouse

--- src/Miscellaneous/warehouse.clj
+++ src/Miscellaneous/warehouse.clj
@@ -8,6 +8,7 @@
             [monger.collection :as mc]
             [monger.operators :refer :all]
             [monger.query :refer :all]
+            [monger.joda-time :as mjt]
             [data-mall.ansj-seg :as seg]
             [data-mall.synonym :as syn]
             [data-mall.pivot-table :as pt]
@@ -17,7 +18,8 @@
             [clj-time.local :as l]
             )
   (:import [com.mongodb MongoOptions ServerAddress WriteConcern];the following two is for mongo use
-           org.bson.types.ObjectId))
+           org.bson.types.ObjectId)
+  (:use clj-excel.core))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;extract text ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -28,7 +30,7 @@

 (defn insert-by-part
   [collection data]
-  (let [parts (partition-all 500 data)]
+  (let [parts (partition-all 5000 data)]
     (map #(mc/insert-batch collection %) parts)))

 (defn integrate-text
@@ -199,10 +201,16 @@

 (defn associate-date
   [location {:as entry}]
-  (let [fmt (f/formatter "YYYY-MM-dd")]
-    (assoc entry :pubdate (l/format-local-time (extract-date location entry) :date))))
-
-#_(associate-date locations {:source "weibo" :mid (ObjectId. "530ec0ad07b83b420009e8b5")})
+  (assoc entry :pubdate (l/format-local-time (extract-date location entry) :date)))
+
+(defn associate-joda-date
+  [location {:as entry}]
+  (let [joda (extract-date location entry)
+        string (l/format-local-time (extract-date location entry) :date)
+        date (f/parse (f/formatter (t/default-time-zone) "YYYY-MM-dd" "YYYY/MM/dd") string)]
+    (assoc entry :pubdate date)))
+
+(associate-joda-date locations {:source "weibo" :mid (ObjectId. "530ec0ad07b83b420009e8b5")})

@@ -232,10 +240,90 @@
        (map #(associate-date locations %))
        (#(word-seg % :text :source :mid :pubdate))))

-(->> (make-all locations)
+(defn make-all-joda
+  [locations]
+  (->> locations
+       integrate-text
+       (map #(associate-joda-date locations %))
+       (#(word-seg % :text :source :mid :pubdate))
+       ;(take 5)
+       ))
+
+#_(->> (make-all locations)
      (insert-by-part "xuetestall"))

+(->> (make-all-joda locations)
+     (insert-by-part "xuetestall"))
+
+(mc/find-maps "xuetestall" {})
+
+(defn word-date-distribution
+  ([collection word start-day end-day]
+   (let [result (mc/aggregate collection [{$group {:_id {:pubdate "$pubdate" :word "$word" :nature "$nature"} :counts {$sum 1}}}
+                              {$match {"_id.pubdate" {$gte (t/from-time-zone (apply t/date-time start-day) (t/time-zone-for-offset +8))
+                                                      $lte (t/from-time-zone (apply t/date-time end-day) (t/time-zone-for-offset +8))}
+                                       "_id.word" word}}
+                              {$sort {"_id.pubdate" 1}}
+                              ;{$match {"_id.nature" "形容词"}}
+                              ])
+        fstr #(l/format-local-time % :date)
+        fdate #((comp fstr :pubdate :_id) %)
+        fn #(assoc {} :word word :date (fdate %) :counts (:counts %))]
+    (map fn result)
+    ))
+  ([collection start-day end-day]
+   (let [result (mc/aggregate collection [{$group {:_id {:pubdate "$pubdate" :word "$word" :nature "$nature"} :counts {$sum 1}}}
+                                          {$sort {"_id.pubdate" 1}}
+                                          {$match {"_id.pubdate" {$gte (t/from-time-zone (apply t/date-time start-day) (t/time-zone-for-offset +8))
+                                                                  $lte (t/from-time-zone (apply t/date-time end-day) (t/time-zone-for-offset +8))}}}
+                              ;{$match {"_id.nature" "形容词"}}
+                              ])
+        fstr #(l/format-local-time % :date)
+        fdate #((comp fstr :pubdate :_id) %)
+        fword #((comp :word :_id) %)
+        fn #(assoc {} :word (fword %) :date (fdate %) :counts (:counts %))]
+    (map fn result)
+    )))
+
+
+;(word-date-distribution "xuetestall" [2014 2 1] [2014 3 1])
+
+(def black-list [])
+
+(def white-list [])
+
+(defn word-list
+  [collection nature]
+  (let [result (mc/aggregate collection [{$group {:_id {:word "$word" :nature "$nature"} :counts {$sum 1}}}
+                              {$sort {"counts" -1}}
+                              {$match {"_id.nature" nature}}
+                              ])
+        fword #((comp :word :_id) %)
+        fnature #((comp :nature :_id) %)
+        fn #(assoc {} :word (fword %) :nature (fnature %) :counts (:counts %))
+        ]
+    (map fn result)))
+
+
+(t/from-time-zone (t/date-time 2014 2 1) (t/time-zone-for-offset +8))
+
+(word-list "xuetestall" "人名")
+
+(defn write-excel
+  [collection sheet file]
+  (let [func #(map val %)
+        cols (map key (first collection))]
+    (->> collection
+         (map #(func %))
+         (#(build-workbook (workbook-xssf) {sheet (into (vector cols) %)}))
+         (#(save % file))
+         )))
+
+(write-excel (word-list "xuetestall" "人名") "haha" "D:/data/人名.xlsx")
+
+
+

 ;;;;;;;;;;;;;;;;;;;;;tips;;;;;;;;;;;;;;;;;;;;;;;;

@@ -243,4 +331,4 @@

 (f/show-formatters)

-(f/formatters :basic-date-time)
+


CMR-4537: Downgraded ring-swagger due to breaking change in API between 0.22 and 0.24.

--- search-app/project.clj
+++ search-app/project.clj
@@ -37,7 +37,7 @@
     ;; Temporary inclusion of libraries needed for swagger UI until the dev portal is
     ;; done.
     [metosin/ring-swagger-ui "2.1.4-0"]
-    [metosin/ring-swagger "0.25.0"]
+    [metosin/ring-swagger "0.22.14"]
     [prismatic/schema "1.1.7"]]
   :plugins [
     [lein-exec "0.3.7"]


4clojure: least common multiple of real-nums + ratio-nums

--- src/clojure_learning/4clojure-exercises.clj
+++ src/clojure_learning/4clojure-exercises.clj
@@ -1940,25 +1940,45 @@
 ;; (== (__ 3/4 1/6) 3/2)
 ;; (== (__ 1/3 2/5) 2)
 ;; solution:
-;; real numbers:
+;;;;;;; real numbers:
 ;; find the sum of each number -> yielding many sum of nums lists -> find least common number
-
-;; rational:
-;; 1. take all denominators + find their LCM by summing each and found least common number(reuse real-nums impl)
-;; 2. using the LCM for denominators -> build new list of numbers by: multiplying
-;; each fractional number with the found LCM:
-;; (+ (/ 2 21) (/ 1/6)) = (+ (/ 4 42) (/ 7 42)) -> LCM: (/ 11 42)
-(* 42 2/21) ; 4N
-(* 42 1/6)  ; 7N
-;; 3. using the result of processed numerators, divide each with the found LCM and
-;; 4. reduce the sum -> to get the LCM for fractal numbers
-
-
+;;;;;;; rational:
+;; (= LCM(a b) (/ (* a b) gcd(a b)))
+
+(defn lcm [& xs]
+  (letfn [(gen-step-seq [bound step]
+            (take bound (iterate #(+ % step) step)))
+          (real-nums-lcm [xs]
+            (apply min
+                (reduce clojure.set/intersection
+                    (map (comp (partial apply hash-set)
+                               (partial gen-step-seq (reduce * xs)))
+                         xs))))
+          (find-numerators [xs] (map (fn [x] (if (ratio? x) (numerator x) x)) xs))
+          (find-denominators [xs] (map (fn [x] (if (ratio? x) (denominator x) 1)) xs))
+          (find-divisibles [x] (filter #(integer? (/ x %)) (gen-step-seq x 1)))
+          (gcd [xs]
+            (apply max
+              (reduce clojure.set/intersection
+                      (map (comp (partial apply hash-set) find-divisibles) xs))))]
+    (/ (real-nums-lcm (find-numerators xs)) (gcd (find-denominators xs)))))
+
+;; demo:
+(lcm 2 3)         ;; 6 -> OK
+(lcm 1/3 2/5)     ;; 2 -> OK
+(lcm 3/4 1/6)     ;; 3/2 -> NOK 3
+(lcm 7 5/7 2 3/5) ;; 210 -> OK
+(lcm 5 3 7) ;; 105 -> OK
+
+;; most elegant solution:
+(defn lcm [& nums]
+    (letfn [(gcd [a b] (if (zero? b) a (gcd b (mod a b))))]
+      (/ (reduce * nums) (reduce gcd nums))))
+
+
+(doc every?) ;; every pred coll -> boolean: returns true if predicate(x) is true for every x in coll
 (numerator 3/2)   ;; 3
 (denominator 3/2) ;; 2
 (take 40 (iterate #(+ % 5) 5)) ;; 5 10 15...105 110
-(take 40 (iterate #(+ % 3) 3)) ;; 3 6 9 ...105 108
-;; --> least common 105
-
-;; actually there's another solution for computing the LCM:
-;; (= LCM(a b) (/ (* a b) gcd(a b)))
+(apply min [1 2 3]) ;; 1
+(min 1 2 3) ;; 1


Doubled max points

Doubled max points

--- src/clojush/problems/synthetic/majority.clj
+++ src/clojush/problems/synthetic/majority.clj
@@ -42,7 +42,7 @@
     (reset! global-problem-size size)
     (println "problem-size =" size)
     (def argmap
-      {:max-points (* 10 2 size)
+      {:max-points (* 10 4 size)
        :max-genome-size-in-initial-program (* 10 size)
        :error-function majority-fitness
        :atom-generators atom-generators
@@ -53,4 +53,4 @@
        :uniform-mutation-constant-tweak-rate 0.0
        })))

-(majority-pushgp {})+(majority-pushgp {})


Update ClojureScript

Update ClojureScript

--- src/clojure/leiningen/new/web_clojure/project.clj
+++ src/clojure/leiningen/new/web_clojure/project.clj
@@ -1,7 +1,7 @@
 (defproject {{name}} "0.0.1-SNAPSHOT"
   :description "FIXME: write this!"
   :dependencies [[org.clojure/clojure "1.5.1"]
-                 [org.clojure/clojurescript "0.0-2127"]
+                 [org.clojure/clojurescript "0.0-2138"]
                  [ring "1.2.1"]]
   :plugins [[lein-cljsbuild "1.0.1"]
             [lein-ring "0.8.8"]]


Increasing the number of replicas on the index set.

--- src/cmr/index_set/config/elasticsearch_config.clj
+++ src/cmr/index_set/config/elasticsearch_config.clj
@@ -6,7 +6,7 @@
 (def idx-cfg-for-index-sets
   {:index-name "index-sets"
    :settings {"index" {"number_of_shards" 1
-                       "number_of_replicas"  0
+                       "number_of_replicas"  1
                        "refresh_interval" "30s"}}
    :mapping {"set" { "dynamic"  "strict"
                     "_source"  {"enabled" true}


Use defmulti instead

Use defmulti instead

--- src/github_changelog/formatters/markdown.clj
+++ src/github_changelog/formatters/markdown.clj
@@ -52,14 +52,13 @@
             (map markdown/li)
             join)))

-(def highlight-mapping {:major markdown/h1
-                        :minor markdown/h2
-                        :patch markdown/h3
-                        :pre-release markdown/h4
-                        :build markdown/h5})
+(defmulti highlight-fn get-type)

-(defn highlight-fn [version]
-  (get highlight-mapping (get-type version) markdown/h5))
+(defmethod highlight-fn :major [_] markdown/h1)
+(defmethod highlight-fn :minor [_] markdown/h2)
+(defmethod highlight-fn :patch [_] markdown/h3)
+(defmethod highlight-fn :pre-release [_] markdown/h4)
+(defmethod highlight-fn :default [_] markdown/h5)

 (s/defn format-tag :- s/Str
   [tag :- Tag]


Change working-dir sweep pause from 60 seconds to 1 second

--- src/cider_ci/ex/trials/working_dir_sweeper.clj
+++ src/cider_ci/ex/trials/working_dir_sweeper.clj
@@ -48,11 +48,10 @@
           (logging/info "deleting working-dir " working-dir)
           (delete-recursively working-dir))))))

-(defdaemon "trial-working-dir-sweeper" 60 (delete-orphans))
+(defdaemon "trial-working-dir-sweeper" 1 (delete-orphans))

 (defn initialize []
-  (start-trial-working-dir-sweeper)
-  )
+  (start-trial-working-dir-sweeper))

 ;### Debug ####################################################################


Use new data format for sse data and translate them to clojure data

--- src/cljs/funnel_front/actions/app_actions.cljs
+++ src/cljs/funnel_front/actions/app_actions.cljs
@@ -6,11 +6,14 @@

 (defn update-app-state [event]
   (let [data (.parse js/JSON (.-data event))
-        queries (.-query_ids data)
+        queries (.-queries data)
         body (.parse js/JSON (.-body data))]
     (.log js/console data)
+    (.log js/console "first match :" (.-id (first queries)))
     (swap! app-state
            update-in
-           [:queries (keyword (first queries)) :items]
-           conj {:body body})))
+           [:queries (keyword (.-id (first queries))) :items]
+           conj {:body (js->clj body)})
+    (.log js/console @app-state)
+    ))


fixed init state handling for volume create form

--- src/cljs/swarmpit/component/secret/create.cljs
+++ src/cljs/swarmpit/component/secret/create.cljs
@@ -48,12 +48,11 @@
   (comp/form-comp
     "ENCODE DATA"
     (comp/form-checkbox
-      {:name     "encoded"
-       :key      "encoded"
-       :hintText "Data must be base64 encoded. Disable if data already encoded"
-       :checked  value
-       :onCheck  (fn [_ v]
-                   (state/update-value [:encode] v cursor))})))
+      {:name    "encoded"
+       :key     "encoded"
+       :checked value
+       :onCheck (fn [_ v]
+                  (state/update-value [:encode] v cursor))})))

 (defn- create-secret-handler
   []
@@ -83,7 +82,8 @@
     (fn [_]
       (init-state))))

-(rum/defc form < rum/reactive []
+(rum/defc form < rum/reactive
+                 init-state-mixin []
   (let [{:keys [secretName
                 data
                 encode


Allow infinite heuristic in a*

Allow infinite heuristic in a*

--- src/angelic/search/textbook.clj
+++ src/angelic/search/textbook.clj
@@ -17,13 +17,16 @@
          (when-not (queues/pq-empty? q)
            (let [[s c] (queues/pq-remove-min-with-cost! q)]
              (util/print-debug 3 "dequeueing " (:act-seq (meta s)) c s "\n")
-             (or (and (goal s) [(reverse (:act-seq (meta s))) (:reward (meta s))])
+             (or (and (goal s) [(reverse (:act-seq (meta s))) (:reward (meta s)) #_ (println s)])
                  (do
                    (let [acts (actions s)]
                      (util/print-debug 4 "Actions are:" (map env/action-name acts) "\n")
                      (doseq [a acts :when (env/applicable? a s)]
-                       (let [[ss sc] (env/successor a s)]
-                         (queues/pq-add! q ss (- 0 (:reward (meta ss)) (heuristic ss))))))
+                       (let [[ss sc] (env/successor a s)
+                             f-val (+ (:reward (meta ss)) (heuristic ss))]
+                         (when (> f-val Double/NEGATIVE_INFINITY)
+                           (util/print-debug 1 "warning: pruning " ss)
+                           (queues/pq-add! q ss (- 0 f-val ))))))
                    (recur)))))))))


Remove volunteeer_for_task file.

Remove volunteeer_for_task file.

--- src/onyx/log/commands/volunteer_for_task.clj
+++ src/onyx/log/commands/volunteer_for_task.clj
@@ -1,180 +0,0 @@
-(ns onyx.log.commands.volunteer-for-task
-  (:require [clojure.core.async :refer [chan go >! <! close! >!!]]
-            [clojure.set :refer [union difference map-invert]]
-            [clojure.data :refer [diff]]
-            [com.stuartsierra.component :as component]
-            [onyx.log.commands.common :as common]
-            [onyx.log.entry :refer [create-log-entry]]
-            [onyx.peer.task-lifecycle :refer [task-lifecycle]]
-            [onyx.extensions :as extensions]
-            [taoensso.timbre]))
-
-(defmulti select-task
-  (fn [replica job peer-id]
-    (get-in replica [:task-schedulers job])))
-
-(defn incomplete-tasks [replica job tasks]
-  (let [tasks (get-in replica [:tasks job])
-        completed (get-in replica [:completions job])]
-    (filter identity (second (diff completed tasks)))))
-
-(defmethod select-task :onyx.task-scheduler/round-robin
-  [replica job peer-id]
-  (let [allocations (get-in replica [:allocations job])]
-    (->> (get-in replica [:tasks job])
-         (incomplete-tasks replica job)
-         (common/active-tasks-only replica)
-         (common/unsaturated-tasks replica job)
-         (map (fn [t] {:task t :n (count (get allocations t))}))
-         (sort-by :n)
-         (first)
-         :task)))
-
-(defmethod select-task :onyx.task-scheduler/percentage
-  [replica job peer-id]
-  (let [candidates (->> (get-in replica [:tasks job])
-                        (incomplete-tasks replica job)
-                        (common/active-tasks-only replica))]
-    (or (common/task-needing-pct-peers replica job candidates peer-id)
-        (common/highest-pct-task replica job candidates))))
-
-(defmethod select-task :default
-  [replica job peer-id]
-  (throw (ex-info
-           (format "Task scheduler %s not recognized. Check that you have not supplied a job scheduler instead."
-                   (get-in replica [:task-schedulers job]))
-           {:replica replica})))
-
-(defmulti select-job
-  (fn [{:keys [args]} replica]
-    (:job-scheduler replica)))
-
-(defn universally-executable-jobs [replica]
-  (->> replica
-       (common/incomplete-jobs)
-       (common/alive-jobs replica)
-       (common/jobs-with-available-tasks replica)))
-
-(defn exempt-from-acker? [replica job task args]
-  (or (some #{task} (get-in replica [:exempt-tasks job]))
-      (and (get-in replica [:acker-exclude-inputs job])
-           (some #{task} (get-in replica [:input-tasks job])))
-      (and (get-in replica [:acker-exclude-outputs job])
-           (some #{task} (get-in replica [:output-tasks job])))))
-
-(defn offer-acker [replica job task args]
-  (let [peers (count (apply concat (vals (get-in replica [:allocations job]))))
-        ackers (count (get-in replica [:ackers job]))
-        pct (get-in replica [:acker-percentage job])
-        current-pct (int (Math/ceil (* 10 (double (/ ackers peers)))))]
-    (if (and (< current-pct pct) (not (exempt-from-acker? replica job task args)))
-      (-> replica
-          (update-in [:ackers job] conj (:id args))
-          (update-in [:ackers job] vec))
-      replica)))
-
-(defmethod select-job :onyx.job-scheduler/greedy
-  [{:keys [args]} replica]
-  (let [job (first (universally-executable-jobs replica))
-        allocation (common/peer->allocated-job (:allocations replica) (:id args))]
-    (if job
-      (if-let [task (select-task replica job (:id args))]
-        (if (or (not= task (:task allocation))
-                (not= job (:job allocation)))
-          (-> replica
-              (common/remove-peers args)
-              (update-in [:allocations job task] conj (:id args))
-              (update-in [:allocations job task] vec)
-              (assoc-in [:peer-state (:id args)] :warming-up)
-              (offer-acker job task args))
-          replica)
-        replica)
-      replica)))
-
-(defmethod select-job :onyx.job-scheduler/round-robin
-  [{:keys [args]} replica]
-  (if-not (common/saturated-cluster? replica)
-    (let [candidates (universally-executable-jobs replica)
-          allocation (common/peer->allocated-job (:allocations replica) (:id args))
-          job (or (common/find-job-needing-peers replica candidates)
-                  (common/round-robin-next-job replica candidates))]
-      (if job
-        (if-let [task (select-task replica job (:id args))]
-          (if (or (not= task (:task allocation))
-                  (not= job (:job allocation)))
-            (-> replica
-                (common/remove-peers args)
-                (update-in [:allocations job task] conj (:id args))
-                (update-in [:allocations job task] vec)
-                (assoc-in [:peer-state (:id args)] :warming-up)
-                (offer-acker job task args))
-            replica)
-          replica)
-        replica))
-    replica))
-
-(defmethod select-job :onyx.job-scheduler/percentage
-  [{:keys [args]} replica]
-  (let [candidates (universally-executable-jobs replica)
-        balanced (common/percentage-balanced-workload replica)
-        allocation (common/peer->allocated-job (:allocations replica) (:id args))
-        job
-        (reduce
-         (fn [_ job]
-           (let [required-count (:allocation (get balanced job))
-                 actual-count (count (get (common/job->peers replica) job))]
-             (when (< actual-count required-count)
-               (reduced job))))
-         nil
-         candidates)]
-    (if job
-      (if-let [task (select-task replica job (:id args))]
-        (if (or (not= task (:task allocation))
-                (not= job (:job allocation)))
-          (-> replica
-              (common/remove-peers args)
-              (update-in [:allocations job task] conj (:id args))
-              (update-in [:allocations job task] vec)
-              (assoc-in [:peer-state (:id args)] :warming-up)
-              (offer-acker job task args))
-          replica)
-        replica)
-      replica)))
-
-(defmethod select-job :default
-  [_ replica]
-  (throw (ex-info
-           (format "Job scheduler %s not recognized. Check that you have not supplied a task scheduler instead."
-                   (:job-scheduler replica))
-           {:replica replica})))
-
-(defmethod extensions/apply-log-entry :volunteer-for-task
-  [entry replica]
-  (select-job entry replica))
-
-(defmethod extensions/replica-diff :volunteer-for-task
-  [{:keys [args]} old new]
-  (let [allocation (second (diff (:allocations old) (:allocations new)))]
-    {:job (first (keys allocation))
-     :task (first (keys (get allocation (first (keys allocation)))))}))
-
-(defmethod extensions/reactions :volunteer-for-task
-  [{:keys [args]} old new diff peer-args]
-  (let [scheduler (get-in new [:task-schedulers (:job diff)])]
-    (when (and (common/volunteer? old new peer-args (:job peer-args))
-               (common/reallocate-from-task? scheduler old new (:job peer-args) peer-args))
-      [{:fn :volunteer-for-task :args {:id (:id peer-args)}}])))
-
-(defmethod extensions/fire-side-effects! :volunteer-for-task
-  [{:keys [args]} old new diff state]
-  (if (and (= (:id args) (:id state)) (:job diff) (:task diff)
-           (or (not= (:job state) (:job diff))
-               (not= (:task state) (:task diff))))
-    (do (when (:lifecycle state)
-          (component/stop @(:lifecycle state)))
-        (let [seal-ch (chan)
-              new-state (assoc state :job (:job diff) :task (:task diff) :seal-ch seal-ch)
-              new-lifecycle (future (component/start ((:task-lifecycle-fn state) diff new-state)))]
-          (assoc new-state :lifecycle new-lifecycle :seal-response-ch seal-ch)))
-    state))
-


change translation key

change translation key


(PDB-3723) Restrict numeric comparisons to numeric json values

[rlb@puppet.com: adjust message]

--- src/puppetlabs/puppetdb/query_eng/engine.clj
+++ src/puppetlabs/puppetdb/query_eng/engine.clj
@@ -1466,8 +1466,8 @@
   [node]
   (cm/match [node]

-            [[(op :guard (classic-facts-pred #{"=" "<" ">" "<=" ">="})) "value" (value :guard #(number? %))]]
-            [op "value" value] ;; TODO add coercion support here
+            [[(op :guard #{"=" "<" ">" "<=" ">="}) "value" (value :guard #(number? %))]]
+            ["and" ["=" ["function" "jsonb_typeof" "value"] "number"] [op "value" value]]

             [[(op :guard (classic-facts-pred #{"="})) "value"


remove old/irrelevant comment

remove old/irrelevant comment

--- src/asphalt/internal/iparam.clj
+++ src/asphalt/internal/iparam.clj
@@ -139,7 +139,7 @@
   an expression to set JDBC prepared statement param."
   [pstmt-sym param-type pidx-sym pval-sym]
   (when-not (contains? t/all-typemap param-type) (i/expected-param-type param-type))
-  (if (contains? t/multi-typemap param-type)  ; multi-bit?
+  (if (contains? t/multi-typemap param-type)
     (let [i-sym (gensym "i-")
           v-sym (gensym "v-")]
       `(i/each-indexed [~i-sym ~pidx-sym


make it possible to disable hawk fs-watch on macOS

--- src/main/shadow/cljs/devtools/server/fs_watch.clj
+++ src/main/shadow/cljs/devtools/server/fs_watch.clj
@@ -10,7 +10,7 @@

 (defn start [config directories file-exts publish-fn]
   (let [ns-sym
-        (if (str/includes? os-name "Mac")
+        (if (and (str/includes? os-name "Mac") (not (false? (:hawk config))))
           ;; macOS doesn't have native support so it uses polling
           ;; which means 2sec delay, hawk does the native stuff
           ;; so its a lot faster but doesn't properly support delete


remove unused :generate

remove unused :generate

--- src/babel/italiano/grammar.cljc
+++ src/babel/italiano/grammar.cljc
@@ -741,7 +741,6 @@
      {:index-fn (fn [spec] (lookup-spec spec indices index-lexicon-on-paths))
       :default-fn default-fn
       :name "Italiano language model created with ❤ by babel.italiano.grammar/model-plus-lexicon."
-      :generate {:lexicon lexicon-for-generation}
       :grammar grammar
       :language "it"
       :language-keyword :italiano


support nounplf and nounplurf

support nounplf and nounplurf

--- src/babel/italiano/lexicon.cljc
+++ src/babel/italiano/lexicon.cljc
@@ -543,7 +543,8 @@
                   :agr {:gender :fem
                         :number :sing}}}]}

-      (= vocab-cat "nounplurm")
+      (or (= vocab-cat "nounplurm")
+          (= vocab-cat "nounplf"))
       {surface
        [{:vocab-cat vocab-cat
          :italiano {:plur surface}
@@ -551,7 +552,8 @@
                   :agr {:gender :masc
                         :number :plur}}}]}

-      (= vocab-cat "nounplurf")
+      (or (= vocab-cat "nounplurf")
+          (= vocab-cat "nounplf"))
       {surface
        [{:vocab-cat vocab-cat
          :italiano {:plur surface}


Refactor: tidied up boundary->coords fn

Refactor: tidied up boundary->coords fn

--- src/acfe/core.clj
+++ src/acfe/core.clj
@@ -32,20 +32,14 @@
 (defqueries "sql/queries.sql")

-(def to-double #(Double/parseDouble %))
-
-
 (defn boundary->coords
-  "Take boundary string (see regions.csv), return coords."
+  "Take boundary string (see db>areas>boundary-string), return coord maps."
   [s]
   (->>
-   (split s #"\s")
-   (map #(split % #","))
-   (map drop-last)
-   (map #(map to-double %))
-   (map #(map (partial format "%.5f") %))
-   (map #(map to-double %))
-   (map #(zipmap [:lng :lat] %))))
+   (for [t (split s #"[\s,]")]
+	 (Double/parseDouble (format t "%.5f")))
+   (partition 3)
+   (map #(zipmap [:lng :lat :alt] %))))

 (defn get-areas


don't even need core.logic when handling facts only for conversion to entities

--- sample/src/sample/core.clj
+++ sample/src/sample/core.clj
@@ -41,17 +41,17 @@

 (defn cltest2 []
-  (cldb/db-rel fact e a v t)
+  #_(cldb/db-rel fact e a v t)

   (defn facts->entities [facts & {:keys [at-t]}]
-    (let [ldb (apply cldb/db facts)
-          lres (cldb/with-db ldb
+    (let [;;;ldb (apply cldb/db facts)
+          #_lres #_(cldb/with-db ldb
                  (cl/run* [q]
                    (cl/fresh [e a v t]
                      (fact e a v t)
                      (cl/== q [e a v t]))))]
-      (when (not-empty lres)
-        (->> lres
+      (when (not-empty facts #_lres)
+        (->> facts #_lres
              (reduce (fn [s [e a v t]]
                        (if (or (not at-t) (<= t at-t))
                          (update-in s [e a]
@@ -71,33 +71,34 @@
                                am)]))
              (into {})))))

-  (defn merge-entities [es1 es2]
-    (merge-with #(merge %1 %2)
-                es1 es2))
+  (defn entities+facts->entities [entities facts & {:keys [at-t]}]
+    (letfn [(merge-entities [es1 es2]
+              (merge-with #(merge %1 %2)
+                          es1 es2))]
+      (merge-entities entities (facts->entities facts :at-t at-t))))

-  (defn entities+facts->entities [entities facts & {:keys [at-t]}]
-    (merge-entities entities (facts->entities facts :at-t at-t)))
+  (let [facts1 [[#_fact 200 :type     :address      1]
+                [#_fact 200 :street   "street 111"  1]
+                [#_fact 200 :number   111           1]

-  (let [facts1 [[fact 200 :type     :address      1]
-                [fact 200 :street   "street 111"  1]
-                [fact 200 :number   111           1]
+                [#_fact 100 :type     :person       2]
+                [#_fact 100 :name     "foo"         2]
+                [#_fact 100 :email    "foo@bar.com" 2]
+                [#_fact 100 :address  200           2]

-                [fact 100 :type     :person       2]
-                [fact 100 :name     "foo"         2]
-                [fact 100 :email    "foo@bar.com" 2]
-                [fact 100 :address  200           2]
+                [#_fact 101 :type     :person       2]
+                [#_fact 101 :name     "bar1"        2]
+                [#_fact 101 :email    "bar@foo.com" 2]
+                [#_fact 101 :address  200           2]
+                [#_fact 101 :name     "bar3"        4]
+                [#_fact 101 :name     "bar5"        6]
+                [#_fact 101 :name     "bar2"        3]
+                [#_fact 101 :name     "bar4"        5]]

-                [fact 101 :type     :person       2]
-                [fact 101 :name     "bar1"        2]
-                [fact 101 :email    "bar@foo.com" 2]
-                [fact 101 :address  200           2]
-                [fact 101 :name     "bar3"        4]
-                [fact 101 :name     "bar5"        6]
-                [fact 101 :name     "bar2"        3]
-                [fact 101 :name     "bar4"        5]]
-
-        facts2 [[fact 101 :name     "bar7"        8]
-                [fact 101 :name     "bar6"        7]]]
+        facts2 [[#_fact 101 :name     "bar7"        8]
+                [#_fact 101 :name     "bar6"        7]
+                [#_fact 101 :name     "bar9"        10]
+                [#_fact 101 :name     "bar8"        9]]]

     (entities+facts->entities (facts->entities facts1) facts2)))


add vendors to garden config

add vendors to garden config

--- src/leiningen/new/reagent_liveedit/project.clj
+++ src/leiningen/new/reagent_liveedit/project.clj
@@ -67,12 +67,14 @@
                      :source-paths ["src/styles"]
                      :stylesheet {{ns-name}}.styles.site/site
                      :compiler {:output-to "resources/public/css/site.css"
+                                :vendors ["webkit"]
                                 :pretty-print? false}}
                     {:id "dev"
                      :source-paths ["src/styles"]
                      :stylesheet {{ns-name}}.styles.site/site
                      :env {:dev? true}
                      :compiler {:output-to "resources/public/css/site.css"
+                                :vendors ["webkit"]
                                 :pretty-print? true}}]}

   :cljsbuild {:builds {:app {:source-paths ["src/cljs"]


Make kibit happy. Thanks kibit!

Make kibit happy. Thanks kibit!

--- src/open_company/resources/stakeholder_update.clj
+++ src/open_company/resources/stakeholder_update.clj
@@ -152,8 +152,8 @@
          (every? :created-at updates)]}
   (let [all (reverse (sort-by :created-at updates)) ; all updates, most recent first
         by-author (vals (group-by #(-> % :author :user-id) all)) ; separate by distinct authorship
-        by-medium (apply concat (map #(vals (group-by :medium %)) by-author)) ; separate those by distinct medium
-        by-title (apply concat (map #(vals (group-by :title %)) by-medium)) ; separate those by distinct title
+        by-medium (mapcat #(vals (group-by :medium %)) by-author) ; separate those by distinct medium
+        by-title (mapcat #(vals (group-by :title %)) by-medium) ; separate those by distinct title
         time-filtered (map time-filter by-title)] ; filter those to the most recent per time period
     ; flatten the remaining sequences of distinct updates into a single sequence and order them by most recent
     (vec (reverse (sort-by :created-at (apply concat time-filtered))))))


change future points to expected value

change future points to expected value

--- src/bracketolojy/tournament.clj
+++ src/bracketolojy/tournament.clj
@@ -40,7 +40,7 @@
   [team-data]
   (->> team-data
        (remove (comp nil? :seed))
-       (map #(vector (:name %) (assoc % :weight 1 :avg-pts 0 :future-pts 0)))
+       (map #(vector (:name %) (assoc % :weight 1 :avg-pts 0 :expected-value 0)))
        (into {})))

 (defn ->tournament-bracket
@@ -93,21 +93,21 @@
     (partial compute-matchup pick-scoring upset-scoring)
     tournament-bracket))

-(defn- update-child-future-pts
-  "Update the future-pts of each team in the field using parent-team-map.  The future-pts for each team in the
-  field is the team's average points plus the future-pts of the team in the parent-team-map."
+(defn- update-child-expected-value
+  "Update the expected value of each team in the field using parent-team-map.  The expected value for each team in the
+  field is the team's average points plus the expected value of the team in the parent-team-map."
   [parent-team-map [field children]]
   (vector
     (map
-      #(update-in % [:future-pts] +
-        (get-in parent-team-map [(:name %) :future-pts] 0)
+      #(update-in % [:expected-value] +
+        (get-in parent-team-map [(:name %) :expected-value] 0)
         (:avg-pts %))
       field)
     children))

-(defn- update-future-pts
-  "For each child in children, update the future-pts of the teams in that child's field.  The future-pts for each team
-  in a field is the team's average points plus the future-pts of the team in the parent field."
+(defn- update-expected-value
+  "For each child in children, update the expected value of the teams in that child's field.  The expected value for each team
+  in a field is the team's average points plus the expected value of the team in the parent field."
   [[field children]]
   (vector
     field
@@ -116,21 +116,21 @@
                             (map #((juxt :name identity) %))
                             (into {}))]
       (map
-        (partial update-child-future-pts parent-team-map)
+        (partial update-child-expected-value parent-team-map)
         children))))

-(defn- compute-future-pts-helper
-  "Recursively traverse the zipper, updating each node with the future points computation."
+(defn- compute-expected-value-helper
+  "Recursively traverse the zipper, updating each node with the expected value computation."
   [loc]
   (if (zip/end? loc)
     loc
-    (recur (zip/next (zip/edit loc update-future-pts)))))
+    (recur (zip/next (zip/edit loc update-expected-value)))))

-(defn compute-future-pts
-  "Compute the future points for each node in the tournament probabilites tree."
+(defn compute-expected-value
+  "Compute the expected value for each node in the tournament probabilites tree."
   [tp]
   (->>
-    (update-child-future-pts nil tp)
+    (update-child-expected-value nil tp)
     (zip/zipper
       (fn [[_ cn]]
         (or (vector? cn) (seq? cn)))
@@ -138,11 +138,11 @@
         (seq cn))
       (fn [node cn]
         (assoc node 1 cn)))
-    compute-future-pts-helper
+    compute-expected-value-helper
     zip/root))

 (defn predict-bracket
-  "Predict the expected future points for each team in each round of the tournament.  Bracket should be
+  "Predict the expected value for each team in each round of the tournament.  Bracket should be
   a bracket of team names in a tree structure.  pick-scoring is an associative structure that gives the points
   per a correct pick for each round.  upset-scoring is an associative structure that gives the points per an
   upset pick for each round.  team-data is a seq of team data."
@@ -154,4 +154,4 @@
     (tournament-probabilities
       pick-scoring
       upset-scoring)
-    compute-future-pts))+    compute-expected-value))


removed leftover println

removed leftover println

--- src/chat/client/dispatcher.cljs
+++ src/chat/client/dispatcher.cljs
@@ -85,7 +85,6 @@
         (store/set-message-failed! message)))))

 (defmethod dispatch! :hide-thread [_ data]
-  (println "hide-thread" data)
   (sync/chsk-send! [:chat/hide-thread (data :thread-id)])
   (store/hide-thread! (data :thread-id)))


bump up the timeout for search-history

bump up the timeout for search-history

--- src/chat/client/dispatcher.cljs
+++ src/chat/client/dispatcher.cljs
@@ -127,7 +127,7 @@
 (defmethod dispatch! :search-history [_ query]
   (sync/chsk-send!
     [:chat/search query]
-    5000
+    15000
     (fn [reply]
       (when (seq (:thread-ids reply))
         (store/set-search-results! reply)))))


Make :corpus/metadata-categories a component

--- src/clj/cglossa/models/core.clj
+++ src/clj/cglossa/models/core.clj
@@ -12,7 +12,7 @@
            (fields
              [name :string]
              [short-name :string :unique-identity]
-             [metadata-categories :ref :many]))
+             [metadata-categories :ref :many :component]))

    (schema metadata-category
            (fields


Move default port calculation to `go` fn

--- src/clj/comic_reader/system.clj
+++ src/clj/comic_reader/system.clj
@@ -26,15 +26,15 @@
   (alter-var-root #'system
     (fn [s] (when s (component/stop s)))))

-(defn go [config-options]
-  (init config-options)
-  (start))
+(defn go [& [port]]
+  (let [port (Integer. (or port (env :port) 10555))]
+    (init {:app server/app
+           :port port})
+    (start)))

 (defn reset []
   (stop)
-  (refresh :after 'comic-reader.system/-main))
+  (refresh :after 'comic-reader.system/go))

-(defn -main [& [port]]
-  (let [port (Integer. (or port (env :port) 10555))]
-    (go {:app server/app
-         :port port})))
+(defn -main [& args]
+  (apply go args))


push Turntable prompt to the front of the queue during multi-access

--- src/clj/game/cards-hardware.clj
+++ src/clj/game/cards-hardware.clj
@@ -524,13 +524,13 @@
              :runner-spent-click {:req (req (:swap card))
                                   :effect (effect (update! (dissoc card :swap)))}}
     :abilities [{:req (req (:swap card))
-                 :effect (req (let [agendas (get-in corp [:scored])
-                                    st (last (get-in runner [:scored]))]
+                 :effect (req (let [st (last (get-in runner [:scored]))]
                                 (resolve-ability
                                   state side
                                   {:req (req (is-type? st "Agenda"))
                                    :prompt (msg "Choose a scored Corp agenda to swap for " (:title st))
-                                   :choices {:req #(some (fn [c] (= (:cid %) (:cid c))) agendas)}
+                                   :priority true
+                                   :choices {:req #(in-corp-scored? state side %)}
                                    :effect (req (let [sw target
                                                       stpts-corp (get-agenda-points state :corp st)
                                                       swpts-corp (get-agenda-points state :corp sw)