Layout manager #41

Layout manager #41

--- src/flatgui/layout.clj
+++ src/flatgui/layout.clj
@@ -15,7 +15,7 @@
   (:import (java.util.regex Pattern)))

-(def gap 0.125)
+(def gap 0.0625)

 (def component-min-size (m/defpoint 0.375 0.375))

@@ -131,7 +131,7 @@
       (let [stretch-space (- 1.0 stable-pref-total)
             _ (println "stretch-space" stretch-space)
             index-range (range 0 (count dir))
-            ws (map #(if (stretches? %) (do (println "sw" (:stch-weight %)) (* (:stch-weight %) stretch-space)) (sfn (:pref %))) dir)
+            ws (map #(if (stretches? %) (* (:stch-weight %) stretch-space) (sfn (:pref %))) dir)
             xs (map #(reduce + (take % ws)) index-range)]
            ;; y and h are here temporarily
            ;; instead of :x and :w there should be variables (params)
@@ -150,7 +150,7 @@
   (if-let [coord-map (get-property [] :coord-map)]
     (if-let [coord ((:id component) coord-map)]
       (let [ps (get-property [] :clip-size)]
-        (m/translation (* (:x coord) (m/x ps)) (* (:y coord (m/y ps)))))
+        (m/translation (+ gap (* (:x coord) (m/x ps))) (+ gap (* (:y coord (m/y ps))))))
       old-position-matrix)
     old-position-matrix))

@@ -158,7 +158,7 @@
   (if-let [coord-map (get-property [] :coord-map)]
     (if-let [coord ((:id component) coord-map)]
       (let [ps (get-property [] :clip-size)]
-        (m/defpoint (* (:w coord) (m/x ps)) (* (:h coord (m/y ps)))))
+        (m/defpoint (- (* (:w coord) (m/x ps)) gap gap) (- (* (:h coord (m/y ps))) gap gap)))
       old-clip-size)
     old-clip-size))


[#2212] Remove explicit http exceptions, so we use http-client ones

Relates to
https://github.com/akvo/akvo-lumen/pull/2227#discussion_r296701407

--- backend/src/akvo/lumen/component/keycloak.clj
+++ backend/src/akvo/lumen/component/keycloak.clj
@@ -51,11 +51,7 @@
                                 json/decode
                                 (get "access_token"))]
        {"Authorization" (str "bearer " access-token)
-        "Conternt-Type" "application/json"}
-       (throw
-        (ex-info "Down stream auth server timed out (Keycloak)"
-                 {:response-code 503}))))))
-
+        "Conternt-Type" "application/json"}))))

 (defn group-by-path
   "Get the group id (uuid) by using group path.
@@ -164,7 +160,6 @@
         (not (empty? (set/intersection possible-group-paths user-group-paths))))
       false)))

-
 (defn add-user-to-group
   "Returns status code from Keycloak response."
   [request-headers api-root user-id group-id]
@@ -267,16 +262,11 @@
   (if-some [user-id (get-user-id user-id-cache email)]
     user-id
     (let [url (format "%s/users/?email=%s" api-root email)]
-      (if-some [users (-> (client/get url (assoc req-opts :connection-manager cm)) :body json/decode)]
-        (if-some [user-id (active-user users email)]
+      (let [users (-> (client/get url (assoc req-opts :connection-manager cm)) :body json/decode)]
+        (when-some [user-id (active-user users email)]
           (-> user-id-cache
               (swap! assoc email user-id)
-              (get email))
-          (throw
-           (ex-info "No active user with email provided" {:response-code 401})))
-        (throw
-         (ex-info "Down stream auth server timed out (Keycloak)"
-                  {:response-code 503}))))))
+              (get email)))))))

 (defn allowed-paths
   "Provided an email address from the authentication process dig out the
@@ -291,18 +281,14 @@
    (let [bare-req-opts {:timeout timeout}]
      (if-some [headers (request-headers keycloak (assoc bare-req-opts :timeout timeout))]
        (let [req-opts (assoc bare-req-opts :headers headers)]
-         (if-let [user-id (lookup-user-id cm req-opts api-root user-id-cache email)]
-           (if-let [allowed-paths
+         (when-let [user-id (lookup-user-id cm req-opts api-root user-id-cache email)]
+           (when-let [allowed-paths
                     (-> (client/get (format "%s/users/%s/groups" api-root user-id)
                                     (assoc req-opts :connection-manager cm)) :body json/decode)]
              (reduce (fn [paths {:strs [path]}]
                        (conj paths (subs path 12)))
                      #{}
-                     allowed-paths)
-             (throw (ex-info "Down stream auth server timed out"
-                             {:response-code 503})))))
-       (throw (ex-info "Down stream auth server timed out"
-                       {:response-code 503}))))))
+                     allowed-paths))))))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


[#2212] Add cache for email->Keycloak user id lookup.

--- backend/src/akvo/lumen/component/keycloak.clj
+++ backend/src/akvo/lumen/component/keycloak.clj
@@ -11,6 +11,7 @@
             [clojure.set :as set]
             [clojure.tools.logging :as log]
             [ring.util.response :refer [response]]))
+

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Helper fns
@@ -221,33 +222,44 @@
           (println (format "Tried to remove user: %s" user-id))
           (lib/internal-server-error))))))

+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; WIP
+;;; API Authorization
 ;;;

 (defn- api-get
   [headers url]
-  (-> url
-      (client/get {:headers headers})
-      :body
-      json/decode))
+  (-> url (client/get {:headers headers}) :body json/decode))
+
+(defn- lookup-user-id
+  "Lookup email -> Keycloak user-id, via cached Keycloak API."
+  [request-headers api-root user-id-cache email]
+  (if-let [user-id (get @user-id-cache email)]
+    user-id
+    (let [users (api-get request-headers
+                         (format "%s/users/?email=%s" api-root email))
+          verified-user-id (-> (filter #(and (= (get % "email") email)
+                                             (get % "emailVerified"))
+                                       users)
+                               first
+                               (get "id"))]
+      (-> user-id-cache
+          (swap! assoc email verified-user-id)
+          (get email)))))

 (defn allowed-paths
-  "From email get Keycloak user and returns the set of allowed paths for email"
-  [{:keys [api-root] :as keycloak} email]
+  "Provided an email address from the authentication process dig out the
+  Keycloak user and get allowed set of paths, as in #{\"demo/admin\" \"t1\"}
+
+  The Keycloak groups are on the form /akvo/lumen/demo/admin, to simplify  we
+  remove the leading /akvo/lumen and return paths as demo/admin."
+  [{:keys [api-root user-id-cache] :as keycloak} email]
   (let [request-headers (request-headers keycloak)
-        users (api-get request-headers
-                       (format "%s/users/?email=%s" api-root email))
-        validated-user-id (-> (filter #(and (= (get % "email") email)
-                                            (get % "emailVerified"))
-                                      users)
-                              first
-                              (get "id"))
+        user-id (lookup-user-id request-headers api-root user-id-cache email)
         user-groups (api-get request-headers
-                             (format "%s/users/%s/groups" api-root
-                                     validated-user-id))]
+                             (format "%s/users/%s/groups" api-root user-id))]
     (reduce (fn [paths {:strs [path]}]
-              (conj paths (subs path 12))) ;; remove leading /akvo/lumen/
+              (conj paths (subs path 12)))
             #{} user-groups)))

@@ -255,7 +267,7 @@
 ;;; KeycloakAgent Component
 ;;;

-(defrecord KeycloakAgent [issuer openid-config api-root]
+(defrecord KeycloakAgent [issuer openid-config api-root user-id-cache]
   p/KeycloakUserManagement
   (add-user-with-email [{:keys [api-root] :as keycloak} tenant-label email]
     (let [request-headers (request-headers keycloak)
@@ -314,7 +326,8 @@
 (defn- keycloak [{:keys [credentials url realm]}]
   (map->KeycloakAgent {:api-root (format "%s/admin/realms/%s" url realm)
                        :credentials credentials
-                       :issuer (format "%s/realms/%s" url realm)}))
+                       :issuer (format "%s/realms/%s" url realm)
+                       :user-id-cache (atom {})}))

 (defmethod ig/init-key :akvo.lumen.component.keycloak/data  [_ {:keys [url realm] :as opts}]
   (try


Create new session every time connection to db is required.

--- src/kixi/hecuba/db.clj
+++ src/kixi/hecuba/db.clj
@@ -7,15 +7,9 @@
    (jig Lifecycle)
    (kixi.hecuba.protocols Commander)))

-
-(defn execute-query
-  "Executes raw CQL query."
-  [session query]
-  (client/execute session query))
-
 (defn create-db-session
   "Connects to a cluster, creates a session and binds it to system."
-  [system config]
+  [config]
   (let [host        (:hosts config)
         ks          (:keyspace config)
         port        (:port config)
@@ -26,12 +20,19 @@
                       :credentials credentials})]
     (client/connect cluster ks)))

+(defn execute-query
+  "Executes raw CQL query."
+  [config query]
+  (let [session (create-db-session config)]
+    (client/execute session query)
+   ; (client/disconnect!)
+    ))
+
 (deftype Database [config]
   Lifecycle
   (init [_ system]
     system)
   (start [_ system]
-    (let [session (create-db-session system config)]
-      (update-in system [(:jig/id config) ::db-session] (constantly session))))
+    (update-in system [(:jig/id config) ::cluster] (constantly (select-keys config [:hosts :keyspace :port :credentials]))))
   (stop [_ system]
     system))


Update to latest s/fn-spec API

Update to latest s/fn-spec API

Fixes #315

--- planck-cljs/src/planck/repl.cljs
+++ planck-cljs/src/planck/repl.cljs
@@ -1236,14 +1236,13 @@
             (println " " doc))))
       (when n
         (let [spec-lookup (fn [ns-suffix]
-                            (s/fn-specs (symbol (str (ns-name n) ns-suffix) (name nm))))
-              specs       (concat (spec-lookup "") (spec-lookup "$macros"))]
-          (when (some identity (vals specs))
+                            (s/fn-spec (symbol (str (ns-name n) ns-suffix) (name nm))))]
+          (when-let [fnspec (or (spec-lookup "")
+                                (spec-lookup "$macros"))]
             (print "Spec")
-            (run! (fn [[role spec]]
-                    (when (and spec (not (= spec ::s/unknown)))
-                      (print (str "\n " (name role) ":") (format-spec spec (+ 3 (count (name role))) n))))
-              specs)
+            (doseq [role [:args :ret :fn]]
+              (when-let [spec (get fnspec role)]
+                (print (str "\n " (name role) ":") (format-spec spec (+ 3 (count (name role))) n))))
             (println)))))))

 (defn- doc*


Use :version-mvn for version ranges in dep metadata

--- src/leiningen/voom.clj
+++ src/leiningen/voom.clj
@@ -1061,7 +1061,7 @@
   - g. narrow proj dir changes to candidates by finding proj dir changes
        with no childer proj dir changes in this set
 "
-  [proj-name {:keys [sha version repo branch path allow-snaps]
+  [proj-name {:keys [sha version-mvn repo branch path allow-snaps]
               :or {allow-snaps true sha (l/lvar)}}]
   (for [gitdir (all-repos-dirs)
         :when (or (nil? repo) (= repo (-> (remotes gitdir) :origin :fetch)))
@@ -1091,16 +1091,16 @@
                        (conj shas-c branch-sha)
                        shas-c)
               gvs (GenericVersionScheme.)
-              version-constraint (when version
-                                   (.parseVersionConstraint gvs version))
-              candidates-d (if version
-                        (keep #(let [[candidate] (get sha-candidates-a %)]
-                                 (when (.containsVersion
-                                        version-constraint
-                                        (.parseVersion gvs (:version candidate)))
-                                   candidate))
-                              shas-c)
-                        (map (comp first sha-candidates-a) shas-c))
+              version-constraint (when version-mvn
+                                   (.parseVersionConstraint gvs version-mvn))
+              candidates-d (if version-mvn
+                             (keep #(let [[candidate] (get sha-candidates-a %)]
+                                      (when (.containsVersion
+                                             version-constraint
+                                             (.parseVersion gvs (:version candidate)))
+                                        candidate))
+                                   shas-c)
+                             (map (comp first sha-candidates-a) shas-c))
               [_ max-ver-e] (apply compare-max
                                    (map #(vector (when % (.parseVersion gvs %)) %)
                                         (distinct (map :version candidates-d))))


fn set hue

fn set hue

--- src/lights/my_show.clj
+++ src/lights/my_show.clj
@@ -225,8 +225,13 @@
     )
 )

