Populate bounds.

Populate bounds.

--- dev/migrate.clj
+++ dev/migrate.clj
@@ -2,7 +2,10 @@
   (:require [qbits.hayt :as hayt]
             [kixi.hecuba.storage.db :as db]
             [kixi.hecuba.api.measurements :as measurements]
-            [clojure.tools.logging :as log]))
+            [clojure.tools.logging :as log]
+            [clj-time.core :as t]
+            [clj-time.format :as tf]
+            [clj-time.coerce :as tc]))

 (defn do-map
   "Map with side effects."
@@ -25,7 +28,6 @@
   (db/with-session [session (:hecuba-session store)]
     (let [sensors (db/execute session (hayt/select :sensors))]
       (doseq [s sensors]
-        (prn "Sensor:" (:device_id s) (:type s))
         (let [measurements (measurements/all-measurements store s)]
           (do-map #(db/execute session
                                (hayt/update :measurements
@@ -35,3 +37,28 @@
                                                          [= :month (:month %)]
                                                          [= :timestamp (:timestamp %)]]))) measurements)))))
   (log/info "Finished migrating reading metadata."))
+
+(defn fill-sensor-bounds
+  "Gets very first measurement row for each sensor and updates lower_ts in sensor_metadata with its timestamp.
+  Upper_ts is populated with current date."
+  [{:keys [store]}]
+  (log/info "Populating sensor bounds.")
+  (db/with-session [session (:hecuba-session store)]
+    (let [sensors (db/execute session (hayt/select :sensors))]
+      (doseq [s sensors]
+        (let [where [[= :device_id (:device_id s)]
+                     [= :type (:type s)]]
+              first-ts (:timestamp (first (db/execute session
+                                                      (hayt/select :measurements
+                                                                   (hayt/where where)
+                                                                   (hayt/limit 1)))))
+              last-ts  (:timestamp (first (db/execute session
+                                                      (hayt/select :measurements
+                                                                   (hayt/where where)
+                                                                   (hayt/order-by [:type :desc])
+                                                                   (hayt/limit 1)))))]
+          (db/execute session (hayt/update :sensor_metadata
+                                           (hayt/set-columns :upper_ts first-ts
+                                                             :lower_ts last-ts)
+                                           (hayt/where where)))))))
+  (log/info "Finished populating sensor bounds."))


fixed using gopass apt-source on right place

--- main/src/dda/pallet/dda_managed_vm/infra/credential_management.clj
+++ main/src/dda/pallet/dda_managed_vm/infra/credential_management.clj
@@ -73,7 +73,6 @@
   (actions/as-action
    (logging/info (str facility "-install system: init-gopass")))
   (install-gpg)
-  (init-gopass facility)
   (actions/packages :aptitude ["gopass"]))
   ;au BufNewFile,BufRead /dev/shm/gopass.* setlocal noswapfile nobackup noundofile
   ;ln -s $GOPATH/bin/gopass $HOME/bin/pass
@@ -107,7 +106,7 @@
   [facility :- s/Keyword
    settings]
   (when (contains? settings :install-gopass)
-    (install-gopass facility)))
+    (init-gopass facility)))

 (s/defn install-system
   [facility :- s/Keyword


Set TTL of ring session to one hour, instead of 1 minute for testing.

--- dev-resources/spec.clj
+++ dev-resources/spec.clj
@@ -16,7 +16,7 @@
  :cassandra {:config-file "cassandra.yaml"}
  :alia {:contact-points ["localhost"]
         :port 9042}
- :session-store {:ttl 1}
+ :session-store {:ttl 60}
  :kafka {:server {:port 9090
                   :broker.id 1
                   :log.dir "target/kafka-log"


Centre map on first marker instead of hard coded position

--- src-cljs/acfe/render.cljs
+++ src-cljs/acfe/render.cljs
@@ -25,7 +25,7 @@
 (defn create-map
   "Creates Google Map object in DOM, binds to global gmap."
   []
-  (let [opts {:center {:lat -37 :lng 143} :zoom 7}
+  (let [opts {:zoom 7}
 		mapobj (google.maps.Map. (sel1 :#map) (clj->js opts))]
 	(reset! gmap mapobj)
 	))
@@ -67,11 +67,9 @@

 (defn create-markers
   [places click-handler]
-  (reset! gmarkers
-		  (doall (map
-				  #(create-marker (:lat %) (:lng %) @gmap (:title %) (:id %) (:category %)
-								  click-handler)
-				  places))))
+  (let [f #(create-marker (:lat %) (:lng %) @gmap (:title %) (:id %) (:category %) click-handler)]
+	(reset! gmarkers (doall (map f places))))
+  (.setCenter @gmap (.getPosition (first @gmarkers))))


filter links no longer an issue sir

filter links no longer an issue sir

--- src/crawler/crawl.clj
+++ src/crawler/crawl.clj
@@ -283,8 +283,8 @@
                                                              (set visited)
                                                              (set [url])
                                                              (set (map :url queue))))
-                              (catch Exception e nil))
-
+                                     (catch Exception e nil))
+
               score   (try (cur-nav-fraction body content)
                            (catch Exception e nil))

@@ -306,6 +306,10 @@
               mined      (when-not leaf?
                            (rich-char-extractor/filter-content
                             content))
+
+              observed   (when-not leaf?
+                           (rich-char-extractor/filter-content
+                            unchecked-content))

               obs-links  (try
                            (distinct-by-key
@@ -326,7 +330,7 @@
                                concat
                                (map
                                 (fn [{xpath :xpath
-                                     l-score :score
+                                     score :score
                                      hrefs :hrefs
                                      text  :texts}]
                                   ;; take only a 25 % sample from here.
@@ -337,7 +341,7 @@
                                       :src-url url
                                       :src-nav-num (cons (if body l-score 0) src-nav-num)})
                                    hrefs))
-                                mined))))
+                                observed))))
                             :url)
                            (catch Exception e []))

@@ -360,7 +364,7 @@
                                concat
                                (map
                                 (fn [{xpath :xpath
-                                     l-score :score
+                                     score :score
                                      hrefs :hrefs
                                      text  :texts}]
                                   ;; take only a 25 % sample from here.
@@ -371,11 +375,19 @@
                                       {:url h
                                        :src-xpath (cons xpath src-xp)
                                        :src-url url
-                                       :src-nav-num (cons (if body l-score 0) src-nav-num)})
+                                       :src-nav-num (cons (if body score 0) src-nav-num)})
                                     hrefs)))
                                 mined))))
                              :url)
-                            (catch Exception e []))]
+                            (catch Exception e []))
+
+              mined-obs-links (if-not leaf?
+                               (/ (- (count obs-links)
+                                     (count mined-links))
+                                  (count obs-links))
+                               :leaf)
+
+              _ (println :retained mined-obs-links)]
           (cond
            (and (not leaf?) (seq mined-links))
            (recur (concat (rest queue)


add fressian serializer and deserializer to filestore

--- src/konserve/filestore.cljs
+++ src/konserve/filestore.cljs
@@ -1,14 +1,20 @@
 (ns konserve.filestore
-  (:require [cljs.nodejs :as node]
-            [konserve.core :as k]
-            [hasch.core :refer [uuid]]
-            [fressian-cljs.core :as fress]
-            [konserve.serializers :as ser]
-            [konserve.protocols :refer [PEDNAsyncKeyValueStore -exists? -get-in -update-in -assoc-in -dissoc
-                                        PJSONAsyncKeyValueStore -jget-in -jassoc-in -jupdate-in
-                                        PBinaryAsyncKeyValueStore -bget -bassoc
-                                        -serialize -deserialize]]
-            [cljs.core.async :as async :refer (take! <! >! put! take! close! chan poll!)])
+  (:require
+   [cljs.nodejs :as node]
+   [konserve.core :as k]
+   [hasch.core :refer [uuid]]
+   [incognito.edn :refer [read-string-safe]]
+   [konserve.serializers :as ser]
+   [fress.api :as fress]
+   [konserve.protocols :refer [PEDNAsyncKeyValueStore -exists? -get-in -update-in -assoc-in -dissoc
+                               PJSONAsyncKeyValueStore -jget-in -jassoc-in -jupdate-in
+                               PBinaryAsyncKeyValueStore -bget -bassoc
+                               -serialize -deserialize]]
+   [incognito.transit :refer [incognito-read-handler
+                              incognito-write-handler]]
+   [cognitect.transit :as transit]
+   [cljs.core.async :as async :refer (take! <! >! put! take! close! chan poll!)]
+   [cljs.tools.reader.impl.inspect :as i])
   (:require-macros [cljs.core.async.macros :refer [go go-loop]]))

 ;; TODO serializer
@@ -51,14 +57,15 @@
       (catch js/Object err
         (println err)))))

-(defn write-edn-key [folder {:keys [key] :as meta}]
+(defn write-edn-key [serializer write-handlers folder {:keys [key] :as meta}]
   (let [key       (uuid (first key))
         temp-file (str folder "/meta/" key ".new")
         new-file  (str folder "/meta/" key)
         fd        (.openSync fs new-file "w+")
         _         (.closeSync fs fd)
         ws        (.createWriteStream fs temp-file)
-        res-ch    (chan)]
+        res-ch    (chan)
+        buf       (fress/byte-stream)]
     (.on ws "close" #(try (.renameSync fs temp-file new-file)
                           (catch js/Object err
                             (put! res-ch (ex-info "Could not write edn key."
@@ -74,11 +81,13 @@
                                   :key       key
                                   :exception err}))
            (close! res-ch)))
-    (.write ws (js/Uint8Array. (fress/write meta)))
+    (-serialize serializer buf write-handlers (update meta :key first))
+    (.write ws (js/Uint8Array. (js->clj (.from js/Array @buf))))
     (.end ws)
     res-ch))

-(defn write-edn [folder key up-fn]
+
+(defn write-edn [serializer write-handlers read-handlers folder key up-fn]
   (let [key       (uuid (first key))
         temp-file (str folder "/data/" key ".new")
         new-file  (str folder "/data/" key)
@@ -91,8 +100,9 @@
                                                                        (. chunk -buffer)
                                                                        (js/Buffer.concat #js [old (. chunk -buffer)]))))))
         (.on rs "close" #(let [ws    (.createWriteStream fs temp-file)
-                               value (up-fn data-buffer)
-                               old   (fress/read (:buffer @data-buffer))]
+                               old   (-deserialize serializer read-handlers (:buffer @data-buffer))
+                               value (up-fn old)
+                               buf   (fress/byte-stream)]
                            (.on ws "finish" (fn [_]
                                               (.renameSync fs temp-file new-file)
                                               (put! res-ch [old value])
@@ -104,7 +114,8 @@
                                                          :key       key
                                                          :exception err}))
                                   (close! res-ch)))
-                           (.write ws (js/Uint8Array. (fress/write value)))
+                           (-serialize serializer buf write-handlers value)
+                           (.write ws (js/Uint8Array. (js->clj (.from js/Array @buf))))
                            (.close ws)))
         (.on rs "error" (fn [err]
                           (put! res-ch (ex-info "Could not write edn."
@@ -115,6 +126,7 @@
       (let [fd    (.openSync fs new-file "w+")
             _     (.closeSync fs fd)
             ws    (.createWriteStream fs temp-file)
+            buf   (fress/byte-stream)
             value (up-fn nil)]
         (.on ws "close" #(try
                            (.renameSync fs temp-file new-file)
@@ -126,7 +138,8 @@
                                                     :key       key
                                                     :exception err}))
                              (close! res-ch))))
