add endorsement icon to profile badges

add endorsement icon to profile badges

--- src/cljs/salava/user/ui/profile.cljs
+++ src/cljs/salava/user/ui/profile.cljs
@@ -21,11 +21,11 @@

 (defn toggle-visibility [visibility-atom]
   (ajax/POST
-     (path-for "/obpv1/user/profile/set_visibility")
-     {:params  {:visibility (if (= "internal" @visibility-atom) "public" "internal")}
-      :handler (fn [new-value]
-                 (reset! visibility-atom new-value)
-                 )}))
+    (path-for "/obpv1/user/profile/set_visibility")
+    {:params  {:visibility (if (= "internal" @visibility-atom) "public" "internal")}
+     :handler (fn [new-value]
+                (reset! visibility-atom new-value)
+                )}))

 (defn profile-visibility-input [visibility-atom]
   [:div.col-xs-12
@@ -37,32 +37,47 @@
               :checked   (= "public" @visibility-atom)}]
      (t :user/Publishandshare)]]])

+#_(defn badge-grid-element [element-data]
+    (let [{:keys [id image_file name description issuer_content_name issuer_content_url]} element-data]
+      ;[:div {:class "col-xs-12 col-sm-6 col-md-4" :key id}
+      [:div {:class "media grid-container"}
+       [:div.media-content
+        (if image_file
+          [:div.media-left
+           [:a{:href "#"
+               :on-click #(do
+                            (mo/open-modal [:badge :info] {:badge-id id})
+                            ;(b/open-modal id false init-data state)
+                            (.preventDefault %)) }
+            [:img {:src (str "/" image_file)
+                   :alt name}]]])
+        [:div.media-body
+         [:div.media-heading
+          [:a.heading-link {:href "#"
+                            :on-click #(do
+                                         (mo/open-modal [:badge :info] {:badge-id id})
+                                         ;(b/open-modal id false init-data state)
+                                         (.preventDefault %)) }
+           name]]
+         [:div.media-issuer
+          [:p issuer_content_name]]]]]
+      ;]
+      ))
 (defn badge-grid-element [element-data]
-  (let [{:keys [id image_file name description issuer_content_name issuer_content_url]} element-data]
-    ;[:div {:class "col-xs-12 col-sm-6 col-md-4" :key id}
-     [:div {:class "media grid-container"}
-      [:div.media-content
-       (if image_file
-         [:div.media-left
-          [:a{:href "#"
-              :on-click #(do
-                           (mo/open-modal [:badge :info] {:badge-id id})
-                                        ;(b/open-modal id false init-data state)
-                           (.preventDefault %)) }
-            [:img {:src (str "/" image_file)
-                 :alt name}]]])
+  (let [{:keys [id image_file name description issuer_content_name issuer_content_url endorsement_count user_endorsements_count]} element-data]
+    [:div.media.grid-container
+     [:div.media-content
+      [:a {:href "#" :on-click #(do
+                                  (.preventDefault %)
+                                  (mo/open-modal [:badge :info] {:badge-id id})
+                                  )}
+       (when image_file [:div.media-left [:img {:src (str "/" image_file)}]])
        [:div.media-body
-        [:div.media-heading
-         [:a.heading-link {:href "#"
-                           :on-click #(do
-                                        (mo/open-modal [:badge :info] {:badge-id id})
-                                        ;(b/open-modal id false init-data state)
-                                        (.preventDefault %)) }
-          name]]
-        [:div.media-issuer
-         [:p issuer_content_name]]]]]
-              ;]
-              ))
+        [:div.media-heading name]
+        [:div.media-issuer [:p issuer_content_name]]
+        (when (or (pos? user_endorsements_count) (pos? endorsement_count)) [:div.badge-view.text-center [:i.fa.fa-handshake-o]])]
+
+       ]]]))

 (defn page-grid-element [element-data profile_picture]
   (let [{:keys [id name first_name last_name badges mtime]} element-data
@@ -132,8 +147,8 @@
       [:div.row.flip
        [:div {:class "col-md-3 col-sm-3 col-xs-12"}
         [:div.profile-picture-wrapper
-        [:img.profile-picture {:src (profile-picture profile_picture)
-                               :alt fullname}]]]
+         [:img.profile-picture {:src (profile-picture profile_picture)
+                                :alt fullname}]]]
        [:div {:class "col-md-9 col-sm-9 col-xs-12"}
         (if (not-empty about)
           [:div {:class "row about"}
@@ -191,14 +206,14 @@
                          :status "false"}]

     (ajax/GET
-     (path-for (str "/obpv1/user/profile/" user-id) true)
-     {:handler (fn [data]
-                 (reset! state (assoc data :user-id user-id
-                                      :show-link-or-embed-code nil
-                                      :permission "success"
-                                      :badge-small-view false
-                                      :reporttool reporttool-init)))}
-     (fn [] (swap! state assoc :permission "error")))))
+      (path-for (str "/obpv1/user/profile/" user-id) true)
+      {:handler (fn [data]
+                  (reset! state (assoc data :user-id user-id
+                                  :show-link-or-embed-code nil
+                                  :permission "success"
+                                  :badge-small-view false
+                                  :reporttool reporttool-init)))}
+      (fn [] (swap! state assoc :permission "error")))))

 (defn handler [site-navi params]
   (let [user-id (:user-id params)


CMR-483: added invalid id message functions

--- src/cmr/common/services/messages.clj
+++ src/cmr/common/services/messages.clj
@@ -27,4 +27,16 @@
   [input-str]
   (format "%s is not of the form 'value', 'min-value,max-value', 'min-value,', or ',max-value'
           where value, min-value, and max-value are optional numeric values."
-          input-str))+          input-str))
+
+(defn invalid-ignore-case-opt-setting-msg
+  "Creates a message saying which parameters would not allow ignore case option setting."
+  [params-set]
+  (let [params (reduce (fn [params param] (conj params param)) '() (seq params-set))]
+    (format "Ignore case option setting disallowed on these parameters: %s" params)))
+
+(defn invalid-pattern-opt-setting-msg
+  "Creates a message saying which parameters would not allow pattern option setting."
+  [params-set]
+  (let [params (reduce (fn [params param] (conj params param)) '() (seq params-set))]
+    (format "Pattern option setting disallowed on these parameters: %s" params)))


re-implement check tasks.

re-implement check tasks.

--- src/leiningen/ancient/check.clj
+++ src/leiningen/ancient/check.clj
@@ -1,108 +1,35 @@
-(ns ^{ :doc "Check for outdated dependencies."
-       :author "Yannick Scherer" }
-  leiningen.ancient.check
-  (:require [leiningen.ancient.utils.projects :refer :all]
-            [leiningen.ancient.utils.cli :refer :all]
-            [leiningen.ancient.utils.io :refer :all]
-            [leiningen.core.main :as main]
-            [ancient-clj.verbose :refer :all]
-            [ancient-clj.core :as anc]
-            [clojure.java.io :as io]))
+(ns leiningen.ancient.check
+  (:require [leiningen.ancient.artifact
+             [options :as o]
+             [files :as f]]
+            [leiningen.ancient
+             [collect :refer :all]
+             [console :as console]
+             [utils :as utils]
+             [verbose :refer :all]]))

-;; ## Check/Update
+;; ## Logic

-(defn check-artifact!
-  "Checks the given artifact and stores the latest version in `:latest`."
-  [repos settings {:keys [group-id artifact-id version] :as artifact}]
-  (let [path (artifact-path artifact)]
-    (verbose "Checking " group-id "/" artifact-id " (current version: " (version-string version)
-             " at " (artifact-path artifact) ") ...")
-    (assoc artifact :latest (anc/artifact-outdated? settings repos artifact))))
+(defn- check-file!
+  [{:keys [artifact-opts]} file]
+  (utils/with-success [r (f/read! file)]
+    (utils/with-success [outdated (f/check! r artifact-opts)]
+      (if (seq outdated)
+        (doseq [artifact outdated]
+          (console/print-outdated-message artifact))
+        (verbosef "all artifacts are up-to-date.")))))

-(defn get-outdated-artifacts!
-  "Get (a lazy seq of) all outdated artifacts (with the latest version in `:latest`).
-   Input and Output are artifact maps."
-  [repos settings artifacts]
-  (let [checked-artifacts (map #(check-artifact! repos settings %) artifacts)]
-    (filter :latest checked-artifacts)))
+;; ## Tasks

-;; ## Console Interaction
+(utils/deftask check
+  {:docstring "Check projects for outdated artifacts. (default)"
+   :exclude [:interactive :print :no-tests]}
+  [opts]
+  (utils/call-on-project-files check-file! opts))

-(defn print-outdated-message
-  "Takes an artifact map (containing the `:latest` element) and prints
-   the \"[...] is available but we use ...\" message to stdout."
-  [{:keys [group-id artifact-id version latest]}]
-  (main/info
-    (artifact-string group-id artifact-id latest)
-    "is available but we use"
-    (yellow (version-string version))))
-
-;; ## Check Logic
-
-(defn- check-project-map!
-  "Run project/plugin checker on the given project/settings maps."
-  [project settings]
-  (with-output-settings settings
-    (let [repos (collect-repositories project)
-          artifacts (collect-artifacts project settings)
-          outdated (get-outdated-artifacts! repos settings artifacts)]
-      (verbose "Checking " (count artifacts) " Dependencies using " (count repos) " Repositories ...")
-      (doseq [artifact outdated]
-        (print-outdated-message artifact))
-      (verbose "Done."))))
-
-(defn- check-profiles-file!
-  "Check a single profiles file."
-  [repositories path settings]
-  (when-let [profiles (read-profiles-map! path)]
-    (check-project-map! {:repositories repositories :profiles profiles}
-                        (-> settings
-                          (assoc :profiles true)
-                          (assoc :plugins true)))))
-
-(defn- check-project-file!
-  "Check a single project file."
-  [path settings]
-  (when-let [project (read-project-map! path)]
-    (when (:recursive settings) (main/info "--" path))
-    (check-project-map! project settings)
-    (when (:recursive settings) (main/info))))
-
-(defn- check-project-directory!
-  "Check files in directory, possibly recursively."
-  [path settings]
-  (let [top-file (io/file path "project.clj")]
-    (cond (:recursive settings) (let [project-files (find-files-recursive! path "project.clj")]
-                                  (doseq [^java.io.File project-file project-files]
-                                    (check-project-file! (.getPath project-file) settings)))
-          (.isFile top-file) (check-project-file! (.getPath top-file) settings)
-          :else (main/abort "No file at:" (.getPath top-file)))))
-
-(defn- check-path!
-  "Run project/plugin checker on the given path."
-  [repositories path args]
-  (let [^java.io.File f (io/file path)
-        settings (parse-cli args)]
-    (cond (.isFile f) (let [settings (assoc settings :recursive false)]
-                        (cond (= (.getName f) "project.clj") (check-project-file! path settings)
-                              (= (.getName f) "profiles.clj") (check-profiles-file! repositories path settings)
-                              :else (main/abort "Can only check 'project.clj' or 'profiles.clj'.")))
-          (.isDirectory f) (check-project-directory! path settings)
-          :else (main/abort "No such file or directory:" path))))
-
-;; Tasks
-
-(defn run-check-task!
-  "Run project/plugin checker."
-  [{:keys [repositories root]} args]
-  (if (exists? (last args))
-    (check-path! repositories (last args) (butlast args))
-    (check-path! repositories (or root ".") args)))
-
-(defn run-profiles-task!
-  "Run plugin checker on global profiles file."
-  [{:keys [repositories]} args]
-  (let [f (java.io.File. (System/getProperty "user.home") ".lein/profiles.clj")]
-    (if (.isFile f)
-      (check-path! repositories f args)
-      (main/info "No file at: ~/.lein/profiles.clj"))))
+(utils/deftask profiles
+  {:docstring "Check profiles for outdated artifacts."
+   :exclude [:no-profiles :interactive :print :no-tests :recursive]
+   :fixed {:plugins? true}}
+  [opts]
+  (utils/call-on-profiles-files check-file! opts))


wrong option used. fixed now

wrong option used. fixed now

--- src/crawler/main.clj
+++ src/crawler/main.clj
@@ -233,7 +233,7 @@

           (:discussion-forum options)
           (discussion-forum-crawler-3 (:start options)
-                                      (:num-docs options))
+                                      (:num-leaves options))

           (:fix-model options)
           (let [model-file (:fix-model options)


fix typo

fix typo


Add weasel stop-server.

Add weasel stop-server.

--- src/dev/clj/user.clj
+++ src/dev/clj/user.clj
@@ -9,7 +9,8 @@
             [clojure.java.io :as io]
             [clojure.tools.namespace.repl :as r]
             [com.potetm.tire-iron :as ti]
-            [weasel.repl.websocket :as weasel])
+            [weasel.repl.websocket :as weasel]
+            [weasel.repl.server :as wserver])
   (:import (java.io File)))

 (defn browser-build []
@@ -122,6 +123,9 @@
                                :before 'com.potetm.weasel-client/before
                                :after 'com.potetm.weasel-client/after)))

+(defn stop-weasel []
+  (wserver/stop))
+
 ;; TODO: Try with austin

 (defn copy-index-to-target []


some haskell-servant related fixes

some haskell-servant related fixes

--- src/ctia/task/codegen.clj
+++ src/ctia/task/codegen.clj
@@ -3,7 +3,8 @@
   (:require [ctia.init :refer [start-ctia!]]
             [clojure.java.io :as io]
             [clojure.java.shell :as shell]
-            [ctia.properties :refer [properties]]))
+            [ctia.properties :refer [properties]]
+            [clojure.string :as str]))

 ;; swagger codegen package
 (def codegen-version "2.1.6")
@@ -29,9 +30,12 @@
    :python {:packageName artifact-id
             :packageVersion artifact-version}
    :haskell-servant {:apiVersion artifact-version
-                     :title artifact-id
-                     :titleLower artifact-id
-                     :package artifact-id}
+                     :title "CTIA Client"
+                     :titleLower "ctia client"
+                     :package "CTIAClient"
+                     :baseNamespace "CTIAClient"
+                     :modelpackage "CTIAClient"
+                     :artifact-id "CTIAClient"}
    :ruby {:gemName artifact-id
           :gemVersion artifact-version
           :gemHomepage "http://github.com/threatgrid/ctia"
@@ -65,15 +69,15 @@
   "base command for all languages"
   [lang output-dir]
   ["java"
-   "-jar"
-   local-jar-uri
+   "-jar" local-jar-uri
    "generate"
    "-i" (spec-uri)
    "-l" (name lang)
    "--group-id" "cisco"
    "-o" (str (or output-dir "/tmp/ctia-client") "/" (name lang))
-   "--api-package" artifact-id
-   "--artifact-id" artifact-id
+   "--api-package" (get-in langs [lang :baseNamespace] artifact-id)
+   "--model-package" (get-in langs [lang :modelpackage] "model")
+   "--artifact-id" (get-in langs [lang :artifact-id] artifact-id)
    "--artifact-version" artifact-version])


Fix jws_tests/wrong-data test

Fix jws_tests/wrong-data test

jws/unsign fails with :header validation cause if the header is
malformed, not with :signature.

--- test/buddy/sign/jws_tests.clj
+++ test/buddy/sign/jws_tests.clj
@@ -157,7 +157,7 @@
   (let [data (str "."
                   "eyJmb28iOiJiYXIifQ."
                   "FvlogSd-xDr6o2zKLNfNDbREbCf1TcQri3N7LkvRYDs")]
-    (unsign-exp-fail data :signature))
+    (unsign-exp-fail data :header))
   (let [data (str "eyJmb28iOiJiYXIifQ."
                   "FvlogSd-xDr6o2zKLNfNDbREbCf1TcQri3N7LkvRYDs")]
-    (unsign-exp-fail data :signature)))
+    (unsign-exp-fail data :header)))


