Remove some reflection

Remove some reflection

--- transactions/src/immutant/transactions/jdbc.clj
+++ transactions/src/immutant/transactions/jdbc.clj
@@ -15,7 +15,8 @@
 (ns immutant.transactions.jdbc
   "Enables `clojure.java.jdbc` to behave within an XA transaction"
   (:import [java.sql Connection Statement CallableStatement
-            PreparedStatement DatabaseMetaData])
+            PreparedStatement DatabaseMetaData]
+           java.lang.reflect.Method)
   (:require [immutant.transactions :refer (set-rollback-only)]
             [clojure.java.jdbc :as jdbc]))

@@ -24,10 +25,10 @@
   (let [delegate (gensym)
         expanded (map macroexpand body)
         overrides (group-by first expanded)
-        methods (for [m (.getMethods (resolve type))
+        methods (for [^Method m (.getMethods ^Class (resolve type))
                       :let [f (-> (.getName m) symbol (with-meta {:tag (-> m .getReturnType .getName)}))]
                       :when (not (overrides f))
-                      :let [args (for [t (.getParameterTypes m)] (with-meta (gensym) {:tag (.getName t)}))]]
+                      :let [args (for [^Class t (.getParameterTypes m)] (with-meta (gensym) {:tag (.getName t)}))]]
                   (list f (vec (conj args '_)) `(. ~delegate ~f ~@(map #(with-meta % nil) args))))]
     `(let [~delegate ~delegate-expr]
        (reify ~type ~@expanded ~@methods))))


GAWB-1688: cleaning it up

GAWB-1688: cleaning it up

--- src/cljs/main/broadfcui/common/gcs_file_preview.cljs
+++ src/cljs/main/broadfcui/common/gcs_file_preview.cljs
@@ -7,6 +7,7 @@
     [broadfcui.common.style :as style]
     [broadfcui.endpoints :as endpoints]
     [broadfcui.utils :as utils]
+    [clojure.string :as str]
     ))

 (def ^:private preview-byte-count 20000)
@@ -23,18 +24,19 @@
              labeled (fn [label & contents]
                        [:div {}
                         [:div {:style {:display "inline-block" :width 185}} (str label ": ")]
-                        contents])]
+                        contents])
+             data-empty (or (= data-size "0") (str/blank? data-size))]
          [:div {:style {:width 700 :overflow "auto"}}
           (labeled "Google Bucket" (:bucket-name props))
           (labeled "Object" (:object props))
           [:div {:style {:marginTop "1em"}}
-           [:div {} (when-not (or (= data-size "0") (clojure.string/blank? data-size))
+           [:div {} (when-not data-empty
                       "Previews for some filetypes may be unsupported. ")]
            (when (> data-size preview-byte-count) (str "Last " (:preview-line-count @state)
                                                        " lines are shown. Use link below to view entire file."))
            ;; The max-height of 206 looks random, but it's so that the top line of the log preview is half cut-off
            ;; to hint to the user that they should scroll up.
-           (when-not (or (= data-size "0") (clojure.string/blank? data-size))
+           (when-not data-empty
              (react/create-element
                [:div {:ref "preview" :style {:marginTop "1em" :whiteSpace "pre-wrap" :fontFamily "monospace"
                                              :fontSize "90%" :overflowY "auto" :maxHeight 206
@@ -46,7 +48,7 @@
             [:div {:style {:marginTop "1em"}}
              (labeled "File size"
                       (common/format-filesize data-size)
-                      (if (or (= data-size "0") (clojure.string/blank? data-size))
+                      (if data-empty
                         (react/create-element [:span {:style {:marginLeft "2em" :fontWeight "bold"}} "File Empty"])
                         (react/create-element
                           [:span {:style {:marginLeft "1em"}}
@@ -56,7 +58,7 @@
                             "Open"]
                            [:span {:style {:fontStyle "italic" :color (:text-light style/colors)}}
                             " (right-click to download)"]])))
-             (when-not (or (= data-size "0") (clojure.string/blank? data-size))
+             (when-not data-empty
                (labeled "Estimated download fee"
                         (if (nil? cost) "Unknown" (common/format-price cost))
                         [:span {:style {:marginLeft "1em"}}
@@ -109,7 +111,8 @@
                                     :preview-line-count (count (clojure.string/split raw-response #"\n+")))
                              (after-update
                                (fn []
-                                 (aset (@refs "preview") "scrollTop" (aget (@refs "preview") "scrollHeight")))))}))})
+                                 (when-not (str/blank? (@refs "preview"))
+                                   (aset (@refs "preview") "scrollTop" (aget (@refs "preview") "scrollHeight"))))))}))})

@@ -124,3 +127,4 @@
          (if (= bucket-name workspace-bucket)
            object
            (if link-label (str link-label) (str "gs://" bucket-name "/" object)))]]))})
+


CMR-2420 Added "ongoing" element to DIF9 collection progress element.

--- umm-lib/src/cmr/umm/dif/collection/progress.clj
+++ umm-lib/src/cmr/umm/dif/collection/progress.clj
@@ -15,6 +15,7 @@
       "in work"  :in-work
       "complete" :complete
       "completed" :complete
+      "ongoing" :in-work
       :in-work)))

 (defn generate


Adds get-files, for copying files from the buildbox

--- src/circleci/backend/action/transfer.clj
+++ src/circleci/backend/action/transfer.clj
@@ -1,14 +1,61 @@
 (ns circleci.backend.action.transfer
+  (:import java.io.File)
+  (:require [clojure.string :as str])
   (:require [clj-ssh.ssh :as ssh])
+  (:require pallet.compute)
+  (:require [circleci.backend.action :as action])
   (:require [circleci.backend.ssh :as circle-ssh])
-  (:require pallet.compute))
+  (:require [circleci.backend.action.bash :as bash])
+  (:use [circleci.utils :only (printfln)])
+  (:use circleci.utils.except))

 (defn get-file
-  "direction is either :get or :put"
   [context remote-path local-path]
   (circle-ssh/with-session (-> context :node) ssh-session
     (ssh/sftp ssh-session
               :get
               remote-path
               (-> local-path java.io.FileOutputStream.
-                  java.io.BufferedOutputStream.))))+                  java.io.BufferedOutputStream.))))
+
+(defn path-exists? [path]
+  (.exists (File. path)))
+
+(defn directory? [path]
+  (.isDirectory (File. path)))
+
+(defn get-files
+  "copies over the seq of remote files to local-dir "
+  [context remote-files local-dir & {:keys [no-overwrite] :as opts}]
+  (let [local-dir (if (re-find #"/$" local-dir)
+                    local-dir
+                    (str local-dir "/"))]
+    (circle-ssh/with-session (-> context :node) ssh-session
+    (assert (and (path-exists? local-dir) (directory? local-dir)))
+    (doseq [remote-path remote-paths
+            :let [new-local (str local-dir (.getName (File. remote-path)))]]
+      (when no-overwrite
+        (throw-if (path-exists? new-local) "Attempting to transfer %s to %s, but file already exists" remote-path new-local))
+      (printfln "%s -> %s" remote-path new-local)
+      (ssh/sftp ssh-session
+                :get
+                remote-path
+                (-> new-local java.io.FileOutputStream.
+                    java.io.BufferedOutputStream.))))))
+
+(defn find-files
+  "Runs find on the remote box, returns the list of files that matched. Find starts at directory, Pattern is a grep -P regex"
+  [context directory pattern]
+  (let [pattern (str pattern)] ;; in case we were passed a clojure
+                               ;; regex, naively convert it. This
+                               ;; should work most of the time
+    (let [resp (bash/remote-bash context [(cd ~directory)
+                                          (pipe
+                                           (find .)
+                                           (grep -P ~pattern))])]
+      (if (action/successful? resp)
+        (-> resp
+            :out
+            (clojure.string/split #"\n")
+            (->>
+             (map #(str (str/replace directory #"/$" "") "/" (str/replace % #"^./" "")))))))))


validate storm components subscribe from existing components/streams

--- src/clj/backtype/storm/daemon/common.clj
+++ src/clj/backtype/storm/daemon/common.clj
@@ -1,9 +1,11 @@
 (ns backtype.storm.daemon.common
   (:use [backtype.storm log config util])
   (:import [backtype.storm.generated StormTopology
-            InvalidTopologyException GlobalStreamId])
+            InvalidTopologyException GlobalStreamId
+            Grouping Grouping$_Fields])
   (:import [backtype.storm.utils Utils])
   (:import [backtype.storm Constants])
+  (:require [clojure.set :as set])
   (:require [backtype.storm.daemon.acker :as acker])
   (:require [backtype.storm.thrift :as thrift])
   )
@@ -126,15 +128,32 @@
       (throw (InvalidTopologyException. "May not declare inputs for a spout"))
       )))

-(defn validate-structure! [^StormTopology topology]
-  ;; TODO: validate that all subscriptions are to valid component/streams
-  )
-
 (defn all-components [^StormTopology topology]
   (apply merge {}
          (for [f thrift/STORM-TOPOLOGY-FIELDS]
            (.getFieldValue topology f)
            )))
+
+(defn validate-structure! [^StormTopology topology]
+  ;; validate all the component subscribe from component+stream which actually exists in the topology
+  ;; and if it is a fields grouping, validate the corresponding field exists
+  (let [all-components (all-components topology)]
+    (doseq [[id comp] all-components
+            :let [inputs (.. comp get_common get_inputs)]]
+      (doseq [[global-stream-id grouping] inputs
+              :let [source-component-id (.get_componentId global-stream-id)
+                    source-stream-id    (.get_streamId global-stream-id)]]
+        (if-not (contains? all-components source-component-id)
+          (throw (InvalidTopologyException. (str "Component: [" id "] subscribe from non-exists component [" source-component-id "]")))
+          (let [source-streams (-> all-components (get source-component-id) .get_common .get_streams)]
+            (if-not (contains? source-streams source-stream-id)
+              (throw (InvalidTopologyException. (str "Component: [" id "] subscribe from non-exists stream: [" source-stream-id "] of component [" source-component-id "]")))
+              (if (= Grouping$_Fields/FIELDS (.getSetField grouping))
+                (let [grouping-fields (set (.get_fields grouping))
+                      source-stream-fields (-> source-streams (get source-stream-id) .get_output_fields set)
+                      diff-fields (set/difference grouping-fields source-stream-fields)]
+                  (when-not (empty? diff-fields)
+                    (throw (InvalidTopologyException. (str "Component: [" id "] subscribe from stream: [" source-stream-id "] of component [" source-component-id "] with non-exists fields: " diff-fields)))))))))))))

 (defn acker-inputs [^StormTopology topology]
   (let [bolt-ids (.. topology get_bolts keySet)


Removed running-sum include.

Removed running-sum include.

--- src/clj/forma/hadoop/jobs/timeseries.clj
+++ src/clj/forma/hadoop/jobs/timeseries.clj
@@ -1,6 +1,5 @@
 (ns forma.hadoop.jobs.timeseries
   (:use cascalog.api
-        [forma.utils :only (running-sum)]
         [forma.matrix.utils :only (sparse-expander)]
         [forma.source.tilesets :only (tile-set)])
   (:require [cascalog.ops :as c]


use http for localhost requests to the gee-gateway

--- src/clj/org/openforis/ceo/db/geodash.clj
+++ src/clj/org/openforis/ceo/db/geodash.clj
@@ -54,9 +54,9 @@
 (defn gateway-request [{:keys [params json-params server-name]}]
   (let [path (:path params)
         url  (if (str/starts-with? server-name "local")
-               "https://ceodev.servirglobal.net"
-               "https://localhost")]
-    (client/post (str url ":8888/" path)
+               "https://ceodev.servirglobal.net:8888/"
+               "http://localhost:8881/")]
+    (client/post (str url path)
                  {:body (tc/clj->json json-params)
                   :content-type :json
                   :accept :json})))


refactor KMP more

refactor KMP more

--- src/cljs/strmatch/logic/kmp_matcher.cljs
+++ src/cljs/strmatch/logic/kmp_matcher.cljs
@@ -37,12 +37,17 @@
      :colors (color-array padding length-of-match)}))

 (defn match
-  ([needle haystack] (vec (reverse (match needle haystack (failure-array needle) 0 nil 0))))
-  ([needle haystack fail-array index result prev-fail]
-   (let [discrep (discrepancy-index needle haystack index)
-         jump (- discrep (fail-array discrep))
-         next-entry (entry-for index discrep needle prev-fail)
-         next-result (cons next-entry result)]
-     (if (and discrep (<= index (count haystack)))
-       (recur needle haystack fail-array (+ index jump) next-result (fail-array discrep))
-       next-result))))
+  [needle haystack]
+  (let [fail-array (failure-array needle)]
+    (loop [index 0
+           result []
+           prev-fail 0]
+      (let [discrep (discrepancy-index needle haystack index)
+            jump (- discrep (fail-array discrep))
+            next-index (+ index jump)
+            next-entry (entry-for index discrep needle prev-fail)
+            next-result (conj result next-entry)
+            not-done (and discrep (<= index (count haystack)))]
+        (if not-done
+          (recur next-index next-result (fail-array discrep))
+          next-result)))))


Add doesnt-clone-genetically diversification test

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -846,6 +846,12 @@
               {:genome (produce-child-genome-by-autoconstruction g g argmap)}
               argmap)))))

+(defn doesnt-clone-genetically-diversifying?
+  [ind argmap]
+  (let [g (:genome ind)]
+    (assoc ind :diversifying
+      (not= g (produce-child-genome-by-autoconstruction g g argmap)))))
+
 (defn child-doesnt-clone-diversifying?
   [ind argmap]
   (let [g (:genome ind)]
@@ -1155,6 +1161,7 @@
                 :use-mate-differently use-mate-differently-diversifying?
                 :si-and-mate-use si-and-mate-use-diversifying?
                 :doesnt-clone doesnt-clone-diversifying?
+                :doesnt-clone-genetically doesnt-clone-genetically-diversifying?
                 :child-doesnt-clone child-doesnt-clone-diversifying?
                 :not-a-clone not-a-clone-diversifying?
                 :minimum-genetic-difference minimum-genetic-difference-diversifying?


Use clojush.pushgp.selection.selection in clojush.pushgp.genetic-operators

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -1,6 +1,7 @@
 (ns clojush.pushgp.genetic-operators
   (:use [clojush util random individual globals interpreter translate pushstate]
         [clojush.instructions tag gtm]
+        [clojush.pushgp.selection.selection]
         [clojure.math.numeric-tower])
   (:import (org.apache.commons.math3.stat.inference TTest))
   (:require [clojure.string :as string]))
@@ -1736,3 +1737,4 @@
                            :grain-size (compute-grain-size [] argmap)
                            :ancestors ()
                            :is-random-replacement true))))))
+


Use console.warn instead of log

Use console.warn instead of log

--- src/adzerk/boot_reload/client.cljs
+++ src/adzerk/boot_reload/client.cljs
@@ -23,9 +23,9 @@
         protocol   (.getScheme passed-uri)
         host       (or ws-host
                        (.-hostname (.-location js/window))
-                       (do (js/console.log "Both :ws-host and window.location.hostname are empty."
-                                           "This might happen if you are accessing the files directly instead of over http."
-                                           "You should probably set :ws-host manually.")
+                       (do (js/console.warn "Both :ws-host and window.location.hostname are empty."
+                                            "This might happen if you are accessing the files directly instead of over http."
+                                            "You should probably set :ws-host manually.")
                            nil))
         port       (.getPort passed-uri)]
     (str protocol "://" host ":" port)))


rewritten code to use transducers for single pass solution

--- exercises/pangram/src/example.clj
+++ exercises/pangram/src/example.clj
@@ -1,15 +1,13 @@
-(ns pangram
-  (:require [clojure.string :refer [lower-case]]))
+(ns pangram)

-(def ^:private a-int (int \a))
-(def ^:private z-int (int \z))
-
-(def ^:private alphabet (set (range a-int (inc z-int))))
+(def ^:private in-range? ((fn [] (let [start (int \a)
+                                       end (inc (int \z))]
+                                   #(<= start (int %) end)))))

 (defn pangram? [input]
-  (= alphabet
-     (->> input
-          lower-case
-          (map int)
-          (filter #(<= a-int % z-int))
-          set)))
+  (->> input
+       (into [] (comp (map #(Character/toLowerCase %))
+                      (filter in-range?)
+                      (distinct)))
+       count
+       (= 26)))


Remove requirement for .boot extension on scripts (fixes #105)

--- boot/core/src/boot/main.clj
+++ boot/core/src/boot/main.clj
@@ -76,17 +76,25 @@
           (when-let [main# (resolve 'boot.user/-main)] (main# ~@argv))
           (core/boot ~@(or (seq argv) ["boot.task.built-in/help"])))))))

+(defn shebang? [arg]
+  (when (and (<= 0 (.indexOf arg (int \/))) (.exists (io/file arg)))
+    (let [bang-line (str (first (string/split (slurp arg) #"\n")))
+          full-path (System/getProperty "boot.app.path")
+          base-path (.getName (io/file full-path))
+          full-pat  (re-pattern (format "^#!\\s*\\Q%s\\E(?:\\s+.*)?$" full-path))
+          base-pat  (re-pattern (format "^#!\\s*/usr/bin/env\\s+\\Q%s\\E(?:\\s+.*)?$" base-path))]
+      (or (re-find full-pat bang-line) (re-find base-pat bang-line)))))
+
 (defn -main [pod-id worker-pod shutdown-hooks [arg0 & args :as args*]]
   (reset! pod/pod-id pod-id)
   (reset! pod/worker-pod worker-pod)
   (reset! pod/shutdown-hooks shutdown-hooks)

-  (let [dotboot?         #(.endsWith (.getName (io/file %)) ".boot")
-        script?          #(when (and % (.isFile (io/file %)) (dotboot? %)) %)
-        bootscript       "build.boot"
-        have-bootscript? (script? bootscript)
+  (let [bootscript       "build.boot"
+        exists?          #(when (.isFile (io/file %)) %)
+        have-bootscript? (exists? bootscript)
         [arg0 args]      (cond
-                           (script? arg0)   [arg0 args]
+                           (shebang? arg0)  [arg0 args]
                            have-bootscript? [bootscript args*]
                            :else            [nil args*])
         boot?            (contains? #{nil bootscript} arg0)
@@ -106,7 +114,7 @@
       (util/exit-ok
         (let [userscript  (-> (System/getProperty "user.home")
                               (io/file ".profile.boot")
-                              script?)
+                              exists?)
               verbosity   (if (:quiet opts)
                             (* -1 @util/*verbosity*)
                             (or (:verbose opts) 0))


Fixes #73.

Fixes #73.

--- src/onyx/api.clj
+++ src/onyx/api.clj
@@ -118,7 +118,8 @@

     (extensions/write-log-entry (:log client) entry)
     (component/stop client)
-    id))
+    {:job-id id
+     :task-ids tasks}))

 (defn ^{:added "0.6.0"} kill-job
   "Kills a currently executing job, given it's job ID. All peers executing


Fixes #4783

Fixes #4783

--- src/status_im/ui/screens/add_new/new_public_chat/view.cljs
+++ src/status_im/ui/screens/add_new/new_public_chat/view.cljs
@@ -29,6 +29,7 @@
        :on-submit-editing   #(when (and topic (spec/valid? ::v/topic topic))
                                (re-frame/dispatch [:create-new-public-chat topic]))
        :auto-capitalize     :none
+       :auto-focus          false
        :accessibility-label :chat-name-input
        :placeholder         nil
        :return-key-type     :go


:pencil2: Fix typo for i18n key

:pencil2: Fix typo for i18n key


rename fn with-storage -> update-in-storage

--- src/shoutout.clj
+++ src/shoutout.clj
@@ -89,7 +89,7 @@
   [storage feature-name]
   (parse-feature feature-name (read-from-storage storage feature-name)))

-(defn with-storage
+(defn update-in-storage
   "alter a feature using the supplied function f. handles reading, serializing,
   deserializing, you just write f to modify the feature as wanted"
   [storage feature-name f]
@@ -100,7 +100,7 @@
 (defn activate
   "completely activate a feature for all users"
   [{storage :storage} feature-name]
-  (with-storage
+  (update-in-storage
     #(assoc %
             :percentage
             100)))
@@ -109,7 +109,7 @@
   "activate a feature for a particular group.
   A group should just be a string"
   [{storage :storage} feature-name group]
-  (with-storage
+  (update-in-storage
     (fn [feature]
       (update-in feature
                 :groups
@@ -119,7 +119,7 @@
   "deactivate a feature for a particular group.
   A group is just a string"
   [{storage :storage} feature-name group]
-  (with-storage
+  (update-in-storage
     (fn [feature]
       (update-in feature
                  :groups
@@ -128,7 +128,7 @@
 (defn activate-user
   "activate a feature for a particular user"
   [{storage :storage} feature-name user]
-  (with-storage
+  (update-in-storage
     (fn [feature]
       (update-in feature
                 :users
@@ -137,7 +137,7 @@
 (defn deactivate-user
   "deactivate a feature for a particular user"
   [{storage :storage} feature-name user]
-  (with-storage
+  (update-in-storage
     (fn [feature]
       (update-in feature
                  :users
@@ -147,7 +147,7 @@
   "activate a feature for a percentage of users.
   percentages are out of 100"
   [{storage :storage} feature-name percent]
-  (with-storage
+  (update-in-storage
     (fn [feature]
       (assoc feature
              :percentage


minor dependency updates

minor dependency updates

--- kuona-api/project.clj
+++ kuona-api/project.clj
@@ -17,7 +17,7 @@
                  [cheshire "5.8.1"]
                  [clj-http "3.9.1"]
                  [clj-jgit "0.8.10"]
-                 [clj-time "0.14.4"]
+                 [clj-time "0.15.1"]
                  [clojurewerkz/quartzite "2.1.0"]
                  [com.jcabi/jcabi-log "0.18"]
                  [commons-codec/commons-codec "1.11"]
@@ -30,7 +30,7 @@
                  [org.gradle/gradle-tooling-api "4.10.2"]
                  [org.slf4j/slf4j-log4j12 "1.7.25"]
                  [ring/ring-defaults "0.3.2"]
-                 [ring/ring-jetty-adapter "1.7.0"]
+                 [ring/ring-jetty-adapter "1.7.1"]
                  [ring/ring-json "0.4.0"]
                  [slingshot "0.12.2"]
                  ]
@@ -46,5 +46,5 @@
          :auto-refresh true}
   :profiles {:dev     {:dependencies [[javax.servlet/servlet-api "2.5"]
                                       [ring/ring-mock "0.3.2"]
-                                      [midje "1.9.3"]]}
+                                      [midje "1.9.4"]]}
              :uberjar {:aot :all}})


use WeakSet for caching validator results

--- cljs/src/common/plastic/validator.cljs
+++ cljs/src/common/plastic/validator.cljs
@@ -5,17 +5,16 @@

 ; shared validation utils

-; note: we don't clear this cache, it is just a bool per object instance (under dev environment)
-(defonce *valid-ids* #js {})
+; see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet
+(assert js/WeakSet)
+(defonce *valid-objects* (js/WeakSet.))

 (defn check-or-update-cache! [schema obj]
-  (let [id (goog/getUid obj)
-        lookup (gobj/get *valid-ids* id)]
-    (if lookup
-      true
-      (when (nil? (s/check schema obj))
-        (gobj/set *valid-ids* id true)
-        true))))
+  (if (.has *valid-objects* obj)
+    true
+    (when (nil? (s/check schema obj))
+      (.add *valid-objects* obj)
+      true)))

 ;  to speed up validation we can cache some expensive validation results
 (defn cached [schema]


handle asset_paths being nil

handle asset_paths being nil

--- src-cljs/frontend/stefon.cljs
+++ src-cljs/frontend/stefon.cljs
@@ -6,10 +6,10 @@
   "Returns the data-uri version of the image for the given url.
    Image must be specified in resources/assets/js/stefon-hack-for-om.coffee.ref!"
   [url]
-  (let [uri-string (-> js/window
-                       (aget "stefon_hack_for_om")
-                       (aget "data_uris")
-                       (aget url))]
+  (let [uri-string (some-> js/window
+                           (aget "stefon_hack_for_om")
+                           (aget "data_uris")
+                           (aget url))]
     (if uri-string
       uri-string
       (utils/mwarn "Unable to find data-uri for" url
@@ -20,10 +20,10 @@
    the link to the cdn version if we're in the right environment.
    Path must be specified in resources/assets/js/stefon-hack-for-om.coffee.ref!"
   [path]
-  (let [uri-string (-> js/window
-                       (aget "stefon_hack_for_om")
-                       (aget "asset_paths")
-                       (aget path))]
+  (let [uri-string (some-> js/window
+                           (aget "stefon_hack_for_om")
+                           (aget "asset_paths")
+                           (aget path))]
     (if uri-string
       (utils/cdn-path uri-string)
       (utils/mwarn "Unable to find asset-path for" path


(PDB-5022) migrate: convert doall to doseqs for more idiomatic side-effects

--- src/puppetlabs/puppetdb/scf/migrate.clj
+++ src/puppetlabs/puppetdb/scf/migrate.clj
@@ -843,16 +843,14 @@
   (jdbc/call-with-query-rows
    ["select id from factsets where hash is null"]
    (fn [rows]
-     (doseq [batch (partition-all 500 rows)]
-       (doall
-        (map #(jdbc/do-prepared
-               "update factsets set hash=? where id=?"
-               [(-> (:id %)
-                    .toString
-                    kitchensink/utf8-string->sha1
-                    sutils/munge-hash-for-storage)
-                (:id %)])
-             batch)))))
+     (doseq [batch (partition-all 500 rows)
+             row batch]
+       (jdbc/do-prepared "update factsets set hash=? where id=?"
+                         [(-> (:id row)
+                              .toString
+                              kitchensink/utf8-string->sha1
+                              sutils/munge-hash-for-storage)
+                          (:id row)]))))

   (jdbc/do-commands
    "ALTER TABLE factsets ALTER COLUMN hash SET NOT NULL"))


(PDB-4641) get unique dates properly in UTC

Force the timezone to UTC for determining the unique dates of
resource_events.

PostgreSQL returns dates in the client's timezone. What we need to do
here is force the connection into UTC. We want the date of the event, in
UTC, so that we can create the partition for it. To do this, we have the
find_resource_events_unique_dates plpgsql function above. For the
duration of this migration transaction, dates will be displayed in UTC.
If the timezone is in the local timezone (say, EST, or CEST), you get
the date in that timezone with the time cut off. So,
2020-01-30T05:00:00Z, which truncates to 2020-01-30 using the pgsql date
functions. In reality, this is actually 2020-01-31 in UTC, which is the
date we need for creating the partition successfully.

--- src/puppetlabs/puppetdb/scf/migrate.clj
+++ src/puppetlabs/puppetdb/scf/migrate.clj
@@ -69,9 +69,10 @@
             [puppetlabs.puppetdb.scf.storage :as scf]
             [puppetlabs.puppetdb.scf.partitioning :as partitioning])
   (:import [org.postgresql.util PGobject]
-           [java.time LocalDate ZonedDateTime ZoneId]
+           [java.time LocalDate ZonedDateTime ZoneId OffsetDateTime]
            (java.sql Timestamp)
-           (java.time.temporal ChronoUnit)))
+           (java.time.temporal ChronoUnit)
+           (java.time.format DateTimeFormatter)))

 (defn init-through-2-3-8
   []
@@ -1606,46 +1607,56 @@
    (reporting-partitioned-tables 500))
   ([batch-size]
    (jdbc/do-commands
-    "ALTER TABLE resource_events RENAME TO resource_events_premigrate"
-
-    "CREATE TABLE resource_events (
-       event_hash bytea NOT NULL PRIMARY KEY,
-       report_id bigint NOT NULL,
-       certname_id bigint NOT NULL,
-       status text NOT NULL,
-       \"timestamp\" timestamp with time zone NOT NULL,
-       resource_type text NOT NULL,
-       resource_title text NOT NULL,
-       property text,
-       new_value text,
-       old_value text,
-       message text,
-       file text DEFAULT NULL::character varying,
-       line integer,
-       name text,
-       containment_path text[],
-       containing_class text,
-       corrective_change boolean)"
-
-    "CREATE OR REPLACE FUNCTION resource_events_insert_trigger()
-    RETURNS TRIGGER AS $$
-    DECLARE
-      tablename varchar;
-    BEGIN
-      SELECT FORMAT('resource_events_%sZ',
-                    TO_CHAR(NEW.\"timestamp\" AT TIME ZONE 'UTC', 'YYYYMMDD')) INTO tablename;
-
-      EXECUTE 'INSERT INTO ' || tablename || ' SELECT ($1).*'
-      USING NEW;
-
-      RETURN NULL;
-    END;
-    $$
-    LANGUAGE plpgsql;"
-
-    "CREATE TRIGGER insert_resource_events_trigger
-    BEFORE INSERT ON resource_events
-    FOR EACH ROW EXECUTE PROCEDURE resource_events_insert_trigger();")
+     "ALTER TABLE resource_events RENAME TO resource_events_premigrate"
+
+     "CREATE TABLE resource_events (
+        event_hash bytea NOT NULL PRIMARY KEY,
+        report_id bigint NOT NULL,
+        certname_id bigint NOT NULL,
+        status text NOT NULL,
+        \"timestamp\" timestamp with time zone NOT NULL,
+        resource_type text NOT NULL,
+        resource_title text NOT NULL,
+        property text,
+        new_value text,
+        old_value text,
+        message text,
+        file text DEFAULT NULL::character varying,
+        line integer,
+        name text,
+        containment_path text[],
+        containing_class text,
+        corrective_change boolean)"
+
+     "CREATE OR REPLACE FUNCTION resource_events_insert_trigger()
+     RETURNS TRIGGER AS $$
+     DECLARE
+       tablename varchar;
+     BEGIN
+       SELECT FORMAT('resource_events_%sZ',
+                     TO_CHAR(NEW.\"timestamp\" AT TIME ZONE 'UTC', 'YYYYMMDD')) INTO tablename;
+
+       EXECUTE 'INSERT INTO ' || tablename || ' SELECT ($1).*'
+       USING NEW;
+
+       RETURN NULL;
+     END;
+     $$
+     LANGUAGE plpgsql;"
+
+     "CREATE TRIGGER insert_resource_events_trigger
+     BEFORE INSERT ON resource_events
+     FOR EACH ROW EXECUTE PROCEDURE resource_events_insert_trigger();"
+
+     "CREATE OR REPLACE FUNCTION find_resource_events_unique_dates()
+     RETURNS TABLE (rowdate DATE)
+     AS $$
+     DECLARE
+     BEGIN
+       EXECUTE 'SET local timezone to ''UTC''';
+       RETURN QUERY SELECT DISTINCT \"timestamp\"::DATE AS rowdate FROM resource_events_premigrate;
+     END;
+     $$ language plpgsql;")

   ;; create range of partitioned tables

@@ -1667,15 +1678,26 @@

    ;; pre-create partitions
    (log/info (trs "Creating partitions based on unique days in resource_events"))
-   (jdbc/call-with-query-rows
-    ["select distinct date_trunc('day', \"timestamp\") as rowdate
-      from resource_events_premigrate"]
-    (fn [rows]
-      (doseq [row rows]
-        (partitioning/create-resource-events-partition (-> (:rowdate row)
-                                                           (.toInstant)
-                                                           (ZonedDateTime/ofInstant (ZoneId/of "UTC"))
-                                                           (.truncatedTo (ChronoUnit/DAYS)))))))
+   ;; PDB-4641 - PostgreSQL returns dates in the client's timezone. What we need
+   ;; to do here is force the connection into UTC. We want the date of the event,
+   ;; in UTC, so that we can create the partition for it. To do this, we have
+   ;; the find_resource_events_unique_dates plpgsql function above. For the duration
+   ;; of this migration transaction, dates will be displayed in UTC.
+   ;; If the timezone is in the local timezone (say, EST, or CEST), you get the date
+   ;; in that timezone with the time cut off. So, 2020-01-30T05:00:00Z, which truncates
+   ;; to 2020-01-30 using the pgsql date functions. In reality, this is actually
+   ;; 2020-01-31 in UTC, which is the date we need for creating the partition successfully.
+   (let [current-timezone (:current_setting (first (jdbc/query-to-vec "SELECT current_setting('TIMEZONE')")))]
+     (jdbc/call-with-query-rows
+       ["select rowdate from find_resource_events_unique_dates()"]
+       (fn [rows]
+         (doseq [row rows]
+           (partitioning/create-resource-events-partition (-> (:rowdate row)
+                                                              (.toLocalDate)
+                                                              (.atStartOfDay (ZoneId/of "UTC")))))))
+     (jdbc/do-commands
+       ;; restore the transaction's timezone setting after creating the partitions
+       (str "SET local timezone to '" current-timezone "'")))

   (let [event-count (-> "select count(*) from resource_events_premigrate"
                         jdbc/query-to-vec first :count)
@@ -1753,7 +1775,8 @@

   (jdbc/do-commands
    ;; Indexes are created on the individual partitions, not on the base table
-   "DROP TABLE resource_events_premigrate")))
+   "DROP TABLE resource_events_premigrate"
+   "DROP FUNCTION find_resource_events_unique_dates()")))

 (def migrations
   "The available migrations, as a map from migration version to migration function."


Factor out timestamp-of-newest-record

Factor out timestamp-of-newest-record

--- src/puppetlabs/puppetdb/scf/storage.clj
+++ src/puppetlabs/puppetdb/scf/storage.clj
@@ -42,7 +42,8 @@
             [metrics.histograms :refer [histogram update!]]
             [metrics.timers :refer [timer time!]]
             [puppetlabs.puppetdb.jdbc :refer [query-to-vec dashes->underscores]]
-            [puppetlabs.puppetdb.time :refer [to-timestamp]]))
+            [puppetlabs.puppetdb.time :refer [to-timestamp]]
+            [honeysql.core :as hcore]))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Schemas
@@ -1184,17 +1185,25 @@
                     WHERE certname=? AND deactivated IS NULL"
                    [(to-timestamp (now)) certname]))

+
+(defn- timestamp-of-newest-record [entity certname]
+  (let [query {:select [:timestamp]
+               :from [entity]
+               :where [:= :certname certname]
+               :order-by [[:timestamp :desc]]
+               :limit 1}]
+    (sql/with-query-results result-set (hcore/format query)
+      (:timestamp (first result-set)))))
+
 (pls/defn-validated catalog-newer-than?
   "Returns true if the most current catalog for `certname` is more recent than
   `time`."
   [certname :- String
    time :- pls/Timestamp]
-  (let [timestamp (to-timestamp time)]
-    (sql/with-query-results result-set
-      ["SELECT timestamp FROM catalogs WHERE certname=? ORDER BY timestamp DESC LIMIT 1" certname]
-      (if-let [catalog-timestamp (:timestamp (first result-set))]
-        (.after catalog-timestamp timestamp)
-        false))))
+  (let [time (to-timestamp time)]
+    (if-let [db-timestamp (timestamp-of-newest-record :catalogs certname)]
+      (.after db-timestamp time)
+      false)))

 (pls/defn-validated replace-catalog!
   "Given a catalog, replace the current catalog, if any, for its


fix bug that prevented deleting entities

--- src/cljs/flow_editor/handlers/flow_runtime.cljs
+++ src/cljs/flow_editor/handlers/flow_runtime.cljs
@@ -79,7 +79,6 @@
   :flow-runtime/remove-entity
   (fn [db [_ entity-id]]
     (.removeEntity (:runtime db) entity-id)
-    (dispatch [:flow-runtime-ui/close-node {:id entity-id :type "entity"}]);
     (update-runtime db)))

@@ -158,7 +157,6 @@
   :flow-runtime/remove-process
   (fn [db [_ process-id]]
     (.removeProcess (:runtime db) process-id)
-    (dispatch [:flow-runtime-ui/close-node {:id process-id :type "process"}]);
     (update-runtime db)))


fix graph node dragging bug

fix graph node dragging bug

--- src/cljs/flow_editor/handlers/flow_runtime.cljs
+++ src/cljs/flow_editor/handlers/flow_runtime.cljs
@@ -228,11 +228,11 @@
                      (clj->js (-> item
                                 (assoc-in [:meta :ui :x] (get val "x"))
                                 (assoc-in [:meta :ui :y] (get val "y")))))]
-        (when (= type :entity)
-          (when-let [e (get-in db [:graph :entities id])]
+        (when (= type "entity")
+          (when-let [e (get-in db [:graph :entities (keyword id)])]
             (.addEntity (:runtime db) (update e))))
-        (when (= type :process)
-          (when-let [p (get-in db [:graph :processes id])]
+        (when (= type "process")
+          (when-let [p (get-in db [:graph :processes (keyword id)])]
             (.addProcess (:runtime db) (update p))))))
     (update-runtime db)))


Documented new opencl macros and functions.

--- src/clojure/uncomplicate/neanderthal/opencl.clj
+++ src/clojure/uncomplicate/neanderthal/opencl.clj
@@ -20,6 +20,14 @@
 (def ^:dynamic *opencl-factory*)

 (defmacro with-engine
+  "Creates a concrete OpenCL factory that executes in the provided queue,
+  and binds *opencl-factory* to it. Enables the use of clv and clge in body.
+
+  (with-default
+    (with-engine clblast-single *command-queue*
+      (with-release [gpu-x (clv (range 3))]
+        (sum gpu-x))))
+  "
   ([factory queue & body]
    `(binding [*opencl-factory* (~factory (queue-context ~queue) ~queue)]
       (try
@@ -27,13 +35,30 @@
         (finally (release *opencl-factory*))))))

 (defmacro with-default-engine
-  ([& body]
-   `(binding [*opencl-factory* (clblast-single *context* *command-queue*)]
-      (try
-        ~@body
-        (finally (release *opencl-factory*))))))
+  "Creates a concrete single-precision CLBlast OpenCL factory that executes
+  in the default context and queue, and binds *opencl-factory* to it.
+  clv and clge in its body will create single-precision blocks.

-(defn host [cl]
+  (with-default
+    (with-default-engine
+      (with-release [gpu-x (clv (range 3))]
+        (sum gpu-x))))
+  "
+  [& body]
+  `(binding [*opencl-factory* (clblast-single *context* *command-queue*)]
+     (try
+       ~@body
+       (finally (release *opencl-factory*)))))
+
+(defn host
+  "Transfers cl object from the device memory to the appropriate structure
+  on the host. A more convenient and (sometimes) a slightly faster alternative
+  to transfer!
+
+  (host (clv [1 2 3]))
+  (host (clge 2 3 (range 6)))
+  "
+  [cl]
   (let-release [raw-host (p/raw cl (p/factory (p/factory cl)))]
     (cl-to-host cl raw-host)))


GAWB-1818: changing position of message

GAWB-1818: changing position of message

--- src/cljs/main/broadfcui/page/method_repo/create_method.cljs
+++ src/cljs/main/broadfcui/page/method_repo/create_method.cljs
@@ -44,8 +44,6 @@
          (style/create-form-label "Documentation (optional)")
          (style/create-text-area {:ref "documentation" :style {:width "100%"} :rows 5})

-         [:div {:style {:marginBottom "0.8em" :fontSize "88%"}} "WDL must use Docker image digests to allow call caching"
-          (common/question-icon-link "Guide to Call Caching" (config/call-caching-guide-url))]
          [:input {:type "file" :ref "wdl-uploader" :style {:display "none"}
                   :onChange (fn [e]
                               (let [file (-> e .-target .-files (aget 0))
@@ -87,7 +85,9 @@
          [CodeMirror {:ref "wdl-editor" :read-only? false}]

          [comps/ErrorViewer {:error (:upload-error @state)}]
-         (style/create-validation-error-message (:validation-errors @state))])
+         (style/create-validation-error-message (:validation-errors @state))
+         [:div {:style {:marginTop "0.8em" :fontSize "88%"}} "WDL must use Docker image digests to allow call caching"
+          (common/question-icon-link "Guide to Call Caching" (config/call-caching-guide-url))]])
        :ok-button (react/create-element
                    [comps/Button {:ref "ok-button" :text "Upload" :onClick #(react/call :create-method this)}])}])
    :component-did-mount


Do not send pin to board link in case entry is in a private board.

--- src/oc/storage/representations/entry.clj
+++ src/oc/storage/representations/entry.clj
@@ -284,7 +284,7 @@
                         bookmarks-link
                         user-visibility-link])
                ;; Add home pin link only if it's a non private board and user is member
-               (and member? (not= board-access :private))
+               (and member? (not= board-access "private"))
                (concat [home-pin-link])
                 ;; Add board pin link only if user is member
                member?


Fix flow conditions route IDs. Route no where when exception without handlers.

--- src/onyx/flow_conditions/fc_routing.cljc
+++ src/onyx/flow_conditions/fc_routing.cljc
@@ -40,7 +40,7 @@
       (let [e (:exception (ex-data message))]
         (lc/handle-exception
          event :lifecycle/apply-fn e (:compiled-handle-exception-fn compiled)))
-      (->Route egress-ids nil nil nil))
+      (->Route [] nil nil nil))
     (if (exception? message)
       (if (seq compiled-ex-fcs)
         (choose-output-paths event compiled-ex-fcs result (:exception (ex-data message)) egress-ids)


all thread and author data

all thread and author data

--- src/bonews_rest/scraper/forums.clj
+++ src/bonews_rest/scraper/forums.clj
@@ -14,6 +14,20 @@
   (-> (url-by-page subforum page)
       (utils/fetch-url)
       (html/select [:div#phorum :table])))
+
+(defn get-thread-num-replies
+  [col]
+  (let [replies (first (first (rest (first (rest (rest col))))))]
+  (Integer/parseInt replies)))
+
+(defn get-thread-last-update
+  [col]
+  (first (:content col)))
+
+(defn get-author-url
+  [col]
+  (let [title-node (html/select col [[:a (html/attr? :href)]])]
+  (:href (first (rest (first (rest (last title-node))))))))

 (defn get-thread-author
   [col]
@@ -35,13 +49,21 @@
   (let [cols (rest (html/select row [:td]))
         thread-title (get-thread-title (first cols))
         thread-url (get-thread-url (first cols))
-        thread-author (get-thread-author (first cols))]
-  {:url thread-url :title thread-title :author thread-author}))
+        thread-last-update (get-thread-last-update (last cols))
+        thread-num-replies (get-thread-num-replies (first (rest cols)))
+        thread-author (get-thread-author (first cols))
+        author-url (get-author-url (first cols))]
+  {:thread-url thread-url
+   :thread-title thread-title
+   :thread-num-replies thread-num-replies
+   :thread-last-update thread-last-update
+   :author thread-author
+   :author-url author-url}))

 (defn get-rows
   [table]
   (map-indexed vector
-    (for [row (html/select table [:tr])
+    (for [row (rest (html/select table [:tr]))
       :let [cols (get-cols row)]
       :when (seq cols)]
     cols)))


wip motion params

wip motion params

--- src/cap_and_send/webcam/motion.clj
+++ src/cap_and_send/webcam/motion.clj
@@ -13,8 +13,12 @@
   (fs/copy+ "resources/motion.conf" newfile)
   newfile)

-(defn- alter-conf [file new-thing new-thing2]
+(defn- alter-conf [file motion-dir device]
   ())
+
+(defn- do-motion-conf [config-dest motion-dir device] ""
+  (copy-conf-to-new config-dest)
+  (alter-conf config-dest motion-dir device))

 (defn- do-motion [motion-dir device] ""
   (println "INFO running motion with output dir: " motion-dir " and device: " device)


criteria in dfs

criteria in dfs

--- src/clj/morpheus/traversal/dfs.clj
+++ src/clj/morpheus/traversal/dfs.clj
@@ -7,7 +7,8 @@
             [clojure.core.async :as a]
             [neb.core :as neb]
             [cluster-connector.utils.for-debug :refer [$ spy]]
-            [morpheus.models.edge.base :as eb])
+            [morpheus.models.edge.base :as eb]
+            [morpheus.query.lang.AST :as AST])
   (:import (java.util.concurrent TimeoutException)))

 ;; Distributed deepeth first search divised by S.A.M. Makki and George Havas
@@ -25,7 +26,10 @@
 (defn proc-forward-msg [task-id data]
   (let [[vertex-id stack] data
         {:keys [filters max-deepth stop-cond path-only? tail-only?]} (compute/get-task task-id)
-        neighbours (apply edges/neighbours-edges (vertex/get-veterx-by-id vertex-id) (if filters (mapcat identity filters) []))
+        vertex (vertex/get-veterx-by-id vertex-id)
+        vertex-criteria (get-in filters [:criteria :vertex])
+        vertex-vailed (if vertex-criteria (AST/eval-with-data vertex vertex-criteria) true)
+        neighbours (if vertex-vailed (apply edges/neighbours-edges vertex (if filters (mapcat identity filters) [])) [])
         current-vertex-stat (atom nil)
         proced-stack (doall (map (fn [v]
                                    (let [[svid] v]
@@ -35,6 +39,9 @@
                                            )
                                        v)))
                                  stack))
+        proced-stack (if vertex-vailed
+                       proced-stack
+                       (filter (fn [[svid]] (not= svid vertex-id)) proced-stack))
         deepth (@current-vertex-stat 2)
         next-depth (inc deepth)
         stack-verteics (set (map first stack))


Don't println on every nrepl execution

Don't println on every nrepl execution

Fixes the extra line break on completion in nrepl mode

--- src/clj/reply/eval_modes/nrepl.clj
+++ src/clj/reply/eval_modes/nrepl.clj
@@ -32,7 +32,6 @@
         (when err ((:err options print) err))
         (flush)
         (when ns (reset! current-ns ns)))))
-    (println)
     (reset! current-command-id nil)
     @current-ns))

@@ -41,6 +40,7 @@
   ([connection {:keys [prompt] :as options}]
     (let [{:keys [major minor incremental qualifier]} *clojure-version*]
       (loop [ns "user"]
+        (println)
         (prompt ns)
         (flush)
         (let [done (Object.)


basic om.next ui component setup

basic om.next ui component setup

--- src/tudu/ui.cljs
+++ src/tudu/ui.cljs
@@ -1,8 +1,15 @@
-(ns tudu.ui)
+(ns tudu.ui
+  (:require [goog.dom :as gdom]
+            [om.next :as om :refer-macros [defui]]
+            [om.dom :as dom]))

 (enable-console-print!)

-(prn "hello world!")
-(.log js/console "hello console!")
-(.alert js/window "hello world!")
+(defui UI
+  Object
+  (render [this]
+          (dom/div nil "hello om.next")))

+(def reconciler (om/reconciler {}))
+
+(om/add-root! reconciler UI (gdom/getElement "main-app-area"))


Image create example improving.

Image create example improving.

--- src/quil_cljs_examples/image/create.cljs
+++ src/quil_cljs_examples/image/create.cljs
@@ -10,7 +10,8 @@
 	(q/set-pixel @img 10 10 (q/color 0 90 102))

 	(reset! new-img (q/create-image 50 50 :rgb))
-	(q/copy @img @new-img [0 0 50 50] [0 0 50 50]))
+	(q/copy @img @new-img [0 0 50 50] [0 0 50 50])
+	(q/resize @new-img 25 25))

 (defn draw []


Skip watchers loop when they are none

Skip watchers loop when they are none

--- src/com/wsscode/pathom/parser.cljc
+++ src/com/wsscode/pathom/parser.cljc
@@ -370,14 +370,15 @@
                                 ::provides       provides
                                 ::response-value response-value})
                     (swap! (:com.wsscode.pathom.core/entity env) merge response-value)
-                    (doseq [pkey provides]
-                      (trace env {::pt/event      ::flush-watchers
-                                  :key            pkey
-                                  ::watcher-count (count (get @key-watchers pkey))})
-                      (doseq [out (get @key-watchers pkey)]
-                        (async/put! out {::provides #{pkey}})
-                        (async/close! out))
-                      (swap! key-watchers dissoc pkey))
+                    (when (seq @key-watchers)
+                      (doseq [pkey provides]
+                        (trace env {::pt/event      ::flush-watchers
+                                    :key            pkey
+                                    ::watcher-count (count (get @key-watchers pkey))})
+                        (doseq [out (get @key-watchers pkey)]
+                          (async/put! out {::provides #{pkey}})
+                          (async/close! out))
+                        (swap! key-watchers dissoc pkey)))
                     (recur (cond-> res
                              merge-result?
                              (merge response-value))


Fixed kibit error in acl-lib.

Fixed kibit error in acl-lib.

--- acl-lib/src/cmr/acl/acl_fetcher.clj
+++ acl-lib/src/cmr/acl/acl_fetcher.clj
@@ -80,24 +80,27 @@
     ;; Otherwise we'd just silently fail to find any acls.
     (if-let [not-cached-oits (seq (set/difference
                                     (set object-identity-types)
-                                    (set (context->cached-object-identity-types context))))]
+                                    (set (context->cached-object-identity-types
+                                           context))))]
       (do
-        (info (str "The application is not configured to cache acls of the following"
-                   " object-identity-types so we will fetch them from ECHO each time they are needed. "
+        (info (str "The application is not configured to cache acls of the "
+                   "following object-identity-types so we will fetch them "
+                   "from ECHO each time they are needed. "
                    (pr-str not-cached-oits)))
         (echo-acls/get-acls-by-types context object-identity-types))
       ;; Fetch ACLs using a cache
-      (->> (cache/get-value
-             cache
-             acl-cache-key
-             #(echo-acls/get-acls-by-types
-                context
-                ;; All of the object identity types needed by the application are fetched. We want
-                ;; the cache to contain all of the acls needed.
-                (context->cached-object-identity-types context)))
-           (filter (fn [acl]
-                     (some #(get acl (echo-acls/acl-type->acl-key %))
-                           object-identity-types)))))
+      (filter
+        (fn [acl]
+          (some #(get acl (echo-acls/acl-type->acl-key %))
+                object-identity-types))
+        (cache/get-value
+          cache
+          acl-cache-key
+          #(echo-acls/get-acls-by-types
+             context
+             ;; All of the object identity types needed by the application are
+             ;; fetched. We want the cache to contain all of the acls needed.
+             (context->cached-object-identity-types context)))))

     ;; No cache is configured. Directly fetch the acls.
     (echo-acls/get-acls-by-types context object-identity-types)))


fix typo

fix typo

--- src/babel/espanol/lexicon.clj
+++ src/babel/espanol/lexicon.clj
@@ -408,23 +408,24 @@
                        :sem {:pred :talk
                              :subj {:human true}}}}]

-   "hacer" {:espanol {:future-stem "har"
-                   :present {:1sing "hago"
-                             :2sing "haces"
-                             :3sing "hace"
-                             :1plur "hacemos"
-                             :2plur "hacéis"
-                             :3plur "hacen"}
-                   :preterito {:1sing "hize"
-                               :2sing "hiciste"
-                               :3sing "hize"
-                               :1plur "hicimos"
-                               :2plur "hicisteis"
-                               :3plur "hicieron"}}
-         [(merge shared-part-of-hacer
-                {:synsem {:pred :do}})
-         (merge shared-part-of-hacer
-                {:synsem {:pred :make}})]
+   "hacer" (let [shared-part-of-hacer
+                 {:espanol {:future-stem "har"
+                            :present {:1sing "hago"
+                                      :2sing "haces"
+                                      :3sing "hace"
+                                :1plur "hacemos"
+                                      :2plur "hacéis"
+                                      :3plur "hacen"}
+                            :preterito {:1sing "hize"
+                                        :2sing "hiciste"
+                                        :3sing "hize"
+                                        :1plur "hicimos"
+                                        :2plur "hicisteis"
+                                        :3plur "hicieron"}}}]
+             [(merge shared-part-of-hacer
+                     {:synsem {:pred :do}})
+              (merge shared-part-of-hacer
+                     {:synsem {:pred :make}})])

    "hervir" {:espanol {:boot-stem "hierv"}
              :synsem {:cat :verb


logging

logging

--- src/babel/italiano/writer.clj
+++ src/babel/italiano/writer.clj
@@ -40,7 +40,7 @@
     (.size (map (fn [verb]
                   (log/trace (str "verb: " (strip-refs verb)))
                   (let [root-form (get-in verb [:italiano :italiano])]
-                    (log/debug (str "generating from root-form:" root-form))
+                    (log/info (str "generating with verb: '" root-form "'"))
                     (.size (map (fn [tense]
                                   (let [spec (unify {:root {:italiano {:italiano root-form}}}
                                                     tense)]


use logger instead of println.

use logger instead of println.

--- src/metabase/metabot.clj
+++ src/metabase/metabot.clj
@@ -37,7 +37,7 @@
                           {(if (true? dispatch-token)
                              (keyword symb)
                              dispatch-token) varr}))]
-    (println (u/format-color 'cyan verb) fn-map)
+    (log/debug (u/format-color 'cyan verb) fn-map)
     (fn dispatch*
       ([]
        (keys-description (format "Here's what I can %s:" verb) fn-map))
@@ -164,7 +164,7 @@
     (when-let [tokens (seq (edn/read-string (str "(" (-> s
                                                          (str/replace "“" "\"") ; replace smart quotes
                                                          (str/replace "”" "\"")) ")")))]
-      (println (u/format-color 'magenta tokens))
+      (log/debug (u/format-color 'magenta tokens))
       (apply apply-metabot-fn tokens))))

@@ -173,14 +173,14 @@
 (defn- message->command-str [{:keys [text]}]
   (u/prog1 (when (seq text)
              (second (re-matches #"^mea?ta?boa?t\s+(.*)$" text)))
-    (println (u/format-color 'yellow <>))))
+    (log/debug (u/format-color 'yellow <>))))

 (defn- respond-to-message! [message response]
   (when response
     (let [response (if (coll? response) (str "```\n" (u/pprint-to-str response) "```")
                        (str response))]
       (when (seq response)
-        (println (u/format-color 'green response))
+        (log/debug (u/format-color 'green response))
         (slack/post-chat-message! (:channel message) response)))))

 (defn- handle-slack-message [message]
@@ -199,14 +199,14 @@

 (defn- handle-slack-event [socket start-time event]
   (when-not (= socket @websocket)
-    (println "Go home websocket, you're drunk.")
+    (log/debug "Go home websocket, you're drunk.")
     (s/close! socket)
     (throw (Exception.)))

   (when-let [event (json/parse-string event keyword)]
     (when (and (human-message? event)
                (> (event-timestamp-ms event) start-time))
-      (println (u/pprint-to-str 'cyan event))
+      (log/debug (u/pprint-to-str 'cyan event))
       (binding [*channel-id* (:channel event)]
         (do-async (handle-slack-message event))))))


improved error messages for bad config

improved error messages for bad config

--- qanal/src/qanal/core.clj
+++ qanal/src/qanal/core.clj
@@ -86,13 +86,6 @@
     (log/set-config! [:shared-appender-config :rotor] appender-config)))

-(defn valid-config? [c]
-  (let [errors (s/check config-schema c)]
-    (if (empty? errors)
-      c
-      (log/warn "The configuration file has invalid values/structure : " errors))))
-
-
 (defn parse-opt-errors->str [errors]
   (str "There was an error in the command line : \n" (clojure.string/join \newline errors)))

@@ -205,7 +198,7 @@
 ;; and now that some of the not relevant stuff
 ;; have been moved out is a bit cleaner,
 ;; but still not clear enough...
-;; NEED NORE clean loop
+;; NEED CLEANER loop
 ;;
 (defn siphon [{:keys [kafka-source elasticsearch-target]}]
   (loop [consumer (connect-to-kafka kafka-source)
@@ -227,6 +220,7 @@
               updated-state (assoc state :consumer-offset next-consumer-offset)]
           ;; TODO: don't like this as it won't
           ;; consume more msgs until the check point is saved
+          ;; this would be better off in a separate thread
           (set-consumer-offset updated-state)
           (recur consumer updated-state))))))

@@ -248,7 +242,7 @@
 (defn- init-tracking!
   "Initialises the metrics tracking system"
   [{enabled :enabled :as cfg}]
-  ;; TODO: remove this
+  ;; TODO: remove this when done with changes
   (trackit/start-reporting! {:type :console :reporting-frequency-seconds 30})
   (when enabled
     (log/info "Sending metrics to:" cfg)
@@ -258,7 +252,6 @@

 (defn init! [config]
   (init-log!      (:logging-options config))
-  ;; TODO: replace this with TRACKit
   (init-tracking! (:tracking config)))

@@ -271,8 +264,8 @@
     (when (nil? config-file)
       (exit 2 "Please supply a configuration file via -c option"))
     (let [cfg (read-config-file config-file)]
-      (when-not (valid-config? cfg)
-        (exit 3 "Please fix the configuration file"))
+      (when-let [errors (s/check config-schema cfg)]
+        (exit 3 (str "Please fix the configuration file: " errors)))
       (init! cfg)
       (siphon cfg))))


conditional get

conditional get

--- dev/src/yada/dev/examples.clj
+++ dev/src/yada/dev/examples.clj
@@ -11,7 +11,7 @@
    [yada.core :refer (make-async-handler)]
    [hiccup.core :refer (html h) :rename {h escape-html}]
    [markdown.core :as markdown]
-   [com.stuartsierra.component :refer (using)]
+   [com.stuartsierra.component :refer (using Lifecycle)]
    [tangrammer.component.co-dependency :refer (co-using)]
    [ring.mock.request :refer (request) :rename {request mock-request}]))

@@ -182,9 +182,11 @@

 ;; Conditional GETs

-(defrecord ConditionalGet []
-  Example
-  (resource-map [_] {:body "Hello World!"})
+(defrecord ConditionalGet [start-time]
+  Example
+  (resource-map [_] {:body "Hello World!"
+                     :resource {:last-modified start-time}
+                     })
   (request [_] {:method :get
                 :headers {"Accept" "text/plain"}})
   (expected-response [_] {:status 200}))
@@ -193,7 +195,7 @@

 #_(defrecord PostNewResource []
   Example
-  (resource-map [_] {})
+  (resource-map [_] '{})
   (request [_] {:method :get
                 :headers {"Accept" "text/plain"}})
   (expected-response [_] {:status 200}))
@@ -485,35 +487,14 @@
    :headers {"content-type" "text/html;charset=utf-8"}
    :body body})

-(defrecord ExamplesService [router handlers]
+(defrecord ExamplesService [router]
+  Lifecycle
+  (start [component] (assoc component :start-time (java.util.Date.)))
+  (stop [component] component)
+
   RouteProvider
-  (routes [this]
-    ["/examples"
-     [["/"
-       (vec
-        (concat
-         (for [h handlers]
-           [(get-path h) (handler (keyword (basename h))
-                                  (make-async-handler (eval (resource-map h))))])
-         [["index.html"
-           (handler
-            ::index
-            (fn [_]
-              (ok
-               (index (:routes @router) handlers))))]
-          ["tests.html"
-           (handler
-            ::tests
-            (fn [_]
-              (ok (tests (:routes @router) handlers))))
-           ]
-          ["" (redirect ::index)]]))]
-      ["" (redirect ::index)]]]))
-
-(defn new-examples-service [& {:as opts}]
-  (-> (->> opts
-           (merge {:handlers
-                   [(->BodyAsString)
+  (routes [component]
+    (let [handlers [(->BodyAsString)
                     (->StatusAndHeaders)
                     (->DynamicBody)
                     (->AsyncBody)
@@ -529,7 +510,7 @@
                     (->ResourceStateWithBody)
                     (->ResourceStateTopLevel)

-                    (->ConditionalGet)
+                    (->ConditionalGet (:start-time component))

                     (->PutResourceMatchedEtag)
                     (->PutResourceUnmatchedEtag)
@@ -542,8 +523,35 @@
                     (->DisallowedGet)
                     (->DisallowedPut)
                     (->DisallowedDelete)
-                    ]})
-           (s/validate {:handlers [(s/protocol Example)]})
+                    ]]
+      (s/validate [(s/protocol Example)] handlers)
+      ["/examples"
+       [["/"
+         (vec
+          (concat
+           (for [h handlers]
+             [(get-path h) (handler (keyword (basename h))
+                                    (make-async-handler (eval (resource-map h))))])
+           [["index.html"
+             (handler
+              ::index
+              (fn [_]
+                (ok
+                 (index (:routes @router) handlers))))]
+            ["tests.html"
+             (handler
+              ::tests
+              (fn [_]
+                (ok (tests (:routes @router) handlers))))
+             ]
+            ["" (redirect ::index)]]))]
+        ["" (redirect ::index)]]]
+      )))
+
+(defn new-examples-service [& {:as opts}]
+  (-> (->> opts
+           (merge {})
+
            map->ExamplesService)
       (using [])
       (co-using [:router])))


Make Eastwood happy. Thanks Eastwood!

Make Eastwood happy. Thanks Eastwood!

--- src/open_company/app.clj
+++ src/open_company/app.clj
@@ -10,7 +10,6 @@
     [org.httpkit.server :refer (run-server)]
     [compojure.core :refer (defroutes ANY)]
     [open-company.config :as c]
-    [open-company.db.pool :as pool]
     [open-company.api.companies :refer (company-routes)]
     [open-company.api.sections :refer (section-routes)]))


Refactor

Refactor

--- src/buildviz/teamcity/api.clj
+++ src/buildviz/teamcity/api.clj
@@ -5,29 +5,31 @@
             [clojure.string :as string]
             [clojure.tools.logging :as log]))

-(defn- get-json [teamcity-url relative-url]
-  (log/info (format "Retrieving %s" relative-url))
-  (j/parse-string (:body (client/get (string/join [(url/with-plain-text-password teamcity-url)
-                                                   relative-url])
-                                     {:accept "application/json"})) true))
+(defn- get-json [teamcity-url path-template & path-params]
+  (let [relative-url (apply format (cons path-template path-params))]
+    (log/info (format "Retrieving %s" relative-url))
+    (j/parse-string (:body (client/get (string/join [(url/with-plain-text-password teamcity-url)
+                                                     relative-url])
+                                       {:accept "application/json"})) true)))

 (defn get-jobs [teamcity-url project-name]
-  (let [response (get-json teamcity-url
-                           (format "/httpAuth/app/rest/projects/%s" project-name))]
+  (let [response (get-json teamcity-url "/httpAuth/app/rest/projects/%s" project-name)]
     (map :id (-> response
                  (get :buildTypes)
-                 (get :buildType )))))
+                 (get :buildType)))))

 (defn get-builds [teamcity-url job-id]
   (let [response (get-json teamcity-url
-                           (format "/httpAuth/app/rest/buildTypes/id:%s/builds/?fields=build(id,number,status,startDate,finishDate)" job-id))]
+                           "/httpAuth/app/rest/buildTypes/id:%s/builds/?fields=build(id,number,status,startDate,finishDate)"
+                           job-id)]
     (get response :build)))

 (def ^:private test-occurrence-paging-count 100)

 (defn get-test-report-from [teamcity-url build-id offset]
   (let [response (get-json teamcity-url
-                           (format "/httpAuth/app/rest/testOccurrences?locator=count:%s,start:%s,build:(id:%s)" test-occurrence-paging-count offset build-id))
+                           "/httpAuth/app/rest/testOccurrences?locator=count:%s,start:%s,build:(id:%s)"
+                           test-occurrence-paging-count offset build-id)
         test-occurrences (get response :testOccurrence)]
     (if (< (count test-occurrences) test-occurrence-paging-count)
       test-occurrences
@@ -35,6 +37,5 @@
         (concat test-occurrences
                 (lazy-seq (get-test-report-from teamcity-url build-id next-offset)))))))

-
 (defn get-test-report [teamcity-url build-id]
   (get-test-report-from teamcity-url build-id 0))


Remove print

Remove print

--- frontend/src/cruncher/moves/main.cljs
+++ frontend/src/cruncher/moves/main.cljs
@@ -22,5 +22,4 @@
         STAB (if (or (= type-1 (:type move)) (= type-2 (:type move)))
                1.25
                1)]
-    (print type-1 " - " type-2 " - Move-Type: " (:type move))
     (pprint/cl-format nil "~,2f" (/ (* (:power move) 1000 STAB) (:duration-ms move)))))


correct ref to left-side?

correct ref to left-side?

--- src/clj/clj_money/reports.clj
+++ src/clj/clj_money/reports.clj
@@ -8,7 +8,8 @@
             [clj-money.models.helpers :refer [with-storage]]
             [clj-money.models.entities :as entities]
             [clj-money.models.accounts :as accounts]
-            [clj-money.x-platform.accounts :refer [nest]]
+            [clj-money.x-platform.accounts :refer [nest
+                                                   left-side?]]
             [clj-money.models.budgets :as budgets]
             [clj-money.models.transactions :as transactions]
             [clj-money.models.commodities :as commodities]
@@ -225,7 +226,7 @@
         actual-amount (transactions/balance-delta storage (:id account)
                                                   (:start-date budget)
                                                   as-of)
-        difference (if (accounts/left-side? account)
+        difference (if (left-side? account)
                      (- budget-amount actual-amount)
                      (- actual-amount budget-amount))]
     (with-precision 10


Send a proper HTTP response.

Send a proper HTTP response.

--- src/clj/cljs/eval/browser.clj
+++ src/clj/cljs/eval/browser.clj
@@ -52,14 +52,23 @@
   (swap! server-state (fn [old] (assoc old :return-value-fn f))))

 (defn send-and-close
-  "Use the passed connection to send a form to the browser."
+  "Use the passed connection to send a form to the browser. Send a
+  proper HTTP response."
   [conn form]
-  (with-open [writer (BufferedWriter.
-                      (OutputStreamWriter. (.getOutputStream conn)))]
-    (do (.write writer form)
-        (.write writer "\r\n") ;; remove this
-        (.flush writer)
-        (.close conn))))
+  (let [utf-8-form (.getBytes form "UTF-8")
+        content-length (count utf-8-form)
+        headers (map #(.getBytes (str % "\r\n"))
+                     ["HTTP/1.1 200 OK"
+                      "Server: ClojureScript REPL"
+                      "Content-Type: text/html; charset=utf_8"
+                      (str "Content-Length: " content-length)
+                      ""])]
+    (with-open [os (.getOutputStream conn)]
+      (do (doseq [header headers]
+            (.write os header 0 (count header)))
+          (.write os utf-8-form 0 content-length)
+          (.flush os)
+          (.close conn)))))

 (defn send-for-eval
   "Given a form and a return value function, send the form to the


Fix namespace expansion

Fix namespace expansion

--- src/clj/clojuredocs/pages.clj
+++ src/clj/clojuredocs/pages.clj
@@ -115,19 +115,23 @@
                       (filter #(get #{"var" "function" "special-form" "macro"} (:type %)))))})

 (defn expand-ns [ns]
-  (:name (mon/fetch-one :namespaces
-           :where {:name (->> (str/split ns #"\.")
-                              (map #(str % "[^.]*"))
-                              (interpose "\\.")
-                              (apply str)
-                              re-pattern)})))
+  (let [pattern (->> (str/split ns #"\.")
+                     (map #(str % "[^.]*"))
+                     (interpose "\\.")
+                     (apply str)
+                     re-pattern)]
+    (->> search/clojure-lib
+         :namespaces
+         (map :name)
+         (filter #(re-find pattern %))
+         first)))

 (defn lookup-var [ns name]
   (mon/fetch-one :vars :where {:name name :ns ns}))

 (defn lookup-var-expand [ns name]
-  (or (lookup-var ns name)
-      (lookup-var (expand-ns ns) name)))
+  (or (search/lookup (str ns "/" name))
+      (search/lookup (str (expand-ns ns) "/" name))))

 (defn format-concept-title [concept]
   (->> (str/split concept #"-")


fix Tinkering server identification in log

--- src/clj/game/cards-events.clj
+++ src/clj/game/cards-events.clj
@@ -593,11 +593,7 @@
    {:prompt "Choose a piece of ICE"
     :choices {:req #(and (= (last (:zone %)) :ices) (= (:type %) "ICE"))}
     :effect (req (let [ice target
-                       serv (cond
-                             (= (second (:zone ice)) :hq) "HQ"
-                             (= (second (:zone ice)) :rd) "R&D"
-                             (= (second (:zone ice)) :archives) "Archives"
-                             :else (join " " ["Server" (last (butlast (:zone ice)))]))
+                       serv (zone->name (second (:zone ice)))
                        stypes (:subtype ice)]
               (resolve-ability
                  state :runner


Push on brew start and finish

Push on brew start and finish

--- src/clj/mokkameister/brew.clj
+++ src/clj/mokkameister/brew.clj
@@ -33,15 +33,15 @@
         total-count  (get-in stats [:regular :total])
         starting-msg (coffee-message-starting brew today-count)
         msg          (str starting-msg " - " mokkameister-link)]
-    (slack/notify msg :channel channel)
-    (pusher/push! "coffee" "coffee" starting-msg)))
+    (slack/notify msg :channel channel)))

 (defn- notify-done! [brew]
   (let [msg (coffee-message-finished)]
     (slack/notify msg :channel channel)))

 (defn- finish-brewing! [brew]
-  (notify-done! brew))
+  (notify-done! brew)
+  (pusher/push! "coffee" "brewing" "finish"))

 (defmacro delayed!
   "Execute body after time-ms"
@@ -53,4 +53,5 @@
   (let [brew     (persist-brew! in-brew)
         delay-ms (* (:brew-time brew) 60 1000)]
     (notify-start! brew)
+    (pusher/push! "coffee" "brewing" "start")
     (delayed! delay-ms (finish-brewing! brew))))


WIP

WIP

- Get data URI version of a resource with by /rez/<name>/<type>

--- src/clj/my_project/server.clj
+++ src/clj/my_project/server.clj
@@ -16,6 +16,21 @@
 (deftemplate page (io/resource "index.html") []
   [:body] (if is-dev? inject-devmode-html identity))

+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defn read-file [file-name]
+
+  (let [f (file file-name)
+        length (.length f)
+        buffer (byte-array length)]
+    (println file-name)
+    (with-open[in (input-stream (file file-name))]
+      (.read in buffer 0 length))
+    buffer
+    ))
+
+
 (defn get-enc-64-as-str [file]
   (->>
     file
@@ -24,8 +39,6 @@
     (map char)
     (apply str)))

-
-
 (defn get-file-as-mime-type [rez-name mime-type]
   (->>
     (io/resource rez-name)
@@ -33,13 +46,28 @@
     (str "data:" mime-type ";base64,")))

 (defn get-png-enc [name]
-  (get-file-as-mime-type (str  "public/data/" name ".png"), "image/png")
+  (get-file-as-mime-type (str  "public/data/" name ".png"), "image/png"))
+
+(def type-to-mtype
+  {:png "image/png"})
+
+(defn get-rez [rez-name rez-type]
+  (let [file-name (str "public/data/" rez-name "." rez-type)
+        mime-type ((keyword rez-type) type-to-mtype) ]
+    (get-file-as-mime-type file-name mime-type)
+    )
   )
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (defroutes routes
   (resources "/")
   (resources "/react" {:root "react"})
-  (GET ["/rez/:name.txt" :name #".*"] [name] (get-png-enc name))
+
+  (GET ["/rez/:rez-type/:rez-name" :rez-name #".*" :rez-type #".*"] [rez-name rez-type]
+       ; (str rez-name " " rez-type)
+       (get-rez rez-name rez-type)
+       )

   (GET "/*" req (page)))


delete user badge endorsment

delete user badge endorsment

--- src/clj/salava/badge/main.clj
+++ src/clj/salava/badge/main.clj
@@ -478,11 +478,14 @@

 (defn delete-badge-evidences! [db badge-id user-id]
   (if-let [evidences (select-user-badge-evidence {:user_badge_id badge-id} db)]
-    (when-not (empty? evidences)
+    (when (seq evidences)
       (delete-all-badge-evidences! {:user_badge_id badge-id} db)
       (doseq [evidence evidences
               :let [name (str "evidence_id:"(:id evidence))]]
         (delete-user-evidence-property! {:name name :user_id user-id} db)))))
+
+(defn delete-badge-endorsements! [db id]
+  (delete-user-badge-endorsements! {:id id} db))

 (defn delete-badge-with-db! [db user-badge-id]
   (delete-badge-tags! {:user_badge_id user-badge-id} db)
@@ -501,7 +504,8 @@
       (do
         #_(db/delete-badge-endorsements ctx badge-id)
         (delete-badge-with-db! {:connection tr-cn} badge-id)
-        (delete-badge-evidences! {:connection tr-cn} badge-id user-id)))
+        (delete-badge-evidences! {:connection tr-cn} badge-id user-id)
+        (delete-badge-endorsements! {:connection tr-cn} badge-id)))
     (if (some #(= :social %) (get-in ctx [:config :core :plugins]))
       (so/delete-connection-badge-by-badge-id! ctx user-id badge-id ))
     {:status "success" :message "Badge deleted"}


proposed gallery bug fix

proposed gallery bug fix

--- src/clj/salava/gallery/db.clj
+++ src/clj/salava/gallery/db.clj
@@ -71,14 +71,14 @@
     (str "('" (apply str (interpose "','" (map #(string/replace % #"\W" "") ids))) "')"))

 (defn badge-count [search page_count]
-  (let [limit 1
+  (let [limit 20
         badges-left (- (count search) (* limit (+ page_count 1)))]
     (if (pos? badges-left)
       badges-left
       0)))

 (defn select-badges [ctx badge_ids order page_count]
-  (let [limit 1
+  (let [limit 20
         offset (* limit page_count)]
     (if (not-empty badge_ids)
       (case order
@@ -136,7 +136,7 @@
         badges (remove #(some nil? (vals %)) (select-badges ctx badge-ids order page_count))]
     {:badges badges #_(select-badges ctx badge-ids order page_count)
      :tags (select-tags ctx badge-ids)
-     :badge_count (badge-count badge-ids page_count) }))
+     :badge_count (badge-count (if-not (= (count badge-ids) (count badges)) badge-ids badges) page_count) }))


Removed commented out code.

Removed commented out code.

--- src/clj_record/validation.clj
+++ src/clj_record/validation.clj
@@ -19,17 +19,7 @@

 (defn validate-by-model [model-name record]
   (callbacks/before-validation model-name record)
-  (let [errors (reduce
-                  #(collect-errors record %1 %2)
-                  ;(fn [errors [attr message validation-fn]]
-                  ;  (if (validation-fn (record attr))
-                  ;    errors
-                  ;    (merge-with
-                  ;      (fn [result addl-val] (apply conj result addl-val))
-                  ;      errors
-                  ;      {attr [message]})))
-                  {}
-                  (validations-for model-name))]
+  (let [errors (reduce #(collect-errors record %1 %2) {} (validations-for model-name))]
     (callbacks/after-validation model-name record)
     errors))


Server side require placeholder

Server side require placeholder

--- src/cljc/salava/registry.cljc
+++ src/cljc/salava/registry.cljc
@@ -1,5 +1,7 @@
 (ns salava.registry
    (:require
+     ; SERVER SIDE
+     #?@(:clj [[salava.core.helper]])
      ; CLIENT SIDE
      ; List all your clojurescript route files here:
      #?@(:cljs [[salava.badge.ui.routes]


Fix namespace docstring

Fix namespace docstring

--- src/cljx/cats/monad/lazy.cljx
+++ src/cljx/cats/monad/lazy.cljx
@@ -1,5 +1,5 @@
 (ns cats.monad.lazy
-  "The Maybe Monad."
+  "The Lazy Monad."
   #+clj
   (:require [cats.protocols :as proto]
             [cats.core :as m :refer (with-context)])
@@ -8,8 +8,6 @@
   #+cljs
   (:require [cats.protocols :as proto]
             [cats.core :as m]))
-
-

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Delay/Lazy Monad
@@ -44,4 +42,3 @@
   proto/Context
   (get-context [_] lazy-monad)
   (get-value [self] @self))
-


Changed cmr.cmr-indexer namespace to cmr.indexer.

--- src/cmr/dev_system/system.clj
+++ src/cmr/dev_system/system.clj
@@ -1,7 +1,7 @@
 (ns cmr.dev-system.system
   (:require [cmr.common.log :refer (debug info warn error)]
             [cmr.metadata-db.system :as mdb-system]
-            [cmr.cmr-indexer.system :as indexer-system]
+            [cmr.indexer.system :as indexer-system]
             [cmr.search.system :as search-system]
             [cmr.ingest.system :as ingest-system]))


trim whitespace around channel names in PART command


Add extra component to ordering test

Add extra component to ordering test

The added component has no dependencies and is not depended upon, so
it can be started at any time.

--- test/com/stuartsierra/component_test.clj
+++ test/com/stuartsierra/component_test.clj
@@ -98,7 +98,7 @@
 (defn component-e []
   (map->ComponentE {:state (rand-int Integer/MAX_VALUE)}))

-(defrecord System1 [d a c b]
+(defrecord System1 [d a e c b]  ; deliberately scrambled order
   component/Lifecycle
   (start [this]
     (log 'System1.start this)
@@ -113,7 +113,8 @@
                  :c (component-c)
                  :d (component/using (component-d)
                       {:b :b
-                       :my-c :c})}))
+                       :my-c :c})
+                 :e (component-e)}))

 (defmacro with-log [& body]
   `(binding [*log* []]


Replace uses of :children with container? predicate

--- src/main/clojure/com/stuartsierra/lazytest/report.clj
+++ src/main/clojure/com/stuartsierra/lazytest/report.clj
@@ -9,7 +9,7 @@
   "Given a single TestResult, returns a depth-first sequence of that
   TestResult and all its children."
   [r]
-  (tree-seq :children :children r))
+  (tree-seq container? :children r))

 (defn details
   "Given a TestResult, returns the map of :name, :ns, :file, :line,
@@ -83,7 +83,7 @@
     (flush)))

 (defn- spec-report* [r parents]
-  (if (seq (:children r))
+  (if (container? r)
     (doseq [c (:children r)]
       (spec-report* c (conj parents r)))
     (if (and (success? r) (not (pending? r)))


bump cljs

bump cljs

--- src/leiningen/new/mies/project.clj
+++ src/leiningen/new/mies/project.clj
@@ -3,7 +3,7 @@
   :url "http://example.com/FIXME"

   :dependencies [[org.clojure/clojure "1.5.1"]
-                 [org.clojure/clojurescript "0.0-2024"]]
+                 [org.clojure/clojurescript "0.0-2030"]]

   :plugins [[lein-cljsbuild "1.0.0-alpha2"]]


Start converting "big" message test to Actor (WIP)

--- test/frereth_cp/message/message_test.clj
+++ test/frereth_cp/message/message_test.clj
@@ -292,15 +292,15 @@
                         (log/info "Success!"))
                       (fn [bad] (is (not bad))))

-    (reset! client-atom (message/initial-state "Client" client-parent-cb client-child-cb false))
-    (message/start! @client-atom)
+    (reset! client-atom (message/initial-state "Client" false))
+    (message/start! @client-atom client-parent-cb client-child-cb)

     ;; It seems like this next part really shouldn't happen until the initial message arrives
     ;; from the client.
     ;; Actually, it starts when the Initiate(?) packet arrives as part of the handshake. So
     ;; that isn't quite true
-    (reset! server-atom (message/initial-state "Server" server-parent-cb server-child-cb true))
-    (message/start! @server-atom)
+    (reset! server-atom (message/initial-state "Server" true))
+    (message/start! @server-atom server-parent-cb server-child-cb)

     (try
       (strm/consume (fn [bs]
@@ -436,10 +436,8 @@
                                 (log/info (str test-run "::srvr-child-cb Received all expected packets"))
                                 (deliver response @srvr-child-state))))
           srvr-initialized (message/initial-state (str "(test " test-run ") Server w/ Big Inbound")
-                                                  server-parent-cb
-                                                  server-child-cb
                                                   true)
-          srvr-state (message/start! srvr-initialized)
+          srvr-io-handle (message/start! srvr-initialized server-parent-cb server-child-cb)

           parent-cb (fn [bs]
                       (log/info test-run "Forwarding buffer to server")
@@ -450,7 +448,7 @@
                       ;; And, realistically, push the message onto another
                       ;; queue that handles all the details like encrypting
                       ;; and actually writing bytes to the wire.
-                      (message/parent->! srvr-state bs))
+                      (message/parent->! srvr-io-handle bs))
           child-message-counter (atom 0)
           strm-address (atom 0)
           child-cb (fn [_]
@@ -463,58 +461,56 @@
                      ;; Q: (which failure? feature?)
                      (is false "This should never get called"))
           client-initialized (message/initial-state (str "(test " test-run ") Client w/ Big Outbound")
-                                                    parent-cb child-cb false)
-          client-state (message/start! client-initialized)]
-      (reset! state-agent-atom client-state)
+                                                    false)
+          client-io-handle (message/start! client-initialized parent-cb child-cb)]
+      (reset! state-agent-atom client-io-handle)
       (try
         (let [;; Note that this is what the child sender should be supplying
               message-body (byte-array (range msg-len))]
-          (log/debug test-run "Replicating child-send to " client-state)
-          (message/child->! client-state message-body)
+          (log/debug test-run "Replicating child-send to " client-io-handle)
+          (message/child->! client-io-handle message-body)
           (let [outcome (deref response 10000 ::timeout)
                 end-time (System/nanoTime)]
             (log/info test-run
                       "Verifying that state hasn't errored out after"
                       (float (utils/nanos->millis (- end-time start-time))) "milliseconds")
-            (if-let [err (agent-error client-state)]
-              (is (not err))
-              (do
-                (is (not= outcome ::timeout))
-                (when-not (= outcome ::timeout)
-                  ;; TODO: What do I need to set up a full-blown i/o
-                  ;; loop to make this accurate?
-                  (let [result-buffer (:buffer outcome)]
-                    (is (= packet-count (count result-buffer)))
-                    (is (= K/initial-max-block-length (count (first result-buffer))))
-                    (doseq [packet (butlast result-buffer)]
-                      (is (= (count packet) K/k-div2)))
-                    (let [final (last result-buffer)]
-                      (is (= (count final) K/k-div4)))
-                    (let [rcvd-strm
-                          (reduce (fn [acc block]
-                                    (conj acc block))
-                                  []
-                                  result-buffer)]
-                      (is (b-t/bytes= (->> rcvd-strm
-                                           first
-                                           byte-array)
-                                      (->> message-body
-                                           vec
-                                           (take K/initial-max-block-length)
-                                           byte-array))))))))))
+            ;; Q: Can I do anything better in terms of checking for errors?
+            (let [client-state (message/get-state client-io-handle ::timeout)]
+              (is outcome)
+              (is (not= ::timeout outcome))
+              (is (not (instance? Exception outcome)))
+              (when-not (= outcome ::timeout)
+                (let [result-buffer (:buffer outcome)]
+                  (is (= packet-count (count result-buffer)))
+                  (is (= K/initial-max-block-length (count (first result-buffer))))
+                  (doseq [packet (butlast result-buffer)]
+                    (is (= (count packet) K/k-div2)))
+                  (let [final (last result-buffer)]
+                    (is (= (count final) K/k-div4)))
+                  (let [rcvd-strm
+                        (reduce (fn [acc block]
+                                  (conj acc block))
+                                []
+                                result-buffer)]
+                    (is (b-t/bytes= (->> rcvd-strm
+                                         first
+                                         byte-array)
+                                    (->> message-body
+                                         vec
+                                         (take K/initial-max-block-length)
+                                         byte-array)))))))))
         (finally
           (log/info "Ending test" test-run)
           (try
-            (message/halt! client-state)
+            (message/halt! client-io-handle)
             (catch RuntimeException ex
               (is not ex)))
           (try
-            (message/halt! srvr-state)
+            (message/halt! srvr-io-handle)
             (catch RuntimeException ex
               (is not ex)))))
+      (throw (RuntimeException. "The rest of this is pretty broken"))
       (let [state-agent @state-agent-atom]
-        (await state-agent)
-        (await srvr-state)
         (log/info test-run "Deref'ing the state-agent")
         (let [{:keys [::specs/incoming
                       ::specs/outgoing]


don't use a simple sequence if there are too many slices for a particular Z stage

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@12405 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/sequence_generator.clj
+++ acqEngine/src/org/micromanager/sequence_generator.clj
@@ -215,6 +215,9 @@
     (when-not (empty? z-drive)
       (.isStageSequenceable mmc z-drive))))

+(defn sequence-fits-stage? [z-drive n-slices]
+  (<= n-slices (.getStageSequenceMaxLength mmc z-drive)))
+
 (defn event-triggerable
   "Returns true if an event can be added to a burst."
   [burst event]
@@ -229,7 +232,7 @@
           (when-let [z-drive (. mmc getFocusDevice)]
             (and
               (stage-sequenceable?)
-              (< n (.getStageSequenceMaxLength mmc z-drive))
+              (sequence-fits-stage? z-drive (inc n))
               (<= (Math/abs (- (e1 :slice) (e2 :slice))) MAX-Z-TRIGGER-DIST)
               (<= (e1 :slice-index) (e2 :slice-index))))))))

@@ -411,12 +414,14 @@
                 autofocus-skip custom-intervals-ms slices-first
                 relative-slices]} settings
         property-sequences (make-property-sequences (map :properties channels))
+        n-slices (count slices)
         have-multiple-frames (< 1 numFrames)
         have-multiple-positions (< 1 (count positions))
-        have-multiple-slices (< 1 (count slices))
+        have-multiple-slices (< 1 n-slices)
         have-multiple-channels (< 1 (count channels))
         channel-properties-sequenceable (channels-sequenceable property-sequences channels)
-        slices-sequenceable (stage-sequenceable?)
+        slices-sequenceable (and (stage-sequenceable?)
+                                 (sequence-fits-stage? (.getFocusDevice mmc) n-slices))
         no-channel-skips-frames (all-equal? 0 (map :skip-frames channels))
         all-channels-do-z-stack (all-equal? true (map :use-z-stack channels))]
     (println slices-first)


POC: database test

POC: database test

--- test/territory_bro/congregation_test.clj
+++ test/territory_bro/congregation_test.clj
@@ -3,11 +3,38 @@
 ;; The license text is at http://www.apache.org/licenses/LICENSE-2.0

 (ns territory-bro.congregation-test
-  (:require [clojure.test :refer :all]
-            [territory-bro.congregation :refer :all]))
+  (:require [clojure.java.jdbc :as jdbc]
+            [clojure.test :refer :all]
+            [conman.core :as conman]
+            [luminus-migrations.core :as migrations]
+            [mount.core :as mount]
+            [territory-bro.config :as config]
+            [territory-bro.congregation :refer :all]
+            [territory-bro.db :as db]))

-; TODO
+(defn test-db-fixture [f]
+  (mount/stop) ; during interactive development, app might be running when tests start
+  (mount/start-with-args {:test true}
+                         #'config/env
+                         #'db/databases)
+  ;(migrations/migrate ["reset"] {:database-url config/env})
+  (f)
+  (mount/stop))
+
+(defn rollback-db-fixture [f]
+  (binding [db/*db* (:default db/databases)]
+    (conman/with-transaction [db/*db* {:isolation :serializable}]
+      (jdbc/db-set-rollback-only! db/*db*)
+      (f))))
+
+(use-fixtures :once test-db-fixture)
+(use-fixtures :each rollback-db-fixture)
+
+; TODO: init database with https://flywaydb.org
+
 (deftest my-congregations-test
+  (assert (= [{:test 1}] (jdbc/query db/*db* ["select 1 as test"])))
+
   (is true)
   (testing "lists congregations to which the user has access")
   (testing "hides congregations to which the user has no access")


Limit the generated data size for empty-time-map-test

--- test/time_tracker/invoices/core_test.clj
+++ test/time_tracker/invoices/core_test.clj
@@ -6,7 +6,7 @@

 (deftest empty-time-map-test
   (testing "Generative test"
-    (assert-generative-test `invoices-core/empty-time-map)))
+    (assert-generative-test `invoices-core/empty-time-map {:max-size 30})))

 (deftest add-hours-test
   (testing "Generative test"


Fix namespace

Fix namespace

--- src/cylon/impl/webrequest.clj
+++ src/cylon/impl/webrequest.clj
@@ -12,7 +12,7 @@
    cylon.impl.session
    cylon.impl.authentication)
   (:import
-   (cylon.impl.session CookieAuthenticator)
+;   (cylon.impl.session CookieAuthenticator)
    (cylon.impl.authentication StaticAuthenticator
                               HttpBasicAuthenticator
                               CompositeDisjunctiveAuthenticator)))


Add new field for reference attitude

Add new field for reference attitude

--- src/discuss/utils/common.cljs
+++ src/discuss/utils/common.cljs
@@ -35,12 +35,13 @@
                                    :selection          nil
                                    :logged-in?         false}
                 :reference-usages {:selected-reference nil
-                                   :selected-statement nil}
+                                   :selected-statement nil
+                                   :supportive? nil}
                 :clipboard        {:selections nil
                                    :current    nil}
                 :sidebar          {:show? true}
                 :common           {:references       []
-                                   :reference-usages {}}}))
+                                   :reference-usages {}}})) ; Put this into :reference-usages

 (defn str->int
   "Convert String to Integer."


Add fn to parse query-parameters

Add fn to parse query-parameters

--- src/discuss/utils/common.cljs
+++ src/discuss/utils/common.cljs
@@ -8,7 +8,9 @@
             [inflections.core :refer [plural]]
             [discuss.config :as config]
             [discuss.parser :as parser]
-            [discuss.utils.logging :as log]))
+            [discuss.utils.logging :as log]
+            [clojure.string :as string]
+            [cemerick.url :as url]))

 (defn prefix-name
   "Create unique id for DOM elements."
@@ -313,54 +315,6 @@
   (gstring/unescapeEntities
    (clojure.string/replace (trim-newline (trim str)) #"\s+" " ")))

-
-;;;; CSS modifications
-(defn toggle-class
-  "Toggle CSS class of provided DOM element. A third paramenter as boolean can
-  be provided to force removing or adding the class."
-  ([dom-element class] (.classList/toggle dom-element class))
-  ([dom-element class bool] (.classList/toggle dom-element class bool)))
-
-(defn remove-class
-  "Remove a specific class of a DOM element."
-  [dom-element class]
-  (toggle-class dom-element class false))
-
-(defn add-class
-  "Add a specific class to a DOM element."
-  [dom-element class]
-  (toggle-class dom-element class true))
-
-
-;;;; Language
-(defn language
-  "Returns currently selected language."
-  []
-  (load-from-app-state :layout/lang))
-
-(defn language-next!
-  "Set new language. Should be a keyword."
-  [lang]
-  (store-to-app-state! 'layout/lang lang))
-
-(defn language-locale
-  "Return String as a locale for DateTime instances etc. Defaults to en-US."
-  []
-  (let [lang (language)]
-    (case lang
-      :de "de-DE"
-      "en-US")))
-(s/fdef language-locale
-  :ret string?)
-
-
-;;;; Other
-(defn get-value-by-id
-  "Return value of element matching the id."
-  [id]
-  (let [element (.getElementById js/document (prefix-name id))]
-    (when element (.-value element))))
-
 (defn remove-trailing-slash
   "Remove trailing slash if it exists."
   [s]
@@ -369,6 +323,62 @@
   :args (s/cat :s string?)
   :ret string?)

+(defn prepend-slash
+  "Prepend slash to string if none found."
+  [s]
+  (if (string/starts-with? s "/") s (str "/" s)))
+(s/fdef prepend-slash
+  :args (s/cat :s string?)
+  :ret string?)
+
+
+;;;; CSS modifications
+(defn toggle-class
+  "Toggle CSS class of provided DOM element. A third paramenter as boolean can
+  be provided to force removing or adding the class."
+  ([dom-element class] (.classList/toggle dom-element class))
+  ([dom-element class bool] (.classList/toggle dom-element class bool)))
+
+(defn remove-class
+  "Remove a specific class of a DOM element."
+  [dom-element class]
+  (toggle-class dom-element class false))
+
+(defn add-class
+  "Add a specific class to a DOM element."
+  [dom-element class]
+  (toggle-class dom-element class true))
+
+
+;;;; Language
+(defn language
+  "Returns currently selected language."
+  []
+  (load-from-app-state :layout/lang))
+
+(defn language-next!
+  "Set new language. Should be a keyword."
+  [lang]
+  (store-to-app-state! 'layout/lang lang))
+
+(defn language-locale
+  "Return String as a locale for DateTime instances etc. Defaults to en-US."
+  []
+  (let [lang (language)]
+    (case lang
+      :de "de-DE"
+      "en-US")))
+(s/fdef language-locale
+  :ret string?)
+
+
+;;;; Other
+(defn get-value-by-id
+  "Return value of element matching the id."
+  [id]
+  (let [element (.getElementById js/document (prefix-name id))]
+    (when element (.-value element))))
+
 (defn log
   "Print argument as JS object to be accessible from the console."
   [arg]
@@ -386,6 +396,15 @@
   :args (s/cat :col coll? :namespace any?)
   :ret coll?)

+(defn parse-query-parameter
+  "Provide a key which should be parsed from the URL. Return nil if key was not
+  found."
+  [query-parameter]
+  (get (:query (url/url (-> js/window .-location .-href)))
+       query-parameter))
+(s/fdef parse-query-parameter
+  :args (s/cat :query-parameter string?)
+  :ret (s/? string?))

 ;; -----------------------------------------------------------------------------
 ;; Configuration Settings


update with mongo id

update with mongo id

--- s3/src/s3/blog.clj
+++ s3/src/s3/blog.clj
@@ -113,7 +113,7 @@
 (defn update-with [user blog]
   (let [new-blog (assoc blog :user user)
         id (:id new-blog)
-        db-object (find-blog-object-by-sid id)]
+        db-object (find-blog-object id)]
     (if (and (not= nil db-object) (own? user db-object))
       (-> new-blog
           (generate-title)


Allow wrap-file to accept either String or File instances

--- ring-core/src/ring/middleware/file.clj
+++ ring-core/src/ring/middleware/file.clj
@@ -1,22 +1,22 @@
 (ns ring.middleware.file
   "Static file serving."
-  (:import java.io.File)
   (:require [ring.util.codec :as codec]
             [ring.util.response :as response]
             [ring.util.request :as request]
-            [ring.middleware.head :as head]))
+            [ring.middleware.head :as head]
+            [clojure.java.io :as io]))

 (defn- ensure-dir
   "Ensures that a directory exists at the given path, throwing if one does not."
-  [^String dir-path]
-  (let [dir (File. dir-path)]
+  [dir-path]
+  (let [dir (io/file dir-path)]
     (if-not (.exists dir)
       (throw (Exception. (format "Directory does not exist: %s" dir-path))))))

 (defn file-request
   "If request matches a static file, returns it in a response. Otherwise returns nil."
   [req root-path & [opts]]
-  (let [opts (merge {:root root-path, :index-files? true, :allow-symlinks? false} opts)]
+  (let [opts (merge {:root (str root-path), :index-files? true, :allow-symlinks? false} opts)]
     (if (= :get (:request-method req))
       (let [path (subs (codec/url-decode (request/path-info req)) 1)]
         (response/file-response path opts)))))
@@ -28,7 +28,7 @@

   An map of options may be optionally specified. These options will be passed
   to the ring.util.response/file-response function."
-  [handler ^String root-path & [opts]]
+  [handler root-path & [opts]]
   (ensure-dir root-path)
   (fn [req]
     (or ((head/wrap-head #(file-request % root-path opts)) req)


Properly captialize "Transfer Plan"

Properly captialize "Transfer Plan"

--- src-cljs/frontend/components/org_settings.cljs
+++ src-cljs/frontend/components/org_settings.cljs
@@ -830,7 +830,7 @@
                                   {:from-org {:org-name org-name
                                               :vcs-type vcs_type}
                                    :to-org selected-transfer-org}])}
-             "Transfer plan")]])]]))))
+             "Transfer Plan")]])]]))))

 (defn organizations [app owner]
   (om/component