-; Main hue, which is used in the show
-(afterglow.show/set-variable! :main-hue 0)
+(defn set-hue
+  "Set main hue"
+  [hue]
+  (afterglow.show/set-variable! :main-hue hue)
+)
+
+(set-hue 0)

 ; Max lightness in the show
 (afterglow.show/set-variable! :max-lightness 50)


Fix dispatching when clicking on article links

--- src/markiki/views.cljs
+++ src/markiki/views.cljs
@@ -15,8 +15,7 @@

 (defn article-link []
   (fn [{:keys [path title text last-modified]}]
-    [:li [:a {:href (str "#" path)
-              :on-click #(dispatch [:view-article path])} title]]))
+    [:li [:a {:href (str "#" path)} title]]))

 (defn articles-list [articles]
   [:ul#articles-list


code cleanup

code cleanup


Removes a reflection warning

Removes a reflection warning

--- src/paredit/parser.clj
+++ src/paredit/parser.clj
@@ -23,7 +23,7 @@
 #_(def *atoms* (conj *atom* :whitespace))

 (defn eof [s eof?]
-  (when (and (= 0 (.length s)) eof?) [0 eof]))
+  (when (and (= 0 (.length ^String s)) eof?) [0 eof]))

 (defn bracket-end [s eof?]
   (lr+/match #{")" "]" "}" eof} s eof?))


cleaning up

cleaning up

--- src/proxmox/remote.clj
+++ src/proxmox/remote.clj
@@ -32,12 +32,7 @@
   [verb api args]
   (:data (parse-string (:body (verb (<< "~(root)~{api}") (merge args http-opts))) true)))

-(defn proxmox-conf []
-
-  (let [c (get-in config [:hypervisor :proxmox])]
-    (debug c)
-    c
-    ))
+(defn proxmox-conf [] (get-in config [:hypervisor :proxmox]))

 (defn login-creds []
   (select-keys
@@ -72,5 +67,3 @@

 (defn prox-get [api] (call client/get api {:headers auth-headers}))

-
-(login)


Доработка пагинатора и элемента просмотра. Добавлен пагинатор снизу

--- radiolamp-6P3S/src/ixinfestor/omut.cljs
+++ radiolamp-6P3S/src/ixinfestor/omut.cljs
@@ -1693,7 +1693,7 @@
    :page-size 10
    :count-all nil})

-(defn paginator [app owner {:keys [chan-update class+]}]
+(defn paginator [app owner {:keys [chan-update class+ on-click-fn]}]
   (reify
     om/IRender
     (render [this]
@@ -1708,6 +1708,8 @@
                                                  (om/update! app :page 1)
                                                  (when chan-update
                                                    (put! chan-update 1))
+
+                                                 (when on-click-fn (on-click-fn))
                                                  1)
                                      :text     (dom/span #js {:className   "glyphicon glyphicon-fast-backward"
                                                               :aria-hidden "true"})
@@ -1719,6 +1721,8 @@
                                                                #(if (= 1 %) % (dec %)))
                                                  (when chan-update
                                                    (put! chan-update 1))
+
+                                                 (when on-click-fn (on-click-fn))
                                                  1)
                                      :text     (dom/span nil
                                                          (dom/span #js {:className   "glyphicon glyphicon-step-backward"
@@ -1727,14 +1731,19 @@
                                      })
                          )

-               (dom/h4 nil
-                       (str " стр." (@app :page)
-                            (when-let [count-all (:count-all @app)]
-                              (str
-                               (if-let [page-size (:page-size @app)]
-                                 (str " из " (inc (quot count-all page-size)))
-                                 "")
-                               " (" count-all ") "))))
+
+               (let [{:keys [page page-size count-all]} @app]
+                 (dom/div
+                  #js {:className "input-control"
+                       :style #js {:lineHeight 1.2}}
+                  " страница "
+                  (dom/b nil page)
+                  (when (and count-all page-size) " из ")
+                  (when (and count-all page-size) (dom/b nil (inc (quot count-all page-size))))
+
+                  (when count-all (dom/br nil))
+                  (when count-all "всего записей ")
+                  (when count-all (dom/b nil (str count-all)))))

                (dom/span #js {:className "input-group-btn"}
                          (ui-button {:type     :default
@@ -1742,6 +1751,8 @@
                                                  (om/transact! app :page inc)
                                                  (when chan-update
                                                    (put! chan-update 1))
+
+                                                 (when on-click-fn (on-click-fn))
                                                  1)
                                      :text     (dom/span nil "Вперед "
                                                          (dom/span #js {:className   "glyphicon glyphicon-step-forward"
@@ -1876,11 +1887,25 @@

         ;;(dom/br nil)
         (when tools tools)
+
+        ;; top paginator
         (dom/div #js {:className "input-group col-xs-12 col-sm-12"}
                  (om/build paginator app {:opts {:chan-update chan-update}}))
+
         (dom/br nil)
+
         ;; data rendering component
-        (data-rendering-fn app))))))
+        (data-rendering-fn app)
+
+
+        ;; bottom paginator
+        (dom/div #js {:className "input-group col-xs-12 col-sm-12"}
+                 (om/build
+                  paginator app
+                  {:opts {:chan-update chan-update
+                          ;; При отрабатывании прокручивать страницу на верх
+                          :on-click-fn #(.scrollTo js/window 0 0)}}))
+        (dom/br nil))))))

 ;; END Search view


clean up a little more when switching away from search

--- pedestal-app/app/src/semtag_web/rendering.cljs
+++ pedestal-app/app/src/semtag_web/rendering.cljs
@@ -55,6 +55,25 @@
     ;; didn't use get-parent-id cause it doesn't work for new multi-level paths
     (dom/set-html! (dom/by-id "content") (html {}))))

+(defn render-tags-results [_ [_ _ _ new-value] _]
+  (dom/insert-after!
+    (dom/by-id "url_search_text")
+    (p/generate-datalist new-value)))
+
+(defn url-search [{:keys [transform messages]}]
+  (let [search-map {:query (.-value (dom/by-id "url_search_text"))
+                    :search-type (dom/value (css/sel "input[name=search_type]:checked"))}
+        search-id (route/create-screen-id :search search-map)]
+    ;; needed for history navigation
+    (swap! route/dynamic-screens assoc search-id search-map)
+    (msg/fill transform messages (assoc search-map
+                                        :name search-id
+                                        :paths [[:app-model :search-form] [:app-model :search search-id] [:app-model :navbar]]))))
+
+(defn create-url [{:keys [transform messages]}]
+  (msg/fill transform messages {:value (dom/value (dom/by-id "add_url_text"))}))
+
+;; Search page
 (defn set-search-title [renderer [_ path _ new-value] _]
   (dom/set-html! (dom/by-id "search_title") new-value))

@@ -72,23 +91,10 @@
                         :row-partial p/tag-search-row
                         :caption (format "Total: %s" (count (map :url things)))))))

-(defn render-tags-results [_ [_ _ _ new-value] _]
-  (dom/insert-after!
-    (dom/by-id "url_search_text")
-    (p/generate-datalist new-value)))
-
-(defn url-search [{:keys [transform messages]}]
-  (let [search-map {:query (.-value (dom/by-id "url_search_text"))
-                    :search-type (dom/value (css/sel "input[name=search_type]:checked"))}
-        search-id (route/create-screen-id :search search-map)]
-    ;; needed for history navigation
-    (swap! route/dynamic-screens assoc search-id search-map)
-    (msg/fill transform messages (assoc search-map
-                                        :name search-id
-                                        :paths [[:app-model :search-form] [:app-model :search search-id] [:app-model :navbar]]))))
-
-(defn create-url [{:keys [transform messages]}]
-  (msg/fill transform messages {:value (dom/value (dom/by-id "add_url_text"))}))
+;; we'd like to destroy/hide these but that requires changing render-search-results
+(defn clear-search [_ _ _]
+  (dom/set-html! (dom/by-id "table_stats") "")
+  (dom/set-html! (dom/by-id "search_table") ""))

 ;;; Other pages
 ;;;
@@ -160,8 +166,7 @@

      ;; search page
      [:node-create [:app-model :search :*] navigate-search]
-    ;; TODO - still need to clear up more of table
-     [:node-destroy [:app-model :search :*] (clear-id "table_stats")]
+     [:node-destroy [:app-model :search :*] clear-search]
      [:value [:app-model :search :* :search-title] set-search-title]
      [:value [:app-model :search :* :search-results] render-search-results]


gabi's edits

gabi's edits

--- src/reagent_search/core.cljs
+++ src/reagent_search/core.cljs
@@ -26,10 +26,10 @@
                    {:chan-keyboard (chan)
                     :chan-query (chan)
                     :chan-log (:chan-log @logger-props)
-                    :placeholder-text "Type search here"
+                    :placeholder-text "The chicken fell off the roof"
                     :button-label "Search"
                     :sample-timeout-ms 1000
-                    :autocomplete-size 4}))
+                    :autocomplete-size 5}))

 ;; pass in navbar data as properties as the data and navbar is immutable
 (navbar/mount-navbar "navbar" @navbar-props)


Clearer method of derefing a reaction to fire it

--- src/re_demo/h_box.cljs
+++ src/re_demo/h_box.cljs
@@ -772,6 +772,7 @@
   []
   (fn
     []
+    @reset-box-state ;; For reset-box-state to fire, we must dereference it in a component
     [v-box
      :size     "auto"
      :gap      "10px"
@@ -803,5 +804,4 @@
                                         [gap :size "0px"]
                                         [demo]
                                         [gap :size "0px"]
-                                        [choose-a-demo]
-                                        (when (nil? @reset-box-state) "")]]]]]])) ;; For reset-box-state to fire, we must dereference it in a component
+                                        [choose-a-demo]]]]]]]))


Add note on registrar needs.

Add note on registrar needs.

--- src/re_frame/core.cljc
+++ src/re_frame/core.cljc
@@ -103,6 +103,17 @@
 (def console loggers/console)