fix broken tests around primitive JS array printing

--- test/cljs/cljs/core_test.cljs
+++ test/cljs/cljs/core_test.cljs
@@ -254,11 +254,11 @@
              (assoc (cljs.core.ObjMap. nil (array) (js-obj)) :foo 5)))

   (assert (= "\"asdf\" \"asdf\"" (pr-str "asdf" "asdf")))
-  (assert (= "[1 true {:a 2, :b #\"x\\\"y\"} #<Array [3, 4]>]"
+  (assert (= "[1 true {:a 2, :b #\"x\\\"y\"} #js [3 4]]"
              (pr-str [1 true {:a 2 :b #"x\"y"} (array 3 4)])))

   (assert (= "\"asdf\"\n" (prn-str "asdf")))
-  (assert (= "[1 true {:a 2, :b 42} #<Array [3, 4]>]\n"
+  (assert (= "[1 true {:a 2, :b 42} #js [3 4]]\n"
              (prn-str [1 true {:a 2 :b 42} (array 3 4)])))

   (assert (= "asdf" (print-str "asdf")))


Add tests for joins and not-clauses.

Add tests for joins and not-clauses.

--- test/datomish/test/query.cljc
+++ test/datomish/test/query.cljc
@@ -1,9 +1,82 @@
 (ns datomish.test.query
   (:require
-     [datomish.query :as dq]
-     #?(:clj  [clojure.test :as t :refer [is are deftest testing]])
-     #?(:cljs [cljs.test :as t :refer-macros [is are deftest testing]])
+     [datomish.query.context :as context]
+     [datomish.query.source :as source]
+     [datomish.query.transforms :as transforms]
+     [datomish.query :as query]
+     #?@(:clj
+           [
+          [honeysql.core :as sql :refer [param]]
+          [clojure.test :as t :refer [is are deftest testing]]])
+     #?@(:cljs
+           [
+          [honeysql.core :as sql :refer-macros [param]]
+          [cljs.test :as t :refer-macros [is are deftest testing]]])
      ))

-(deftest test-query
-  (is (= 1 1)))
+(defn- fgensym [s c]
+  (symbol (str s c)))
+
+(defn make-predictable-gensym []
+  (let [counter (atom 0)]
+    (fn
+      ([]
+       (fgensym "G__" (dec (swap! counter inc))))
+      ([s]
+       (fgensym s (dec (swap! counter inc)))))))
+
+(defn mock-source [db]
+  (source/map->Source
+    {:table :datoms
+     :columns [:e :a :v :tx :added]
+     :attribute-transform transforms/attribute-transform-string
+     :constant-transform transforms/constant-transform-default
+     :table-alias (comp (make-predictable-gensym) name)
+     :make-constraints nil}))
+
+(defn- expand [find]
+  (let [context (context/->Context (mock-source nil) nil nil)
+        parsed (query/parse find)]
+    (query/find->sql-clause context parsed)))
+
+(deftest test-basic-join
+  (is (= {:select '([:datoms1.v :timestampMicros] [:datoms0.e :page]),
+          :modifiers [:distinct],
+          :from '[[:datoms datoms0]
+                  [:datoms datoms1]],
+          :where (list
+                   :and
+                   [:= :datoms1.e :datoms0.tx]
+                   [:= :datoms0.a "page/starred"]
+                   [:= :datoms0.v 1]
+                   [:= :datoms1.a "db/txInstant"]
+                   [:not
+                    (list :and (list :> :datoms1.e (sql/param :latest)))])}
+         (expand
+           '[:find ?timestampMicros ?page :in $ ?latest :where
+             [?page :page/starred true ?t]
+             [?t :db/txInstant ?timestampMicros]
+             (not [(> ?t ?latest)])]))))
+
+(deftest test-pattern-not-join
+  (is (= '{:select ([:datoms1.v :timestampMicros] [:datoms0.e :page]),
+           :modifiers [:distinct],
+           :from [[:datoms datoms0]
+                  [:datoms datoms1]],
+           :where (:and
+                     [:= :datoms1.e :datoms0.tx]
+                     [:= :datoms0.a "page/starred"]
+                     [:= :datoms0.v 1]
+                     [:= :datoms1.a "db/txInstant"]
+                     [:not
+                      [:exists
+                       {:select [1],
+                        :from [[:datoms datoms2]],
+                        :where (:and
+                                  [:= :datoms2.a "foo/bar"]
+                                  [:= :datoms0.e :datoms2.e])}]])}
+         (expand
+           '[:find ?timestampMicros ?page :in $ ?latest :where
+             [?page :page/starred true ?t]
+             [?t :db/txInstant ?timestampMicros]
+             (not [?page :foo/bar _])]))))


Point users to :onyx/batch? under bulk? doc

--- src/onyx/information_model.cljc
+++ src/onyx/information_model.cljc
@@ -184,7 +184,7 @@
              :added "0.8.0"}

             :onyx/bulk?
-            {:doc "Boolean value indicating whether the function in this catalog entry denoted by `:onyx/fn` should take a single segment, or the entire batch of segments that were read as a parameter. When set to `true`, this function's return value is ignored. The segments are identically propagated to the downstream tasks."
+            {:doc "Boolean value indicating whether the function in this catalog entry denoted by `:onyx/fn` should take a single segment, or the entire batch of segments that were read as a parameter. When set to `true`, this task's `:onyx/fn` return value is ignored. The segments are identically propagated to the downstream tasks. The primary use of `:onyx/bulk?` is for side-effecting functions. Please see `:onyx/batch?` if you require the return value from the `:onyx/fn`."
              :type :boolean
              :default false
              :tags [:function]


Fix on-close handler so it can return any type, not only nil.

--- src/quil/helpers/applet_listener.clj
+++ src/quil/helpers/applet_listener.clj
@@ -5,7 +5,7 @@
     :init init
     :state listeners
     :constructors {[java.util.Map] []}
-    :methods [["dispose" [] java.lang.Void]]))
+    :methods [["dispose" [] java.lang.Object]]))

 (defn safe-call [fn]
   (when fn (fn)))


Extend browser coverage in the example project

--- example/project.clj
+++ example/project.clj
@@ -16,7 +16,7 @@
   :clean-targets ^{:protect false} [:target-path "resources/public/js/" "out"]

   :doo {:paths {:karma "karma"}
-        :alias {:browsers [:chrome]
+        :alias {:browsers [:chrome :firefox]
                 :all [:browsers :headless]}}

   :cljsbuild


For now, commenting out intercom ns, till we can update it with new conversation manager setup

--- src/polismath/meta/intercom.clj
+++ src/polismath/meta/intercom.clj
@@ -13,6 +13,7 @@
             [polismath.components.db :as db]))

+(comment
 (def intercom-http-params
   {:accept :json
    :basic-auth ["nb5hla8s" (env/env :intercom-api-key)]
@@ -142,6 +143,7 @@
         icusers-by-email (filter #(not (get % "user_id")) icusers)
         ; Get users by id, then by email for those without id, then put them all together in one collection
         _                (println "Fetching pg db records")
+        ;; Need to update for db component XXX
         dbusers-by-id    (db/get-users-by-uid
                            (map #(Integer/parseInt (get % "user_id")) icusers-by-id))
         dbusers-by-email (db/get-users-by-email
@@ -180,7 +182,7 @@
     ; Call it a night
     (println "Done!")
     (shutdown-agents)))
-
+)

 :ok


Disable broken index test for now.

Disable broken index test for now.

--- test/merkle_db/index_test.clj
+++ test/merkle_db/index_test.clj
@@ -46,6 +46,7 @@
              ::part/limit 10}))))))