-        (.write ws (js/Uint8Array. (fress/write value)))
+        (-serialize serializer buf write-handlers value)
+        (.write ws (js/Uint8Array. (js->clj (.from js/Array @buf))))
         (.end ws)))
     res-ch))

@@ -169,7 +182,7 @@
         (close! res-ch)))
     res-ch))

-(defn read-edn [path key]
+(defn read-edn [serializer read-handlers path key]
   (let [file-name (str path "/data/" (uuid key))
         res-ch    (chan)]
     (if (.existsSync fs file-name)
@@ -179,7 +192,7 @@
                          (swap! data-buffer update :buffer (fn [old] (if (nil? old)
                                                                        (. chunk -buffer)
                                                                        (js/Buffer.concat #js [old (. chunk -buffer)]))))))
-        (.on rs "close" #(let [data (fress/read (:buffer @data-buffer))]
+        (.on rs "close" #(let [data (-deserialize serializer read-handlers (:buffer @data-buffer))]
                           (put! res-ch data)
                           (close! res-ch)))
         (.on rs "error" (fn [err]
@@ -191,7 +204,7 @@
       (close! res-ch))
     res-ch))

-(defn read-edn-key [path key]
+(defn read-edn-key [serializer read-handlers path key]
   (let [file-name (str path "/meta/" key)
         res-ch    (chan)]
     (if (.existsSync fs file-name)
@@ -201,7 +214,7 @@
                          (swap! data-buffer update :buffer (fn [old] (if (nil? old)
                                                                        (. chunk -buffer)
                                                                        (js/Buffer.concat #js [old (. chunk -buffer)]))))))
-        (.on rs "close" #(let [data  (fress/read (:buffer @data-buffer))]
+        (.on rs "close" #(let [data    (-deserialize serializer read-handlers (:buffer @data-buffer))]
                           (put! res-ch data)
                           (close! res-ch)))
         (.on rs "error" (fn [err]
@@ -236,12 +249,12 @@
       (close! res))
     res))

-(defn list-keys [{:keys [folder]}]
+(defn list-keys [{:keys [folder serializer]} read-handlers]
   (let [filenames
         (for [filename (filter #(re-matches #"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" %) (js->clj (.readdirSync fs (str folder "/meta"))))]
           filename)]
     (->> filenames
-         (map #(read-edn-key folder %))
+         (map #(read-edn-key serializer read-handlers folder %))
          async/merge
          (async/into #{}))))

@@ -273,10 +286,10 @@
       (close! res)
       res))
   (-get-in [this key-vec]
-    (read-edn folder (first key-vec)))
+    (read-edn serializer read-handlers folder (first key-vec)))
   (-update-in [this key-vec up-fn]
-    (go (<! (write-edn-key folder {:key key-vec :format :edn}))
-        (<! (write-edn folder key-vec up-fn))))
+    (go (<! (write-edn-key serializer write-handlers folder {:key key-vec :format :edn}))
+        (<! (write-edn serializer write-handlers read-handlers folder key-vec up-fn))))
   (-assoc-in [this key-vec val] (-update-in this key-vec (fn [_] val)))
   (-dissoc [this key] (let [fn (uuid key)
                             res-ch (chan)]
@@ -284,20 +297,20 @@
                         res-ch))
   PBinaryAsyncKeyValueStore
   (-bget [this key locked-cb] (read-binary folder key locked-cb))
-  (-bassoc [this key input] (do (write-edn-key folder {:key [key] :format :binary})
+  (-bassoc [this key input] (do (write-edn-key serializer write-handlers folder {:key [key] :format :binary})
                                 (write-binary folder key input))))

 (defn new-fs-store
   "Filestore contains a Key and a Data Folder"
-  [path & {:keys  [read-handlers write-handlers serializer config]
-           :or    {read-handlers  (atom {})
-                   write-handlers (atom {})
-                   serializer     (ser/string-serializer)
-                   config {:fsync true}}}]
+  [path & {:keys [read-handlers write-handlers serializer config]
+           :or   {read-handlers  (atom {})
+                  write-handlers (atom {})
+                  serializer     (ser/fressian-serializer)
+                  config         {:fsync true}}}]
   (println "creating store")
-  (let [_         (check-and-create-folder path)
-        _         (check-and-create-folder (str path "/meta"))
-        _         (check-and-create-folder (str path "/data"))]
+  (let [_ (check-and-create-folder path)
+        _ (check-and-create-folder (str path "/meta"))
+        _ (check-and-create-folder (str path "/data"))]
     (println "creating system")
     (go (map->FileSystemNodejsStore {:folder         path
                                      :serializer     serializer
@@ -308,37 +321,32 @@

 (comment

-  (go (println (<! (write-edn "/tmp/mystore" [:new]  (fn [_] 123)))))
-
   (go (def store (<! (new-fs-store "/tmp/mystore"))))

   (delete-store "/tmp/mystore")

   ;;EDN read/write functionality
-  (go (println (<! (-assoc-in store [:new] {:x 123 :y 345}))
+  (go (println (<! (-assoc-in store [:new] 1))
                (<! (-get-in store [:new]))
-               (<! (list-keys store))))
-
-  (go (println (<! (list-keys store))))
-
-  (go (println (<! (-assoc-in store [:new] {:x 123 :y 345}))))
-
-  (go (println (<! (-get-in store [:new1]))))
-
-  (go (println (<! (-exists? store :new))))
-
-  (go (println (<! (-update-in store [:new] (fn [old] (-> old
-                                                          (assoc :new "123")))))))
-
-  (go (println (<! (list-keys store))))
-
-  (go (def x (<! (-get-in store [:new]))))
-  (go (println (<! (-dissoc store :new))))
+               (<! (list-keys store {}))))
+
+  (go (println (<! (list-keys store {}))))
+
+  (go (println (<! (-assoc-in store [:new1] 2))))
+
+
+
+
+  (go (println (<! (-update-in store [:new1] inc))))
+
   (doseq [i (range 1 10)]
     (go (<! (-assoc-in store [i] (+ i i)))))
+
+
+
   ;;Binary read/write functionality
   ;; write / read buffer
-  (go (println (<! (-bassoc store :binary (js/Buffer.from #js [1 2 3 4])))))
+  (go (println (<! (-bassoc store :bin (js/Buffer.from #js [1 2 3 4])))))

   (go (println (<! (-bget store :bin1ary #(go (.pipe (:read-stream %) (.createWriteStream fs "hello")))))))

@@ -355,9 +363,6 @@
                                             (.on rs "error" (fn [err] (prn err)))
                                             mychan)))))

-  (js/Uint8Array. @mybuffer)
-
-  (js/Buffer.from #js [(js/Buffer.from #js [1 2 3 4])])

   )


fix typos in cljs design post

fix typos in cljs design post

--- src/pc/views/blog/clojure_is_a_product_design_tool.clj
+++ src/pc/views/blog/clojure_is_a_product_design_tool.clj
@@ -53,7 +53,7 @@
      [:p [:a {:href "http://clojure.org/"} "Clojure"]
          " carries a stark notoriety among developers, despite being a tremendous feat of design. "
          [:a {:href "http://blog.venanti.us/why-clojure/"} "David Jarvis"]
-         ", a former teammate of mine, faced off that reputation during an interview early last year."]]
+         ", a former teammate of mine, encountered that reputation during an interview last year."]]

     [:article
      [:blockquote
@@ -170,7 +170,7 @@
          And therein lies the point; Clojure makes me more efficient and extends my reach as a designer."]
      [:p "Don’t let fear prevent growth.
          You don’t have to learn Clojure—even though it’d be nice knowing I'm not alone—you just need to learn something.
-         There's something you can learn right now that will make you a build better products.
+         There's something you can learn right now that will help you a build better products.
          Find it and make something."]]

     [:article.blogpost-footnote


fixes

fixes

--- src/webdriver/dsl.clj
+++ src/webdriver/dsl.clj
@@ -7,8 +7,11 @@
             [slingshot.slingshot :refer [try+ throw+]]
             [clojure.test :refer [is deftest]]))

-;; todo bound checks?
-
+;;
+;; todos
+;;
+;; todo variable bound checks?
+;; todo: on exception return source code and screenshot
 ;; (inject-script "http://ya.ru/test.js")

 (def ^:dynamic *session*)
@@ -193,7 +196,7 @@

 (deftest simple-test
   (let [host "127.0.0.1"
-        port 4444
+        port 8910 ;; 4444
         capabilities {}
         input "//input[@id=\"text\"]"]
     (with-session host port capabilities
@@ -204,5 +207,5 @@
         (with-element input
           (fill-human "Clojure")
           (enter)))
-      (wait 5)
+      (wait 2)
       (is 1))))


don't produce errors if the input is empty or only contains whitespaces

--- src/evalback/core.clj
+++ src/evalback/core.clj
@@ -172,7 +172,7 @@
   (GET "/" [] (resp/redirect "index.html"))
   (GET "/js/examples.js" [] (provide-examples))
   (ANY "/version" [] (str (.getVersion (get-api))))
-  (POST "/xxx" [formalism input] old-json-answer)
+  (POST "/xxx" [formalism input] (if (empty? (.trim  input)) (json/write-str {:output  ""}) old-json-answer))
   (resources "/")
   (not-found "Not Found"))


Only wait for mutations on pjax pages

Only wait for mutations on pjax pages

Not all GitHub pages use pjax; for instance, the PR search page
<https://github.com/pulls?q=is%3Aopen+assignee%3Asmcgivern>

The MutationObserver is only needed on pjax pages, so only create it on
those pages. (On regular page transitions, `watch` will get called by
`background.js`, so the extension will still work fine.)

--- src/gitique/core.cljs
+++ src/gitique/core.cljs
@@ -246,7 +246,8 @@
   "Run `main` once, then watch for DOM mutations in the PJAX container and run `main` when
   it changes"
   []
-  (let [is-valid-mutation? #(and (= (.-type %) "childList") (not-empty (.-addedNodes %)))
-        observer (js/MutationObserver. #(when (some is-valid-mutation? %) (main)))]
-    (.observe observer pjax-wrapper #js{:childList true :attributes false :characterData false})
-    (main)))
+  (when pjax-wrapper
+    (let [is-valid-mutation? #(and (= (.-type %) "childList") (not-empty (.-addedNodes %)))
+          observer (js/MutationObserver. #(when (some is-valid-mutation? %) (main)))]
+      (.observe observer pjax-wrapper #js{:childList true :attributes false :characterData false})))
+  (main))


Default workspace name derived from Swagger title and version

--- src/ardoq/swagger/api.clj
+++ src/ardoq/swagger/api.clj
@@ -50,13 +50,19 @@
   ;;if spec is not null then use that as spec
   (let [spec (resolve-spec spec-text url headers)
         spec-title (get-in spec [:info :title])
+        spec-info-version (get-in spec [:info :version])
         spec-version (cond
                        (:openapi spec) :openapi-3.x
                        (= (:swagger spec) "2.0") :swagger-2.x
                        :else :swagger-1.x)
-        wsname (cond (not (str/blank? wsname)) wsname
-                     (not (str/blank? spec-title)) spec-title
-                     :default (str (name spec-version) " - import - " (.format (java.text.SimpleDateFormat. "yyyy.MM.dd HH:mm") (new java.util.Date))))]
+        wsname (cond (not (str/blank? wsname))
+                        wsname
+                     (and (not (str/blank? spec-title)) (not (str/blank? spec-info-version)))
+                        (str spec-title " - " spec-info-version)
+                     (not (str/blank? spec-title))
+                        spec-title
+                     :default
+                        (str (name spec-version) " - import - " (.format (java.text.SimpleDateFormat. "yyyy.MM.dd HH:mm") (new java.util.Date))))]
     (sync-swagger/sync-swagger client spec wsname spec-version overview)))

 (defn send-success-email! [wid org session client]


use of config top-bar instead of details if method loading fails

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/method_configs/method_config_editor.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/method_configs/method_config_editor.cljs
@@ -11,7 +11,6 @@
     [org.broadinstitute.firecloud-ui.page.workspace.method-configs.delete-config :as delete]
     [org.broadinstitute.firecloud-ui.page.workspace.method-configs.launch-analysis :as launch]
     [org.broadinstitute.firecloud-ui.page.workspace.method-configs.publish :as publish]
-    [org.broadinstitute.firecloud-ui.page.workspace.launch-analysis :as launch]
     [org.broadinstitute.firecloud-ui.utils :as utils]
     ))

@@ -63,17 +62,33 @@
                                         (when-not success?
                                           (js/alert (str "Exception:\n" (.-statusText xhr)))))})))))})))

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

 (defn- render-side-bar [state refs config editing? props]


Added some tests

Added some tests

--- test/structural_typing/use/condensed_type_descriptions/f_requires_mentioned_paths.clj
+++ test/structural_typing/use/condensed_type_descriptions/f_requires_mentioned_paths.clj
@@ -33,7 +33,33 @@
   (built-like :X {:points [{:x 1 :y 1}]}) => {:points [{:x 1 :y 1}]}
   (check-for-explanations :X {:points [{:x 1}]}) => (just (err:required [:points 0 :y]))

-  (future-fact "use with an `implies` that uses `includes`"))
+  (fact "use with an `implies` that uses `includes`: the `includes` works"
+    (type! :Point {:x integer? :y integer?})
+
+    (fact "(but *contents* of implies are not part of a path)"
+      (type! :Include (requires-mentioned-paths (pred/implies :c (includes :Point))))
+
+      (built-like :Include {}) => {}
+      (built-like :Include {:x :ok-not-to-be-int}) => {:x :ok-not-to-be-int}
+      (check-for-explanations :Include {:c 1 :x :ok-not-to-be-int})
+      => (just (err:shouldbe :x "integer?" :ok-not-to-be-int)))
+
+
+    (fact "deeper nesting"
+      (type! :X (requires-mentioned-paths {:l3 integer?}
+                                          (pred/implies :l4 (includes :Include))))
+      (built-like :X {:l3 3}) => {:l3 3}
+      (check-for-explanations :X {}) => (just (err:required :l3))
+
+      ;; The rest illustrate that deep nesting of included types is unaffected by `requires-mentioned-paths
+      (built-like :X {:l3 3, :l4 true}) => {:l3 3, :l4 true}
+      (built-like :X {:l3 3, :l4 true, :c true}) => {:l3 3, :l4 true, :c true}
+      (built-like :X {:l3 3, :l4 true, :c true, :x 1, :y 2}) => {:l3 3, :l4 true, :c true, :x 1, :y 2}
+
+      (check-for-explanations :X {:l3 3, :l4 true, :c true, :x :notint, :y :notint})
+      => (just (err:shouldbe :x "integer?" :notint)
+               (err:shouldbe :y "integer?" :notint)) )))
+

 (fact "typical use is to force paths in a previous type to be required"
   (type! :P {:x integer? :y {:z string?}})


Very ugly html page

Very ugly html page

--- src-cljs/tranjlator/core.cljs
+++ src-cljs/tranjlator/core.cljs
@@ -1,3 +1,50 @@
-(ns tranjlator.core)
+(ns tranjlator.core
+  (:require [om.core :as om :include-macros true]
+            [om.dom :as dom :include-macros true]
+            [chord.client :refer [ws-ch]]
+            [cljs.core.async :as a]
+            [sablono.core :as html :refer-macros [html]])
+  (:require-macros [cljs.core.async.macros :refer [go]]))

-(.log js/console "hello there")
+(enable-console-print!)
+
+(def +ws-url+ "ws://....")
+
+(def sample-source {:topic "Original" :language "English" :content "Hi" :original-sha "XYZ"
+                    :content-sha "XYZ" :user-name "bob"})
+
+(def sample-translation {:topic "German" :language "German" :content "Guten Tag"
+                         :original-sha "XYZ" :content-sha "ABC" :user-name "bob"})
+
+(def app-state (atom {:original [sample-source]
+                      :translated [sample-translation]}))
+
+(defn chat-view [app owner]
+  (reify
+    om/IRender
+    (render [this]
+      (apply dom/ul nil
+             (map (fn [item] (dom/li nil (:content item))) app)))))
+
+(defn master-view [app owner]
+  (reify
+    om/IRender
+    (render [this]
+      (dom/div #js {:className "container"}
+               (dom/h3 nil "Enter Chat stuff")
+               (dom/form #js {:className "form-horizontal"}
+                         (dom/div nil
+                                  (dom/div nil
+                                           (om/build chat-view (:original app)))
+                                  (dom/div nil
+                                           (om/build chat-view (:translated app))))
+                         (dom/div #js {:className "form-group"}
+                                  (dom/input #js {:className "form-control" :type "text"}))
+                         (dom/div #js {:className "col-xs-offset-2 col-xs-10"}
+                                  (dom/button #js {:type "button" :className "button"}
+                                              "click me")))))))
+
+(om/root
+ master-view
+ app-state
+ {:target (. js/document (getElementById "app"))})


OO: Add saved charts view to initial state Fixes permalinking problem

--- src/hatti/shared.cljs
+++ src/hatti/shared.cljs
@@ -35,7 +35,7 @@
   "An initial, empty, app-state, which can be modified to change dataviews."
   []
   (atom
-   {:views {:all [:overview :map :table :chart :settings]
+   {:views {:all [:overview :map :table :chart :saved-charts :settings]
             :selected :overview}
     :map-page {:submission-clicked {:data nil}
                :geofield {}}


Reformat a few lines in file store.

Reformat a few lines in file store.

--- src/blocks/store/file.clj
+++ src/blocks/store/file.clj
@@ -122,7 +122,9 @@
   "Creates a lazy block to read from the given file."
   [id ^File file]
   (block/with-stats
-    (data/lazy-block id (.length file) #(io/input-stream file))
+    (data/lazy-block
+      id (.length file)
+      (fn file-reader [] (io/input-stream file)))
     (file-stats file)))


Remove unnecessary brackets

Remove unnecessary brackets

--- src/braid/server/sync.clj
+++ src/braid/server/sync.clj
@@ -376,7 +376,7 @@
   (if-let [invite (invitation/invite-by-id (?data :id))]
     (do
       (events/user-join-group! user-id (invite :group-id))
-      (db/run-txns! [(invitation/retract-invitation-txn (invite :id))])
+      (db/run-txns! (invitation/retract-invitation-txn (invite :id)))
       (chsk-send! user-id [:braid.client/joined-group
                            {:group (group/group-by-id (invite :group-id))
                             :tags (group/group-tags (invite :group-id))}])


fixed going forwards - needs to be at beginning of rendering :facepunch:

--- pedestal-app/app/src/semtag_web/rendering.cljs
+++ pedestal-app/app/src/semtag_web/rendering.cljs
@@ -62,7 +62,6 @@
                         :caption (format "Total: %s" (count (map :url things)))))))

 (defn render-types-results [_ [_ _ _ new-value] _]
-  (history/navigated input-queue :types)
   (dom/set-html!
     (dom/by-id "content")
     (p/generate-table "type_stats_table" (:results new-value)
@@ -100,6 +99,7 @@
   (msg/fill transform messages {:value (dom/value (dom/by-id "add_url_text"))}))

 (defn render-types-page [_ _ input-queue]
+  (history/navigated input-queue :types)
   (prot/put-message input-queue {msg/type :set-value msg/topic [:page] :value "types"}))

 (defn render-config []


Indentation

Indentation

--- worker/src/patavi/worker/pirate/util.clj
+++ worker/src/patavi/worker/pirate/util.clj
@@ -130,10 +130,10 @@
   [data-seq]
   (if (and (counted? data-seq) (every? (or associative? sequential?) data-seq))
     (REXPGenericVector.
-     (if (map? data-seq)
-       (RList. (map into-r (vals data-seq))
-               (into-array String (map #(if (keyword? %) (name %) (str %)) (keys data-seq))))
-       (RList. (map into-r data-seq))))
+      (if (map? data-seq)
+        (RList. (map into-r (vals data-seq))
+                (into-array String (map #(if (keyword? %) (name %) (str %)) (keys data-seq))))
+        (RList. (map into-r data-seq))))
     (convert-to data-seq)))

 (defn assign
@@ -155,11 +155,11 @@
   ([] (connect #()))
   ([callback] (connect "localhost" 6311 callback))
   ([host port callback]
-  (let [wrapped-callback (proxy [org.rosuda.REngine.Rserve.RConnection$OutOfBandCallback] []
-                           (update [msg] (callback (into-clj msg))))
-        ^RConnection conn (try
-               (RConnection. host (Integer. port))
-               (catch Exception e (throw (Exception. "Could not connect to RServe" e))))]
-    (when (.isConnected conn)
-      (.addOutOfBandCallback conn wrapped-callback)
-      conn))))
+   (let [wrapped-callback (proxy [org.rosuda.REngine.Rserve.RConnection$OutOfBandCallback] []
+                            (update [msg] (callback (into-clj msg))))
+         ^RConnection conn (try
+                             (RConnection. host (Integer. port))
+                             (catch Exception e (throw (Exception. "Could not connect to RServe" e))))]
+     (when (.isConnected conn)
+       (.addOutOfBandCallback conn wrapped-callback)
+       conn))))


Remove the button for Hörbuch printed ncc

--- src/catalog/web/views.clj
+++ src/catalog/web/views.clj
@@ -51,8 +51,7 @@
         [:div.well
          [:h2 (translations :catalog-hörbuch)]
          (icon-button (format "/%s/%s/neu-als-hörbuch.pdf" year issue) "download" "Download")
-         (icon-button (format "/%s/%s/neu-als-hörbuch.ncc" year issue) "download" "NCC")
-         (icon-button (format "/%s/%s/neu-als-hörbuch-toc.pdf" year issue) "download" "TOC")]]]))))
+         (icon-button (format "/%s/%s/neu-als-hörbuch.ncc" year issue) "download" "NCC")]]]))))

 (defn- file-name [k year issue]
   (let [name (-> (k translations)


Remove maybe monad transformer.

Remove maybe monad transformer.

--- src/cats/monad/maybe.cljc
+++ src/cats/monad/maybe.cljc
@@ -238,62 +238,7 @@

 (util/make-printable (type context))

-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Monad Transformer
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defn maybe-t
-  "The maybe transformer constructor."
-  [inner]
-  (reify
-    p/Context
-    (-get-level [_] ctx/+level-transformer+)
-
-    p/Functor
-    (-fmap [_ f fv]
-      (p/-fmap inner
-               #(p/-fmap context f %)
-               fv))
-
-    p/Monad
-    (-mreturn [m v]
-      (p/-mreturn inner (just v)))
-
-    (-mbind [_ mv f]
-      (p/-mbind inner
-                mv
-                (fn [maybe-v]
-                  (if (just? maybe-v)
-                    (f (p/-extract maybe-v))
-                    (p/-mreturn inner (nothing))))))
-
-    p/MonadZero
-    (-mzero [_]
-      (p/-mreturn inner (nothing)))
-
-    p/MonadPlus
-    (-mplus [_ mv mv']
-      (p/-mbind inner
-                mv
-                (fn [maybe-v]
-                  (if (just? maybe-v)
-                    (p/-mreturn inner maybe-v)
-                    mv'))))
-
-    p/MonadTrans
-    (-lift [_ mv]
-      (p/-mbind inner
-                mv
-                (fn [v]
-                  (p/-mreturn inner (just v)))))
-
-    p/Printable
-    (-repr [_]
-      "#<Maybe-T>")))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Utility functions
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; --- Utility functions

 (defn maybe
   "Given a default value, a maybe and a function, return the default


* src/clj/cljs/analyzer.clj: comment about role of *reader-ns-name* and *reader-ns*

--- src/clj/cljs/analyzer.clj
+++ src/clj/cljs/analyzer.clj
@@ -22,6 +22,9 @@
 (declare confirm-bindings)
 (declare ^:dynamic *cljs-file*)

+;; to resolve keywords like ::foo - the namespace
+;; must be determined during analysis - the reader
+;; did not know
 (def ^:dynamic *reader-ns-name* (gensym))
 (def ^:dynamic *reader-ns* (create-ns *reader-ns-name*))


create fiddle table when necessary

create fiddle table when necessary

--- src/clj/cljsfiddle/db.clj
+++ src/clj/cljsfiddle/db.clj
@@ -3,14 +3,21 @@
   (:require [clojure.java.jdbc :as sql]
             [environ.core :refer (env)]))

+(defn table-exists? [tablename]
+  (not (empty? (sql/with-connection (env :database-url)
+                 (sql/with-query-results results
+                   ["SELECT * FROM pg_tables WHERE tablename=?" tablename]
+                   (into [] results))))))
+
 (defn create []
-  (sql/with-connection (env :database-url)
-    (sql/create-table :fiddles
-      [:ns :varchar "PRIMARY KEY"]
-      [:cljs :text "NOT NULL"]
-      [:html :text]
-      [:css :text]
-      [:created :timestamp "NOT NULL" "DEFAULT CURRENT_TIMESTAMP"])))
+  (when-not (table-exists? "fiddles")
+    (sql/with-connection (env :database-url)
+      (sql/create-table :fiddles
+                        [:ns :varchar "PRIMARY KEY"]
+                        [:cljs :text "NOT NULL"]
+                        [:html :text]
+                        [:css :text]
+                        [:created :timestamp "NOT NULL" "DEFAULT CURRENT_TIMESTAMP"]))))

 (defn drop []
   (sql/with-connection (env :database-url)
@@ -27,5 +34,3 @@
      (sql/with-query-results results
        ["SELECT * FROM fiddles WHERE ns = ?" ns]
        (into [] results)))))
-
-(find-by-ns "jonase.bezier")


add withQueryLocation => :query-location option in bq/read-bq-raw (#130)

--- src/clj/datasplash/bq.clj
+++ src/clj/datasplash/bq.clj
@@ -21,10 +21,12 @@
    (org.apache.beam.sdk.values PBegin PCollection)))

 (defn read-bq-raw
-  [{:keys [query table standard-sql?] :as options} p]
+  [{:keys [query table standard-sql? query-location] :as options} p]
   (let [opts (assoc options :label :read-bq-table-raw)
         ptrans (cond
-                 query (.fromQuery (BigQueryIO/readTableRows) query)
+                 query (cond-> (.fromQuery (BigQueryIO/readTableRows) query)
+                               standard-sql? (.usingStandardSql)
+                               query-location (.withQueryLocation query-location))
                  table (.from (BigQueryIO/readTableRows) table)
                  :else (throw (ex-info
                                "Error with options of read-bq-table, should specify one of :table or :query"
@@ -32,9 +34,7 @@
     (-> p
         (cond-> (instance? Pipeline p) (PBegin/in))
         (ds/apply-transform
-         (if (and standard-sql? query)
-           (.usingStandardSql ptrans)
-           ptrans)
+         ptrans
          ds/named-schema opts))))

 (defn auto-parse-val


Fix validation on profile

Fix validation on profile

--- src/clj_crud/accounts.clj
+++ src/clj_crud/accounts.clj
@@ -294,9 +294,9 @@
                                  :name (:name params)}]
              (when-not (seq errors)
                (accounts/update-account (h/db ctx) account-update))
-             {:user (merge account-update
-                           (when (seq errors)
-                             {:errors errors}))}))
+             {:account (merge account-update
+                              (when (seq errors)
+                                {:errors errors}))}))
   :post-redirect? (fn [ctx]
                     (not (get-in ctx [:account :errors])))
   :handle-see-other (fn [ctx]


cleanup

cleanup

--- src/cljs/chat42/core.cljs
+++ src/cljs/chat42/core.cljs
@@ -36,7 +36,7 @@
 (defn create-msg [name text]
   {:text text :name name :date (js/Date.)})

-(def val-atom (atom {:messages [(create-msg "Greetings" "Chat42")]}))
+(def val-atom (atom {:messages [(create-msg "Replikativ.io" "Welcome!")]}))

 (defn start-local []
@@ -69,7 +69,7 @@
   Object
   (componentDidMount [this]
                      (.log js/console "will mount")
-                     (om/set-state! this {:input-name "Chat42" :input-text "Hi"}))
+                     (om/set-state! this {:input-name "" :input-text ""}))
   (render [this]
     (let [app-state (om/props this)
           {:keys [input-name input-text]} (om/get-state this)]
@@ -77,13 +77,18 @@
        [:div
         [:div
          [:input {:value input-name
-                            :on-change
-                            (fn [e]
-                              (om/update-state! this assoc :input-name (target-val e)))}]
+                  :placeholder "Name"
+                  :on-change
+                  (fn [e]
+                    (om/update-state! this assoc :input-name (target-val e)))}]
          [:input {:value input-text
-                          :on-change (fn [e]
-                                       (om/update-state! this assoc :input-text (target-val e)))}]
-         [:button {:on-click (fn [_] (send-message! app-state (create-msg input-name input-text)))} "Send"]]
+                  :placeholder "Message"
+                  :on-change (fn [e]
+                               (om/update-state! this assoc :input-text (target-val e)))}]
+         [:button {:on-click (fn [_]
+                               (do
+                                 (send-message! app-state (create-msg input-name input-text))
+                                 (om/update-state! this assoc :input-text "")))} "Send"]]
         (map (fn [{:keys [text name date]}]
                [:p (str date ": " name " -> " text)])
              (:messages app-state))]))))


fix `cljs.nodejs/enable-util-print!`, incorrectly monkey patched `cjls.core/string-print` instead of setting `cljs.core/*print-fn*`

--- src/cljs/cljs/nodejs.cljs
+++ src/cljs/cljs/nodejs.cljs
@@ -17,4 +17,4 @@

 ; Have ClojureScript print using Node's sys.print function
 (defn enable-util-print! []
-  (set! cljs.core/string-print (.-print (require "util"))))
+  (set! *print-fn* (.-print (require "util"))))


remove debug statements

remove debug statements

--- src/cljs/re_dnd/subs.cljs
+++ src/cljs/re_dnd/subs.cljs
@@ -145,7 +145,6 @@
     (re-frame/subscribe [:dnd/draggable-overlaps? id])
     (re-frame/subscribe [:dnd/dropped-elements id])])
  (fn [[dragged-element options overlap-id overlap-dropzone? dropzone-elements]]
-   (debug dragged-element)
    (if (and (or overlap-dropzone? overlap-id) dragged-element)
      ;;we have overlap, and there is dragging going on, insert the separator in there.
      (let [dm          (:drop-marker options)
@@ -161,7 +160,6 @@
                          js/document
                          (str "dropped-element-" (name overlap-id))))
            sz          (count parts)]
-       (debug dragged-element  overlap-id dragbox overlap-elt)
        (flatten
         (case sz
           0 [sep]
@@ -174,8 +172,7 @@
               [(first parts) (last parts) sep])
           3 [(first parts) (second parts) sep (last parts)])))
      ;;else no dragging going on, return the elements
-     (do (debug dropzone-elements)
-         dropzone-elements))))
+     dropzone-elements)))

 (re-frame/reg-sub
  :dnd/get-colliding-drop-zone-and-index
@@ -185,7 +182,6 @@
  :<- [:dnd/drop-zones]
  :<- [:dnd/dragged-element]
  (fn [[mouse drop-zones dragged-element]]
-   (debug mouse (count drop-zones) dragged-element)
    (into {}
          (comp
           (map


Holy balls it works.

Holy balls it works.

--- src/clojurecraft/core.clj
+++ src/clojurecraft/core.clj
@@ -6,13 +6,11 @@

 ; Packet Type Maps -----------------------------------------------------------------
 (def packet-ids {
+     :keepalive 0x00
      :login 0x01
      :handshake 0x02
 })
-(def packet-types {
-     0x01 :login
-     0x02 :handshake
-})
+(def packet-types (apply assoc {} (mapcat reverse packet-ids)))

 (declare conn-handler)

@@ -56,11 +54,6 @@
       (doto (:out @conn)
          (.writeChars s)))

-(defn writ-chars [conn s]
-      (println (str "-> CHARS: " s))
-      (doto (:out @conn)
-         (.writeChars s)))
-

 ; Writing Packets ------------------------------------------------------------------
 (defn write-packet-handshake [conn {username :username}]
@@ -68,7 +61,7 @@

       (writ-string16 conn username))

-(defn write-packet-login [conn {version :version username :username}]
+(defn write-packet-login [conn {version :version, username :username}]
       (writ-byte conn (:login packet-ids))

       (writ-int conn version)
@@ -83,6 +76,7 @@

 (defn write-packet [conn packet-type payload]
       (cond
+        (= packet-type :keepalive) nil
         (= packet-type :handshake) (write-packet-handshake conn payload)
         (= packet-type :login) (write-packet-login conn payload)
         )
@@ -109,6 +103,10 @@

 ; Handling Packets -----------------------------------------------------------------
+(defn handle-packet-keepalive [conn]
+      (println "OMG got a keepalive")
+      nil)
+
 (defn handle-packet-handshake [conn]
       (println "OMG got a handshake")
       (-> {}
@@ -123,12 +121,14 @@
           (assoc :dimension (red-byte conn))))

 (defn handle-packet [conn packet-id]
-      (let [packet-id (int packet-id)]
+      (let [packet-id (int packet-id)
+            packet-type (packet-types packet-id)]
         (println "\n----->")
         (println
           (cond
-            (= (packet-types packet-id) :handshake) (handle-packet-handshake conn)
-            (= (packet-types packet-id) :login) (handle-packet-login conn)
+            (= packet-type :keepalive) (handle-packet-keepalive conn)
+            (= packet-type :handshake) (handle-packet-handshake conn)
+            (= packet-type :login) (handle-packet-login conn)
             :else (str "UNKNOWN PACKET TYPE: " packet-id)
             ))
         (println "\n\n\n")))
@@ -166,5 +166,5 @@

 ; REPL -----------------------------------------------------------------------------
 (def server (connect minecraft-local))
-(disconnect server)
+;(disconnect server)


Moar.

Moar.


Don't log incoming events by default - also improve event log messages.

--- src/overtone/libs/event.clj
+++ src/overtone/libs/event.clj
@@ -12,6 +12,7 @@
 (defonce ^:private monitoring?* (atom false))
 (defonce ^:private monitor* (atom {}))
 (defonce ^:private lossy-workers* (atom {}))
+(defonce ^:private log-events? (atom false))

 (defn- log-event
   "Log event on separate thread to ensure logging doesn't interfere with
@@ -81,7 +82,7 @@
   Handlers can return :overtone/remove-handler to be removed from the
   handler list after execution."
   [event-type handler key]
-  (log-event "Registering async event handler:: " event-type key)
+  (log-event "Registering async event handler:: " event-type " with key: " key)
   (handlers/add-handler! handler-pool event-type key handler ))

 (defn on-sync-event
@@ -105,7 +106,7 @@
   Handlers can return :overtone/remove-handler to be removed from the
   handler list after execution."
   [event-type handler key]
-  (log-event "Registering sync event handler:: " event-type key)
+  (log-event "Registering sync event handler:: " event-type " with key: " key)
   (handlers/add-sync-handler! handler-pool event-type key handler))

 (defn on-latest-event
@@ -121,7 +122,7 @@
   potentially long-running handler fns where handling the most recent
   event is all that matters."
   [event-type handler key]
-  (log-event "Registering lossy event handler:: " event-type key)
+  (log-event "Registering lossy event handler:: " event-type " with key:" key)
   (let [worker (lossy-worker (fn [val]
                                (handler val)))
         [old _] (swap-returning-prev! lossy-workers* assoc key worker)]
@@ -135,13 +136,13 @@
 (defn oneshot-event
   ""
   [event-type handler key]
-  (log-event "Registering async self-removing event handler:: " event-type key)
+  (log-event "Registering async self-removing event handler:: " event-type " with key: " key)
   (handlers/add-one-shot-handler! handler-pool event-type key handler))

 (defn oneshot-sync-event
   ""
   [event-type handler key]
-  (log-event "Registering sync self-removing event handler:: " event-type key)
+  (log-event "Registering sync self-removing event handler:: " event-type " with key: " key)
   (handlers/add-one-shot-sync-handler! handler-pool event-type key handler))

 (defn remove-handler
@@ -160,6 +161,7 @@
   (let [[old new] (swap-returning-prev! lossy-workers* dissoc key)]
     (when-let [old-worker (get old key)]
       (.put (:queue old-worker) :die)))
+  (log-event "Removing event handler associated with key: " key)
   (handlers/remove-handler! handler-pool key))

 (defn remove-all-handlers
@@ -168,6 +170,7 @@
   (let [[old new] (swap-returning-prev! lossy-workers* (fn [_] {}))]
     (doseq [old-worker (vals old)]
       (.put (:queue old-worker) :die)))
+  (log-event "Removing all event handlers!")
   (handlers/remove-all-handlers! handler-pool))

 (defn event
@@ -180,7 +183,8 @@
   (event ::my-event)
   (event ::filter-sweep-done :instrument :phat-bass)"
   [event-type & args]
-  (log-event "event: " event-type " " args)
+  (when @log-events?
+    (log-event "event: " event-type " " args))
   (when @event-debug*
     (println "event: " event-type " " args "\n"))
   (when @monitoring?*
@@ -198,7 +202,8 @@
   new threads which generate events, these will revert back to the
   default behaviour of event (i.e. not forced sync). See event."
   [event-type & args]
-  (log-event "sync-event: " event-type " " args)
+  (when @log-events?
+    (log-event "sync-event: " event-type " " args))
   (when @event-debug*
     (println "sync-event: " event-type " " args "\n"))
   (when @monitoring?*


More tests for all-closed-sets-in-family

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

--- src/conexp/tests/base.clj
+++ src/conexp/tests/base.clj
@@ -81,7 +81,11 @@

 (deftest test-all-closed-sets-in-family
   (is (= '(#{2} #{1 2} #{0 2} #{3} #{1 3} #{0 3} #{2 3})
-         (all-closed-sets-in-family #(< (count %) 3) [3 2 0 1] identity #{2}))))
+         (all-closed-sets-in-family #(< (count %) 3) [3 2 0 1] identity #{2})))
+  (is (= '(#{0} #{0 3} #{0 2} #{0 1})
+         (all-closed-sets-in-family #(< (count %) 3) [0 1 2 3] #(conj % 0) #{})))
+  (is (= '(#{0} #{0 3} #{0 2} #{0 1})
+         (all-closed-sets-in-family #(< (count %) 3) [0 1 2 3] #(conj % 0) #{0}))))

 (deftest test-next-closed-set
   (are [set next] (= (next-closed-set [3 2 1] identity set) next)


Updated stackdriver.clj

Updated stackdriver.clj

--- src/riemann/stackdriver.clj
+++ src/riemann/stackdriver.clj
@@ -32,13 +32,14 @@
 (defn stackdriver
   "Returns a function which accepts an event and sends it to Stackdriver."
   [opts]
-  (let [opts (merge { :api-key "stackdriver-api-key"
-                      :name :service } opts)]
+  (let [ts (atom 0)
+        opts (merge {:api-key "stackdriver-api-key"
+                     :name :service} opts)]
     (fn [event]
       (when (:metric event))
-      (let [post-data { :timestamp (-> (System/currentTimeMillis) (quot 1000))
-                        :proto_version 1
-                        :data (generate-datapoint opts event) }
+      (let [post-data {:timestamp (swap! ts #(max (inc %) (riemann.time/unix-time)))
+                       :proto_version 1
+                       :data (generate-datapoint opts event)}
             json-data (generate-string post-data)]
         (when (:metric event)
           (post-datapoint (:api-key opts) gateway-url json-data))))))


loop and disable controls params in docs

--- src/cljs/work_sessions/components/proxy_viewer_page.cljs
+++ src/cljs/work_sessions/components/proxy_viewer_page.cljs
@@ -34,6 +34,7 @@
               :src "https://www.youtube.com/embed/TuGG9Wts-zA?autoplay=1"
               :frame-border 0
               :auto-play 1
+              :controls 0
               :loop 1
               :allow-full-screen true}]]]]])})))


Fixed binding large collections (closes #120)

--- src/datascript/query.cljc
+++ src/datascript/query.cljc
@@ -92,7 +92,7 @@
     res))

 (defn sum-rel [a b]
-  (Relation. (:attrs a) (concat (:tuples a) (:tuples b))))
+  (Relation. (:attrs a) (into (:tuples a) (:tuples b))))

 (defn prod-rel
   ([] (Relation. {} [(da/make-array 0)]))


Fix alias usage.

Fix alias usage.

--- src/stuttaford/generate.clj
+++ src/stuttaford/generate.clj
@@ -53,7 +53,7 @@
   (clean)
   (ensure-site)
   (copy-public-to-site)
-  (let [session (session/session (service/handler))]
+  (let [session (peridot/session (service/handler))]
     (generate-path session "/atom.xml" "/atom.xml")
     (generate-html-path session "/")
     (generate-html-path session "/about/")


Property test for dense matrix loader.

Property test for dense matrix loader.

--- test/cavm/db_test.clj
+++ test/cavm/db_test.clj
@@ -1,5 +1,6 @@
 (ns cavm.db-test
   (:require [clojure.java.io :as io])
+  (:require [clojure.string :as s])
   (:require [cavm.h2 :as h2])
   (:require [cavm.db :as cdb])
   (:require [cavm.readers :as cr])
@@ -13,29 +14,45 @@
   (:require [clojure.test.check.clojure-test :as tcct :refer [defspec]])
   (:require [clojure.test.check.properties :as prop]))

-(def eps 0.000001)
-
-(defn- nearly-equal [e a b]
+; XXX fix nearly-equal-matrix to also log failures
+(def ^:dynamic *verbose* false)
+
+(defmacro is= [a b]
+  `(let [a# ~a
+         b# ~b
+         r# (= a# b#)]
+    (when (and (not r#) *verbose*)
+      (println "expected (=" ~(str a) ~(str b) ")")
+      (print "actual (not (=")
+      (clojure.pprint/write a#)
+      (print " ")
+      (clojure.pprint/write b#)
+      (println "))"))
+     r#))
+
+(def ^:dynamic *eps* 0.0001)
+
+(defn- nearly-equal [a b]
   (and (= (count a) (count b))
        (reduce (fn [acc pair]
                  (or (let [[x y] pair]
                        (and
                          (Double/isNaN x)
                          (Double/isNaN y)))
-                     (and acc (< (java.lang.Math/abs (apply - pair)) e))))
+                     (and acc (< (java.lang.Math/abs (apply - pair)) *eps*))))
                true
                (map vector a b))))

-(defn- nearly-equal-matrix [e a b]
+(defn- nearly-equal-matrix [a b]
   (and (= (count a) (count b))
-       (every? (fn [[a1 b1]] (nearly-equal e a1 b1)) (map vector a b))))
+       (every? (fn [[a1 b1]] (nearly-equal a1 b1)) (map vector a b))))

 (def gen-mostly-ints
   (gen/frequency [[9 gen/int] [1 (gen/return Double/NaN)]]))

-; work-around for broken gen/vector, which will stack-overflow.
 ; The conditional is necessary to smoothly handle small numbers.
-; Otherwise we only do squares, like 1,4,9.
+; Otherwise we only do squares, like 1,4,9. Above the threshold we
+; are not perfectly accurate. This can't be avoided.
 (defn gen-vector-of-size
   "Generate vector of given size, working-around gen/vector
   stackoverflow problem."
@@ -58,11 +75,14 @@
           size
           (+ s (* (- size s) slope)))))))

-(defn gen-distinct-names [n]
+(defn gen-distinct-names
+  "Generate a list of names which are non-empty after trimming, and
+  are distinct after trimming."
+  [n]
   (gen/such-that
-    #(= (count %) (count (set %)))
+    #(= (count %) (count (set (map s/trim %))))
     (gen-vector-of-size
-      (gen/such-that not-empty gen/string-ascii)
+      (gen/such-that #(not-empty (s/trim %)) gen/string-ascii)
       n)))

 (defn scale-gen
@@ -122,44 +142,47 @@

 (def ^:dynamic *test-runs* 100)

+(defn check-matrix [db id tsv]
+  (let [{:keys [probes samples matrix]} tsv
+        exp (cdb/run-query db {:select [:name :status :rows] :from [:dataset]})
+        q-samples (cdb/run-query db
+                                 {:select [[:value :name]]
+                                  :from [:field]
+                                  :where [:= :name "sampleID"]
+                                  :left-join [:code [:= :field.id :field_id]]
+                                  :order-by [:ordering]})
+        q-probes (cdb/run-query db {:select [:*] :from [:field]})
+        q-data (cdb/fetch db [{:table id
+                               :columns probes
+                               :samples samples}])]
+    (and (is= exp [{:name id :status "loaded" :rows (count samples)}])
+         (is= (map :name q-samples) samples)
+         (is= (map :name q-probes) (cons "sampleID" probes))
+         (nearly-equal-matrix
+            matrix
+            (vec (map #(into [] %) (map ((first q-data) :data) probes)))))))
+
+(defn genomic-matrix-memory-run
+  "Run a generated genomic-matrix-loader test case. Useful for repeated failed
+  cases. Run with *verbose* to print detailed test failures"
+  [tsv id]
+  (db-disk-fixture
+    db
+    (let [fields (fields-from-tsv tsv)]
+      (cdb/write-matrix
+        db id
+        [{:name id
+          :time (org.joda.time.DateTime. 2014 1 1 0 0 0 0)
+          :hash "1234"}]
+        {} (fn [] fields) nil false)
+      (check-matrix db id tsv))))
+
 (defspec genomic-matrix-memory
   *test-runs*
   (prop/for-all
     [tsv gen-tsv
      id (gen/such-that not-empty gen/string-ascii)]
-    (db-disk-fixture
-      db
-      (let [fields (fields-from-tsv tsv)
-            {:keys [probes samples matrix]} tsv]
-        (cdb/write-matrix
-          db
-          id
-          [{:name id
-            :time (org.joda.time.DateTime. 2014 1 1 0 0 0 0)
-            :hash "1234"}]
-          {}
-          (fn [] fields)
-          nil
-          false)
-
-        (let [exp (cdb/run-query db {:select [:name :status :rows] :from [:dataset]})
-              q-samples (cdb/run-query db
-                                       {:select [[:value :name]]
-                                        :from [:field]
-                                        :where [:= :name "sampleID"]
-                                        :left-join [:code [:= :field.id :field_id]]
-                                        :order-by [:ordering]})
-              q-probes (cdb/run-query db {:select [:*] :from [:field]})
-              q-data (cdb/fetch db [{:table id
-                                     :columns probes
-                                     :samples samples}])]
-          (and (= exp [{:name id :status "loaded" :rows (count samples)}])
-               (= (map :name q-samples) samples)
-               (= (map :name q-probes) (cons "sampleID" probes))
-               (nearly-equal-matrix
-                 0.0001
-                 matrix
-                 (vec (map #(into [] %) (map ((first q-data) :data) probes))))))))))
+    (genomic-matrix-memory-run tsv id)))

 (defn matrix1 [db]
   (ct/testing "tsv matrix from memory"
@@ -241,12 +264,12 @@
                  {:field_id 3 :row 1 :gene "BLAH"}]))
       (let [[probe1 probe2]
             (vec (map #(into [] %) (map ((first data) :data) ["probe1" "probe2"])))]
-        (ct/is (nearly-equal 0.0001 probe1 [1.2 1.1]))
-        (ct/is (nearly-equal 0.0001 probe2 [2.2 2.1])))
+        (ct/is (nearly-equal probe1 [1.2 1.1]))
+        (ct/is (nearly-equal probe2 [2.2 2.1])))
       (let [[probe1 probe2]
             (vec (map #(into [] %) (map ((first data2) :data) ["probe1" "probe2"])))]
-        (ct/is (nearly-equal 0.0001 probe1 [1.1 Double/NaN]))
-        (ct/is (nearly-equal 0.0001 probe2 [2.1 Double/NaN]))))))
+        (ct/is (nearly-equal probe1 [1.1 Double/NaN]))
+        (ct/is (nearly-equal probe2 [2.1 Double/NaN]))))))

 (def docroot "test/cavm/test_inputs")

@@ -260,6 +283,56 @@
   (ct/testing "detect tsv matrix"
     (let [{file-type :file-type} (detector "test/cavm/test_inputs/matrix")]
       (ct/is (= file-type :cgdata.core/tsv)))))
+
+(defn str-nan [f]
+  (if (and (number? f) (Double/isNaN f)) "" (str f)))
+
+(def ^:dynamic *delete-tmp-files* true)
+
+(defmacro with-file
+  "Execute body, ensuring that file is always deleted before returning."
+  [[bindvar file] & body]
+  `(let [~bindvar ~file]
+     (try
+       ~@body
+       (finally (when *delete-tmp-files*
+                  (io/delete-file (io/file ~bindvar) true))))))
+
+(defn write-genomic-matrix
+  "Write a genomic matrix to a file."
+  [file {:keys [matrix probes samples]}]
+  (let [header (cons "sampleID" samples)
+        rows (map (fn [probe row] (cons probe row)) probes matrix)]
+    (spit (io/file file)
+          (s/join "\n"
+                  (map #(s/join "\t" (map str-nan %)) (cons header rows))))))
+
+(defn trim-tsv
+  "Rewrite tsv with probes and samples trimmed of leading and trailing
+  whitespace. Useful for comparing with tsv read from files, which we
+  similarly trim."
+  [{:keys [probes samples] :as tsv}]
+  (assoc tsv
+         :probes (map s/trim probes)
+         :samples (map s/trim samples)))
+
+(defn genomic-matrix-loader-run
+  "Run a generated genomic-matrix-loader test case. Useful for repeated failed
+  cases. Run with *verbose* to print detailed test failures"
+  [tsv id]
+  (with-file [file (str (io/file docroot "generated" id))]
+    (write-genomic-matrix file tsv)
+    (db-disk-fixture
+      db
+      (loader db detector docroot file)
+      (check-matrix db (str (io/file "generated" id)) (trim-tsv tsv)))))
+
+(defspec genomic-matrix-loader
+  *test-runs*
+  (prop/for-all
+    [tsv gen-tsv
+     id (gen/such-that not-empty gen/string-alpha-numeric)]
+    (genomic-matrix-loader-run tsv id)))

 (defn matrix2 [db]
   (ct/testing "tsv matrix from file"
@@ -290,8 +363,8 @@
                  {:name "probe5" :id 6 :dataset_id 1} ]))
       (let [[probe1 probe2]
             (vec (map #(into [] %) (map ((first data) :data) ["probe1" "probe2"])))]
-        (ct/is (nearly-equal 0.0001 probe1 [2.1 1.1]))
-        (ct/is (nearly-equal 0.0001 probe2 [2.2 1.2]))))))
+        (ct/is (nearly-equal probe1 [2.1 1.1]))
+        (ct/is (nearly-equal probe2 [2.2 1.2]))))))

 (defn matrix2-reload [db]
   (ct/testing "reload tsv matrix from file"
@@ -323,8 +396,8 @@
                  {:name "probe5" :id 12 :dataset_id 1} ]))
       (let [[probe1 probe2]
             (vec (map #(into [] %) (map ((first data) :data) ["probe1" "probe2"])))]
-        (ct/is (nearly-equal 0.0001 probe1 [2.1 1.1]))
-        (ct/is (nearly-equal 0.0001 probe2 [2.2 1.2]))))))
+        (ct/is (nearly-equal probe1 [2.1 1.1]))
+        (ct/is (nearly-equal probe2 [2.2 1.2]))))))

 (defn detect-cgdata-genomic [db]
   (ct/testing "detect cgdata genomic"


fixed upload slots

fixed upload slots

--- src/frontend/uploads.cljs
+++ src/frontend/uploads.cljs
@@ -39,26 +39,27 @@
         inactive-uploads (:inactive-uploads new-state)
         uploads (:uploads new-state)]
     (cond
-      (< old-upload-slots new-upload-slots)
+      (and (< old-upload-slots new-upload-slots)
+           (< (count active-uploads) new-upload-slots))
         (if-not (empty? inactive-uploads)
           {:active-uploads (append-upload active-uploads
                                           (first inactive-uploads))
            :inactive-uploads (drop-first-upload inactive-uploads)
            :uploads (merge uploads {(first inactive-uploads)
-                                    (start-upload (first inactive-uploads))})})
-      (> old-upload-slots new-upload-slots)
+                                    (start-upload (uploads (first inactive-uploads)))})})
+      (and (> old-upload-slots new-upload-slots)
+           (> (count active-uploads) new-upload-slots))
         (if-not (empty? active-uploads)
           {:active-uploads (drop-last-upload active-uploads)
            :inactive-uploads (prepend-upload inactive-uploads
                                              (last active-uploads))
            :uploads (merge uploads {(last active-uploads)
-                                    (stop-upload (last active-uploads))})}))))
+                                    (stop-upload (uploads (last active-uploads)))})}))))

 (defn upload-slots-watch-fn! [_ _ old-state new-state]
   (let [new-uploads-info (handle-upload-slots-change old-state new-state)]
     (if-not (nil? new-uploads-info)
-      (do
-        (swap! app-state/app-state merge new-uploads-info)))))
+      (swap! app-state/app-state merge new-uploads-info))))

 (add-watch app-state/app-state :upload-slots  upload-slots-watch-fn!)


refactor cljs IReduce workaround: add IReduce impl for LazyTransformer

--- src/thi/ng/fabric/core.cljc
+++ src/thi/ng/fabric/core.cljc
@@ -14,6 +14,28 @@
         [clojure.core.reducers :as r]
         [cljs.core.async :as async :refer [<! >!]])]))

+#?(:cljs
+   (when-not (satisfies? IReduce LazyTransformer)
+     (defn- seq-reduce*
+       ([f coll]
+        (if-let [s (seq coll)]
+          (reduce f (first s) (next s))
+          (f)))
+       ([f val coll]
+        (loop [val val, coll (seq coll)]
+          (if coll
+            (let [nval (f val (first coll))]
+              (if (reduced? nval)
+                @nval
+                (recur nval (next coll))))
+            val))))
+
+     (extend-type LazyTransformer
+       IReduce
+       (-reduce
+         ([coll f] (seq-reduce* f coll))
+         ([coll f start] (seq-reduce* f start coll))))))
+
 ;;#?(:clj (taoensso.timbre/set-level! :warn))

 ;; (warn :free-ram (.freeMemory (Runtime/getRuntime)))
@@ -61,15 +83,13 @@
 (defn default-score-signal
   "Computes vertex signal score. Returns 0 if value equals prev-val,
   else returns 1."
-  [vertex]
-  (if (= @vertex @(:prev-val vertex)) 0 1))
+  [vertex] (if (= @vertex @(:prev-val vertex)) 0 1))

 (defn score-signal-with-new-edges
   "Computes vertex signal score. Returns number of *new* outgoing
   edges plus 1 if value not equals prev-val. New edge counter is reset
   each time signal! is called."
-  [vertex]
-  (+ (::new-edges @(:state vertex)) (if (= @vertex @(:prev-val vertex)) 0 1)))
+  [vertex] (+ (::new-edges @(:state vertex)) (if (= @vertex @(:prev-val vertex)) 0 1)))

 (defn default-score-collect
   "Computes vertex collect score, here simply the number
@@ -359,14 +379,15 @@
   [ctx]
   (let [processor ((:processor ctx) (:signal-thresh ctx) (:collect-thresh ctx))]
     (fn [workgroup-size vertices]
-      (r/fold workgroup-size single-pass-combine processor vertices))))
+      (r/fold workgroup-size single-pass-combine processor #?(:clj vertices :cljs (seq vertices))))))

 (defn two-pass-scheduler
   [ctx]
   (let [sig-fn  ((:signal-fn ctx) (:signal-thresh ctx))
         coll-fn ((:collect-fn ctx) (:collect-thresh ctx))]
     (fn [_ vertices]
-      (let [[s-act sigs]  (sig-fn vertices)
+      (let [#?@(:cljs [vertices (seq vertices)])
+            [s-act sigs]  (sig-fn vertices)
             [c-act colls] (coll-fn vertices)]
         [(into s-act c-act) sigs colls]))))

@@ -470,7 +491,7 @@
       (execute!
         [_]
         (let [t0     (now)
-              active (atom #?(:clj (sequence v-filter (vertices g)) :cljs (into [] v-filter (vertices g))))
+              active (atom (sequence v-filter (vertices g)))
               queue  (atom #{})]
           (add-context-watches g watch-id queue)
           (loop [colls 0, sigs 0]
@@ -480,11 +501,7 @@
                 (let [grp-size            (max 512 (long (/ (count @active) threads)))
                       [act' sigs' colls'] (scheduler grp-size @active)]
                   ;;(warn :auto (count @queue))
-                  (reset! active
-                          #?(:clj
-                             (into (into #{} v-filter act') @queue)
-                             :cljs ;; FIXME CLJS doesn't support reducers on sets
-                             (vec (into (into #{} v-filter act') @queue))))
+                  (reset! active (into (into #{} v-filter act') @queue))
                   (reset! queue #{})
                   (recur (long (+ colls colls')) (long (+ sigs sigs'))))
                 (->result :max-ops-reached sigs colls t0))
@@ -530,7 +547,7 @@
       (execute!
         [_]
         (let [t0     (atom (now))
-              active (atom #?(:clj (sequence v-filter (vertices g)) :cljs (into [] v-filter (vertices g))))
+              active (atom (sequence v-filter (vertices g)))
               queue  (atom #{})]
           (add-context-watches g watch-id queue)
           (go-loop [colls 0, sigs 0]
@@ -540,11 +557,7 @@
                 (let [grp-size            (max 512 (long (/ (count @active) threads)))
                       [act' sigs' colls'] (scheduler grp-size @active)]
                   ;;(warn :auto (count @queue))
-                  (reset! active
-                          #?(:clj
-                             (into (into #{} v-filter act') @queue)
-                             :cljs ;; FIXME CLJS doesn't support reducers on sets
-                             (vec (into (into #{} v-filter act') @queue))))
+                  (reset! active (into (into #{} v-filter act') @queue))
                   (reset! queue #{})
                   (recur (long (+ colls colls')) (long (+ sigs sigs'))))
                 (do (stop! _)
@@ -554,7 +567,7 @@
                     (stop! _)
                     (when (<! notify-chan)
                       (reset! t0 (now))
-                      (reset! active (into [] v-filter (vertices g)))
+                      (reset! active (sequence v-filter (vertices g)))
                       (reset! queue #{})
                       ;;(warn :rerun (count @active))
                       (recur 0 0))))))


Rename variable to z for consistency.

Rename variable to z for consistency.

--- project/analyze-data/src/analyze_data/naive_bayes/predict.clj
+++ project/analyze-data/src/analyze_data/naive_bayes/predict.clj
@@ -4,12 +4,12 @@

 (defn predict
   "parameters: map produced by analyze-data.naive-bayes.train/train
-   x: vector of term weights representing a document
+   z: vector of term weights representing a document

   Return a vector of [most-likely-label score]"
-  [parameters x]
+  [parameters z]
   (let [{:keys [log-phi log-phi-y]} parameters
-        log-probs (->> (m/mul log-phi x)
+        log-probs (->> (m/mul log-phi z)
                        (map m/esum)
                        (m/add log-phi-y))
         indexed-log-probs (map-indexed #(vector %1 %2) log-probs)]


bump cache to 10000

bump cache to 10000

--- src/pc/http/sente.clj
+++ src/pc/http/sente.clj
@@ -624,7 +624,7 @@
                                          (replay/reproduce-transaction *db*)
                                          (datomic-common/frontend-document-transaction)
                                          :read-only-data))
-                                     :lru/threshold 2000))
+                                     :lru/threshold 10000))

 (defn get-frontend-tx-data [db tx-id]
   (binding [*db* db]


display post in overview at 9am thursday

--- src/pc/views/blog.clj
+++ src/pc/views/blog.clj
@@ -41,7 +41,8 @@
   [
    {:slug "clojure-is-a-product-design-tool"
     :display-in-overview true
-    :scheduled-time (clj-time.format/parse "Wed, 11 Mar 2015 09:00:00 -0800")}
+    ;; 9am dst
+    :scheduled-time (clj-time.format/parse "Thu, 12 Mar 2015 08:00:00 -0800")}
    {:slug "optimizing-om-apps"
     :display-in-overview true}
    {:slug "blue-ocean-made-of-ink"


Fix math docstrings and rename symbol

Fix math docstrings and rename symbol

--- src/play_clj/math.clj
+++ src/play_clj/math.clj
@@ -9,7 +9,7 @@
 ; static methods/fields

 (defmacro geometry!
-  "Calls a single method on [GeometryUtils](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/GeometryUtils.html)"
+  "Calls a single static method on [GeometryUtils](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/GeometryUtils.html)"
   [k & options]
   `(~(u/gdx-field :math :GeometryUtils (u/key->camel k)) ~@options))

@@ -21,14 +21,14 @@
   `~(u/gdx-class :math :Interpolation (u/key->pascal k)))

 (defmacro intersector!
-  "Calls a single method on [Intersector](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Intersector.html)
+  "Calls a single static method on [Intersector](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Intersector.html)

     (intersector! :is-point-in-triangle 0 1 0 0 1 2 3 0)"
   [k & options]
   `(~(u/gdx-field :math :Intersector (u/key->camel k)) ~@options))

 (defmacro math!
-  "Calls a single method on [MathUtils](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/MathUtils.html)
+  "Calls a single static method on [MathUtils](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/MathUtils.html)

     (math! :ceil 0.1)"
   [k & options]
@@ -62,18 +62,18 @@

 ; bresenham2

-(defn bresenham2*
-  "The function version of `bresenham2`"
+(defn bresenham-2*
+  "The function version of `bresenham-2`"
   []
   (Bresenham2.))

-(defmacro bresenham2
+(defmacro bresenham-2
   "Returns a [Bresenham2](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Bresenham2.html)"
   [& options]
-  `(u/calls! ^Bresenham2 (bresenham2*) ~@options))
-
-(defmacro bresenham2!
-  "Calls a single method on a `bresenham2`"
+  `(u/calls! ^Bresenham2 (bresenham-2*) ~@options))
+
+(defmacro bresenham-2!
+  "Calls a single method on a `bresenham-2`"
   [object k & options]
   `(u/call! ^Bresenham2 ~object ~k ~@options))


Make the filter-fn the first arg to be consistent with filter

--- src/play_clj/repl.clj
+++ src/play_clj/repl.clj
@@ -20,26 +20,23 @@
   "Returns the entities in `screen-object`, optionally filtered by a supplied
 function.

-    (e main-screen :player?)"
+    (e :player? main-screen)
+    (e texture? main-screen)"
   ([screen-object]
     (-> screen-object :entities deref))
-  ([screen-object filter-fn]
+  ([filter-fn screen-object]
     (vec (filter filter-fn (e screen-object)))))

 (defn e!
-  "Resets the entities in `screen-object`, or associates values to the entities
-in `screen-object` that match the supplied function. Returns the entities that
-were changed.
+  "Associates values to the entities in `screen-object` that match the supplied
+function. Returns the entities that were changed.

-    (e! main-screen [])
-    (e! main-screen :player? :health 10)"
-  ([screen-object new-entities]
-    (reset! (:entities screen-object) new-entities))
-  ([screen-object filter-fn & args]
-    (swap! (:entities screen-object)
-           (fn [entities]
-             (vec (for [e entities]
-                    (if (filter-fn e)
-                      (apply assoc e args)
-                      e)))))
-    (e screen-object filter-fn)))
+    (e! :player? main-screen :health 10)"
+  [filter-fn screen-object & args]
+  (swap! (:entities screen-object)
+         (fn [entities]
+           (vec (for [e entities]
+                  (if (filter-fn e)
+                    (apply assoc e args)
+                    e)))))
+  (e filter-fn screen-object))


Add error/err functions.

Add error/err functions.

--- src/promesa/core.cljc
+++ src/promesa/core.cljc
@@ -411,13 +411,22 @@

 (defn catch
   "Catch all promise chain helper."
-  ([p callback]
-   (-catch p callback))
-  ([p type callback]
+  ([p f]
+   (-catch p f))
+  ([p type f]
    (-catch p (fn [e]
                  (if (instance? type e)
-                   (callback e)
+                   (f e)
                    (throw e))))))
+
+(defn error
+  "Same as `catch` but with parameters inverted."
+  ([f p] (catch p f))
+  ([f type p] (catch p type f)))
+
+(def err
+  "A short alias for `error` function."
+  error)

 (defn finally
   "Attach handler to promise that will be


Make `chain` use inline composition.

Make `chain` use inline composition.

--- src/promesa/core.cljc
+++ src/promesa/core.cljc
@@ -158,7 +158,7 @@
 (defn chain
   "Like then but accepts multiple parameters."
   [p & funcs]
-  (reduce #(then %1 %2) p funcs))
+  (reduce #(map' %2 %1) p funcs))

 (defn branch
   [p success failure]


CMR-6206: Remove `simplify-shapefile` parameter form Query if it is not provided

--- search-app/src/cmr/search/services/parameters/conversion.clj
+++ search-app/src/cmr/search/services/parameters/conversion.clj
@@ -432,7 +432,8 @@
                                 [:temporal-conditions])
         keywords (when (:keyword params)
                    (str/split (str/lower-case (:keyword params)) #" "))
-        params (if keywords (assoc params :keyword (str/join " " keywords)) params)]
+        params (if keywords (assoc params :keyword (str/join " " keywords)) params)
+        simplify-shapefile? (= "true" (:simplify-shapefile params))]
     [(dissoc params
              :boosts :include-granule-counts :include-has-granules :include-facets :echo-compatible
              :hierarchical-facets :include-highlights :include-tags :all-revisions :facets-size
@@ -442,7 +443,7 @@
                  :result-features (seq result-features)
                  :echo-compatible? (= "true" (:echo-compatible params))
                  :all-revisions? (= "true" (:all-revisions params))
-                 :simplify-shapefile? (= "true" (:simplify-shapefile params))
+                 :simplify-shapefile? (when simplify-shapefile? simplify-shapefile?)
                  :facets-size (:facets-size params)
                  :result-options (merge (when-not (str/blank? (:include-tags params))
                                           {:tags (map str/trim (str/split (:include-tags params) #","))})


src/riemann/xymon.clj: Added events->combo, send-combo and xymon-batch functions, which make possible to send multiple messages in one connection.

--- src/riemann/xymon.clj
+++ src/riemann/xymon.clj
@@ -120,3 +120,45 @@
       (when (and state service)
         (let [statusmessage (formatter event)]
           (send-line opts statusmessage))))))
+
+(def xymon-max-line 4096)
+
+(def- combo-header "combo\n")
+(def- combo-header-len (count combo-header))
+
+(defn events->combo
+  "
+  Returns a lazy sequence of combo messages. Each message is at most
+  xymon-max-line long.
+  "
+  ([formatter events] (asdf formatter events combo-header combo-header-len))
+  ([formatter events message len]
+   (if (empty? events)
+     (when-not (= len combo-header-len) '(message))
+     (let [next (formatter (first events))
+           next-length (count next)
+           length (+ len next-length 2)
+           events (rest events)]
+       (if (< length xymon-max-line)
+         (recur formatter events (str message next "\n\n") length)
+         (cons message (lazy-seq (asdf formatter events))))))))
+
+(defn send-combo
+  "
+  Turns events into combo messages (using events->combo) and send them
+  to Xymon.
+  "
+  [opts events]
+  (let [formatter (or (:formatter opts) event->status)]
+    (doseq [combo-message (events->combo formatter events)]
+      (send-line opts combo-message))))
+
+(defn xymon-batch
+  "
+  Returns a function which accepts multiple events and send them to
+  xymon as 'combo' messages. Filters events without nil :state
+  or :service.
+  "
+  [opts]
+  (fn [events]
+    (send-combo opts (filter #(and (:service %) (:state %)) events))))


Delete debug print.

Delete debug print.

--- src/tames/handler.clj
+++ src/tames/handler.clj
@@ -170,7 +170,7 @@
         ext               (fs/ext relative-path)
         content-type      (content-types (. ext toLowerCase))
         file              (if config-resource?
-                              (?= (config/resource-file relative-path))
+                              (config/resource-file relative-path)
                               (systems/get-target-file relative-path))
         last-modified     (time-to-RFC1123 (. file lastModified))
         not-modified?     (= if-modified-since last-modified)]


Fix offset calculations for effect row.

Fix offset calculations for effect row.

Also fix handling single-variable encoders.

--- src/afterglow/controllers/ableton_push.clj
+++ src/afterglow/controllers/ableton_push.clj
@@ -1162,8 +1162,8 @@
   [controller note]
   (let [room (room-for-effects controller)
         fx-info @(:active-effects (:show controller))
-        fx (:effects fx-info)
-        fx-meta (:meta fx-info)
+        fx (vec (drop (- (count (:effects fx-info)) room) (:effects fx-info)))
+        fx-meta (vec (drop (- (count (:meta fx-info)) room) (:meta fx-info)))
         offset (- 4 room)
         x (quot (- note 20) 2)
         index (- x offset)]
@@ -1347,9 +1347,9 @@
   [controller note]
   (let [room (room-for-effects controller)
         fx-info @(:active-effects (:show controller))
-        fx (:effects fx-info)
-        fx-meta (:meta fx-info)
-        offset (if (<= (count fx) room) (- 4 room) 0)
+        fx (vec (drop (- (count (:effects fx-info)) room) (:effects fx-info)))
+        fx-meta (vec (drop (- (count (:meta fx-info)) room) (:meta fx-info)))
+        offset (- 4 room)
         x (quot note 2)
         index (- x offset)
         var-index (rem note 2)]
@@ -1362,7 +1362,7 @@
           1 (add-overlay controller
                          ;; Just one variable, take full cell, using either encoder,
                          ;; suppress the other one.
-                         (let [paired-note (odd? note (dec note) (inc note))]
+                         (let [paired-note (if (odd? note) (dec note) (inc note))]
                            (reify IOverlay
                              (captured-controls [this] #{(control-for-top-encoder-note note)})
                              (captured-notes [this] #{note paired-note})


support linking native libs to a relative path

--- tasks.clj
+++ tasks.clj
@@ -18,10 +18,15 @@
   (clean (file "src" tokyocabinet-java)))

 (defn fix-install-path [src lib]
-  (when (= "macosx" (os-name))
-    (ant Replace {:file (file src "Makefile")
-                  :token (str "-install_name $(LIBDIR)/lib" lib ".$(LIBVER).dylib")
-                  :value (str "-install_name @loader_path/lib" lib ".dylib")})))
+  (case (os-name)
+        "macosx"
+        (ant Replace {:file (file src "Makefile")
+                      :token (str "-install_name $(LIBDIR)/lib" lib ".$(LIBVER).dylib")
+                      :value (str "-install_name @loader_path/lib" lib ".dylib")})
+        "linux"
+        (let [token "\nLDFLAGS ="
+              rpath "-Wl,-R,'$$ORIGIN'"]
+          (ant Replace {:file (file src "Makefile") :token token :value (str token " " rpath)}))))

 (deftask compile-native #{clean}
   (log (format "Compiling tokyocabinet for %s/%s" (os-name) (os-arch)))
@@ -43,7 +48,7 @@
            (args prefix)
            (env {"JAVA_HOME" (System/getProperty "java.home") "CFLAGS" cflags}))
       (let [token "\nCFLAGS ="] ; hack because configure doesn't set CFLAGS correctly in Makefile
-        (ant Replace {:file (file src "Makefile") :token token :value (str token cflags)}))
+        (ant Replace {:file (file src "Makefile") :token token :value (str token " " cflags)}))
       (fix-install-path src "jtokyocabinet")
       (ant ExecTask {:executable "make" :dir src :failonerror true})
       (ant ExecTask {:executable "make" :dir src :failonerror true}


Clustered asplan works (but doesn't help) on depots

--- src/angelic/search/action_set/asplan_c.clj
+++ src/angelic/search/action_set/asplan_c.clj
@@ -289,7 +289,7 @@
           (for [n-val (acyclic-succ-fn v c-val d-val), a (dtg n-val)]
             (make-add-action-action var->cluster a)))
         (add-actions s c var->cluster cluster-sgs))) ;; only for cyclic domains -- TODO: remove?
-    (let [child-action (state/get-var s (action-var s (current-child s ccm c)))
+    (let [child-action (state/get-var s (action-var (current-child s ccm c)))
           restricted-pm (select-keys (:precond-map child-action) c)]
       (cond (empty? restricted-pm) (add-actions s c var->cluster cluster-sgs) ;; for cyclic ?
             (state/state-matches-map? s restricted-pm) [(make-freeze-var-action c)]
@@ -343,7 +343,11 @@
        (assert (= (util/keyset cluster-map)
                   (graphs/ancestor-set (remove #(apply = %) (sas-analysis/standard-causal-graph sas-problem))
                                        [sas/goal-var-name])))
-       (doseq [a (:actions sas-problem)] (assert (every? #(contains? (:precond-map a) %) (keys (:effect-map a)))))
+
+       ;;     (doseq [a (:actions sas-problem)] (assert (every? #(contains? (:precond-map a) %) (keys (:effect-map a)))))
+       ;; TODO: Need this for real generalization, here it only has to be true on cluster!
+       (doseq [a (:actions sas-problem)] (assert (some (var->cluster (first (keys (:effect-map a))))
+                                                        (keys (:precond-map a)))))
        (doseq [c clusters] (println c))
        (println )
        (ASPlanEnv.
@@ -374,8 +378,8 @@
                 (do (println "A!") (add-actions s (first sources) var->cluster cluster-sgs))

                 :else (assert "Unknown source type!")))))
-        (env/goal-map sas-problem)))
-     ))
+        (env/goal-map sas-problem)))))
+


Sort resources and actions.

Sort resources and actions.

Helpful when there's a long list.

--- src/cljs/gc_api_browser/schema_select.cljs
+++ src/cljs/gc_api_browser/schema_select.cljs
@@ -80,12 +80,14 @@
 (defn resource->actions [schema resource]
   (->> (schema->resource-node schema resource)
        :links
-       (map :title)))
+       (map :title)
+       sort))

 (defn schema->resources [schema]
   (->> (vals (:definitions schema))
        (map :title)
-       (map name)))
+       (map name)
+       sort))

 (defn store-schema! [json]
   (.setItem js/localStorage "schema" (gjson/serialize json)))


Make project-view as separate om component.

--- src/cljs/hatnik/web/client/components.cljs
+++ src/cljs/hatnik/web/client/components.cljs
@@ -37,22 +37,23 @@
   (let [name (get action "library")
         template (get action "template")]
   (dom/div
-   #js {:onClick (fn []
-                   (state/set-form-type :email-edit-action)
-                   (state/set-current-project project-id)
-                   (state/set-current-action action)
-                   (state/set-current-artifact-value name)
-                   (state/set-current-email-template template)
-                   (.modal ($ :#iModal)))
+   #js {:onClick
+        (fn []
+          (state/set-form-type :email-edit-action)
+          (state/set-current-project project-id)
+          (state/set-current-action action)
+          (state/set-current-artifact-value name)
+          (state/set-current-email-template template)
+          (.modal ($ :#iModal)))
         :className "panel panel-default action"}
    (dom/div
     #js {:className "panel-body bg-success"}
-            (render-action-type (get action "type"))
-            (dom/span #js {:className "action-info"}
-                      (dom/div #js {:className "library-name"}
-                               (get action "library"))
-                      (dom/div #js {:className "version"}
-                               (get action "last-processed-version")))))))
+    (render-action-type (get action "type"))
+    (dom/span #js {:className "action-info"}
+              (dom/div #js {:className "library-name"}
+                       (get action "library"))
+              (dom/div #js {:className "version"}
+                       (get action "last-processed-version")))))))

 (defn add-action [id]
   (state/set-form-type :email-action)
@@ -99,19 +100,24 @@
                  :onClick #(project-menu project)}
             (dom/span #js {:className "glyphicon glyphicon-pencil pull-right"}))))

+(defn project-view [prj owner]
+  (reify
+    om/IRender
+    (render [_]
+      (accordion-panel
+       :header (dom/div #js {:className "bg-primary"} (get prj "name"))
+       :button (project-header-menu-button prj)
+       :body (actions-table (get prj "id") (get prj "actions"))
+       :body-id (str "__PrjList" (get prj "id"))))))
+
 (defn project-list [data owner]
   (reify
     om/IRender
     (render [this]
-      (apply dom/div nil
-       (map
-        (fn [prj]
-          (accordion-panel
-           :header (dom/div #js {:className "bg-primary"} (get prj "name"))
-           :button (project-header-menu-button prj)
-           :body (actions-table (get prj "id") (get prj "actions"))
-           :body-id (str "__PrjList" (get prj "id"))))
-        (->> (-> data :data :projects)
-             (sort-by first)
-             (map second)))))))
+      (apply
+       dom/div nil
+       (map #(om/build project-view %)
+            (->> (-> data :data :projects)
+                 (sort-by first)
+                 (map second)))))))