+;; -- Registrar
+;; XXX
+;; In testing you often need to store the current state of the registrar
+;; and then reinstate it  state, and then reinstate
+;; that state at the end of the
+;; then re-instate it.
+;; So, in a testing scenario, you'd store the
+;; current state,  make changes and then put back the way it was.
+;; OR should this be done with bindings ??
+
+
 ;; -- Event Procssing Callbacks

 (defn add-post-event-callback


Fix whitespace errors in src/re_frame/core.cljc

--- src/re_frame/core.cljc
+++ src/re_frame/core.cljc
@@ -21,7 +21,7 @@
 ;; -- dispatch ----------------------------------------------------------------

 (defn dispatch
-  "Queue `event` for processing (handling).
+  "Queue `event` for processing (handling).

   `event` is a vector and the first element is typically a keyword
   which identifies the kind of event.
@@ -32,7 +32,7 @@
   will be processed first.

   Usage:
-
+
       (dispatch [:order \"pizza\" {:supreme 2 :meatlovers 1 :veg 1}])
   "
   {:api-docs/heading "Dispatching Events"}
@@ -41,17 +41,17 @@

 (defn dispatch-sync
   "Synchronously (immediately) process `event`. It does **not** queue
-  the event for handling later as `dispatch` does.
-
-  `event` is a vector and the first element is typically a keyword
+  the event for handling later as `dispatch` does.
+
+  `event` is a vector and the first element is typically a keyword
   which identifies the kind of event.

-  It is an error to use `dispatch-sync` within an event handler because
+  It is an error to use `dispatch-sync` within an event handler because
   you can't immediately process an new event when one is already
   part way through being processed.

-  Generally, avoid using this function, and instead, use `dispatch`.
-  Only use it in the narrow set of cases where any delay in
+  Generally, avoid using this function, and instead, use `dispatch`.
+  Only use it in the narrow set of cases where any delay in
   processing is a problem:

     1. the `:on-change` handler of a text field where we are expecting fast typing
@@ -79,8 +79,8 @@

   Example Usage:

-      (reg-event-db
-        :token
+      (reg-event-db
+        :token
         (fn [db event]
           (assoc db :some-key (get event 2)))  ;; return updated db

@@ -90,7 +90,7 @@
         :namespaced/id           ;; <-- namespaced keywords are often used
         [one two three]          ;; <-- a seq of interceptors
         (fn [db [_ arg1 arg2]]   ;; <-- event vector is destructured
-          (-> db
+          (-> db
             (dissoc arg1)
             (update :key + arg2))))   ;; return updated db
   "
@@ -112,8 +112,8 @@

   Example Usage:

-      (reg-event-fx
-        :event-id
+      (reg-event-fx
+        :event-id
         (fn [cofx event]
           {:db (assoc (:db cofx) :some-key (get event 2))}))   ;; return a map of effects

@@ -137,22 +137,22 @@
 (defn reg-event-ctx
   "Register the given event `handler` (function) for the given `id`. Optionally, provide
   an `interceptors` chain:
-
+
     - `id` is typically a namespaced keyword  (but can be anything)
     - `handler` is a function: context-map -> context-map

   You can explore what is provided in `context` [here](https://day8.github.io/re-frame/Interceptors/#what-is-context).
-
+
   Example Usage:

-      (reg-event-ctx
+      (reg-event-ctx
         :event-id
         (fn [{:keys [coeffects] :as context}]
           (let [initial  {:db     (:db coeffects)
                           :event  (:event coeffects)
                           :fx     []}
                 result   (-> initial
-                           function1
+                           function1
                            function2
                            function3)
                 effects  (selectkeys result [:db :fx])]
@@ -165,12 +165,12 @@
    (events/register id [cofx/inject-db fx/do-fx std-interceptors/inject-global-interceptors interceptors (ctx-handler->interceptor handler)])))

 (defn clear-event
-  "Unregisters event handlers (presumably registered previously via the use of `reg-event-db` or `reg-event-fx`).
-
-  When called with no args, it will unregister all currently registered event handlers.
-
-  When given one arg, assumed to be the `id` of a previously registered
-  event handler, it will unregister the associated handler. Will produce a warning to
+  "Unregisters event handlers (presumably registered previously via the use of `reg-event-db` or `reg-event-fx`).
+
+  When called with no args, it will unregister all currently registered event handlers.
+
+  When given one arg, assumed to be the `id` of a previously registered
+  event handler, it will unregister the associated handler. Will produce a warning to
   console if it finds no matching registration."
   {:api-docs/heading "Event Handlers"}
   ([]
@@ -183,48 +183,48 @@

 (defn reg-sub
   "A call to `reg-sub` associates a `query-id` WITH two functions.
-
-  The two functions provide 'a mechanism' for creating a node
-  in the Signal Graph. When a node of type `query-id` is needed,
+
+  The two functions provide 'a mechanism' for creating a node
+  in the Signal Graph. When a node of type `query-id` is needed,
   the two functions can be used to create it.
-
-  The three arguments are:
-
+
+  The three arguments are:
+
   - `query-id` - typically a namespaced keyword (later used in subscribe)
   - optionally, an `input signals` function which returns the input data
-    flows required by this kind of node.
-  - a `computation function` which computes the value (output) of the
+    flows required by this kind of node.
+  - a `computation function` which computes the value (output) of the
     node (from the input data flows)
-
+
   Later, during app execution, a call to `(subscribe [:sub-id 3 :blue])`,
-  will trigger the need for a new `:sub-id` Signal Graph node (matching the
-  query `[:sub-id 3 :blue]`). And, to create that node the two functions
+  will trigger the need for a new `:sub-id` Signal Graph node (matching the
+  query `[:sub-id 3 :blue]`). And, to create that node the two functions
   associated with `:sub-id` will be looked up and used.

-  Just to be clear: calling `reg-sub` does not immediately create a node.
-  It only registers 'a mechanism' (the two functions) by which nodes
-  can be created later, when a node is bought into existence by the
+  Just to be clear: calling `reg-sub` does not immediately create a node.
+  It only registers 'a mechanism' (the two functions) by which nodes
+  can be created later, when a node is bought into existence by the
   use of `subscribe` in a `View Function`.

   The `computation function` is expected to take two arguments:
-
+
     - `input-values` - the values which flow into this node (how is it wierd into the graph?)
     - `query-vector` - the vector given to `subscribe`
-
+
   and it returns a computed value (which then becomes the output of the node)

-  When `computation function` is called, the 2nd `query-vector` argument will be that
+  When `computation function` is called, the 2nd `query-vector` argument will be that
   vector supplied to the `subscribe`. So, if the call was `(subscribe [:sub-id 3 :blue])`,
   then the `query-vector` supplied to the computaton function will be `[:sub-id 3 :blue]`.

-  The argument(s) supplied to `reg-sub` between `query-id` and the `computation-function`
-  can vary in 3 ways, but whatever is there defines the `input signals` part
-  of `the mechanism`, specifying what input values \"flow into\" the
+  The argument(s) supplied to `reg-sub` between `query-id` and the `computation-function`
+  can vary in 3 ways, but whatever is there defines the `input signals` part
+  of `the mechanism`, specifying what input values \"flow into\" the
   `computation function` (as the 1st argument) when it is called.

-  So, `reg-sub` can be called in one of three ways, because there are three ways
-  to define the input signals part. But note, the 2nd method, in which a
-  `signals function` is explicitly supplied, is the most canonical and
+  So, `reg-sub` can be called in one of three ways, because there are three ways
+  to define the input signals part. But note, the 2nd method, in which a
+  `signals function` is explicitly supplied, is the most canonical and
   instructive. The other two are really just sugary variations.

   **First variation** - no input signal function given:
@@ -317,7 +317,7 @@

   For further understanding, read the tutorials, and look at the detailed comments in
   /examples/todomvc/src/subs.cljs.
-
+
   See also: `subscribe`
   "
   {:api-docs/heading "Subscriptions"}
@@ -329,17 +329,17 @@
   time, reactively deliver a stream of values. So, in FRP-ish terms,
   it returns a `Signal`.

-  To obtain the current value from the Signal, it must be dereferenced:
-
+  To obtain the current value from the Signal, it must be dereferenced:
+
       (let [signal (subscribe [:items])
             value  (deref signal)]     ;; could be written as @signal
         ...)
-
+
    which is typically written tersely as simple:
-
-      (let [items  @(subscribe [:items])]
+
+      (let [items  @(subscribe [:items])]
         ...)
-
+

   `query` is a vector of at least one element. The first element is the
   `query-id`, typically a namespaced keyword. The rest of the vector's
@@ -355,26 +355,26 @@
       (subscribe [:items])
       (subscribe [:items \"blue\" :small])
       (subscribe [:items {:colour \"blue\"  :size :small}])
-
+
   Note: for any given call to `subscribe` there must have been a previous call
-  to `reg-sub`, registering the query handler (functions) associated with
+  to `reg-sub`, registering the query handler (functions) associated with
   `query-id`.

   **Hint**

   When used in a view function BE SURE to `deref` the returned value.
   In fact, to avoid any mistakes, some prefer to define:
-
+
       (def <sub  (comp deref re-frame.core/subscribe))
-
+
   And then, within their views, they call  `(<sub [:items :small])` rather
   than using `subscribe` directly.

   **De-duplication**

-  Two, or more, concurrent subscriptions for the same query will
+  Two, or more, concurrent subscriptions for the same query will
   source reactive updates from the one executing handler.
-
+
   See also: `reg-sub`
   "
   {:api-docs/heading "Subscriptions"}
@@ -384,12 +384,12 @@
    (subs/subscribe query dynv)))

 (defn clear-sub ;; think unreg-sub
-  "Unregisters subscription handlers (presumably registered previously via the use of `reg-sub`).
-
-  When called with no args, it will unregister all currently registered subscription handlers.
-
-  When given one arg, assumed to be the `id` of a previously registered
-  subscription handler, it will unregister the associated handler. Will produce a warning to
+  "Unregisters subscription handlers (presumably registered previously via the use of `reg-sub`).
+
+  When called with no args, it will unregister all currently registered subscription handlers.
+
+  When given one arg, assumed to be the `id` of a previously registered
+  subscription handler, it will unregister the associated handler. Will produce a warning to
   console if it finds no matching registration.

   NOTE: Depending on the usecase, it may be necessary to call `clear-subscription-cache!` afterwards"
@@ -417,8 +417,8 @@

   This function can be used at development time or test time. Useful when hot realoding
   namespaces containing subscription handlers. Also call it after a React/render exception,
-  because React components won't have been cleaned up properly. And this, in turn, means
-  the subscriptions within those components won't have been cleaned up correctly. So this
+  because React components won't have been cleaned up properly. And this, in turn, means
+  the subscriptions within those components won't have been cleaned up correctly. So this
   forces the issue.
   "
   {:api-docs/heading "Subscriptions"}
@@ -454,12 +454,12 @@

 (defn clear-fx ;; think unreg-fx
-  "Unregisters effect handlers (presumably registered previously via the use of `reg-fx`).
-
-  When called with no args, it will unregister all currently registered effect handlers.
-
-  When given one arg, assumed to be the `id` of a previously registered
-  effect handler, it will unregister the associated handler. Will produce a warning to
+  "Unregisters effect handlers (presumably registered previously via the use of `reg-fx`).
+
+  When called with no args, it will unregister all currently registered effect handlers.
+
+  When given one arg, assumed to be the `id` of a previously registered
+  effect handler, it will unregister the associated handler. Will produce a warning to
   console if it finds no matching registration.
   "
   {:api-docs/heading "Effect Handlers"}
@@ -478,7 +478,7 @@
     - `handler` is a function which takes either one or two arguements, the first of which is
        always `coeffects` and which returns an updated `coeffects`.

-  See also: `inject-cofx`
+  See also: `inject-cofx`
   "
   {:api-docs/heading "Coeffects"}
   [id handler]
@@ -518,7 +518,7 @@
         [ ... (inject-cofx :datetime) ... ]  ;; <-- create an injecting interceptor
         (fn event-handler
           [coeffect event]
-            ;;... in here can access (:now coeffect) to obtain current datetime ...
+            ;;... in here can access (:now coeffect) to obtain current datetime ...
           )))

   **Background**
@@ -537,7 +537,7 @@
   Instead, the interceptor created by this function is a way to 'inject'
   'necessary resources' into the `:coeffects` (map) subsequently given
   to the event handler at call time.
-
+
   See also `reg-cofx`
   "
   {:api-docs/heading "Coeffects"}
@@ -547,12 +547,12 @@
    (cofx/inject-cofx id value)))

 (defn clear-cofx ;; think unreg-cofx
-  "Unregisters coeffect handlers (presumably registered previously via the use of `reg-cofx`).
-
-  When called with no args, it will unregister all currently registered coeffect handlers.
-
-  When given one arg, assumed to be the `id` of a previously registered
-  coeffect handler, it will unregister the associated handler. Will produce a warning to
+  "Unregisters coeffect handlers (presumably registered previously via the use of `reg-cofx`).
+
+  When called with no args, it will unregister all currently registered coeffect handlers.
+
+  When given one arg, assumed to be the `id` of a previously registered
+  coeffect handler, it will unregister the associated handler. Will produce a warning to
   console if it finds no matching registration."
   {:api-docs/heading "Coeffects"}
   ([]
@@ -594,11 +594,11 @@
   std-interceptors/debug)

 (defn path
-  "Returns an interceptor which acts somewhat like `clojure.core/update-in`, in the sense that
-  the event handler is given a specific part of `app-db` to change, not all of `app-db`.
-
-  The interceptor has both a `:before` and `:after` functions. The `:before` replaces
-  the `:db` key within coeffects with a sub-path within `app-db`. The `:after` reverses the process,
+  "Returns an interceptor which acts somewhat like `clojure.core/update-in`, in the sense that
+  the event handler is given a specific part of `app-db` to change, not all of `app-db`.
+
+  The interceptor has both a `:before` and `:after` functions. The `:before` replaces
+  the `:db` key within coeffects with a sub-path within `app-db`. The `:after` reverses the process,
   and it grafts the handler's return value back into db, at the right path.

   Examples:
@@ -617,7 +617,7 @@
           ... new-b))   ;; returns a new value for that path (not the entire db)

   Notes:
-
+
     1. `path` may appear more than once in an interceptor chain. Progressive narrowing.
     2. if `:effects` contains no `:db` effect, can't graft a value back in.
   "
@@ -627,8 +627,8 @@

 (defn enrich
   "Returns an Interceptor which will run the given function `f` in the `:after`
-  position.
-
+  position.
+
   `f` is called with two arguments: `db` and `v`, and is expected to
   return a modified `db`.

@@ -779,12 +779,12 @@
   (settings/reg-global-interceptor interceptor))

 (defn clear-global-interceptor
-  "Unregisters global interceptors (presumably registered previously via the use of `reg-global-interceptor`).
-
-  When called with no args, it will unregister all currently registered global interceptors.
-
-  When given one arg, assumed to be the `id` of a previously registered
-  global interceptors, it will unregister the associated interceptor. Will produce a warning to
+  "Unregisters global interceptors (presumably registered previously via the use of `reg-global-interceptor`).
+
+  When called with no args, it will unregister all currently registered global interceptors.
+
+  When given one arg, assumed to be the `id` of a previously registered
+  global interceptors, it will unregister the associated interceptor. Will produce a warning to
   console if it finds no matching registration."
   {:api-docs/heading "Global Interceptors"}
   ([]
@@ -809,21 +809,21 @@
          :id     :my-interceptor
          :before (fn [context]
                    ... modifies and returns `context`)
-         :after  (fn [context]
+         :after  (fn [context]
                    ... modifies and returns `context`)))
-
+
   Notes:
-
-    - `:before` functions modify and return their `context` argument. Sometimes they
+
+    - `:before` functions modify and return their `context` argument. Sometimes they
       only side effect, in which case, they'll perform the side effect and return
       `context` unchanged.
-    - `:before` functions often modify the `:coeffects` map within `context` and,
-      if they do, then they should use the utility functions `get-coeffect` and
+    - `:before` functions often modify the `:coeffects` map within `context` and,
+      if they do, then they should use the utility functions `get-coeffect` and
       `assoc-coeffect`.
-    - `:after` functions modify and return their `context` argument. Sometimes they
-      only side effect, in which case, they'll perform the side effect and return
+    - `:after` functions modify and return their `context` argument. Sometimes they
+      only side effect, in which case, they'll perform the side effect and return
       `context` unchanged.
-    - `:after` functions often modify the `:effects` map within `context` and,
+    - `:after` functions often modify the `:effects` map within `context` and,
       if they do, then they should use the utility functions `get-effect`
       and `assoc-effect`"
   {:api-docs/heading "Writing Interceptors"}
@@ -881,10 +881,10 @@
 (defn enqueue
   "A utility function, used when writing an interceptor's `:before` function.

-  Adds the given collection of `interceptors` to those already in `context's`
+  Adds the given collection of `interceptors` to those already in `context's`
   execution `:queue`. It returns the updated `context`.
-
-  So, it provides a way for one Interceptor to add more interceptors to the
+
+  So, it provides a way for one Interceptor to add more interceptors to the
   currently executing interceptor chain.
   "
   {:api-docs/heading "Writing Interceptors"}
@@ -895,13 +895,13 @@
 ;; --  logging ----------------------------------------------------------------

 (defn set-loggers!
-  "re-frame outputs warnings and errors via the API function `console`
-   which, by default, delegates to `js/console`'s default implementation for
+  "re-frame outputs warnings and errors via the API function `console`
+   which, by default, delegates to `js/console`'s default implementation for
   `log`, `error`, `warn`, `debug`, `group` and `groupEnd`. But, using this function,
-   you can override that behaviour with your own functions.
-
-  The argument `new-loggers` should be a map containing a subset of they keys
-  for the standard `loggers`, namely  `:log` `:error` `:warn` `:debug` `:group`
+   you can override that behaviour with your own functions.
+
+  The argument `new-loggers` should be a map containing a subset of they keys
+  for the standard `loggers`, namely  `:log` `:error` `:warn` `:debug` `:group`
   or `:groupEnd`.

   Example Usage:
@@ -919,12 +919,12 @@

 (defn console
-  "A utility logging function which is used internally within re-frame to produce
-  warnings and other output. It can also be used by libraries which
+  "A utility logging function which is used internally within re-frame to produce
+  warnings and other output. It can also be used by libraries which
   extend re-frame, such as effect handlers.

   By default, it will output the given `args` to `js/console` at the given log `level`.
-  However, an application using re-frame can redirect `console` output via `set-loggers!`.
+  However, an application using re-frame can redirect `console` output via `set-loggers!`.

   `level` can be one of `:log`, `:error`, `:warn`, `:debug`, `:group` or `:groupEnd`.

@@ -977,8 +977,8 @@
 ;; -- Event Processing Callbacks  ---------------------------------------------

 (defn add-post-event-callback
-  "Registers the given function `f` to be called after each event is processed.
-
+  "Registers the given function `f` to be called after each event is processed.
+
    `f` will be called with two arguments:

     - `event`: a vector. The event just processed.
@@ -991,7 +991,7 @@
        handlers for the one event, etc.  Hook in here.
      - libraries providing 'isomorphic javascript' rendering on  Nodejs or Nashorn.

-  `id` is typically a keyword. If it supplied when an `f` is added, it can be
+  `id` is typically a keyword. If it supplied when an `f` is added, it can be
   subsequently be used to identify it for removal. See `remove-post-event-callback`.
   "
   {:api-docs/heading "Miscellaneous"}
@@ -1002,8 +1002,8 @@

 (defn remove-post-event-callback
-  "Unregisters a post event callback function, identified by `id`.
-
+  "Unregisters a post event callback function, identified by `id`.
+
   Such a function must have been previously registered via `add-post-event-callback`"
   {:api-docs/heading "Miscellaneous"}
   [id]


make temperature stand out more

make temperature stand out more

--- src/rpi_wall/style.clj
+++ src/rpi_wall/style.clj
@@ -47,7 +47,10 @@
        [:div.weather    {:background-color (rgba 50 50 50 0.5)}]
        [:div.todo-today {:background-color (rgba 50 50 50 0.5)}]
        [:div.todo       {:background-color (rgba 50 50 50 0.5)}]
-       [:div.temp       {:background-color (rgba 50 50 50 0.5)}]
+       [:div.temp       {:background-color (rgba 50 50 50 0.5)
+                         :font-size        "150%"
+                         :color            (rgb 210 210 210)
+                         :font-family      "OpenSansLight"}]
        [:div.fortune    {:background-color (rgba 50 50 50 0.5)
                          :text-align "left"}]


put the reload handler back in

put the reload handler back in

--- src/smallblog/core.clj
+++ src/smallblog/core.clj
@@ -125,7 +125,7 @@
 	(-> main-routes
 		(with-security security-config authorize)
 		wrap-stateful-session
-		;(wrap-reload '(smallblog.templates)) ; XXX not for production
+		(wrap-reload '(smallblog.templates)) ; XXX not for production
 		(wrap-stacktrace)
 		(wrap-params)
 		(wrap-json-params)))


changed filter_parser to allow for double dots form of escape

--- src/selmer/filter_parser.clj
+++ src/selmer/filter_parser.clj
@@ -69,9 +69,10 @@
         ks))

 (defn split-filter-val
-  "Split accessors like foo.bar.baz by the dot."
+  "Split accessors like foo.bar.baz by the dot.
+   But if there is a double dot '..' then it will leave it"
   [s]
-  (let [ks (s/split s #"\.")]
+  (let [ks (s/split s #"(?<!\.)\.(?!\.)")]
     (fix-accessor ks)))

 (defn fix-filter-args


tweet text fixed again

tweet text fixed again

--- src/tweetiment/web.clj
+++ src/tweetiment/web.clj
@@ -91,7 +91,7 @@
           (url-encode
             (str
               "I got " num
-              " as my Tweet Happiness Quotient! See yours at http://tweetiment.herokuapp.com")))
+              " as my Tweet Happiness Quotient! See yours at")))
         "Tweet")])

 (defpartial error-page []


match wbid without get to case

match wbid without get to case

--- src/wb_es/web/core.clj
+++ src/wb_es/web/core.clj
@@ -4,7 +4,13 @@

 (defn wrap-query-lower-case [handler]
   (fn [request]
-    (handler (update-in request [:params :q] #(some-> % clojure.string/lower-case)))))
+    (let [q-raw (get-in request [:params :q])
+          new-request (-> request
+                          (update-in [:params :q] #(some-> % clojure.string/lower-case))
+                          (assoc-in [:params :q_raw] q-raw)
+                          )]
+      (handler new-request))
+    ))

 (defn get-filter [options]
@@ -27,7 +33,7 @@
                  {:bool
                   {:must [{:bool {:filter (get-filter options)}}
                           {:dis_max
-                           {:queries [{:term {:wbid q}}
+                           {:queries [{:term {:wbid (:q_raw options)}}
                                       {:match_phrase {:label {:query q
                                                               :minimum_should_match "70%"}}}
                                       {:match_phrase {:other_names {:query q
@@ -117,7 +123,7 @@
                  {:bool
                   {:must [{:bool {:filter (get-filter options)}}
                           {:dis_max
-                           {:queries [{:term {:wbid q}}
+                           {:queries [{:term {:wbid (:q_raw options)}}
                                       {:match_phrase {:label {:query q
                                                               :minimum_should_match "70%"}}}
                                       {:match_phrase {:other_names {:query q


Added password to db-spec

Added password to db-spec

--- src/word_keeper/db.clj
+++ src/word_keeper/db.clj
@@ -4,7 +4,8 @@
 (def db-spec {:classname "org.postgresql.Driver"
               :subprotocol "postgresql"
               :subname "//localhost:5432/wordkeeper"
-              :user "cloudsigma"})
+              :user "cloudsigma"
+              :password "wordkeeper"})

 (defquery select-english-russian "sql/select-english-russian.sql")
 (defquery select-russian-english "sql/select-russian-english.sql")


CMR-3774: Fixing oracle project.clj

CMR-3774: Fixing oracle project.clj

--- oracle-lib/project.clj
+++ oracle-lib/project.clj
@@ -5,17 +5,18 @@
    Oracle JDBC jars."
   "CMR_ORACLE_JAR_REPO")

-(def extra-repositories
+(def extra-repository
   "The set of repositories to include if configured"
-  (when-let [repo (get (System/getenv) oracle-jar-repo-env-var)]
-    [["releases" repo]]))
+  (if-let [repo (get (System/getenv) oracle-jar-repo-env-var)]
+    repo
+    "http://example.com/no_url_specified_this_is_ignored"))

 (defproject nasa-cmr/cmr-oracle-lib "0.1.0-SNAPSHOT"
   :description "Contains utilities for connecting to and manipulating data in Oracle."
   :url "***REMOVED***projects/CMR/repos/cmr/browse/oracle-lib"

   ;; Dynamically include extra repositories in the project definition if configured.
-  :repositories ~extra-repositories
+  :repositories [["releases" ~extra-repository]]

   :dependencies [[org.clojure/clojure "1.8.0"]
                  [nasa-cmr/cmr-common-lib "0.1.1-SNAPSHOT"]


add config option to keep import as is for :esm

similar to :keep-as-require but emits actual esm import not require

--- src/main/shadow/build/resolve.clj
+++ src/main/shadow/build/resolve.clj
@@ -233,7 +233,8 @@

     (or (str/starts-with? require "esm:")
         (str/starts-with? require "https://")
-        (str/starts-with? require "http://"))
+        (str/starts-with? require "http://")
+        (contains? (:keep-as-import js-options) require))
     (js-support/shim-import-resource state require)

     :else


Lock down build-helper-maven-plugin version for pom.xml generation (#668)

--- src/main/shadow/cljs/npm/cli.cljs
+++ src/main/shadow/cljs/npm/cli.cljs
@@ -700,6 +700,7 @@
                                [:plugin
                                 [:groupId "org.codehaus.mojo"]
                                 [:artifactId "build-helper-maven-plugin"]
+                                [:version "3.1.0"]
                                 [:executions
                                  [:execution
                                   [:phase "generate-sources"]


don't use clojure.string namespace here

don't use clojure.string namespace here

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

--- acqEngine/src/org/micromanager/mm.clj
+++ acqEngine/src/org/micromanager/mm.clj
@@ -81,7 +81,7 @@
     (.logMessage mmc s true))

 (defn handle-multiline [x]
-  (let [x-trimmed (clojure.string/trim x)]
+  (let [x-trimmed (.trim x)]
     (if (< 1 (count (.split x-trimmed "\n")))
       (str "\n" x-trimmed)
       x-trimmed)))


Some checkers had wrong form.

Some checkers had wrong form.

--- src/midje/checkers/deprecated.clj
+++ src/midje/checkers/deprecated.clj
@@ -11,9 +11,10 @@

 ;; Note: checkers need to be exported in ../checkers.clj

-(defchecker map-containing [expected]
+(defchecker map-containing
   "Accepts a map that contains all the keys and values in expected,
    perhaps along with others"
+  [expected]
   (contains expected))

 (defn- one-level-map-flatten [list-like-thing]
@@ -21,23 +22,25 @@
     list-like-thing
     (first list-like-thing)))

-(defn only-maps-containing [& maps-or-maplist]
+(defn only-maps-containing
   "Each map in the argument(s) contains some map in the expected
    result. There may be no extra maps in either the argument(s) or expected result.

    You can call this with either (only-maps-containing {..} {..}) or
    (only-maps-containing [ {..} {..} ])."
+  [& maps-or-maplist]
   {:midje/checker true}
   (let [expected (one-level-map-flatten maps-or-maplist)
         subfunctions (map contains expected)]
     (just subfunctions :in-any-order)))

-(defchecker maps-containing [& maps-or-maplist]
+(defchecker maps-containing
   "Each map in the argument(s) contains contains some map in the expected
    result. There may be extra maps in the actual result.

    You can call this with either (maps-containing {..} {..}) or
    (maps-containing [ {..} {..} ])."
+  [& maps-or-maplist]
   (let [expected (one-level-map-flatten maps-or-maplist)
         subfunctions (map contains expected)]
     (contains subfunctions :in-any-order :gaps-ok)))


Initial goal details parsing

Initial goal details parsing

--- src/nhl_score_api/html_parser.clj
+++ src/nhl_score_api/html_parser.clj
@@ -12,5 +12,56 @@
 (defn parse-games [dom-page]
   (html/select dom-page [:.sbGame]))

+(defn is-regulation-period? [dom-element]
+  (and (= :b (:tag dom-element))
+       (= " Period:" (last (:content dom-element)))))
+
+(defn is-overtime-period? [dom-element]
+  (and (= :b (:tag dom-element))
+       (= "OT Period:" (:content dom-element))))
+
+(defn get-period-number
+  "Parses the period number from the given DOM element, or nil if none found.
+  Returns 4 for overtime period."
+  [dom-element]
+  (cond
+    (is-regulation-period? dom-element)
+    (read-string (first (:content dom-element)))
+
+    (is-overtime-period? dom-element)
+    4
+
+    :default
+    nil))
+
+(defn get-goal
+  "Parses the goal information from the given DOM element, or nil if none found."
+  [dom-element]
+  (when (= "goalDetails" (:class (:attrs dom-element)))
+    dom-element))
+
+(defn add-period [goals period]
+  (map #(assoc % :period period) goals))
+
+(defn parse-goals-rec
+  "Parses given DOM elements and returns a collection of goals."
+  [dom-elements current-period current-goals all-goals]
+  (if (empty? dom-elements)
+    (concat all-goals (add-period current-goals current-period))
+    (let [dom-element (first dom-elements)
+          period-number (get-period-number dom-element)
+          goal (get-goal dom-element)]
+      (cond
+        period-number
+        (parse-goals-rec (rest dom-elements) period-number [] (concat all-goals (add-period current-goals current-period)))
+
+        goal
+        (parse-goals-rec (rest dom-elements) current-period (conj current-goals goal) all-goals)
+
+        :default
+        (parse-goals-rec (rest dom-elements) current-period current-goals all-goals)))))
+
 (defn parse-goals [dom-game]
-  (html/select dom-game [:.goalDetails]))
+  (let [scoring-infos (html/select dom-game [:.scoringInfo])
+        goal-infos (:content (first scoring-infos))]
+    (parse-goals-rec goal-infos nil [] [])))


use sizetieredcompactionstrategy on t_attr_x table

LeveledCompactionStrategy is much more io intensive with little gain for
time-series data.

--- src/blackbox/src/leela/blackbox/storage/cassandra.clj
+++ src/blackbox/src/leela/blackbox/storage/cassandra.clj
@@ -56,7 +56,7 @@
                cluster colfam
                (if-not-exists)
                (column-definitions {:key :uuid :name :varchar :bucket :bigint :slot :int :data :blob :primary-key [[:key :name :bucket] :slot]})
-               (with {:compaction {:class "LeveledCompactionStrategy" :sstable_size_in_mb "256"}}))))))
+               (with {:compaction {:class "SizeTieredCompactionStrategy" :min_threshold "6"}}))))))
   (when-not (describe-table cluster keyspace :k_attr)
     (warn "creating table k_attr")
     (create-table


Update extract-command documentation

Update extract-command documentation

--- src/yetibot/core/handler.clj
+++ src/yetibot/core/handler.clj
@@ -55,7 +55,7 @@
        (filter #(command? (-> % second second second)))))

 (defn extract-command
-  "Returns true if body has an command matching the prefix"
+  "Returns the body if it has the command structure with the prefix, otherwise nil"
   [body prefix]
     (re-find (re-pattern (str "^\\" prefix "(.+)")) body))


Start working on update

Start working on update

--- src/clojure/clojurewerkz/cassaforte/new_query_api.clj
+++ src/clojure/clojurewerkz/cassaforte/new_query_api.clj
@@ -210,6 +210,25 @@
                  (println builder statement)
                  (statement builder))
                (QueryBuilder/select)
+               )
+       (.toString)
+       ))
+
+(defn ^:private insert-order
+  {:values        1
+   :using         2
+   :if-not-exists 3})
+
+(defn insert
+  [table-name & statements]
+  (->> statements
+       (complete-select-query)
+       (sort-by #(get select-order (first %)))
+       (map second)
+       (reduce (fn [builder statement]
+                 (println builder statement)
+                 (statement builder))
+               (QueryBuilder/insertInto (name table-name))
                )
        (.toString)
        ))


Profiles rows.

Profiles rows.

--- src-cljs/kixi/hecuba/tabs/profiles.cljs
+++ src-cljs/kixi/hecuba/tabs/profiles.cljs
@@ -207,6 +207,21 @@
                (text-control profile_data state owner :frame_type "Frame Type")
                (text-control profile_data state owner :frame_type_other "Frame Type Other")])]))]))))

+(defn issues-row [profiles owner]
+  (reify
+    om/IRenderState
+    (render-state [_ state]
+      (html
+       [:div.col-md-12
+        (for [profile profiles]
+          (let [profile_data (:profile_data profile)]
+            [:div {:class (profile-column-width)}
+             (bs/panel
+              "Issues"
+              [:div
+               (text-control profile_data state owner :moisture_condensation_mould_strategy "Moisture Condensation Mould Strategy")
+               (text-control profile_data state owner :appliances_strategy "Appliances Strategy")
+               (text-control profile_data state owner :cellar_basement_issues "Cellar Basement Issues")])]))]))))

 (defn profile-rows [profiles owner]
   (reify
@@ -223,7 +238,7 @@
          (om/build flats-row profiles)
          (om/build fireplaces-row profiles)
          (om/build glazing-row profiles)
-         ;; (om/build issues profiles)
+         (om/build issues-row profiles)
          ;; (om/build sap-results profiles)
          ;; (om/build documents profiles)
          ;; (om/build co-heating profiles)


added new tasks

added new tasks


Use a portable path separator.

Use a portable path separator.

--- satellite-slave/src/satellite_slave/recipes.clj
+++ satellite-slave/src/satellite_slave/recipes.clj
@@ -19,8 +19,7 @@

 (defn make-recipe-cmd
   [x & xs]
-  (str (:satellite-recipe-prefix settings) "/satellite-recipes " x (apply str xs))
-)
+  (str (:satellite-recipe-prefix settings) (java.io.File/separator) "satellite-recipes " x (apply str xs)))

 (defn free-memory
   [threshold period]


Use intercom v2 widget - behind a settings switch

--- frontend/intercom.cljs
+++ frontend/intercom.cljs
@@ -4,18 +4,29 @@
 (defn intercom-jquery []
   (aget js/window "intercomJQuery"))

+(defn intercom-v1-new-message [jq message]
+  (.click (jq "#IntercomTab"))
+  (when-not (.is (jq "#IntercomNewMessageContainer") ":visible")
+    (.click (jq "[href=IntercomNewMessageContainer]")))
+  (when-not (.is (jq "#newMessageBody") ":visible")
+    (throw "didn't find intercom v1 widget"))
+  (.focus (jq "#newMessageBody"))
+  (when message
+    (.text (jq "#newMessageBody") (str message "\n\n"))))
+
+(defn intercom-v2-new-message [jq message]
+  (js/Intercom "show"))
+
 (defn raise-dialog [ch & [message]]
   (if-let [jq (intercom-jquery)]
     (try
-      (.click (jq "#IntercomTab"))
-      (when-not (.is (jq "#IntercomNewMessageContainer") ":visible")
-        (.click (jq "[href=IntercomNewMessageContainer]")))
-      (.focus (jq "#newMessageBody"))
-      (when message
-        (.text (jq "#newMessageBody") (str message "\n\n")))
+      (intercom-v1-new-message jq message)
       (catch :default e
-        (utils/notify-error ch "Uh-oh, our Help system isn't available. Please email us instead, at sayhi@circleci.com")
-        (utils/merror e)))
+        (try
+          (intercom-v2-new-message jq message)
+          (catch :default e
+            (utils/notify-error ch "Uh-oh, our Help system isn't available. Please email us instead, at sayhi@circleci.com")
+            (utils/merror e)))))
     (utils/notify-error ch "Uh-oh, our Help system isn't available. Please email us instead, at sayhi@circleci.com")))

 (defn user-link []


added gone out

added gone out

--- src/babel/english/lexicon-verbcoach.clj
+++ src/babel/english/lexicon-verbcoach.clj
@@ -932,7 +932,7 @@
                    :pred :go-out}
              :subcat {:2 '()}}
     :english {:past "went out"
-
+              :past-participle "gone out"
               :participle "going out"
               :present {:3sing "goes out"}}}


Clean up require form

Clean up require form

--- src/braid/server/routes/api/private.clj
+++ src/braid/server/routes/api/private.clj
@@ -6,8 +6,7 @@
    [braid.server.db.user :as user]
    [braid.server.events :as events]
    [braid.server.markdown :refer [markdown->hiccup]]
-   [braid.server.routes.helpers :refer [current-user current-user-id logged-in?
-                                        error-response edn-response session-token]]
+   [braid.server.routes.helpers :as helpers :refer [error-response edn-response]]
    [braid.server.s3 :as s3]
    [clojure.java.io :as io]
    [clojure.string :as string]
@@ -18,9 +17,9 @@

   ; get current logged in user
   (GET "/session" req
-    (if-let [user (current-user req)]
+    (if-let [user (helpers/current-user req)]
       (edn-response {:user user
-                     :csrf-token (session-token)})
+                     :csrf-token (helpers/session-token)})
       {:status 401 :body "" :session nil}))

   ; log out
@@ -31,7 +30,7 @@
   (PUT "/groups" [name slug type :as req]
     (cond
       ; logged in?
-      (not (logged-in? req))
+      (not (helpers/logged-in? req))
       (error-response 401 "Must be logged in.")

       ; group name validations
@@ -66,7 +65,7 @@

       ; passed all validations
       :else
-      (let [user-id (current-user-id req)
+      (let [user-id (helpers/current-user-id req)
             group-id (db/uuid)
             [group] (db/run-txns!
                       (group/create-group-txn {:id group-id
@@ -85,7 +84,7 @@
     (let [group-id (java.util.UUID/fromString group-id)]
       (cond
         ; logged in?
-        (not (logged-in? req))
+        (not (helpers/logged-in? req))
         (error-response 401 "Must be logged in.")

         ; public group?
@@ -94,7 +93,7 @@

         :else
         (do
-          (events/user-join-group! (current-user-id req) group-id)
+          (events/user-join-group! (helpers/current-user-id req) group-id)
           (edn-response {:status "OK"})))))

   (GET "/changelog" []


guard inspect function

guard inspect function

only pass messages through and put on channel when system active

--- src/clj/com/matthiasnehlsen/inspect.clj
+++ src/clj/com/matthiasnehlsen/inspect.clj
@@ -14,9 +14,13 @@

 (def built-in-formatter (f/formatters :date-time))

+(def active (atom false))
+
 (defn inspect
-  "Send message to inspect sub-system with msg-type"
-  [msg-type msg] (put! in-chan {:origin msg-type :received (f/unparse built-in-formatter (t/now)) :payload msg}))
+  "Send message to inspect sub-system with msg-type. Only does anything when system active"
+  [msg-type msg]
+  (when @active
+    (put! in-chan {:origin msg-type :received (f/unparse built-in-formatter (t/now)) :payload msg})))

 (def conf {:port 8000})

@@ -30,6 +34,14 @@

 (def system (get-system conf))

-(defn start [] (alter-var-root #'system component/start))
-(defn stop [] (alter-var-root #'system
-                              (fn [s] (when s (component/stop s)))))
+(defn start
+  "start the inspect system and set active atom to true"
+  []
+  (alter-var-root #'system component/start)
+  (reset! active true))
+
+(defn stop
+  "stop the inspect system and set active atom to false"
+  []
+  (alter-var-root #'system (fn [s] (when s (component/stop s))))
+  (reset! active false))


Switched back to background-color

Switched back to background-color

--- src/cljs/color_eyes/color_selector.cljs
+++ src/cljs/color_eyes/color_selector.cljs
@@ -26,7 +26,7 @@
               #(change-color-value rgba :a (js/parseInt (-> % .-target .-value)))}]
      [:div.color-display
       [:div.color-box
-       {:style {:color css-color}}]]
+       {:style {:background-color css-color}}]]
      [:p (str css-color)]])
   )


update url with badge id

update url with badge id

--- src/cljs/salava/core/ui/badge_grid.cljs
+++ src/cljs/salava/core/ui/badge_grid.cljs
@@ -67,29 +67,29 @@
                                                                                {:size :lg})) :title (t :badge/Delete)} [:i {:class "fa fa-trash"}]]])
                                  [:a {:href "#" :on-click #(mo/open-modal [:badge :info] {:badge-id id} {:hide (fn [] (init-data state))})}
                                   (if image_file
-                                    [:div.media-left
-                                     [:img.badge-img {:src (str "/" image_file)
-                                                      :alt name}]])
-                                  [:div.media-body
-                                   [:div.media-heading
-                                    [:p.heading-link name]]
-                                   [:div.media-issuer
-                                    [:p issuer_content_name]]]
-                                  ]]
+                                   [:div.media-left
+                                    [:img.badge-img {:src (str "/" image_file)
+                                                     :alt name}]])
+                                 [:div.media-body
+                                  [:div.media-heading
+                                   [:p.heading-link name]]
+                                  [:div.media-issuer
+                                   [:p issuer_content_name]]]
+                                 ]]
                                 [:div {:class (str "media-content " (if expired? "media-expired") (if revoked " media-revoked"))}
                                  [:a {:href "#" :on-click #(do
                                                              (.replaceState js/history "" "Badge modal" (str "/badge/" id))
                                                              (mo/open-modal [:badge :info] {:badge-id id} {:hide (fn []
-                                                                                (.replaceState js/history "" "Badge modal" "/badge")
-                                                                                (init-data state))}))}
+                                                                                (.replaceState js/history "" "Badge modal" "/badge")
+                                                                                (init-data state))}))}
                                   [:div.icons
-                                   [:div.visibility-icon.inline
+                                     [:div.visibility-icon.inline
                                     (case visibility
                                       "private" [:i {:class "fa fa-lock"}]
                                       "internal" [:i {:class "fa fa-group"}]
                                       "public" [:i {:class "fa fa-globe"}]
                                       nil)
-                                    (if metabadge-icon-fn [:div.pull-right [metabadge-icon-fn id]])]
+                                     (if metabadge-icon-fn [:div.pull-right [metabadge-icon-fn id]])]

                                    (if expires_on
                                      [:div.righticon
@@ -110,38 +110,38 @@
                                   ]])

        #_(= "export" badge-type) #_[:div {:key id}
-                                    [:div.media-content
-                                     [:a {:href "#" :on-click #(mo/open-modal [:badge :info] {:badge-id id})}
-                                      [:div.visibility-icon
-                                       (case visibility
-                                         "private" [:i {:class "fa fa-lock"}]
-                                         "internal" [:i {:class "fa fa-group"}]
-                                         "public" [:i {:class "fa fa-globe"}]
-                                         nil)]
-                                      (if image_file
-                                        [:div.media-left
-                                         [:img {:src (str "/" image_file) :alt name}]])
-                                      [:div.media-body
-                                       [:div.media-heading name]
-                                       [:div.media-issuer issuer_content_name]]]]
-                                    [:div.media-bottom
-                                     [:div.row
-                                      [:div.col-xs-9
-                                       (let [checked? (boolean (some #(= id %) (:badges-selected @state)))]
-                                         [:div.checkbox
-                                          [:label {:for (str "checkbox-" id)}
-                                           [:input {:type "checkbox"
-                                                    :id (str "checkbox-" id)
-                                                    :on-change (fn []
-                                                                 (if checked?
-                                                                   (swap! state assoc :badges-selected (remove #(= % id) (:badges-selected @state)))
-                                                                   (swap! state assoc :badges-selected (conj (:badges-selected @state) id))))
-                                                    :checked checked?}]
+                                [:div.media-content
+                                 [:a {:href "#" :on-click #(mo/open-modal [:badge :info] {:badge-id id})}
+                                  [:div.visibility-icon
+                                   (case visibility
+                                     "private" [:i {:class "fa fa-lock"}]
+                                     "internal" [:i {:class "fa fa-group"}]
+                                     "public" [:i {:class "fa fa-globe"}]
+                                     nil)]
+                                  (if image_file
+                                    [:div.media-left
+                                     [:img {:src (str "/" image_file) :alt name}]])
+                                  [:div.media-body
+                                   [:div.media-heading name]
+                                   [:div.media-issuer issuer_content_name]]]]
+                                [:div.media-bottom
+                                 [:div.row
+                                  [:div.col-xs-9
+                                   (let [checked? (boolean (some #(= id %) (:badges-selected @state)))]
+                                     [:div.checkbox
+                                      [:label {:for (str "checkbox-" id)}
+                                       [:input {:type "checkbox"
+                                                :id (str "checkbox-" id)
+                                                :on-change (fn []
+                                                             (if checked?
+                                                               (swap! state assoc :badges-selected (remove #(= % id) (:badges-selected @state)))
+                                                               (swap! state assoc :badges-selected (conj (:badges-selected @state) id))))
+                                                :checked checked?}]

-                                           (t :badge/Exporttobackpack)]])]
-                                      [:div {:class "col-xs-3 text-right"}
-                                       [:a {:href (str obf_url "/c/receive/download?url="(js/encodeURIComponent assertion_url)) :class "badge-download"}
-                                        [:i {:class "fa fa-download"}]]]]]]
+                                       (t :badge/Exporttobackpack)]])]
+                                  [:div {:class "col-xs-3 text-right"}
+                                   [:a {:href (str obf_url "/c/receive/download?url="(js/encodeURIComponent assertion_url)) :class "badge-download"}
+                                    [:i {:class "fa fa-download"}]]]]]]

        (= "gallery" badge-type) [:div
                                  [:a {:href "#" :on-click #(mo/open-modal [:gallery :badges] {:badge-id badge_id})


Reimplement poly1305 mac (backward incompatibility introduced).

- Removed iv parameter and now is automatically generated (backward incompatibility).
- Add low level interface to access to the mac engine.
- Proper function naming.

--- src/clojure/buddy/core/mac/poly1305.clj
+++ src/clojure/buddy/core/mac/poly1305.clj
@@ -25,10 +25,11 @@
   Poly1305-AES offers also cipher replaceability. If anything does
   go wrong with AES, it can be substituted with identical security
   guarantee."
-  (:require [buddy.core.hash :refer [sha3-256]]
+  (:refer-clojure :exclude [hash])
+  (:require [buddy.core.hash :as hash]
+            [buddy.core.nonce :as nonce]
             [buddy.core.mac.proto :as proto]
-            [buddy.core.codecs :refer :all]
-            [buddy.core.keys :refer [make-random-bytes]]
+            [buddy.core.codecs :as codecs :refer :all]
             [clojure.java.io :as io])
   (:import org.bouncycastle.crypto.generators.Poly1305KeyGenerator
            org.bouncycastle.crypto.macs.Poly1305
@@ -39,8 +40,7 @@
            org.bouncycastle.crypto.engines.TwofishEngine
            org.bouncycastle.crypto.BlockCipher
            clojure.lang.IFn
-           clojure.lang.Keyword
-           buddy.Arrays))
+           clojure.lang.Keyword))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Low level hmac engine.
@@ -51,6 +51,11 @@
   *available-engines* {:aes     #(AESFastEngine.)
                        :serpent #(SerpentEngine.)
                        :twofish #(TwofishEngine.)})
+
+(def ^{:private true
+       :static true
+       :doc "Length in bytes of poly1305 output."}
+  poly1305-output-size 16)

 (defn- resolve-engine
   "Given dynamic type engine, try resolve it to
@@ -63,122 +68,150 @@
    (instance? IFn engine) (engine)
    (instance? BlockCipher engine) engine))

-(defn- key->poly1305key
-  "Noramalizes any length byte array key to poly1305
-  formatted byte array key.
-
-  It uses sha3 (256 bit) for normalize the size to 32
-  bytes and poly1305 algorithm for transform it."
+(defn- key->polykey
+  "Noramalizes 32 bytes array key to poly1305
+  formatted byte array key."
   [^bytes key]
-  (let [^bytes bkey (sha3-256 key)]
-    (Poly1305KeyGenerator/clamp bkey)
-    bkey))
+  {:pre [(= (count key) 32)]}
+  (let [key (clone-byte-array key)]
+    (Poly1305KeyGenerator/clamp key)
+    key))

 (defn poly1305-engine
-  "Create a hmac engine."
-  ([key iv] (poly1305-engine key iv :aes))
-  ([key iv alg]
-   (let [engine (resolve-engine alg)
-         mac    (Poly1305. engine)
-         kp     (KeyParameter. (key->poly1305key key))]
-     (.init mac (ParametersWithIV. kp iv))
-     (reify
-       proto/IMac
-       (update [_ input offset length]
-         (.update mac input offset length))
-       (end [_]
-         (let [buffer (byte-array (.getMacSize mac))]
-           (.doFinal mac buffer 0)
-           buffer))))))
+  "Create a poly1305 mac engine."
+  [^bytes key ^bytes iv ^Keyword alg]
+  {:pre [(= (count iv) 16)
+         (= (count key) 32)]}
+  (let [engine (resolve-engine alg)
+        mac    (Poly1305. engine)
+        kp     (KeyParameter. (key->polykey key))]
+    (.init mac (ParametersWithIV. kp iv))
+    (reify
+      proto/IMac
+      (update [_ input offset length]
+        (.update mac input offset length))
+      (end [_]
+        (let [buffer (byte-array (.getMacSize mac))]
+          (.doFinal mac buffer 0)
+          buffer)))))
+
+(defprotocol IPoly1305Mac
+  (^:private hash* [data key alg] "Generate the poly1305 digest for provided data.")
+  (^:private verify* [data signature key alg] "Virify the poly1305 digest for provided data."))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Internal implementations
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(defn- make-poly1305-plain-impl
-  "Calculate the poly1305 message authentication code
-  for byte array objects."
-  [^bytes input ^bytes key ^bytes iv ^Keyword alg]
-  (let [engine (poly1305-engine key iv alg)]
-    (proto/update! engine input)
-    (proto/end! engine)))
-
-(defn- make-poly1305-stream-impl
+(defn- hash-plain-data
+  "Calculate the message authentication code
+  for byte array objects using poly1305 algorithm."
+  ([^bytes input ^bytes key ^Keyword alg]
+   (let [iv (nonce/random-nonce 16)]
+     (hash-plain-data input key iv alg)))
+  ([^bytes input ^bytes key ^bytes iv ^Keyword alg]
+   (let [key (hash/sha256 key) ;; Normalizes an arbitrary length key to 32 bytes.
+         engine (poly1305-engine key iv alg)]
+     (proto/update! engine input)
+     (let [result (proto/end! engine)]
+       (concat-byte-arrays result iv)))))
+
+(defn- hash-stream-data
   "Calculate the poly1305 message authentication code
   for file like objects in most memory efficient way."
-  [^java.io.InputStream input ^bytes key ^bytes iv ^Keyword alg]
-  (let [engine (poly1305-engine key iv alg)
-        buffer (byte-array 5120)]
-    (loop []
-      (let [readed (.read input buffer 0 5120)]
-        (when-not (= readed -1)
-          (proto/update! engine buffer 0 readed)
-          (recur))))
-    (proto/end! engine)))
+  ([^java.io.InputStream input ^bytes key ^Keyword alg]
+   (let [iv (nonce/random-nonce 16)]
+     (hash-stream-data input key iv alg)))
+  ([^java.io.InputStream input ^bytes key ^bytes iv ^Keyword alg]
+   (let [key (hash/sha256 key) ;; Normalizes an arbitrary length key to 32 bytes.
+         engine (poly1305-engine key iv alg)
+         buffer (byte-array 5120)]
+     (loop []
+       (let [readed (.read input buffer 0 5120)]
+         (when-not (= readed -1)
+           (proto/update! engine buffer 0 readed)
+           (recur))))
+     (let [result (proto/end! engine)]
+       (concat-byte-arrays result iv)))))
+
+(defn- verify-plain-data
+  "Generic implementation of verify proces of
+  poly1305 mac digest."
+  [^bytes input ^bytes signature ^bytes key ^Keyword alg]
+  (let [outputsize poly1305-output-size
+        iv (codecs/clone-byte-array signature outputsize (count signature))
+        sig (hash-plain-data input key iv alg)]
+    (codecs/equals? sig signature)))
+
+(defn- verify-stream-data
+  "Generic implementation of verify proces of
+  poly1305 mac digest."
+  [^bytes input ^bytes signature ^bytes key ^Keyword alg]
+  (let [outputsize poly1305-output-size
+        iv (clone-byte-array signature outputsize (count signature))
+        sig (hash-stream-data input key iv alg)]
+    (codecs/equals? sig signature)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Low level interface
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(declare make-poly1305)
-
-(defn verify-poly1305-impl
-  "Generic implementation of verify."
-  [input ^bytes signature ^bytes pkey ^bytes iv ^Keyword alg]
-  (let [sig (make-poly1305 input pkey iv alg)]
-    (Arrays/equals sig signature)))
-
-(defprotocol Poly1305Mac
-  "Protocol that defines a low level interface
-  to poly 1305 algorithm and allows extend it for
-  different types.
-  It comes with default implementation for: string,
-  bytes, input stream, file, url and uri."
-  (make-poly1305 [obj key iv alg] "Calculate poly1305 mac for type."))
-
-(alter-meta! #'make-poly1305 assoc :no-doc true :private true)
-
-(extend-protocol Poly1305Mac
+(extend-protocol IPoly1305Mac
   (Class/forName "[B")
-  (make-poly1305 [^bytes input ^bytes key ^bytes iv ^Keyword alg]
-    (make-poly1305-plain-impl input key iv alg))
+  (hash* [^bytes input ^bytes key ^Keyword alg]
+    (hash-plain-data input key alg))
+  (verify* [^bytes input ^bytes signature ^String key ^Keyword alg]
+    (verify-plain-data input signature key alg))

   java.lang.String
-  (make-poly1305 [^String input ^bytes key ^bytes iv ^Keyword alg]
-    (make-poly1305-plain-impl (->byte-array input) key iv alg))
+  (hash* [^String input ^bytes key ^Keyword alg]
+    (hash-plain-data (->byte-array input) key alg))
+  (verify* [^String input ^bytes signature ^String key ^Keyword alg]
+    (verify-plain-data (->byte-array input) signature key alg))

   java.io.InputStream
-  (make-poly1305 [^java.io.InputStream input ^bytes key ^bytes iv ^Keyword alg]
-    (make-poly1305-stream-impl input key iv alg))
+  (hash* [^java.io.InputStream input ^bytes key ^Keyword alg]
+    (hash-stream-data input key alg))
+  (verify* [^java.io.File input ^bytes signature ^String key ^Keyword alg]
+    (verify-stream-data (io/input-stream input) signature key alg))

   java.io.File
-  (make-poly1305 [^java.io.File input ^bytes key ^bytes iv ^Keyword alg]
-    (make-poly1305-stream-impl (io/input-stream input) key iv alg))
+  (hash* [^java.io.File input ^bytes key ^Keyword alg]
+    (hash-stream-data (io/input-stream input) key alg))
+  (verify* [^java.io.File input ^bytes signature ^String key ^Keyword alg]
+    (verify-stream-data (io/input-stream input) signature key alg))

   java.net.URL
-  (make-poly1305 [^java.net.URL input ^bytes key ^bytes iv ^Keyword alg]
-    (make-poly1305-stream-impl (io/input-stream input) key iv alg))
+  (hash* [^java.net.URL input ^bytes key ^Keyword alg]
+    (hash-stream-data (io/input-stream input) key alg))
+  (verify* [^java.net.URL input ^bytes signature ^String key ^Keyword alg]
+    (verify-stream-data (io/input-stream input) signature key alg))

   java.net.URI
-  (make-poly1305 [^java.net.URI input ^bytes key ^bytes iv ^Keyword alg]
-    (make-poly1305-stream-impl (io/input-stream input) key iv alg)))
+  (hash* [^java.net.URI input ^bytes key ^Keyword alg]
+    (hash-stream-data (io/input-stream input) key alg))
+  (verify* [^java.net.URI input ^bytes signature ^String key ^Keyword alg]
+    (verify-stream-data (io/input-stream input) signature key alg)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; High level interface
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(defn poly1305
-  "Make poly1305 mac for specified data, using arbitrary
-  length key and 128 bits iv.
-  Key can be any type that implements ByteArray protocol."
-  [input key ^bytes iv ^Keyword alg]
-  {:pre [(= (count iv) 16)]}
-  (let [key (->byte-array key)]
-    (make-poly1305 input key iv alg)))
+(defn hash
+  "Generate poly1305 digest for arbitrary
+  input data, a secret key and crypto algorithm.
+
+  If algorithm is not supplied, aes will be used
+  as default value."
+  ([input key] (hash input key :aes))
+  ([input key alg]
+   (hash* input key alg)))

 (defn verify
   "Verify poly1305 mac for specified data and signature."
-  [input ^bytes signature pkey ^bytes iv ^Keyword alg]
-  {:pre [(= (count iv) 16)]}
-  (let [key (->byte-array pkey)]
-    (verify-poly1305-impl input signature key iv alg)))
+  [input ^bytes signature key ^Keyword alg]
+  (verify* input signature key alg))
+
+(def ^{:doc "Deprecated alias for `hash` function.`"
+       :deprecated true}
+  poly1305 hash)


Sort out the NPE from Initiate composition (WIP)

Well, it was failing because the server extension field was showing up
as nil. I was also pruning away the ::shared/extension field that I need
for the Client extension.

This version gets past that error and then fails when it tries to filter
the initial message bytes.

--- src/clojure/frereth_cp/client/state.clj
+++ src/clojure/frereth_cp/client/state.clj
@@ -172,7 +172,9 @@
                                                 #_::chan->server
                                                 ;; We still have a circular dependency.
                                                 ::packet-builder
+                                                ::server-extension
                                                 ::server-security
+                                                ::shared/extension
                                                 ;; Note that this doesn't really make
                                                 ;; any sense for message-building.
                                                 ;; But it's absolutely vital for
@@ -428,12 +430,14 @@
                       ::log/logger
                       ::log/state
                       ::msg-specs/message-loop-name
+                      ::shared/extension
                       ::shared/my-keys
                       ::shared/work-area
                       ::specs/inner-i-nonce
                       ::specs/vouch
                       ::packet-builder
                       ::shared-secrets
+                      ::server-extension
                       ::server-security]))

 (s/fdef update-callback!


Make table scrollable.

Make table scrollable.

--- src/clojure/my/stuff/fitlogger/main.clj
+++ src/clojure/my/stuff/fitlogger/main.clj
@@ -175,7 +175,8 @@
    [:button {:text "Add log",
              :on-click (fn [_]
                          (add-event activity))}]
-   (format-listing @listing)])
+   [:scroll-view {}
+    (format-listing @listing)]])

 ;; This is how an Activity is defined. We create one and specify its onCreate
 ;; method. Inside we create a user interface that consists of an edit and a


with-exception func

with-exception func

--- src/clojure/zensols/actioncli/parse.clj
+++ src/clojure/zensols/actioncli/parse.clj
@@ -60,7 +60,21 @@
     (System/exit 1)
     (throw e)))

-(defn error-msg [errors]
+(defmacro with-exception
+  "Wrap a CLI forms in a `try` and call [[handle-exception]] if an exception
+  occurs."
+  {:style/indent 0}
+  [& forms]
+  (let [ex (gensym)]
+   `(try
+      ~@forms
+      (catch Exception ~ex
+        (handle-exception ~ex)))))
+
+(defn error-msg
+  "Print every element of the sequence **errors**.  If there **errors** is a
+  singleton then only print one in the common usage format."
+  [errors]
   (if (= (count errors) 1)
     (format "%s: %s" (program-name) (first errors))
     (str "The following errors occurred while parsing your command:\n\n"


Fixed potential divide by zero error in IFS

--- src/clojush/pushgp/parent_selection.clj
+++ src/clojush/pushgp/parent_selection.clj
@@ -109,7 +109,7 @@
   "Takes an individual and calculates and assigns its IFS based on the summed
    error across each test case."
   [ind summed-reward-on-test-cases]
-  (let [ifs-reward (apply +' (map /
+  (let [ifs-reward (apply +' (map #(if (zero? %2) 1.0 (/ %1 %2))
                                   (map #(- 1.0 %) (:errors ind)) ; Should be dividing REWARD by summed (not ERRORS)
                                   summed-reward-on-test-cases))
         ifs-er (cond
@@ -130,12 +130,12 @@
    assign an implicit fitness sharing error to each individual. Assumes errors
    are in range [0,1] with 0 being a solution."
   [pop-agents {:keys [use-single-thread]}]
-  (println "Calculating implicit fitness sharing errors...")
+  (println "\nCalculating implicit fitness sharing errors...")
   (let [pop (map deref pop-agents)
         summed-reward-on-test-cases (map (fn [list-of-errors]
                                            (reduce +' (map #(- 1.0 %) list-of-errors)))
                                          (apply map list (map :errors pop)))]
-    (println "\nImplicit fitness sharing reward per test case:")
+    (println "Implicit fitness sharing reward per test case (lower means population performs worse):")
     (println summed-reward-on-test-cases)
     (assert (every? (fn [error] (< -0.0000001 error 1.0000001))
                     (flatten (map :errors pop)))


Added point examples to the visual spatial search demo.

--- src/cmr/demos/visual_spatial_search.clj
+++ src/cmr/demos/visual_spatial_search.clj
@@ -9,7 +9,8 @@
             [cmr.system-int-test.data2.collection :as dc]
             [cmr.system-int-test.data2.granule :as dg]
             [cmr.system-int-test.data2.core :as d]
-            [cmr.spatial.polygon :as p]
+            [cmr.spatial.polygon :as poly]
+            [cmr.spatial.point :as p]
             [cmr.spatial.mbr :as m]
             [cmr.spatial.ring :as r]
             [cmr.spatial.derived :as derived]
@@ -27,7 +28,7 @@
 (defn polygon
   "Creates a single ring polygon with the given ordinates. Points must be in counter clockwise order."
   [& ords]
-  (let [polygon (p/polygon [(apply r/ords->ring ords)])
+  (let [polygon (poly/polygon [(apply r/ords->ring ords)])
         outer (-> polygon :rings first derived/calculate-derived)]
     (when (and (:contains-north-pole outer)
                (:contains-south-pole outer))
@@ -39,19 +40,21 @@
   [shape]
   (assoc (srl/shape->lr shape) :options {:color "AA76775E"}))

-(defmulti ords-str->shape
-  (fn [spatial-type ords-str]
+(defmulti ords->shape
+  (fn [spatial-type ords]
     spatial-type))

-(defmethod ords-str->shape :polygon
-  [spatial-type ords-str]
-  (let [ords (map #(Double. ^String %) (str/split ords-str #","))]
-    (derived/calculate-derived (apply polygon ords))))
+(defmethod ords->shape :polygon
+  [spatial-type ords]
+  (derived/calculate-derived (apply polygon ords)))

-(defmethod ords-str->shape :bounding_box
-  [spatial-type ords-str]
-  (let [[w n e s] (map #(Double. ^String %) (str/split ords-str #","))]
-    (m/mbr w n e s)))
+(defmethod ords->shape :bounding_box
+  [spatial-type ords]
+  (apply m/mbr ords))
+
+(defmethod ords->shape :point
+  [spatial-type ords]
+  (apply p/point ords))

 (defn handle-search-area-moved
   "This is the VDD callback function. Everytime the search area is moved this will be called with the
@@ -62,7 +65,8 @@

   (let [[id ords-str] (str/split id-ords-str #":")
         spatial-type (keyword id)
-        shape (ords-str->shape spatial-type ords-str)]
+        ords (map #(Double. ^String %) (str/split ords-str #","))
+        shape (ords->shape spatial-type ords)]

     (let [results (search/find-refs :granule {spatial-type (cmr.spatial.codec/url-encode
                                                              shape)})
@@ -108,7 +112,7 @@
   (let [outer (r/ords->ring -5.26,-2.59, 11.56,-2.77, 10.47,8.71, -5.86,8.63, -5.26,-2.59)
         hole1 (r/ords->ring 6.95,2.05, 2.98,2.06, 3.92,-0.08, 6.95,2.05)
         hole2 (r/ords->ring 5.18,6.92, -1.79,7.01, -2.65,5, 4.29,5.05, 5.18,6.92)
-        polygon-with-holes  (p/polygon [outer hole1 hole2])
+        polygon-with-holes  (poly/polygon [outer hole1 hole2])
         search-area (polygon 0 0, 1 0, 1 1, 0 0)]
     (visual-interactive-search [polygon-with-holes] search-area))

@@ -132,11 +136,20 @@
         outer (r/ords->ring -5.26,-2.59, 11.56,-2.77, 10.47,8.71, -5.86,8.63, -5.26,-2.59)
         hole1 (r/ords->ring 6.95,2.05, 2.98,2.06, 3.92,-0.08, 6.95,2.05)
         hole2 (r/ords->ring 5.18,6.92, -1.79,7.01, -2.65,5, 4.29,5.05, 5.18,6.92)
-        polygon-with-holes  (p/polygon [outer hole1 hole2])
+        polygon-with-holes  (poly/polygon [outer hole1 hole2])

-        search-area (assoc (polygon -6.45,-3.74,12.34,-4.18,12,9.45,-6.69,9.2,-6.45,-3.74)
-                           :options {:id "polygon"})
-        ; search-area (assoc (m/mbr -23.43 5 25.54 -6.31) :options {:id "bounding_box"})
+        ;; points
+        north-pole (p/point 90 0)
+        south-pole (p/point -90 0)
+        normal-point (p/point 10 22)
+        am-point (p/point 180 22)
+
+        ; search-area (assoc (polygon -6.45,-3.74,12.34,-4.18,12,9.45,-6.69,9.2,-6.45,-3.74)
+        ;                    :options {:id "polygon"})
+
+        ;search-area (assoc (m/mbr -23.43 5 25.54 -6.31) :options {:id "bounding_box"})
+
+        search-area (assoc (p/point 0 0) :options {:id "point"})

         ]
     (visual-interactive-search [touches-sp
@@ -150,7 +163,11 @@
                                 on-np
                                 on-sp
                                 normal-poly
-                                polygon-with-holes] search-area))
+                                polygon-with-holes
+                                north-pole
+                                south-pole
+                                normal-point
+                                am-point] search-area))


inner trace -- better handling of macros

--- src/com/billpiel/sayid/inner_trace3.clj
+++ src/com/billpiel/sayid/inner_trace3.clj
@@ -5,23 +5,25 @@
             clojure.set))

 (defn form->xform-map*
-  [form]
+  [ns-sym form]
   (if (coll? form)
-    (let [x (macroexpand form)
-          xx (clojure.walk/macroexpand-all form)] ;; TODO better way?
-      (conj (mapcat form->xform-map* x)
+    (let [x (util/macroexpand-in-ns ns-sym form)
+          xx (util/macroexpand-all-in-ns ns-sym form)]
+      (conj (mapcat (partial form->xform-map*
+                             ns-sym)
+                    x)
             {form xx}))
     [{form form}]))

 (defn form->xform-map
-  [form]
-  (apply merge (form->xform-map* form)))
+  [ns-sym form]
+  (apply merge (form->xform-map* ns-sym form)))

 (defn xform->form-map
-  [form]
-  (-> form
-      form->xform-map
-      clojure.set/map-invert))
+  [ns-sym form]
+  (->> form
+       (form->xform-map ns-sym)
+       clojure.set/map-invert))

 (defn swap-in-path-syms*
   [ns-sym form func parent path skip-macro?]
@@ -124,7 +126,7 @@
         oloc->xloc (clojure.set/map-invert xloc->oloc)
         xl->xform  (util/deep-zipmap (->> form (util/macroexpand-all-in-ns ns-sym) (swap-in-path-syms ns-sym))
                                      (util/macroexpand-all-in-ns ns-sym form))
-        xform->form (xform->form-map form)
+        xform->form (xform->form-map ns-sym form)
         ol->olop (->> form
                       (swap-in-path-syms ns-sym)
                       get-path->form-maps)
@@ -798,11 +800,9 @@

 (defn f1
   [a]
-  (loop [b a
-         c 2]
-    (if (= b 0)
-      (recur 1 666)
-      b)))
+  (-> a
+      inc
+      dec))

 #_ (inner-tracer {:qual-sym 'com.billpiel.sayid.inner-trace3/f1
                   :meta' {:ns 'com.billpiel.sayid.inner-trace3


Added missing tests.

Added missing tests.

--- search-app/test/cmr/search/test/site/routes.clj
+++ search-app/test/cmr/search/test/site/routes.clj
@@ -16,12 +16,12 @@
 (deftest cmr-welcome-page
   (testing "visited on a path without a trailing slash"
     (let [response (site (request :get base-url))]
-      (testing "redirects permanently to the version with a trailing slash"
-        (is (= (:status response) 200))
-        (is (= (:headers response) {})))))
-
+      (testing "produces a HTTP 200 success response"
+        (is (= (:status response) 200)))
+      (testing "returns the welcome page HTML"
+        (is (substring? "The CMR Search API" (:body response))))))
   (testing "visited on a path with a trailing slash"
-    (let [response (site (request :get base-url))]
+    (let [response (site (request :get (str base-url "/")))]
       (testing "produces a HTTP 200 success response"
         (is (= (:status response) 200)))
       (testing "returns the welcome page HTML"
@@ -60,6 +60,39 @@
   (let [response (site
                    (request
                      :get (str base-url "/site/search_api_docs.html")))]
-    (testing "uses the incoming host and scheme for the docs endpoints"
+    (testing "uses the incoming host and scheme for the docs endpoint"
+      (is (= (:status response) 200))
+      (is (substring? "API Documentation" (:body response)))
       (is (substring?
             "https://cmr.example.com/search/collections" (:body response))))))
+
+(deftest cmr-site-documentation-page
+  (let [response (site
+                   (request
+                     :get (str base-url "/site/search_site_docs.html")))]
+    (testing "uses the incoming host and scheme for the docs endpoint"
+      (is (= (:status response) 200))
+      (is (substring?
+            "Site Routes and Web Resources Documentation" (:body response))))))
+
+(deftest cmr-all-documentation-page
+  (let [response (site (request :get (str base-url "/site/docs")))]
+    (testing "all docs links appear here"
+      (is (= (:status response) 200))
+      (is (substring? "Documentation for CMR Search" (:body response)))
+      (is (substring? "site/docs/api" (:body response)))
+      (is (substring? "site/docs/site" (:body response))))))
+
+(deftest cmr-url-reorg-redirects
+  (let [response (site (request :get (str base-url "/site/docs/api")))]
+    (testing "clean docs URL for api docs performs redirect"
+      (is (= (:status response) 307))
+      (is (substring?
+            "site/search_api_docs.html"
+            (get-in response [:headers "Location"])))))
+  (let [response (site (request :get (str base-url "/site/docs/site")))]
+    (testing "clean docs URL for site docs performs redirect"
+      (is (= (:status response) 307))
+      (is (substring?
+            "site/search_site_docs.html"
+            (get-in response [:headers "Location"]))))))