+#_
 (deftest ^:generative index-construction
   (checking "valid properties" 20
     [[field-keys families records] mdgen/data-context


Revert "Upgrade Langohr to 3.0.0 GA"

Revert "Upgrade Langohr to 3.0.0 GA"

This reverts commit 73d8df4758d2c1ca0633947a05b9e78d7ebe831d.

Will re-submit as a pull request.

--- src/rabbitmq-broker/project.clj
+++ src/rabbitmq-broker/project.clj
@@ -4,7 +4,7 @@
                  ;; CF client
                  [clojurewerkz/mold       "1.0.0-beta4"]
                  ;; RabbitMQ client (including HTTP API)
-                 [com.novemberain/langohr "3.0.0" :exclusions [clj-http]]
+                 [com.novemberain/langohr "3.0.0-rc4" :exclusions [clj-http]]
                  ;; HTTP client which uses HTTPCore 4.2.x, compatible
                  ;; with Spring 3 and CF Java client.
                  [clj-http                "0.7.6"]


Create .nrepl-port file on startup

Create .nrepl-port file on startup

Basically, do what lein repl does.

This allows text editors which are nREPL aware to automatically locate
the server when it's started.

--- src/gorilla_repl/core.clj
+++ src/gorilla_repl/core.clj
@@ -12,6 +12,7 @@
             [ring.middleware.json :as json]
             [ring.util.response :as res]
             [clojure.tools.nrepl.server :as nrepl-server]
+            [clojure.java.io :as io]
             [gorilla-repl.websocket-relay :as ws-relay]
             [gorilla-repl.render-values-mw :as render-mw]
             [gorilla-repl.renderer :as renderer] ;; this is needed to bring the render implementations into scope
@@ -82,10 +83,12 @@
         nrepl (nrepl-server/start-server :port nrepl-requested-port
                                          :handler (nrepl-server/default-handler #'render-mw/render-values))
         nrepl-port (:port nrepl)
+        repl-port-file (io/file ".nrepl-port")
         _ (println "Started nREPL server on port" nrepl-port)
         _ (ws-relay/connect-to-nrepl nrepl-port)
         webapp-port (or (:port conf) 8990)
         s (server/run-server app-routes {:port webapp-port :join? false})]
+    (spit (doto repl-port-file .deleteOnExit) nrepl-port)
     (println (str "Running at http://localhost:" webapp-port "/worksheet.html ."))
     (println "Ctrl+C to exit.")
     ;; block this thread by joining the server (which should run until killed)


easy check to not clobber unsaved edits

easy check to not clobber unsaved edits

--- src/semtag_web/client/main.cljs
+++ src/semtag_web/client/main.cljs
@@ -39,7 +39,10 @@
 (defn- expand-editable-text [event]
   (let [$elem ($ (.-target event))]
     (jq/remove-class $elem "ellipsis")
-    (inner $elem (jq/attr $elem "title"))))
+    ;; quick and dirty way - cleaner way would be to track editing state
+    ;; this check ensures we don't clobber that the user has come back to finish edit
+    (when (re-find #"\.\.\.$" (jq/text $elem))
+      (inner $elem (jq/attr $elem "title")))))

 (defn- make-table-editable []
   (let [editable-cells ($ :td.editable)]


Docstring typo

Docstring typo

--- src/simple_check/properties.clj
+++ src/simple_check/properties.clj
@@ -20,7 +20,7 @@
   (fn [args]
     (fn [random-seed size]
       ;; since we need to capture the arguments for shrinking and reporting
-      ;; purposes, perhaps here is were we could do that. Return a single-run
+      ;; purposes, perhaps here is where we could do that. Return a single-run
       ;; `result` map that contains something like:
       ;; {:pass true
       ;;  :args [0 false]}


changing if-let to when-let

changing if-let to when-let

--- src/vignette/util/thumbnail.clj
+++ src/vignette/util/thumbnail.clj
@@ -55,9 +55,7 @@
   [system thumb-map]
   (if-let [thumb (store-prot/get-thumbnail (store system) thumb-map)]
     thumb
-    (if-let [original (store-prot/get-original (store system) thumb-map)]
-      (if-let [thumb (generate-thumbnail original thumb-map)]
-        (do (store-prot/save-thumbnail (store system) thumb thumb-map)
-            thumb) ; TODO: cron to delete thumbs older than X)
-        nil)
-      nil)))
+    (when-let [original (store-prot/get-original (store system) thumb-map)]
+      (when-let [thumb (generate-thumbnail original thumb-map)]
+        (store-prot/save-thumbnail (store system) thumb thumb-map)
+        thumb)))) ; TODO: cron to delete thumbs older than X)


longer server side time echo

longer server side time echo

--- src/ontrail/websocket.clj
+++ src/ontrail/websocket.clj
@@ -43,7 +43,7 @@
                      (json/write-str {:user "Ontrail"
                                       :action "sanoi"
                                       :message (formats/to-human-comment-date (local/local-now))})))
-   1800)) ;; seconds
+   3600)) ;; seconds

 (defn ex-link [ex]
   (str "ex/"


Fixed lifecycle resources that weren't being cleaned up properly because there is no tail-batch if the peer is killed directly.

--- src/onyx/plugin/kafka.clj
+++ src/onyx/plugin/kafka.clj
@@ -6,7 +6,7 @@
             [clj-kafka.core :as k]
             [onyx.peer.task-lifecycle-extensions :as l-ext]
             [onyx.peer.pipeline-extensions :as p-ext]
-            [taoensso.timbre :refer [fatal]]))
+            [taoensso.timbre :refer [fatal] :as log]))

 (defmethod l-ext/inject-lifecycle-resources :kafka/read-messages
   [_ {:keys [onyx.core/task-map] :as pipeline}]
@@ -17,6 +17,7 @@
         ch (chan (:kafka/chan-capacity task-map))]
     {:kafka/future (future
                      (try
+                       (log/debug "Opening Kafka resource " config)
                        (k/with-resource [c (zk/consumer config)]
                          zk/shutdown
                          (loop [ms (zk/messages c (:kafka/topic task-map))]
@@ -24,7 +25,8 @@
                            (recur (rest ms))))
                        (catch InterruptedException e)
                        (catch Exception e
-                         (fatal e))))
+                         (fatal e)))
+                     (log/debug "Stopping Kafka consumer and cleaning up"))
      :kafka/ch ch}))

 (defmethod p-ext/read-batch [:input :kafka]
@@ -51,11 +53,10 @@
   [{:keys [onyx.core/decompressed]}]
   {:onyx.core/results decompressed})

-(defmethod l-ext/close-temporal-resources :kafka/read-messages
+(defmethod l-ext/close-lifecycle-resources :kafka/read-messages
   [_ {:keys [kafka/ch] :as pipeline}]
-  (when (:onyx.core/tail-batch? pipeline)
-    (close! ch)
-    (future-cancel (:kafka/future pipeline)))
+  (future-cancel (:kafka/future pipeline))
+  (close! ch)
   {})

 (defmethod l-ext/inject-lifecycle-resources :kafka/write-messages


Only set the original exception once, thus making deserializable-exception idempontent.

--- src/onyx/static/util.cljc
+++ src/onyx/static/util.cljc
@@ -37,8 +37,10 @@
 #?(:clj
    (defn deserializable-exception [^Throwable throwable more-context]
      (let [{:keys [data trace]} (Throwable->map throwable)
-           data (merge (assoc data :original-exception (keyword (.getName (.getClass throwable))))
-                       more-context)]
+           this-ex-type (keyword (.getName (.getClass throwable)))
+           data (-> data
+                    (assoc :original-exception (:original-exception data this-ex-type))
+                    (merge more-context))]
        ;; First element may either be a StackTraceElement or a vector
        ;; of 4 elements, those of which construct a STE.
        (if (sequential? (first trace))


IReplWindow removed from gui

IReplWindow removed from gui

--- src/overtone/gui/main.clj
+++ src/overtone/gui/main.clj
@@ -6,7 +6,7 @@
                   JSplitPane JMenuBar JMenu JMenuItem SwingUtilities)
      (javax.swing.tree TreeModel DefaultTreeCellRenderer)
      (javax.swing.table TableModel AbstractTableModel)
-     (org.enclojure.repl IReplWindow IReplWindowFactory IRepl)
+;     (org.enclojure.repl IReplWindow IReplWindowFactory IRepl)
      (com.raelity.jvi ViManager ColonCommands)
      (com.raelity.jvi.swing DefaultViFactory StatusDisplay TextView))
   (:require [clojure.inspector :as inspector])


removing missed conflict line

removing missed conflict line

--- src/overtone/sc/synth.clj
+++ src/overtone/sc/synth.clj
@@ -631,4 +631,3 @@
 (defmethod overtone.sc.node/ctl :overtone.sc.synth/synth
   [synth & args]
   (apply modify-synth-params synth args))
->>>>>>> Simplifying gui implementation after seesaw fix.


Cast draw inputs to floats

Cast draw inputs to floats

--- src/play_clj/entities.clj
+++ src/play_clj/entities.clj
@@ -18,18 +18,22 @@
   (draw-entity! [this screen batch]))

 (defrecord TextureEntity [object] Entity
-  (draw-entity! [{:keys [^TextureRegion object x y width height scale-x scale-y angle origin-x origin-y]} _ batch]
+  (draw-entity! [{:keys [^TextureRegion object x y width height scale-x scale-y
+                         angle origin-x origin-y]}
+                 _
+                 batch]
     (let [x (float (or x 0))
           y (float (or y 0))
           width (float (or width (.getRegionWidth object)))
           height (float (or height (.getRegionHeight object)))]
       (if (or scale-x scale-y angle)
-        (let [scale-x (or scale-x 1)
-              scale-y (or scale-y 1)
-              origin-x (or origin-x (/ width 2))
-              origin-y (or origin-y (/ width 2))
-              angle (or angle 0)]
-          (.draw ^SpriteBatch batch object x y origin-x origin-y width height scale-x scale-y angle))
+        (let [scale-x (float (or scale-x 1))
+              scale-y (float (or scale-y 1))
+              origin-x (float (or origin-x (/ width 2)))
+              origin-y (float (or origin-y (/ width 2)))
+              angle (float (or angle 0))]
+          (.draw ^SpriteBatch batch object x y origin-x origin-y width height
+            scale-x scale-y angle))
         (.draw ^SpriteBatch batch object x y width height)))))

 (defrecord NinePatchEntity [object] Entity


Remove obsolete tests

Remove obsolete tests

--- test/cljs/fatlip/core_test.cljs
+++ test/cljs/fatlip/core_test.cljs
@@ -51,15 +51,7 @@

     ;; ESK ordering
     (is (= (count (:marked cm-graph)) 2) "Number of marked edges")
-    (is (= (:crossings cm-graph) 9) "Number of crossings")
-    (is (empty? (->> (:layers cm-graph)
-                     (mapcat #(:minus-ps %))
-                     (filter #(contains? (:ps cm-graph) %))))
-        "No p nodes in :minus-ps")
-    (is (empty? (->> (:layers cm-graph)
-                     (mapcat #(:minus-qs %))
-                     (filter #(contains? (:qs cm-graph) %))))
-        "No q nodes in :minus-qs")))
+    (is (= (:crossings cm-graph) 9) "Number of crossings")))

 ;; Fine-grained ESK


Added test for literals in hyjinks.dom

Added test for literals in hyjinks.dom

--- test/cljs/hyjinks/dom_test.cljs
+++ test/cljs/hyjinks/dom_test.cljs
@@ -15,3 +15,10 @@
     (is (= "some text" (.-textContent (aget (.-childNodes d) 0))))
     (is (= "more text" (.-textContent (aget (.-childNodes d) 2))))
     (is (= "Hi!" (.getAttribute (aget (.-children d) 0) "title")))))
+
+(deftest literals
+  (testing "literals should have no apparent effect"
+    (let [d0 (tag->dom (h/span "<hi>"))
+          d1 (tag->dom (h/span (h/literal "<hi>")))]
+      (is (= "<hi>" (.-textContent d0)))
+      (is (= "<hi>" (.-textContent d1))))))


Bumps version

Bumps version

--- scheduler/project.clj
+++ scheduler/project.clj
@@ -13,7 +13,7 @@
 ;; See the License for the specific language governing permissions and
 ;; limitations under the License.
 ;;
-(defproject cook "1.11.0"
+(defproject cook "1.11.1-SNAPSHOT"
   :description "This launches jobs on a Mesos cluster with fair sharing and preemption"
   :license {:name "Apache License, Version 2.0"}
   :dependencies [[org.clojure/clojure "1.8.0"]


Updating version to 1.62.3-SNAPSHOT

Updating version to 1.62.3-SNAPSHOT

--- scheduler/project.clj
+++ scheduler/project.clj
@@ -13,7 +13,7 @@
 ;; See the License for the specific language governing permissions and
 ;; limitations under the License.
 ;;
-(defproject cook "1.62.2"
+(defproject cook "1.62.3-SNAPSHOT"
   :description "This launches jobs on a Mesos cluster with fair sharing and preemption"
   :license {:name "Apache License, Version 2.0"}
   :dependencies [[org.clojure/clojure "1.10.3"]


Use twosigma clj-http (#967)

Use twosigma clj-http (#967)

--- scheduler/project.clj
+++ scheduler/project.clj
@@ -67,7 +67,7 @@
                  [jarohen/chime "0.1.6"]

                  ;;Networking
-                 [clj-http "2.0.0"]
+                 [twosigma/clj-http "2.0.0-ts1"]
                  [io.netty/netty "3.10.1.Final"]
                  [cc.qbits/jet "0.6.4" :exclusions [org.eclipse.jetty/jetty-io
                                                     org.eclipse.jetty/jetty-security


remove old comments

remove old comments

--- src/schejule/analyser.clj
+++ src/schejule/analyser.clj
@@ -45,11 +45,6 @@

        (gen/gen-schedule* tasks constraints)))

-;; TODO: write distil-rule. It should take a map describing a failed schedule, as emitted by `simulate-schedule*`, and return the smallest possible set of tasks which cannot precede the failed task (or one of its predecessors).
-
-;; 2017-03-13 01:23 NEW THINKING
-;; Bind only tasks at job-boundaries for less binding overall
-;; rather than [a . b c d . e f] -> [a b] [d e] -> [a b d e]
 (defn distil-rule
   "'Rewinds' a bad schedule to identify which subsequence of tasks contributed to the failure"
   [bad-schedule]


indenting

indenting

--- src/aws/provider.clj
+++ src/aws/provider.clj
@@ -94,27 +94,26 @@
   [(provider-validation spec) (-> endpoint nil? not)  (-> uuid nil? not)]
   Vm
   (create [this]
-          (let [{:keys [aws]} spec]
-            (debug "creating" uuid)
-            (swap! (ids) assoc uuid
-                   (-> (ec2 run-instances aws) :instances first :id))
-            (when (= (image-desc endpoint (aws :image-id) :root-device-type) "ebs")
-              (wait-for-attach endpoint uuid [10 :minute]))
-            (update-pubdns this)
-            (wait-for-ssh this)
-            (set-hostname this)
-            this))
+         (let [{:keys [aws]} spec]
+           (debug "creating" uuid)
+           (swap! (ids) assoc uuid
+             (-> (ec2 run-instances aws) :instances first :id))
+          (when (= (image-desc endpoint (aws :image-id) :root-device-type) "ebs")
+            (wait-for-attach endpoint uuid [10 :minute]))
+          (update-pubdns this)
+          (wait-for-ssh this)
+          (set-hostname this)
+          this))
   (delete [this]
-          (debug "deleting" uuid)
-          (ec2 terminate-instances (instance-id uuid))
-          (wait-for-status this "terminated" [5 :minute])
-          (swap! (ids) dissoc uuid))
+        (debug "deleting" uuid)
+        (ec2 terminate-instances (instance-id uuid))
+        (wait-for-status this "terminated" [5 :minute])
+        (swap! (ids) dissoc uuid))
   (start [this]
-         (debug "starting" (instance-id uuid))
-         (ec2 start-instances (instance-id uuid))
-         (wait-for-status this "running" [5 :minute])
-         (update-pubdns this)
-         #_(wait-for-ssh this))
+        (debug "starting" (instance-id uuid))
+        (ec2 start-instances (instance-id uuid))
+        (wait-for-status this "running" [5 :minute])
+        (update-pubdns this))
   (stop [this]
         (debug "stopping" uuid)
         (ec2 stop-instances  (instance-id uuid))


cleanup

cleanup

--- src/babel/latin.cljc
+++ src/babel/latin.cljc
@@ -2,7 +2,7 @@
   (:refer-clojure :exclude [get-in])
   (:require
    [babel.english :as en]
-   [babel.index :refer [build-lex-sch-index create-indices lookup-spec]]
+   [babel.index :refer [create-indices lookup-spec]]
    [babel.latin.morphology :as morph]
    [babel.lexiconfn :refer [default listify map-function-on-map-vals
                             verb-pred-defaults]]


simplify namespace

simplify namespace

--- src/babel/reader.clj
+++ src/babel/reader.clj
@@ -93,28 +93,28 @@
         target-expression
         (target-timing-fn (babel.generate/generate target-spec target-model))

-        pred (dag_unify.core/get-in target-expression
+        pred (unify/get-in target-expression
                                     [:synsem :sem :pred])
-        subj (dag_unify.core/get-in target-expression
+        subj (unify/get-in target-expression
                                     [:synsem :sem :subj :pred])
-        tense (dag_unify.core/get-in target-expression
+        tense (unify/get-in target-expression
                                      [:synsem :sem :tense])
         source-spec
-        (dag_unify.core/strip-refs
-         (dag_unify.core/unify
-          {:synsem {:sem (dag_unify.core/get-in target-expression [:synsem :sem])}}
+        (unify/strip-refs
+         (unify/unify
+          {:synsem {:sem (unify/get-in target-expression [:synsem :sem])}}
           basic-spec))

         source-model @((get models source-language))
         source-expression
-        (source-timing-fn (babel.generate/generate source-spec source-model))]
+        (source-timing-fn (generate source-spec source-model))]
     (let [pairing
           {:target ((:morph (babel.italiano/medium)) target-expression)
-           :pred (dag_unify.core/strip-refs
-                  (dag_unify.core/get-in target-expression [:synsem :sem :pred]))
-           :tense (dag_unify.core/get-in target-expression [:synsem :sem :tense])
-           :sem (dag_unify.core/get-in target-expression [:synsem :sem])
-           :subj (dag_unify.core/get-in target-expression [:synsem :sem :subj :pred])
+           :pred (unify/strip-refs
+                  (unify/get-in target-expression [:synsem :sem :pred]))
+           :tense (unify/get-in target-expression [:synsem :sem :tense])
+           :sem (unify/get-in target-expression [:synsem :sem])
+           :subj (unify/get-in target-expression [:synsem :sem :subj :pred])
            :source (if source-expression
                      ((:morph @((get models source-language)))
                       source-expression
@@ -140,7 +140,7 @@
   (log/debug (str "generate target language set with target-language:" target-language " ;spec: " target-spec))
   (let [target-spec (-> target-spec
                         (unify {:synsem {:subcat '()}})
-                        (dissoc-paths [[:dag_unify.core/serialized]]))]
+                        (dissoc-paths [[:unify/serialized]]))]
     (cond (= target-language "la") ;; TODO: should not have a special case for one language.
           (babel.latin/read-one :top  ;; TODO: use target-spec
                                 @((-> models :la))
@@ -339,7 +339,7 @@
 (defn read-all [spec language]
   (let [spec (dissoc (unify spec
                             {:synsem {:subcat '()}})
-                     :dag_unify.core/serialized)
+                     :unify/serialized)

         ;; normalize for JSON lookup
         json-input-spec (if (= :top spec)


Fix all inconsistences on beicon.core ns (now compiles without warnings).

--- src/beicon/core.cljs
+++ src/beicon/core.cljs
@@ -1,5 +1,5 @@
 (ns beicon.core
-  (:require [beicon.external.rxjs]
+  (:require [beicon.extern.rxjs]
             [cats.protocols :as p]
             [cats.context :as ctx])
   (:refer-clojure :exclude [true? map filter reduce merge repeat repeatedly zip
@@ -9,11 +9,15 @@
                             concat
                             partition]))

+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Observables Constructors
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
 (defn repeat
   "Generates an observable sequence that repeats the
   given element."
   ([v]
-   (repeats v -1))
+   (repeat v -1))
   ([v n]
    {:pre [(number? v)]}
    (js/Rx.Observable.repeat v n)))
@@ -46,33 +50,19 @@
   (-error? [_] false)

   IObservableEndValue
-  (-end? [_] false)e
-
-(extend-protocol IObservableErrorValue
-  js/Error
-  (-error? [_] true)
-
-  cljs.core.ExceptionInfo
+  (-end? [_] false))
+
+(extend-type nil
+  IObservableEndValue
+  (-end? [_] true))
+
+(extend-type js/Error
+  IObservableErrorValue
   (-error? [_] true))

-(deftype EndValue [v]
-  (-end? [_] true))
-
-(defn next
-  [v]
-  (NextValue. v))
-
-(defn next?
-  [v]
-  (instance? NextValue v))
-
-(defn end
-  [v]
-  (EndValue. v))
-
-(defn end?
-  [v]
-  (instance? EndValue v))
+(extend-type cljs.core.ExceptionInfo
+  IObservableErrorValue
+  (-error? [_] true))

 (defn create
   "Creates an observable sequence from a specified
@@ -83,19 +73,86 @@
    (fn [ob]
      (letfn [(callback [v]
                (cond
-                 (next? v)
+                 (-next? v)
                  (.onNext ob)
-                 (end? v)
-                 (if (instance? EndValue v)
-                   (.onComplete ob (.-v v))
-                   (.onComplete ob v))
-
-                 (error? v)
+
+                 (-end? v)
+                 (.onCompleted ob)
+
+                 (-error? v)
                  (.onError ob v)))]
        (try
          (sf callback)
          (catch js/Error e
-           (.onError ob e))))))))
+           (.onError ob e)))))))
+
+(defn observable?
+  "Return true if `ob` is a instance
+  of Rx.Observable."
+  [ob]
+  (instance? js/Rx.Observable ob))
+
+;; (defn from-poll
+;;   "Creates an observable sequence polling given
+;;   function with given interval."
+;;   [ms f]
+;;   (create (fn [sick]
+
+;;             (let [sem (js/setInterval
+;;                        (fn []
+;;                          (let [v (f)]
+;;                            (when (or (-end? v) (-error? v))
+;;                              (js/clearInterval sem))
+;;                            (sick v))))]
+;;                    (.onNext ob)
+
+;;                    (-end? v)
+;;                  (if (instance? EndValue v)
+;;                    (.onComplete ob (.-v v))
+;;                    (.onComplete ob v))
+
+;;                  (-error? v)
+;;                  (.onError ob v))))))
+
+
+
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Observable Subscription
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defn on-value
+  "Subscribes a function to invoke for each element
+  in the observable sequence."
+  [ob f]
+  {:pre [(observable? ob) (fn? f)]}
+  (.subscribeOnNext ob f))
+
+(defn on-error
+  "Subscribes a function to invoke upon exceptional termination
+  of the observable sequence."
+  [ob f]
+  {:pre [(observable? ob) (fn? f)]}
+  (.subscribeOnError ob f))
+
+(defn on-end
+  "Subscribes a function to invoke upon graceful termination
+  of the observable sequence."
+  [ob f]
+  {:pre [(observable? ob) (fn? f)]}
+  (.subscribeOnCompleted ob f))
+
+(defn subscribe
+  "Subscribes an observer to the observable sequence."
+  [ob nf ef cf]
+  {:pre [(observable? ob)]}
+  (.subscribe ob nf ef cf))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Observable Transformations
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (defn choice
   "Create an observable that surfaces any of the given
@@ -105,7 +162,7 @@
           (observable? b)]}
    (.amb a b))
   ([a b & more]
-   (reduce choice (choice a b) more)))
+   (cljs.core/reduce choice (choice a b) more)))

 (defn zip
   "Merges the specified observable sequences or Promises
@@ -124,7 +181,7 @@
           (observable? b)]}
    (.concat a b))
   ([a b & more]
-   (reduce concat (concat a b) more)))
+   (cljs.core/reduce concat (concat a b) more)))

 (defn merge
   "Merges all the observable sequences and Promises
@@ -134,7 +191,7 @@
           (observable? b)]}
    (.merge a b))
   ([a b & more]
-   (reduce merge (merge a b) more)))
+   (cljs.core/reduce merge (merge a b) more)))

 (defn filter
   "Filters the elements of an observable sequence
@@ -164,53 +221,60 @@
   observable sequence and then returns the remaining
   elements."
   [n ob]
-  {:pre [(observable? ob) (number? f)]}
-  (.skip ob f))
+  {:pre [(observable? ob) (number? n)]}
+  (.skip ob n))

 (defn take
   "Bypasses a specified number of elements in an
   observable sequence and then returns the remaining
   elements."
   [n ob]
-  {:pre [(observable? ob) (number? f)]}
-  (.take ob f))
+  {:pre [(observable? ob) (number? n)]}
+  (.take ob n))

 (defn take-while
   "Returns elements from an observable sequence as long as a
   specified predicate returns true."
-  [p ob]
-  {:pre [(observable? ob) (number? p)]}
+  [f ob]
+  {:pre [(observable? ob) (fn? f)]}
   (.takeWhile ob f))
-
-(defn on-value
-  "Subscribes a function to invoke for each element
-  in the observable sequence."
-  [obs f]
-  (.subscribeOnNext obs f))
-
-(defn on-error
-  "Subscribes a function to invoke upon exceptional termination
-  of the observable sequence."
-  [obs f]
-  (.subscribeOnError obs f))
-
-(defn on-end
-  "Subscribes a function to invoke upon graceful termination
-  of the observable sequence."
-  [obs f]
-  (.subscribeOnCompleted obs f))
-
-(defn subscribe
-  "Subscribes an observer to the observable sequence."
-  [obs nf ef cf]
-  (.subscribe obs nf ef cf))

 (defn reduce
   "Applies an accumulator function over an observable
   sequence, returning the result of the aggregation as a
   single element in the result sequence."
   ([f ob]
-   (.reduce ob fn))
+   {:pre [(observable? ob) (fn? f)]}
+   (.reduce ob f))
   ([f seed ob]
-   (.reduce ob fn seed)))
-
+   {:pre [(observable? ob) (fn? f)]}
+   (.reduce ob f seed)))
+
+(defn tap
+  "Invokes an action for each element in the
+  observable sequence."
+  [f ob]
+  {:pre [(observable? ob) (fn? f)]}
+  (.tap ob f))
+
+(defn throttle
+  "Returns an Observable that emits only the first item
+  emitted by the source Observable during sequential
+  time windows of a specified duration."
+  [ms ob]
+  {:pre [(observable? ob) (number? ms)]}
+  (.throttle ob ms))
+
+(defn ignore
+  "Ignores all elements in an observable sequence leaving
+  only the termination messages."
+  [ob]
+  {:pre [(observable? ob)]}
+  (.ignoreElements ob))
+
+(defn pausable
+  [pauser ob]
+  {:pre [(observable? ob) (observable? pauser)]}
+  (.pausable ob pauser))
+
+


reload index as well

reload index as well

--- src/bløggr/core.clj
+++ src/bløggr/core.clj
@@ -13,7 +13,6 @@
 (def site-settings (read-string (slurp "settings.edn")))

 (defn get-pages []
-  (require 'bløggr.posts :reload)
   (stasis/merge-page-sources
    (let [posts (get-posts)
          path-mapped-posts (reduce merge (map post->path-map posts))
@@ -26,7 +25,12 @@
       :rss {"/rss.xml" rss}
       :index {"/index.html" index}})))

-(def ring (-> (stasis/serve-pages get-pages)
+(defn get-pages-reload []
+  (require 'bløggr.posts :reload)
+  (require 'bløggr.index :reload)
+  (get-pages))
+
+(def ring (-> (stasis/serve-pages get-pages-reload)
               (optimus/wrap get-assets optimizations/none strategies/serve-live-assets)))

 (defn export []


drop clojure.string requirement

drop clojure.string requirement

--- src/cellf/media.cljs
+++ src/cellf/media.cljs
@@ -1,11 +1,10 @@
 (ns cellf.media
-  (:require [cljs.core.async :refer [chan put!]]
-            [clojure.string  :refer [upper-case]]))
+  (:require [cljs.core.async :refer [chan put!]]))

 (def prefixes ["webkit" "moz" "ms"])

 (defn find-native [obj fn-name]
-  (let [cap-name (str (upper-case (first fn-name)) (apply str (rest fn-name)))]
+  (let [cap-name (str (.toUpperCase (first fn-name)) (apply str (rest fn-name)))]
     (loop [names (cons fn-name (map #(str % cap-name) prefixes))]
       (when (seq names)
         (if-let [f (aget obj (first names))]


re-organize placement and create sections


Add meta

Add meta

--- src/degasolv/cli.clj
+++ src/degasolv/cli.clj
@@ -200,18 +200,20 @@
                 (map r/explain-problem (:problems result-info))))))))

 (defn- generate-card!
-  [{:keys [id version location requirements card-file]}
+  [{:keys [id version location requirements card-file meta]}
    arguments]
   (default-spit
    card-file
-   (->PackageInfo
+   (into
+    (->PackageInfo
     id
     version
     location
     (into []
           (map
            #(string-to-requirement %)
-           requirements)))))
+           requirements)))
+    meta)))

 (defn query-repo!
   [options arguments]
@@ -296,6 +298,14 @@
            :id :requirements
            :assoc-fn
            (fn [m k v] (update-in m [k] #(conj % v)))]
+          ["-m" "--meta K=V"
+           :validate [#(re-matches #"^[^=]+=[^=].*$" %)
+                      "Metadata must be presented as key=value pair."]
+           :id :meta
+           :assoc-fn
+           (fn [m k v]
+             (let [[_ rk rv] (re-find #"^([^=]+)=([^=].*)$" v)]
+               (update-in m [k] #(assoc % (keyword rk) rv))))]
           ["-v" "--version VERSION"
            "Version of the package"
            :validate [#(re-matches r/version-regex %)
@@ -585,7 +595,6 @@
                        (map #(str "  - " %)
                             configs)))))
       (hash-map))))
-

 (defn -main [& args]
   (let [{:keys [options arguments errors summary]}


Fix min-y and max-y methods

Fix min-y and max-y methods

--- src/fatlip/plot.cljs
+++ src/fatlip/plot.cljs
@@ -110,14 +110,20 @@
          (into {})))

   (min-y [this node-sep char-sep]
-    (apply min (map #(get (ys this node-sep char-sep) (ffirst %)) classes)))
+    (let [node-ys (ys this node-sep char-sep)]
+      (->> classes
+           (mapcat identity)
+           (map #(get node-ys (first %)))
+           (apply min))))

   (max-y [this node-sep char-sep]
-    (->> classes
-         (mapcat peek)
-         (map #(+ (get (ys this node-sep char-sep) %)
-                  (* char-sep (dec (:weight %)))))
-         (apply max)))
+    (let [node-ys (ys this node-sep char-sep)]
+      (->> classes
+           (mapcat identity)
+           (map first)
+           (map #(+ (get node-ys %)
+                    (* char-sep (dec (:weight %)))))
+           (apply max))))

   (width [this node-sep char-sep]
     (- (max-y this node-sep char-sep) (min-y this node-sep char-sep))))


add note about needed test

add note about needed test

--- test/clj_money/models/reconciliations_test.clj
+++ test/clj_money/models/reconciliations_test.clj
@@ -373,6 +373,7 @@
     (is (validation/has-error? result :status) "A validation error is present")
     (is (= 1000M (:balance retrieved)) "The new valud is not saved")))

+; End of period must be after the previous end of period
 ; Test that a completed reconciliation cannot be updated
 ; Test that a completed reconciliation can be deleted if it is the most recent
 ; Test that a completed reconciliation cannot be deleted if it is not the most recent


deleted row/col slicing stuff

deleted row/col slicing stuff

--- src/hangman/core.clj
+++ src/hangman/core.clj
@@ -32,42 +32,20 @@
 (defn to-words-by-length
   "Maps word length to word values.  Each key is a word length. Each value is a collection
   of all words of that length.  Keys are absent if no words of that length are present."
-  [word-seq]
-  (group-by count word-seq) )
+  [word-list]
+  (group-by count word-list) )

 (defn to-word-array
   "Returns all words of the specified length as a 2D array (vector of vectors).
   First index selects a given word, 2nd index selects chars from that word."
-  [word-seq]
+  [word-list]
   (vec
-    (map vec word-seq) ))
-
-(defn num-rows
-  "Given a list of words (seq of seqs), return the number of rows (1st dimension)."
-  [word-list]
-  (count word-list) )
+    (map vec word-list) ))

 (defn num-cols
   "Given a list of words (seq of seqs), return the number of columns (2nd dimension)."
   [word-list]
   (count (first word-list)) )
-
-(defn get-array-col
-  "Given a list of words (seq of seqs), return a vector of elements
-  from the specified column."
-  [word-list col-idx]
-  { :pre  [ (integer? col-idx) ]
-    :post [] }
-  (reduce #(conj %1 (nth %2 col-idx))
-          [] word-list ) )
-
-(defn get-array-row
-  "Given a list of words (seq of seqs), return a vector of elements
-  from the specified row."
-  [word-list row-idx]
-  { :pre  [ (integer? row-idx) ]
-    :post [] }
-  (nth word-list row-idx) )

 (defn filter-with-idx
   "Returns values from data-seq where corresponding pred-seq elements are truthy.
@@ -155,9 +133,9 @@
 (defn make-guess
   "Generate the next guess letter by calculating the bits of information for each possible
   guess letter. "
-  [keep-words used-chars]
+  [word-list used-chars]
   (let [avail-chars   (set/difference all-letters used-chars)
-        char-bits     (zipmap avail-chars (map #(calc-info-bits keep-words %) avail-chars) )
+        char-bits     (zipmap avail-chars (map #(calc-info-bits word-list %) avail-chars) )
         best-char     (apply max-key char-bits avail-chars) ]
     best-char ) )

@@ -218,16 +196,6 @@
     (assert (not (re-find (re-pattern patt-str) "xxcd" )))
     (assert (not (re-find (re-pattern patt-str) "xxxd" )))
     (println)
-  )
-
-  ; Test array slicing functions
-  (let [tstArr [ [:a :b :c] [1 2 3] [\a \b \c]] ]
-    (assert (= (get-array-row tstArr 0) [:a :b :c] ))
-    (assert (= (get-array-row tstArr 1) [ 1  2  3] ))
-    (assert (= (get-array-row tstArr 2) [\a \b \c] ))
-    (assert (= (get-array-col tstArr 0) [:a  1 \a] ))
-    (assert (= (get-array-col tstArr 1) [:b  2 \b] ))
-    (assert (= (get-array-col tstArr 2) [:c  3 \c] ))
   )

   ; Match guesses
@@ -303,7 +271,7 @@
           (println "clue: " (format-clue clue)
                     "  keep-words(" (count keep-words) "):"
                     (take 10 (map str/join keep-words)) "..." )
-          (if (= 1 (num-rows keep-words))
+          (if (= 1 (count keep-words))
             (let [final-guess (str/join (keep-words 0)) ]
               (println (str "***** found word:  '" final-guess "'  *****") )
               (println "matches:" (= final-guess tgt-word)) )


fix bug, the if branches were not properly closed

--- src/herring/core.clj
+++ src/herring/core.clj
@@ -38,15 +38,16 @@
 ;; Handlers
 (defn auth-handler
   [ch {:keys [content-type delivery-tag type] :as meta} ^bytes payload]
+  (println "<< in auth-handler >>") ;; debug
   (if (= content-type "application/json")
     (do
-      (println "<< in auth-handler >>")
       (let [data (json/read-str (String. payload "UTF-8"))
             username (get data "username")
             password (get data "password")
             response-key (get data "responseKey")
             response-payload (json/write-str (authenticate-user username password))]
-        (println (clojure.string/join ", " [username
+        (println "RECEIVED:"
+                 (clojure.string/join ", " [username
                                             password
                                             response-key
                                             response-payload]))
@@ -55,9 +56,9 @@
                     response-key
                     response-payload
                     :content-type "application/json")
-        (lb/ack ch delivery-tag))
+        (lb/ack ch delivery-tag)))
     (do
-      (comment "send back response specifying application/json")))))
+      (println "WARNING: message with content-type" content-type "received"))))

 (defn start-auth-consumer [ch ex-name]


Remove duplicated function from igorle.core ns.

--- src/igorle/core.cljs
+++ src/igorle/core.cljs
@@ -134,11 +134,6 @@
   "A predicate for check that frame comes with id."
   [frame]
   (not (nil? (get-in frame :headers :id))))
-
-(defn debug-mode?
-  "Return true if a client is set into a debug mode."
-  [client]
-  (get-in client [:options :debug] false))

 (defn- fatal-state!
   "Set a client in fatal state.


refactor scaling-for-service-test to use parallelize-requests (#1120)

--- waiter/integration/waiter/autoscaling_test.clj
+++ waiter/integration/waiter/autoscaling_test.clj
@@ -21,23 +21,51 @@
             [waiter.util.client-tools :refer :all]
             [waiter.util.utils :as utils]))

-(defn- scaling-for-service-test [testing-str waiter-url target-instances concurrency-level request-fn]
+(defn- scaling-for-service-test
+  [testing-str waiter-url target-instances concurrency-level request-fn]
   (testing testing-str
-    (let [continue-running (atom true)
-          first-request (request-fn)
+    (let [cancellation-token-atom (atom false)
+          {:keys [cookies] :as first-request} (request-fn {})
           service-id (retrieve-service-id waiter-url (:request-headers first-request))
-          count-instances (fn [] (num-instances waiter-url service-id))]
+          count-instances (fn [] (num-instances waiter-url service-id :cookies cookies))]
       (with-service-cleanup
         service-id
         (is (wait-for #(= 1 (count-instances))) "First instance never started")
-        (future (dorun (pmap (fn [_] (while @continue-running (request-fn)))
-                             (range (* target-instances concurrency-level)))))
-        (is (wait-for #(= target-instances (count-instances))) (str "Never scaled up to " target-instances " instances"))
-        (reset! continue-running false)
+        (let [requests-per-thread 100
+              num-threads (* target-instances concurrency-level)
+              futures (parallelize-requests
+                        num-threads
+                        requests-per-thread
+                        #(request-fn cookies)
+                        :canceled? (fn [] @cancellation-token-atom)
+                        :service-id service-id
+                        :verbose true
+                        :wait-for-tasks false)]
+          (log/info "waiting for" service-id "to scale to" target-instances "instances")
+          (is (wait-for
+                (fn []
+                  (log/info "scale-up:" service-id "retrieving instance count")
+                  (let [current-instances (count-instances)]
+                    (log/info "scale-up:" service-id "currently has" current-instances "instance(s)")
+                    (= target-instances current-instances))))
+              (str "Never scaled up to " target-instances " instances"))
+          (log/info "cancelling parallel requests to" service-id)
+          (reset! cancellation-token-atom true)
+          (log/info "waiting for threads to complete making requests to" service-id)
+          (await-futures futures)
+          (log/info "completed making requests to" service-id))
         ; When scaling down in Marathon, we have to wait for forced kills,
         ; which by default occur after 60 seconds of failed kills.
         ; So give the scale down extra time
-        (is (wait-for #(= 1 (count-instances)) :timeout 300) "Never scaled back down to 1 instance")))))
+        (log/info "waiting for" service-id "to scale down to one instance")
+        (is (wait-for
+              (fn []
+                (log/info "scale-down:" service-id "retrieving instance count")
+                (let [current-instances (count-instances)]
+                  (log/info "scale-down:" service-id "currently has" current-instances "instance(s)")
+                  (= 1 current-instances)))
+              :timeout 300)
+            "Never scaled back down to 1 instance")))))

 (deftest ^:parallel ^:integration-slow ^:resource-heavy test-scaling-healthy-app
   (testing-using-waiter-url
@@ -49,7 +77,7 @@
                           :x-waiter-scale-down-factor 0.9
                           :x-waiter-name (rand-name)}]
       (scaling-for-service-test "Scaling healthy app" waiter-url 3 concurrency-level
-                                #(make-kitchen-request waiter-url custom-headers)))))
+                                #(make-kitchen-request waiter-url custom-headers :cookies %)))))

 (deftest ^:parallel ^:integration-fast ^:resource-heavy test-scaling-unhealthy-app
   (testing-using-waiter-url
@@ -63,7 +91,7 @@
                           :x-waiter-cmd "sleep 600"
                           :x-waiter-queue-timeout 5000}]
       (scaling-for-service-test "Scaling unhealthy app" waiter-url 3 concurrency-level
-                                #(make-shell-request waiter-url custom-headers)))))
+                                #(make-shell-request waiter-url custom-headers :cookies %)))))

 (defn- run-scale-service-requests
   [waiter-url cookies request-fn requests-per-thread delay-secs service-id


Minor code deduplication on core ns.

Minor code deduplication on core ns.

--- src/lentes/core.cljc
+++ src/lentes/core.cljc
@@ -1,5 +1,6 @@
 (ns lentes.core
-  (:refer-clojure :exclude [nth key keys vals filter select-keys cat derive]))
+  (:refer-clojure :exclude [nth key keys vals filter select-keys cat derive])
+  (:require [clojure.core :as c]))

 ;; constructors

@@ -66,10 +67,9 @@
   opposite direction, construct a lens that focuses and updates
   a converted value."
   [one->other other->one]
-  (lens
-   one->other
-   (fn [s f]
-     (other->one (f (one->other s))))))
+  (lens one->other
+        (fn [s f]
+          (other->one (f (one->other s))))))

 ;; lenses

@@ -79,31 +79,25 @@

   The lens is not well-behaved, depens on the outcome of the predicate."
   [applies?]
-  (lens
-   (fn [s]
-     (when (applies? s)
-       s))
-   (fn [s f]
-     (if (applies? s)
-       (f s)
-       s))))
+  (lens (fn [s]
+          (when (applies? s)
+            s))
+        (fn [s f]
+          (if (applies? s)
+            (f s)
+            s))))

 (defn nth
   "Given a number, returns a lens that focuses on the given index of
   a collection."
   [n]
-  (lens
-    (fn [s]
-      (clojure.core/nth s n))
-    (fn [s f]
-      (update s n f))))
+  (lens (fn [s] (c/nth s n))
+        (fn [s f] (update s n f))))

 (def fst (nth 0))
 (def snd (nth 1))

-(defn sequential-empty
-  {:internal true
-   :no-doc true}
+(defn- sequential-empty
   [coll]
   (cond
     (map? coll) {}
@@ -112,61 +106,58 @@

 (def tail
   "A lens into the tail of a collection."
-  (lens
-   rest
-   (fn [s f]
-     (into (sequential-empty s)
-           (cons (first s)
-                 (f (rest s)))))))
+  (lens rest
+        (fn [s f]
+          (into (sequential-empty s)
+                (cons (first s)
+                      (f (rest s)))))))

 (defn key
   "Given a key, returns a lens that focuses on the given key of
   an associative data structure."
   [k]
-  (lens
-   (fn [s]
-     (get s k))
-   (fn [s f]
-     (update s k f))))
-
-(def ^:private core-select-keys
-  #?(:clj clojure.core/select-keys
-     :cljs cljs.core/select-keys))
+  (lens (fn [s] (get s k))
+        (fn [s f] (update s k f))))

 (defn select-keys
   "Return a lens focused on the given keys in an associative data
   structure."
   [ks]
-  (lens
-   (fn [s]
-     (core-select-keys s ks))
-   (fn [s f]
-     (merge (apply dissoc s ks)
-            (-> (core-select-keys s ks)
-                f
-                (core-select-keys ks))))))
+  (lens (fn [s] (c/select-keys s ks))
+        (fn [s f]
+          (merge (apply dissoc s ks)
+                 (-> (c/select-keys s ks)
+                     f
+                     (c/select-keys ks))))))

 (defn in
   "Given a path and optionally a default value, return a lens that
   focuses the given path in an associative data structure."
-  ([path]
-   (in path nil))
+  ([path] (in path nil))
   ([path default]
-   (lens
-    (fn [s]
-      (get-in s path default))
-    (fn [s f]
-      (update-in s path f)))))
+   (lens (fn [s] (get-in s path default))
+         (fn [s f] (update-in s path f)))))

 ;; interop

 (defn- prefix-key
-  {:internal true :no-doc true}
   [key id]
   (keyword (str id "-" (name key))))

-(def ^:private +empty+
-  #?(:clj (Object.) :cljs (js/Object.)))
+(defn- make-watcher
+  [self lens equals?]
+  (letfn [(run-watchers [oldv newv]
+            (run! (fn [[key wf]] (wf key self oldv newv))
+                  (.-watchers self)))]
+    (fn [_ _ oldv newv]
+      (when-not (identical? newv (.-srccache self))
+        (let [old' (focus lens oldv)
+              new' (focus lens newv)]
+          (set! (.-cache self) new')
+          (set! (.-oldcache self) old')
+          (set! (.-srccache self) newv)
+          (when-not (equals? old' new')
+            (run-watchers old' new')))))))

 #?(:clj
    (deftype RWFocus [id lens src equals?
@@ -205,23 +196,10 @@

      clojure.lang.IRef
      (addWatch [self key cb]
-       (letfn [(run-watchers [oldv newv]
-                 (run! (fn [[key wf]] (wf key self oldv newv))
-                       (.-watchers self)))
-               (main-watcher [_ _ oldv newv]
-                 (locking self
-                   (when-not (identical? newv (.-srccache self))
-                     (let [old' (focus lens oldv)
-                           new' (focus lens newv)]
-                       (set! (.-cache self) new')
-                       (set! (.-oldcache self) old')
-                       (set! (.-srccache self) newv)
-                       (when-not (equals? old' new')
-                         (run-watchers old' new'))))))]
-         (locking self
-           (set! (.-watchers self) (assoc watchers key cb))
-           (when (= (count (.-watchers self)) 1)
-             (add-watch src id main-watcher)))
+       (locking self
+         (set! (.-watchers self) (assoc watchers key cb))
+         (when (= (count (.-watchers self)) 1)
+           (add-watch src id (make-watcher self lens equals?)))
          self))

      (removeWatch [self key]
@@ -269,24 +247,10 @@

      IWatchable
      (-add-watch [self key cb]
-       (letfn [(run-watchers [oldv newv]
-                 (run! (fn [[key wf]] (wf key self oldv newv))
-                       (.-watchers self)))
-               (main-watcher [_ _ oldv newv]
-                 (locking self
-                   (when-not (identical? newv (.-srccache self))
-                     (let [old' (focus lens oldv)
-                           new' (focus lens newv)]
-                       (set! (.-cache self) new')
-                       (set! (.-oldcache self) old')
-                       (set! (.-srccache self) newv)
-                       (when-not (equals? old' new')
-                         (run-watchers old' new'))))))]
-         (locking self
-           (set! (.-watchers self) (assoc watchers key cb))
-           (when (= (count (.-watchers self)) 1)
-             (add-watch src id main-watcher)))
-         self))
+       (set! (.-watchers self) (assoc watchers key cb))
+       (when (= (count (.-watchers self)) 1)
+         (add-watch src id (make-watcher self lens equals?)))
+       self)

      (-remove-watch [self key]
        (set! (.-watchers self) (dissoc watchers key))
@@ -313,23 +277,10 @@

      clojure.lang.IRef
      (addWatch [self key cb]
-       (letfn [(run-watchers [oldv newv]
-                 (run! (fn [[key wf]] (wf key self oldv newv))
-                       (.-watchers self)))
-               (main-watcher [_ _ oldv newv]
-                 (locking self
-                   (when-not (identical? newv (.-srccache self))
-                     (let [old' (focus lens oldv)
-                           new' (focus lens newv)]
-                       (set! (.-cache self) new')
-                       (set! (.-oldcache self) old')
-                       (set! (.-srccache self) newv)
-                       (when-not (equals? old' new')
-                         (run-watchers old' new'))))))]
-         (locking self
-           (set! (.-watchers self) (assoc watchers key cb))
-           (when (= (count (.-watchers self)) 1)
-             (add-watch src id main-watcher)))
+       (locking self
+         (set! (.-watchers self) (assoc watchers key cb))
+         (when (= (count (.-watchers self)) 1)
+           (add-watch src id (make-watcher self lens equals?)))
          self))

      (removeWatch [self key]
@@ -357,27 +308,17 @@

      IWatchable
      (-add-watch [self key cb]
-       (letfn [(run-watchers [oldv newv]
-                 (run! (fn [[key wf]] (wf key self oldv newv))
-                       (.-watchers self)))
-               (main-watcher [_ _ oldv newv]
-                 (when-not (identical? newv (.-srccache self))
-                   (let [old' (focus lens oldv)
-                         new' (focus lens newv)]
-                     (set! (.-cache self) new')
-                     (set! (.-oldcache self) old')
-                     (set! (.-srccache self) newv)
-                     (when-not (equals? old' new')
-                       (run-watchers old' new')))))]
-         (set! (.-watchers self) (assoc watchers key cb))
-         (when (= (count (.-watchers self)) 1)
-           (add-watch src id main-watcher))
-         self))
+       (set! (.-watchers self) (assoc watchers key cb))
+       (when (= (count (.-watchers self)) 1)
+         (add-watch src id (make-watcher self lens equals?)))
+       self)

      (-remove-watch [self key]
        (set! (.-watchers self) (dissoc watchers key))
        (when (empty? watchers)
          (remove-watch src id)))))
+
+(def ^:private +empty+ #?(:clj (Object.) :cljs (js/Object.)))

 (defn derive
   "Create a derived atom from an other atom with the provided lense.


Fixed moving bug

Fixed moving bug

Instead of .translate we now call .redraw.

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- conexp/graphics/base.clj
+++ conexp/graphics/base.clj
@@ -146,17 +146,12 @@

 	[new-x new-y] [(+ x dx) (+ y dy)]]

-    ; move node on the device
-    (let [[dx-1 dy-1] (world-to-device (.getScene node) dx dy)
-	  [zx zy]     (world-to-device (.getScene node) 0 0)
-	  device-dx   (- dx-1 zx)
-	  device-dy   (- dy-1 zy)]
-      (doseq [#^GSegment segment (.getSegments node)]
-	(.translate segment device-dx device-dy)))  ;; noch nicht richtig?
-
     ; update self position
     (dosync
      (alter (.getUserData node) assoc :position [new-x new-y]))
+
+    ; move node on the device
+    (.redraw node)

     ; update connections to upper neighbors
     (doseq [#^GObject c (upper-connections node)]


stray println

stray println

--- src/onyx/schema.cljc
+++ src/onyx/schema.cljc
@@ -209,7 +209,6 @@
   (let [r-ns-keys (filter (partial instance? onyx.schema.RestrictedKwNamespace)
                           (keys m))
         r-ns (mapcat :nspaces r-ns-keys)]
-    (println r-ns)
     (if-not (empty? r-ns)
       (-> (apply (partial dissoc m) r-ns-keys)
           (assoc (apply restricted-ns r-ns) s/Any))


Avoid blowing the stack

Avoid blowing the stack

--- src/aurora/btree.cljs
+++ src/aurora/btree.cljs
@@ -439,78 +439,85 @@
                (set! end? true))))
          (dotimes [i (alength seek-key)]
            (aset seek-key i least))
-         (.down this -1))
+         (.search this -1 0 0))
   (key [this]
        (when (false? end?)
          (aclone seek-key)))
-  (search [this var]
-          ;; assumes prefixes all equal, keys not all equal, iterators sorted by ascending key, nothing at end
-          (let [iterators (aget var->iterators var)
-                num-iterators (alength iterators)]
-            (loop [max-key (.key-at (aget iterators (- num-iterators 1)) var)
-                   current 0]
-              (debug :search max-key current seek-key)
-              (let [iterator (aget iterators current)
-                    min-key (.key-at iterator var)]
-                (aset seek-key var max-key)
-                (let [old-key (.inner-key iterator)]
-                  (.seek iterator seek-key)
-                  (if (.end? iterator)
-                    (do
-                      (.undo iterator)
-                      (.up this var))
-                    (let [new-key (.inner-key iterator)]
-                      (if (prefix-not= old-key new-key var)
-                        (do
-                          (.undo iterator)
-                          (.up this var))
-                        (if (== (.key-at iterator var) max-key)
-                          (.down this var max-key)
-                          (recur min-key (mod (+ current 1) num-iterators)))))))))))
-  (up [this old-var]
-      ;; assumes prefixes and keys all equal, nothing at end
-      (debug :up old-var seek-key)
-      (if (== old-var 0)
-        (set! end? true)
-        (let [new-var (- old-var 1)
-              iterators (aget var->iterators new-var)
-              iterator (aget iterators (- (alength iterators) 1))]
-          (when (< old-var (alength var->iterators))
-            (aset seek-key old-var least))
-          (let [old-key (.inner-key iterator)]
-            (.next iterator)
-            (if (.end? iterator)
-              (do
-                (.undo iterator)
-                (.up this new-var))
-              (let [new-key (.inner-key iterator)]
-                (if (prefix-not= old-key new-key new-var)
-                  (do
-                    (.undo iterator)
-                    (.up this new-var))
-                  (.search this new-var))))))))
-  (down [this old-var old-key]
-        ;; assumes prefixes all equal, nothing at end
-        (debug :down old-var old-key seek-key)
-        (if (== old-var (- (alength var->iterators) 1))
-          (aset seek-key old-var old-key) ;; done
-          (let [new-var (+ old-var 1)
-                iterators (aget var->iterators new-var)]
-            (dotimes [i (alength iterators)]
-              (doto (aget iterators i) (.reset) (.seek seek-key))) ;; TODO this could be implemented more efficiently
-            (when (>= old-var 0)
-              (aset seek-key old-var old-key))
-            (js/goog.array.sort iterators (fn [i0 i1] (compare (.key-at i0 new-var) (.key-at i1 new-var))))
-            (if (== (.key-at (aget iterators 0) new-var) (.key-at (aget iterators (- (alength iterators) 1)) new-var))
-              (.down this new-var (.key-at (aget iterators 0) new-var))
-              (.search this new-var)))))
+  (search [this old-var new-var current]
+          (cond
+
+           (== old-var new-var)
+           ;; ACROSS: assumes prefixes all equal, keys not all equal, iterators sorted by ascending key, nothing at end
+           (let [iterators (aget var->iterators new-var)
+                 num-iterators (alength iterators)
+                 previous (mod (- current 1) num-iterators)
+                 max-key (.key-at (aget iterators previous) new-var)
+                 iterator (aget iterators current)
+                 min-key (.key-at iterator new-var)
+                 old-key (.inner-key iterator)]
+             (debug :search max-key current seek-key)
+             (aset seek-key new-var max-key)
+             (.seek iterator seek-key)
+             (if (.end? iterator)
+               (do
+                 (.undo iterator)
+                 (recur new-var (- new-var 1) 0))
+               (let [new-key (.inner-key iterator)]
+                 (if (prefix-not= old-key new-key new-var)
+                   (do
+                     (.undo iterator)
+                     (recur new-var (- new-var 1) 0))
+                   (if (== (.key-at iterator new-var) max-key)
+                     (do
+                       (aset seek-key new-var max-key)
+                       (recur new-var (+ new-var 1) 0))
+                     (recur new-var new-var (mod (+ current 1) num-iterators)))))))
+
+           (< new-var old-var)
+           ;; UP: assumes prefixes and keys all equal, nothing at end
+           (if (== old-var 0)
+             (set! end? true)
+             (let [new-var (- old-var 1)
+                   iterators (aget var->iterators new-var)
+                   iterator (aget iterators (- (alength iterators) 1))]
+               (debug :up old-var seek-key)
+               (when (< old-var (alength var->iterators))
+                 (aset seek-key old-var least))
+               (let [old-key (.inner-key iterator)]
+                 (.next iterator)
+                 (if (.end? iterator)
+                   (do
+                     (.undo iterator)
+                     (recur new-var (- new-var 1) 0))
+                   (let [new-key (.inner-key iterator)]
+                     (if (prefix-not= old-key new-key new-var)
+                       (do
+                         (.undo iterator)
+                         (recur new-var (- new-var 1) 0))
+                       (recur new-var new-var 0)))))))
+
+           (> new-var old-var)
+           ;; DOWN: assumes prefixes all equal, nothing at end
+           (if (== old-var (- (alength var->iterators) 1))
+             nil ;; done
+             (let [new-var (+ old-var 1)
+                   iterators (aget var->iterators new-var)]
+               (debug :down old-var old-key seek-key)
+               (dotimes [i (alength iterators)]
+                 (doto (aget iterators i) (.reset) (.seek seek-key))) ;; TODO this could be implemented more efficiently
+               (js/goog.array.sort iterators (fn [i0 i1] (compare (.key-at i0 new-var) (.key-at i1 new-var))))
+               (if (== (.key-at (aget iterators 0) new-var) (.key-at (aget iterators (- (alength iterators) 1)) new-var))
+                 (do
+                   (aset seek-key new-var (.key-at (aget iterators 0) new-var))
+                   (recur new-var (+ new-var 1) 0))
+                 (recur new-var new-var 0))))))
   (next [this]
         (debug)
         (debug :next seek-key)
         (when (false? end?)
           (let [iterators (aget var->iterators (- (alength var->iterators) 1))
                 iterator (aget iterators (- (alength var->iterators) 1))]
-            (.up this (alength var->iterators))))))
+            (.search this (alength var->iterators) (- (alength var->iterators) 1) 0)))))

 (defn join [iterators num-vars iterator->var->present?]
   (let [seek-key (least-key num-vars)
@@ -898,17 +905,26 @@
     (alength (time (iter-seq j)))
   )

-
-
   (let [tree (tree 10)
         _ (dotimes [i 10]
             (let [i (+ i 0)]
-              (.assoc! tree #js [i i i] (* 2 i))))
-        j (time (join #js [(iterator tree) (iterator tree) (iterator tree)] 4 #js [#js [true false false true false false]
+              (.assoc! tree #js [i i] (* 2 i))))
+        j (time (join #js [(iterator tree) (iterator tree) (iterator tree)] 6 #js [#js [true false false true false false]
                                                                                #js [false true false false true false]
                                                                                #js [false false true false false true]]))
         ]
     (alength (time (iter-seq j)))
   )
+
+  (let [tree (tree 10)
+        _ (dotimes [i 10]
+            (let [i (+ i 0)]
+              (.assoc! tree #js [i i] (* 2 i))))
+        j (time (join #js [(iterator tree) (iterator tree) (iterator tree)] 6 #js [#js [true false false false false true]
+                                                                                #js [false true false false true false]
+                                                                                #js [false false true true false false]]))
+        ]
+    (alength (time (iter-seq j)))
+  )
  )


test future 12345

test future 12345

--- src/pg_demo/core.clj
+++ src/pg_demo/core.clj
@@ -111,7 +111,7 @@
 (def enable-testing true)   ; #todo  FOR TESTING ONLY *******************************************
 (def test-rs-limit-fn       ; #todo  FOR TESTING ONLY *******************************************
   (if enable-testing
-    #(take 1234 %)
+    #(take 12345 %)
     identity ))

 (defn result-set->pg-insert [table-name result-set]
@@ -124,7 +124,8 @@
           (print (format "%s: %7d/%7d  "    table-name
                                             (swap! rows-inserted + (count rows-chunk-new))
                                             table-rows ))
-          (time (apply jdbc/insert! pg-conn table-name rows-chunk-new  )))))
+          (time (apply jdbc/insert! pg-conn table-name rows-chunk-new  ))
+          (flush))))

     (when false
       (newline)
@@ -135,10 +136,18 @@
   ))

 (defn proc-table [table-name]
-  (jdbc/with-db-connection [ora-conn ora-spec]
-    (oracle-set-context ora-conn)
-    (jdbc/query ora-conn [ (format "select * from %s" table-name) ]
-      :result-set-fn  #(result-set->pg-insert table-name %) )))
+  (let [completed (atom false)]
+    (while (not @completed)
+      (Thread/sleep (rand-int (* 30 1000)))
+      (println "Trying tx for:" table-name)
+      (try
+        (jdbc/with-db-connection [ora-conn ora-spec]
+          (oracle-set-context ora-conn)
+          (jdbc/query ora-conn [ (format "select * from %s" table-name) ]
+            :result-set-fn  #(result-set->pg-insert table-name %) ))
+        (reset! completed true)
+        (catch Exception ex
+          (println (format "    %s failed... will retry" table-name)))))))

 (defn transfer-data []
   (newline)


Improve selection behavior and fix overeager bailouts when updates are slow

--- src/player/core.cljs
+++ src/player/core.cljs
@@ -178,8 +178,8 @@
                   :scroll-y        (:scroll-y world-desc)
                   :camera-width    (:camera-width world-desc)
                   :camera-height   (:camera-height world-desc)
-                  :view-width      640
-                  :view-height     480
+                  :view-width      320
+                  :view-height     240
                   :width           (:width world-desc)
                   :height          (:height world-desc)
                   :walls           walls})))
@@ -305,7 +305,7 @@
           (pair (butlast seed-playout) (rest seed-playout)))]
     [(map rest playouts) explored seen]))

-(def explore-around? false)
+(def explore-around? true)

 (defn update-world! [w-atom ufn]
   (swap!
@@ -467,36 +467,38 @@
       w)))

 (defn world-update-desc [w desc]
-  (let [w (reenter-current-config w)
-        old-defs (:ha-defs w)
-        new-world (make-world desc)
-        new-defs (:ha-defs new-world)
-        new-vals (:objects (current-config new-world))
-        old-init-vals (:objects (first (:configs w)))
-        _ (println "world-update-desc")
-        w (assoc w :ha-defs new-defs
-                   :desc desc
-                   :walls (:walls new-world)
-                   :seen-polys {}
-                   :explored #{}
-                   :seen-configs #{}
-                   :width (:width desc)
-                   :height (:height desc))
-        w (update w
-                  :configs
-                  (fn [cfgs]
-                    (mapv
-                      (fn [{old-vals :objects t :entry-time :as cfg}]
-                        (assoc cfg :objects (update-object-vals old-defs
-                                                                new-defs
-                                                                old-init-vals
-                                                                old-vals
-                                                                new-vals
-                                                                t)
-                                   :tr-caches nil))
-                      cfgs)))]
-    (world-append (update w :configs #(subvec % 0 (dec (count %))))
-                  (heval/recache-trs new-defs (current-config w)))))
+  (if (= desc (:desc w))
+    w
+    (let [w (reenter-current-config w)
+          old-defs (:ha-defs w)
+          new-world (make-world desc)
+          new-defs (:ha-defs new-world)
+          new-vals (:objects (current-config new-world))
+          old-init-vals (:objects (first (:configs w)))
+          _ (println "world-update-desc")
+          w (assoc w :ha-defs new-defs
+                     :desc desc
+                     :walls (:walls new-world)
+                     :seen-polys {}
+                     :explored #{}
+                     :seen-configs #{}
+                     :width (:width desc)
+                     :height (:height desc))
+          w (update w
+                    :configs
+                    (fn [cfgs]
+                      (mapv
+                        (fn [{old-vals :objects t :entry-time :as cfg}]
+                          (assoc cfg :objects (update-object-vals old-defs
+                                                                  new-defs
+                                                                  old-init-vals
+                                                                  old-vals
+                                                                  new-vals
+                                                                  t)
+                                     :tr-caches nil))
+                        cfgs)))]
+      (world-append (update w :configs #(subvec % 0 (dec (count %))))
+                    (heval/recache-trs new-defs (current-config w))))))

 (defn world-update-desc! [world desc]
   (update-world! world
@@ -522,7 +524,8 @@
                         new-now
                         ; assume all keys held now were held since "then"
                         [(iv/interval (:now w) new-now) (keys/key-states)]
-                        10
+                        ; bailout if we transition more than 60 times per second
+                        (* 60 (- new-now (:now w)))
                         0)
                 new-w (if (not= c new-c)
                         (world-append w new-c)
@@ -545,7 +548,7 @@
 (defn button-bar [world]
   (let [wld @world
         ha-defs (:ha-defs wld)]
-    (sab/html [:div {:style {:position "fixed"}}
+    (sab/html [:div {:style {:position "fixed" :top 0}}
                [:button {:onClick #(swap! world
                                           (fn [w]
                                             (assoc w :playing (not (:playing w)))))}
@@ -802,16 +805,30 @@
                                                                                :live-objects {})
                                                                                :mouse-down-loc [wx wy]
                                                                                :last-loc [wx wy]
-                                                                                :move-mode :clicking)]
-                                                                               (if-let [new-sel (first found-things)]
-                                                                                (if (.-shiftKey evt)
-                                                                                (if (contains? sel new-sel)
-                                                                                (selection-remove ed new-sel)
-                                                                                (selection-add ed wld new-sel))
-                                                                                (selection-add (selection-init ed) wld new-sel))
-                                                                                (if (.-shiftKey evt)
-                                                                                ed
-                                                                                (selection-init ed))))))))
+                                                                                :move-mode :clicking)
+                                                                                shift? (.-shiftKey evt)
+                                                                                new-sel (first found-things)
+                                                                                present? (and new-sel
+                                                                                (contains? sel new-sel))]
+                                                                               (cond
+                                                                                ; shift-clicked on an object already present --> deselect
+                                                                                (and new-sel shift? present?)
+                                                                                (selection-remove ed new-sel)
+                                                                                ; shift-clicked on a new object --> add to selection
+                                                                                (and new-sel shift?)
+                                                                                (selection-add ed wld new-sel)
+                                                                                ; regular-clicked on a new object --> change selection to new object
+                                                                                (and new-sel (not shift?) (not present?))
+                                                                                (selection-add (selection-init ed)
+                                                                                wld
+                                                                                new-sel)
+                                                                                ; regular-clicked on nothing --> clear selection
+                                                                                (and (not new-sel)
+                                                                                (not shift?))
+                                                                                (selection-init ed)
+                                                                                ; otherwise (eg regular clicked on a selected object), do nothing
+                                                                                :else
+                                                                                ed))))))
                                                   :onMouseMove
                                                          (fn [evt]
                                                            (let [ed @editor
@@ -850,7 +867,7 @@
                                                                                ;create new object and set sel to it and enter either moving state (for HAs) or resizing state (for walls)
                                                                                ; multi-selection or HA selected or mouse in center
                                                                                (editor-start-new-thing ed down-x down-y wx wy)
-                                                                               (or (> 1 (count sel))
+                                                                               (or (> (count sel) 1)
                                                                                (= :objects (ffirst sel))
                                                                                (= :live-objects (ffirst sel))
                                                                                (wall-centerish-point? (get-in (:draft-desc ed) (first sel)) wx wy))


revert scheduler log changes (#138)

revert scheduler log changes (#138)

--- waiter/src/waiter/scheduler.clj
+++ waiter/src/waiter/scheduler.clj
@@ -400,25 +400,15 @@
 (defn do-health-checks
   "Takes a map from service -> service instances and performs health checks in parallel. Returns a map of service -> service instances."
   [service->service-instances available? service-id->service-description-fn]
-  (let [timeout-threshold-mins 2
-        timeout-channel (async/timeout (-> timeout-threshold-mins t/minutes t/in-millis))
-        slowness-monitor-promise (promise)]
-    (async/go
-      (async/<! timeout-channel)
-      (when (not (realized? slowness-monitor-promise))
-        (log/warn "scheduler-syncer: health checks are taking longer than" timeout-threshold-mins "minute(s) to complete")))
-    (let [service->service-instance-futures (start-health-checks service->service-instances available? service-id->service-description-fn)]
-      (loop [[[service {:keys [active-instances] :as instances}] & rest] (seq service->service-instance-futures)
-             service->service-instances' {}]
-        (if-not service
-          (do
-            (deliver slowness-monitor-promise :done)
-            (async/close! timeout-channel)
-            service->service-instances')
-          (let [active-instances (doall (map async/<!! active-instances))]
-            (recur rest (assoc service->service-instances'
-                          service
-                          (assoc instances :active-instances active-instances)))))))))
+  (let [service->service-instance-futures (start-health-checks service->service-instances available? service-id->service-description-fn)]
+    (loop [[[service {:keys [active-instances] :as instances}] & rest] (seq service->service-instance-futures)
+           service->service-instances' {}]
+      (if-not service
+        service->service-instances'
+        (let [active-instances (doall (map async/<!! active-instances))]
+          (recur rest (assoc service->service-instances'
+                        service
+                        (assoc instances :active-instances active-instances))))))))

 (defn- update-scheduler-state
   "Queries marathon, sends data on app and instance statuses to router state maintainer, and returns scheduler state"
@@ -485,10 +475,9 @@
                                 :instance-id->tracked-failed-instance instance-id->tracked-failed-instance'
                                 :instance-id->failed-health-check-count instance-id->failed-health-check-count'}})
                      scheduler-messages' remaining))
-            (do
-              (log/info (timing-message-fn) "for" (count service->service-instances) "services.")
-              {:service-id->health-check-context service-id->health-check-context'
-               :scheduler-messages scheduler-messages}))))
+            (do (log/info (timing-message-fn) "for" (count service->service-instances) "services.")
+                {:service-id->health-check-context service-id->health-check-context'
+                 :scheduler-messages scheduler-messages}))))
       (do
         (log/info (timing-message-fn) "and found no active services")
         {:service-id->health-check-context service-id->health-check-context}))))


Make query support days

Make query support days

--- web/src/web/routes/services.clj
+++ web/src/web/routes/services.clj
@@ -8,12 +8,12 @@
 (defonce elastic-url "http://107.170.217.185:9200")
 (defonce elastic-index "river_flow")

-(defn gen-query [name w s e n year]
+(defn gen-query [name w s e n date]
   {:filtered
    {:query {:match {:name name}}
     :filter {:and [{:range
-                    {:date-time {:gte (str year "-01-01")
-                                 :lte (str year "-12-31")}}}
+                    {:date-time {:gte (str date "T00:00:00")
+                                 :lte (str date "T23:59:59")}}}
                    {:geo_bounding_box
                     {:geo-loc {:top_left {:lat n :lon w}
                                :bottom_right {:lat s :lon e}}}}]}}})
@@ -22,14 +22,14 @@
   {:geo-loc {:terms {:script "doc['geo-loc'].value.toString()"}
              :aggs {:avg_value {:avg {:field "value"}}}}})

-(defn water-quality-search [name w s e n year]
+(defn water-quality-search [name w s e n date]
   (let [conn (es/connect elastic-url)
-        q (gen-query name w s e n year)]
+        q (gen-query name w s e n date)]
     (esd/search conn elastic-index "stream"
                 :query q
                 :aggs aggregation-clause
                 :from 0
-                :size 2000)))
+                :size 5000)))

 (defn gen-small-polygon [point]
   (let [[lat lon] point
@@ -61,11 +61,11 @@
      :features features}))

 (defroutes service-routes
-  (GET "/api/search" [name w s e n year]
+  (GET "/api/search" [name w s e n date]
        {:status 200
         :body (to-geo-json (water-quality-search name
                                                  (Double/parseDouble w)
                                                  (Double/parseDouble s)
                                                  (Double/parseDouble e)
                                                  (Double/parseDouble n)
-                                                 year))}))
+                                                 date))}))