server index.html for requests to /

server index.html for requests to /

--- src/clj/passa_paraula/handler.clj
+++ src/clj/passa_paraula/handler.clj
@@ -2,6 +2,7 @@
   (:require [compojure.core :refer [GET defroutes]]
             [compojure.route :refer [not-found resources]]
             [ring.middleware.defaults :refer [site-defaults wrap-defaults]]
+            [ring.util.response :refer [redirect file-response]]
             [hiccup.core :refer [html]]
             [hiccup.page :refer [include-js include-css]]
             [prone.middleware :refer [wrap-exceptions]]
@@ -20,7 +21,7 @@
      (include-js "js/app.js")]]))

 (defroutes routes
-  (GET "/" [] home-page)
+  (GET "/" [] (file-response "index.html" {:root "resources/public"}))
   (resources "/")
   (not-found "Not Found"))


Improve fn that adds cards to list

Improve fn that adds cards to list

--- src/cljs/decktouch/card-data.cljs
+++ src/cljs/decktouch/card-data.cljs
@@ -38,10 +38,27 @@
             (merge card-data c)
             c)))))

-(defn add-card-to-list! [card-name]
+(defn add-card-quantity [cards card-name quantity]
+  (.log js/console (str "cards with name? " (filter #(= (get % "name") card-name) cards)))
+  (if (empty? (filter #(= (get % "name") card-name) cards))
+    ; add a new card
+    (conj cards {"name" card-name
+                 "quantity" quantity})
+    ; increase the quantity of the existing card
+    (for [c cards]
+      (if (= (get c "name") card-name)
+        (assoc c "quantity" (+ quantity (get c "quantity")))
+        c))))
+
+(defn add-card-to-list!
+  "add-card-to-list! card-name
+   or
+   add-card-to-list! card-name quantity"
+  [card-name & quantity]
   (do
-    (swap! card-list conj {"name" card-name
-                           "quantity" 1})
+    (if quantity
+      (swap! card-list add-card-quantity card-name quantity)
+      (swap! card-list add-card-quantity card-name 1))
     (go
       (let [response (js->clj (.parse js/JSON (<! (<lookup-card-data card-name))))]
         (swap! card-list add-more-card-data response)


Auto-pump first try.

Auto-pump first try.

--- src/cljs/netrunner/gameboard.cljs
+++ src/cljs/netrunner/gameboard.cljs
@@ -154,6 +154,11 @@
   (let [card (-> e .-dataTransfer (.getData "card") ((.-parse js/JSON)) (js->clj :keywordize-keys true))
         side (if (#{"HQ" "R&D" "Archives"} server) "Corp" "Runner")]
     (send-command "move" {:card card :server server})))
+
+(defn ability-costs [ab]
+  (when-let [cost (:cost ab)]
+    (str (clojure.string/join "" (for [c (partition 2 cost)]
+                                   (str (second c) " [" (capitalize (name (first c))) "]"))) ": ")))

 (defn card-view [{:keys [zone code type abilities counter advance-counter advancementcost current-cost subtype
                          advanceable rezzed strength current-strength title remotes selected hosted rec-counter]
@@ -201,10 +206,13 @@
                     [:div {:on-click #(do (send-command action {:card @cursor}))} (capitalize action)])
                   actions)
              (map-indexed
-              (fn [i label]
-                [:div {:on-click #(do (send-command "ability" {:card @cursor :ability i})
-                                      (-> (om/get-node owner "abilities") js/$ .fadeOut))
-                       :dangerouslySetInnerHTML #js {:__html (add-symbols label)}}])
+              (fn [i ab]
+                (if (:auto-boost ab)
+                  [:div {:on-click #(do (send-command "auto-pump" {:card @cursor}))
+                         :dangerouslySetInnerHTML #js {:__html (add-symbols (str (ability-costs ab) (:label ab)))}}]
+                  [:div {:on-click #(do (send-command "ability" {:card @cursor :ability i})
+                                        (-> (om/get-node owner "abilities") js/$ .fadeOut))
+                         :dangerouslySetInnerHTML #js {:__html (add-symbols (str (ability-costs ab) (:label ab)))}}]))
               abilities)]))
         (when (= (first zone) "servers")
           (cond


Remove unnecessary comma

Remove unnecessary comma

--- src/clojure/nightcode/editors.clj
+++ src/clojure/nightcode/editors.clj
@@ -226,7 +226,7 @@
                      "md" SyntaxConstants/SYNTAX_STYLE_NONE
                      "txt" SyntaxConstants/SYNTAX_STYLE_NONE})
 (def ^:const clojure-exts #{"clj" "cljs"})
-(def ^:const wrap-exts #{"md", "txt"})
+(def ^:const wrap-exts #{"md" "txt"})

 (defn get-extension
   [path]


Removing debugging output.

Removing debugging output.

--- src/cmr/common/api/web_server.clj
+++ src/cmr/common/api/web_server.clj
@@ -54,7 +54,6 @@
                                                   :max-threads MAX_THREADS})]

       (when use-compression?
-        (println "using compression")
         ;; Create a GZIP handler to handle compression of responses
         (let [new-handler (doto (GzipHandler.)
                             (.setHandler (.getHandler server))


CMR-1922: Uncommented a test which was commented for testing

--- system-int-test/test/cmr/system_int_test/virtual_product_test.clj
+++ system-int-test/test/cmr/system_int_test/virtual_product_test.clj
@@ -105,7 +105,7 @@
       (testing "Find no granules"
         (is (= 0 (:hits (search/find-refs :granule {}))))))

-    #_(testing "Recreate source granule"
+    (testing "Recreate source granule"
       (let [ast-l1a-gran-r4 (vp/ingest-source-granule "LPDAAC_ECS"
                                                      (dissoc ast-l1a-gran :revision-id :concept-id))]
         (index/wait-until-indexed)


Remove unused require

Remove unused require

--- src/time_tracker/config.clj
+++ src/time_tracker/config.clj
@@ -1,8 +1,7 @@
 (ns time-tracker.config
   (:require [clojure.java.io :as io]
             [nomad :refer [defconfig]]
-            [ragtime.jdbc]
-            [ragtime.repl]))
+            [ragtime.jdbc]))

 (defconfig app-config (io/file "config/backend-config.edn"))

@@ -12,3 +11,4 @@
   {:datastore  (ragtime.jdbc/sql-database {:connection-uri (:db-connection-string (app-config))})
    :migrations (ragtime.jdbc/load-resources (:migrations-resource-dir (app-config)))})

+


Get result out of Riak response

Get result out of Riak response

--- src/icecap/store/riak.clj
+++ src/icecap/store/riak.clj
@@ -17,7 +17,7 @@
     (create! [_ index blob]
       (riak-op (kv/store conn bucket index blob)))
     (retrieve [_ index]
-      (riak-op (kv/fetch-one conn bucket index)))
+      (riak-op (:result (kv/fetch-one conn bucket index))))
     (delete! [_ index]
       (riak-op (kv/delete conn bucket index)))))


Maintain a "fake.class.path" system property with current class path info

--- boot/core/src/boot/core.clj
+++ boot/core/src/boot/core.clj
@@ -99,6 +99,20 @@
       (binding [file/*hard-link* false]
         (apply file/sync :theirs (first d) s)))))

+(defn- set-fake-class-path!
+  []
+  (let [dirs (->> (get-env)
+                  ((juxt :source-paths :resource-paths))
+                  (apply concat)
+                  (map #(.getAbsolutePath (io/file %))))]
+    (->> (pod/get-classpath)
+         (map #(.getPath (URL. %)))
+         (remove #(.isDirectory (io/file %)))
+         (concat dirs)
+         (interpose (System/getProperty "path.separator"))
+         (apply str)
+         (System/setProperty "fake.class.path"))))
+
 (defn- set-user-dirs!
   []
   (@src-watcher)
@@ -107,6 +121,7 @@
     (apply set/union)
     (watch-dirs (fn [_] (sync-user-dirs!)))
     (reset! src-watcher))
+  (set-fake-class-path!)
   (sync-user-dirs!))

 (defn- do-cleanup!
@@ -135,6 +150,7 @@
 (defn- add-directories!
   "Add URLs (directories or jar files) to the classpath."
   [dirs]
+  (set-fake-class-path!)
   (doseq [dir dirs] (pod/add-classpath dir)))

 (defn- configure!*


Improved the Japanese vertical writing output method. (Some Japanese characters require rotation, translation, inversion + rotation, etc.)

--- src/tames/generators/pdf.clj
+++ src/tames/generators/pdf.clj
@@ -44,23 +44,55 @@
   (doseq [pdf-object pdf-objects]
     (add-object parent pdf-object)))

+(defn draw-text-horizontal!
+  [context-byte x y text]
+  (doto context-byte
+      (.setTextMatrix x y)
+      (.showText text)))
+
+(def rotations "()（）[]「」『』【】〔〕［］{}｛｝<>＜＞≪≫〈〉《》")
+(def flip-rot "-ー=＝|｜")
+(def right-top-1 "。、．，")
+(def right-top-2 "ぁぃぅぇぉっゃゅょァィゥェォッャュョ")
+(def specific "様")
+(defn draw-text-vertical!
+  [context-byte x y text font font-size]
+  (loop [chars    #?=(seq text)
+         y-cursor y]
+    (if (= (count chars) 0)
+        nil
+        (let [c     (first chars)
+              width (. font getWidthPoint (int c) (float font-size))
+              move1 (/ width 2)
+              move2 (/ width 8)]
+          ;;; PdfContentByte.setTextMatrix's arguments from 1st to 4th are Matrix element.
+          ;;; You can draw characters as you like by doing mathematical matrix operations. (Rotation, inversion, diagonal, etc.)
+          (cond (<= 0 (. rotations   indexOf (int c))) (. context-byte setTextMatrix 0 -1 1 0 (+ x move1) (- y-cursor move1))
+                (<= 0 (. right-top-1 indexOf (int c))) (. context-byte setTextMatrix (+ x move1) (+ y-cursor move1))
+                (<= 0 (. right-top-2 indexOf (int c))) (. context-byte setTextMatrix (+ x move2) (+ y-cursor move2))
+                (<= 0 (. flip-rot    indexOf (int c))) (. context-byte setTextMatrix 0 -1 -1 0 (- x move1) (- y-cursor move1))
+                :else                                  (. context-byte setTextMatrix x y-cursor))
+          (. context-byte showText (format "%c" c))
+          (recur (rest chars) (- y-cursor width))))))
+
 (defn draw-text!
   [parent pdf-object]
-  ;(pprint/pprint pdf-object)
   (let [context-byte (parent :context-byte)
-        direction    (directions (pdf-object "direction"))
+        direction    (pdf-object "direction")
+        identify     (directions direction)
         font         (let [font-path (fonts/get-font-file-path (pdf-object "font"))]
                        (if (or (nil? font-path) (= font-path ""))
                            (parent :font)
-                           (BaseFont/createFont font-path direction BaseFont/EMBEDDED)))
+                           (BaseFont/createFont font-path identify BaseFont/EMBEDDED)))
         font-size    (let [tmp-font-size (pdf-object "font_size")]
                        (float (if (nil? tmp-font-size) (parent :font-size) tmp-font-size)))
-        ]
-    (.. context-byte beginText)
-    (doto context-byte
-      (.setFontAndSize font font-size)
-      (.setTextMatrix (pdf-object "x") (pdf-object "y"))
-      (.showText (pdf-object "text")))
+        x            (pdf-object "x")
+        y            (pdf-object "y")
+        text         (pdf-object "text")]
+    (. context-byte beginText)
+    (. context-byte setFontAndSize font font-size)
+    (cond (= direction "h") (draw-text-horizontal! context-byte x y text)
+          (= direction "v") (draw-text-vertical! context-byte x y text font font-size))
     (.. context-byte endText)))

 (defn draw-line!


🔒 Hide support email from anonymous users

--- src/territory_bro/routes.clj
+++ src/territory_bro/routes.clj
@@ -77,7 +77,8 @@
                  {:dev (getx config/env :dev)
                   :auth0 {:domain (getx config/env :auth0-domain)
                           :clientId (getx config/env :auth0-client-id)}
-                  :supportEmail (getx config/env :support-email)
+                  :supportEmail (when auth/*user*
+                                  (getx config/env :support-email))
                   :user (assoc (select-keys auth/*user* [:name :sub])
                                :authenticated (not (nil? auth/*user*)))})))


(maint) Don't evaluate unneeded assoc-when values

--- src/puppetlabs/puppetdb/utils.clj
+++ src/puppetlabs/puppetdb/utils.clj
@@ -79,17 +79,17 @@
                      (.getPath (apply io/file export-root-dir file-suffix))
                      contents))

-(defn assoc-when
-  "Assoc to `m` only when `k` is not already present in `m`"
-  [m & kvs]
+(defmacro assoc-when
+  "Assocs the provided values with the corresponding keys if and only
+  if the key is not already present in map."
+  [map key val & kvs]
   {:pre [(even? (count kvs))]}
-  (let [missing-map-entries (into {}
-                                  (for [[k v] (partition 2 kvs)
-                                        :when (not (contains? m k))]
-                                    [k v]))]
-    (if (seq missing-map-entries)
-      (merge m missing-map-entries)
-      m)))
+  (let [deferred-kvs (vec (for [[k v] (cons [key val] (partition 2 kvs))]
+                            [k `(fn [] ~v)]))]
+    `(let [updates# (for [[k# v#] ~deferred-kvs
+                          :when (= ::not-found (get ~map k# ::not-found))]
+                      [k# (v#)])]
+       (merge ~map (into {} updates#)))))

 (pls/defn-validated kwd->str
   "Convert a keyword to a string. This is different from `name` in


Function for checked value update, naming.

--- src/fm/simrunner/config.clj
+++ src/fm/simrunner/config.clj
@@ -43,7 +43,7 @@

 (def ^{:private true} param-defs (zipmap param-ids param-specs))

-(defn- value [param-id value]
+(defn- param-value [param-id value]
   ((get-in param-defs [param-id :value]) value))

 (defn- blank? [trimmed-line]
@@ -76,7 +76,7 @@
     (config {}))
   ([map]
     (reduce (fn [config param-id]
-              (if-let [value (value param-id (param-id map))]
+              (if-let [value (param-value param-id (param-id map))]
                 (assoc config param-id value)
                 config))
             {}
@@ -96,3 +96,10 @@
   (with-open [reader (jio/reader file)]
     (read-config-lines (line-seq reader))))

+(defn with-value [config param-id value]
+  (if-let [param-def (get param-defs param-id)]
+    (when-let [value (param-value param-id value)]
+      (assoc config param-id value))
+    (throw (IllegalArgumentException.
+             (format "Undefined config parameter: '%s'!" param-id)))))
+


Simplify component

Simplify component

--- src/fugue/midi_monitor.cljs
+++ src/fugue/midi_monitor.cljs
@@ -5,14 +5,13 @@
             [fugue.chords :as chords]))

 (defn midi-selector [midi-ctx on-change]
-  (fn []
-    (if-let [mctx @midi-ctx]
-      (do
-        [:select {:on-change #(on-change ((::midi/ins mctx) (.. % -target -value)))}
-         [:option {:value nil} "Select an input"]
-         (for [[in-name] (::midi/ins mctx)]
-           [:option {:value in-name} in-name])])
-      [:p "no midi ctx"])))
+  (if-let [mctx @midi-ctx]
+    (do
+      [:select {:on-change #(on-change ((::midi/ins mctx) (.. % -target -value)))}
+       [:option {:value nil} "Select an input"]
+       (for [[in-name] (::midi/ins mctx)]
+         [:option {:value in-name} in-name])])
+    [:p "no midi ctx"]))

 (defn note-on? [midi-msg]
   (and (= ::midi/note-on (::midi/type midi-msg))


Add rule for story script validation

Add rule for story script validation

--- src/storemi/routes/authorship.clj
+++ src/storemi/routes/authorship.clj
@@ -9,6 +9,7 @@
     [storemi.session :as sess]
     [storemi.models.story :as st]
     [storemi.urlfor :as url]
+    [storemi.js :as js]
     [storemi.routes.policies :refer
      [enforce-story
       enforce-user
@@ -30,10 +31,25 @@
   (when-not (sess/logged-in? request)
     {:error "You must be logged in"}))

+(defn script-is-valid [{params :params}]
+  (let [script (:script params)
+        data (:data params)
+        {:keys [storyTitle synopsis]} data]
+    (cond
+      (> (count storyTitle) st/title-maxlen)
+      {:error "Title is freakin' too long"}
+      (> (count synopsis) st/synopsis-maxlen)
+      {:error "I don't think you know what a synopsis is"})))
+
 (def story-ownership-rules
   (one-by-one
     user-is-logged-in
     user-owns-story))
+
+(def story-edition-rules
+  (one-by-one
+    story-ownership-rules
+    script-is-valid))

 (def story-creation-rules
   (one-by-one
@@ -51,14 +67,12 @@
         (sess/add-notification "Story created"))))

 (defn proceed-edition [{params :params :as req}]
-  (let [data (select-keys params [:storyTitle :synopsis])
+  (let [{:keys [data script]} params
         id (:story-id params)
-        script (clojure.string/replace
-                 (:script params) "\r" "")
-        path
-        (if (:saview params)
-          (url/story (sess/username req) id)
-          (:uri req))]
+        path (if (:saview params)
+               (url/story (sess/username req) id)
+               (:uri req))]
+    (println "-> " data)
     (st/update-story id data script)
     (-> (redirect path)
         (sess/add-notification "Story saved"))))
@@ -71,7 +85,7 @@

 (def resubmit-story
   (enforce-story
-    story-ownership-rules
+    story-edition-rules
     :fail page/story-edit
     :succ proceed-edition))

@@ -98,6 +112,16 @@
           (fn [request]
             (:script (st/story-match-by request)))))

+(defn wrap-parse-script [handler]
+  (fn [request]
+    (let [script (get-in request [:params :script])
+          script (clojure.string/replace script "\r" "")
+          data (js/parse-script script)
+          request (-> request
+                      (assoc-in [:params :script] script)
+                      (assoc-in [:params :data] data))]
+      (handler request))))
+
 ;; TODO: GET, POST and others actually can take a
 ;; function directly instead of an expresssion.
 ;; Thus, rewrite to obliterate redundancies.
@@ -106,11 +130,13 @@
   (routes
     (POST url/story-create-path request
          (submit-story request))
+
     (GET url/story-create-path request
          (page/story-create request))

-    (POST url/story-edit-path request
-         (resubmit-story request))
+    (POST url/story-edit-path _
+         (wrap-parse-script resubmit-story))
+
     (GET url/story-edit-path request
          (coerce enforce-user-owned-story page/story-edit))

@@ -138,3 +164,4 @@

+


(SERVER-1583) Add missing cloud OID shortnames


handle when images are in a form...

handle when images are in a form...

--- src/hypertext_ray/login.clj
+++ src/hypertext_ray/login.clj
@@ -20,8 +20,9 @@
                        :true #(if-not (selected? %) (click %))
                        :false #(if (selected? %) (click %))
                        nil)
-      ))
-  )
+      "image" nil
+      )
+    ))

 (defn get-query-action-map [siteinfo inputs]
   (let [query-action-map (remove #(apply nil? (vals %)) (remove empty?


Fix merge breakage

Fix merge breakage

--- src/lolitemsets/core.cljs
+++ src/lolitemsets/core.cljs
@@ -32,9 +32,6 @@
                                                 {:id "2004" :count 1}
                                                 {:id "3340" :count 1}]}]}}))

-(defn loading? []
-  (or (:generating @app)
-      (:trolling @app)))
 (defonce items (atom nil))
 (defonce champs (atom nil))

@@ -115,8 +112,8 @@
       (:total (:gold item))]]
     [:div {:dangerouslySetInnerHTML {:__html (:description item)}}]]])

-(defn item-recommendation [recommended]
-  (when-not (loading?)
+(defn item-recommendation [recommended loading?]
+  (when-not loading?
     [:div.media-list
      (map (fn [idx item]
             ^{:key idx} [item-component idx item])
@@ -219,18 +216,16 @@
             pretty pretty
             stat-optimized? (as-> el [:b el]))]]))

-(defn current-build []
-  (let [n (:num-items @app)
-        build (:recommended @app)
-        build (concat build (repeat (- n (count build)) nil))]
+(defn current-build [recommended num-items]
+  (let [build (concat recommended (repeat (- num-items (count recommended)) nil))]
     (into [:div]
           (for [i build]
             [item-image i]))))

-(defn build-stats [recommended champ champ-level props]
+(defn build-stats [recommended champ champ-level props num-items]
   [:div.panel.panel-primary
    [:div.panel-heading "Current build"]
-   [:div.panel-body [current-build]]
+   [:div.panel-body [current-build recommended num-items]]
    [:table.table
     [:tr [:th "Stat"] [:th "Value"]]
     [:div
@@ -311,7 +306,9 @@
      " Generate")])

 (defn app-component []
-  (let [state @app]
+  (let [state @app
+        loading? (or (:generating state)
+                     (:trolling state))]
     [:div.container
      [:div.row
       [:h1.col-sm-6 (:text state)]
@@ -351,8 +348,8 @@
          ".json"]]
        [item-set (:itemset state) (:blocks state)]]
       [:div.col-sm-6
-       [build-stats (:recommended state) (:champ state) (:champ-level state) (:props state)]
-       [item-recommendation (:recommended state)]]]]))
+       [build-stats (:recommended state) (:champ state) (:champ-level state) (:props state) (:num-items state)]
+       [item-recommendation (:recommended state) loading?]]]]))

 (reagent/render-component [app-component]
                           (. js/document (getElementById "app")))


Remove monkey-patching of lein-newnew thanks to @Raynes' 0.3.3 release including --todir option.

--- ccw.leiningen/src/clj/ccw/leiningen/util.clj
+++ ccw.leiningen/src/clj/ccw/leiningen/util.clj
@@ -126,112 +126,28 @@
 (defn lein-native-platform-path [lein-project]
   (eval/native-arch-path lein-project))

-;TODO: suggest a patch for getting rid of this monkey patch:
-;lpetit: Raynes: I have some feedback for you wrt lein newnew
-;[11:46pm] Raynes: I'm scared.
-;[11:46pm] Raynes: technomancy: He has feedback. Prepare the cannons.
-;[11:47pm] lpetit: Raynes: don't panic
-;[11:47pm] lpetit: Raynes: I had to monkey patch ->files to be able to make lein new new work in CCW
-;[11:47pm] lpetit: Raynes: 2 problems.
-;[11:49pm] lpetit: 1/ lein new new assumes implicitly that "user.dir" directory is the project's parent directory. In Eclipse (or other tools wanting to embed the plugin I guess), this generally is not the case
-;[11:49pm] Raynes: I don't think it does.
-;[11:49pm] Raynes: Oh.
-;[11:49pm] Raynes: Never mind, you said user.dir, not user.home.
-;[11:49pm] fbru02 left the chat room. (Ping timeout: 260 seconds)
-;[11:50pm] lpetit: 2/ In Eclipse, the user can choose a name for his project, which can be different from the project's directory name
-;[11:50pm] lpetit: Raynes: yeah, (System/getProperty "user.dir") is the equivalent of a "working current directory"
-;[11:50pm] Raynes: I don't quite understand why user.dir wouldn't be the parent directory. It is meant to be called from lein and it is, in every case, the right directory.
-;[11:51pm] Raynes: How is Eclipse calling it?
-;[11:51pm] Raynes: Are you calling the plugin code from Eclipse itself, or are you calling out to lein?
-;[11:51pm] lpetit: 3/ (yeah there's a 3/ finally) In Eclipse, the project's directory is created before lein new new has a chance to work, which make it fail by saying "directory already existing"
-;[11:52pm] lpetit: Raynes: talking about embedding leiningen-core in the IDE JVM, and calling tasks from it
-;[11:52pm] Raynes: Seems like this could be solved with an option like --to-dir to set the directory that the project will be added to.
-;[11:52pm] Raynes: We could make that ignore the fact that a directory already exists.
-;[11:52pm] Raynes: Would that help?
-;[11:52pm] lpetit: Raynes: I played with classlojure and I maintain a map of project-name -> classlojure env. per Eclipse project
-;[11:52pm] technomancy: yeah, I foresee the whole current directory thing being a common problem with leiningen-core outside leiningen
-;[11:52pm] technomancy: it's just too easy to write code that assumes the current directory is the project root
-;[11:53pm] lpetit: Raynes: I don't know if users would complain or not if you remove the "safeguard" ?
-;[11:53pm] technomancy: I try to avoid it, but it sneaks in
-;[11:53pm] Raynes: lpetit: I'm not removing the safeguard, just giving a way for Eclipse to get around it.
-;[11:53pm] lpetit: Raynes: perfect, so point 3/ is solved
-;[11:54pm] Raynes: Number 1 is solved too.
-;[11:54pm] Raynes: Since this lets you set the directory yourself and not assume user.dir.
-;[11:54pm] technomancy: lpetit: does would System/setProperty work for user.dir?
-;[11:55pm] lpetit: technomancy: that's what I'm doing currently, but it's not thread safe
-;[11:55pm] technomancy: oh, of course
-;[11:55pm] lpetit: Ah, system classloader ...
-;[11:56pm] lpetit: Raynes: indeed, for 1/, if there's also a programmatic way to change/bind the var --to-dir sets, we're good with that
-;[11:56pm] Raynes: Why would that be necessary?
-;[11:57pm] lpetit: Raynes: I don't start a separate jvm
-;[11:58pm] Raynes: Yeah, but you call the task. You can pass the option, right?
-;[11:58pm] lpetit: Raynes: oh, via a String-based interface, yeah, I can do that if that's the only option
-;[11:58pm] Raynes: Well, it's a task, not a library.
-;[11:59pm] lpetit: Raynes: shouldn't a task be based on a library ? (just kidding)
-;[11:59pm] Raynes: Heh
-;[11:59pm] Raynes: It could have a better library-like interface.
-;[11:59pm] Raynes: This should solve number 2 as well.
-;[11:59pm] lpetit: Raynes: I'm fine with what you suggested
-;[11:59pm] Raynes: The project name and directory name can be different with --to-dir.
-;[11:59pm] lpetit: Raynes: indeed, if the --to-dir is the project's directory, that would be just fine
-;[12:00am] Raynes: lpetit, technomancy: I don't know when I'll have time to implement this though, so feel free to patch it if you want.
-;[12:00am] Raynes: Shouldn't be hard.
-;[12:01am] technomancy: hm; yeah but I don't know if this should block the preview4 work
-;[12:01am] lpetit: Raynes, technomancy: definitely something I can do. I also may have some time problem, but since I definitely want to get rid of my big monkey patch, I'll do this sooner or later if it hasn't been done then
-;[12:01am] lpetit: technomancy: definitely not
-;[12:01am] technomancy: yeah, now that it's not on the bootclasspath it's easy to bump independently
-;[12:01am] lpetit: don't block it, I'm not blocked myself
-;[12:01am] technomancy: ok, good to hear
-;[12:02am] antares_: Raynes: you know what's funny? Gosu is not open source
-;[12:02am] Raynes: Heh
-
-(defn monkey-patch-lein-new [project]
-  (eval-in-project
-    project
-    '(do
-       (require 'leiningen.new.templates)
-       (in-ns 'leiningen.new.templates)
-       (defn- template-path [_ path data]
-         (io/file (render-text path data)))
-       (defn
-         ->files
-         "Generate a file with content. path can be a java.io.File or string.\n   It will be turned into a File regardless. Any parent directories will\n   be created automatically. Data should include a key for :name so that\n   the project is created in the correct directory"
-         [{:keys [name], :as data} & paths]
-         (.mkdir (io/file (System/getProperty "user.dir")))
-         (doseq
-           [path paths]
-           (if
-             (string? path)
-             (.mkdirs (template-path name path data))
-             (let
-               [[path content] path
-                path (template-path name path data)
-                path (io/file (System/getProperty "user.dir") path)
-                ]
-               (.mkdirs (.getParentFile path))
-               (io/copy content (io/file path)))))))))
-
 (defn lein-new [location template name & args]
-  (let [project-map (lein-project :project-less
-                      :enhance-fn
-                      (fn [p]
-                        (eval-in-project :project-less
-                          `(-> '~p
-                             (leiningen.core.project/add-profiles
-                               '{:user
-                                 ~'{:plugins [[lein-newnew "0.3.1"]]}})
-                             (leiningen.core.project/merge-profiles
-                               [:user])))))]
-    (monkey-patch-lein-new :project-less)
-    (let [user-dir (System/getProperty "user.dir")]
-      (try
-        (System/setProperty "user.dir" location)
-        (eval-in-project
-          :project-less
-          `(do
-             (require 'leiningen.new)
-             (apply (leiningen.new/resolve-template '~template) '~name '~args)))
-        (finally (System/setProperty "user.dir" user-dir))))))
+  (let [project-map
+         (lein-project
+           :project-less
+           :enhance-fn
+           (fn [p]
+             (eval-in-project
+               :project-less
+               `(-> '~p
+                  (leiningen.core.project/add-profiles
+                    '{:user
+                      ~'{:plugins [[lein-newnew "0.3.3"]]}})
+                  (leiningen.core.project/merge-profiles
+                    [:user])))))]
+    (eval-in-project
+      :project-less
+      `(do
+         (require 'leiningen.new)
+         (binding [leiningen.new.templates/*dir* ~location]
+           (apply (leiningen.new/resolve-template '~template)
+                  '~name
+                  '~args))))))

 ;;; JDT utilities


[#359] Reverted to agreed standard java interop convention. Fixed indentation.

--- backend/src/org/akvo/lumen/import/csv.clj
+++ backend/src/org/akvo/lumen/import/csv.clj
@@ -119,12 +119,12 @@
   (or (get spec "path")
       (let [file-on-disk? (contains? spec "fileName")
             url (get spec "url")]
-           (if file-on-disk?
-             (str file-upload-path
-                  "/resumed/"
-                  (last (s/split url #"\/"))
-                  "/file")
-             url))))
+        (if file-on-disk?
+          (str file-upload-path
+            "/resumed/"
+            (last (s/split url #"\/"))
+            "/file")
+          url))))

 (defmethod import/make-dataset-data-table "CSV"
   [tenant-conn {:keys [file-upload-path]} table-name spec]
@@ -145,8 +145,8 @@
       (with-open [conn (-> tenant-conn :datasource .getConnection)
                   input-stream (-> (io/input-stream path)
                                    import/unix-line-ending-input-stream)]
-        (let [copy-manager (.. conn (unwrap PGConnection) (getCopyAPI))]
-          (. copy-manager copyIn copy-sql input-stream)))
+        (let [copy-manager (.getCopyAPI (.unwrap conn PGConnection))]
+          (.copyIn copy-manager copy-sql input-stream)))
       (jdbc/execute! tenant-conn [(get-insert-sql temp-table table-name n-cols)])
       (jdbc/execute! tenant-conn [(get-drop-table-sql temp-table)])
       (jdbc/execute! tenant-conn [(get-vacuum-sql table-name)] {:transaction? false})


Change build-report to extract the :twixt key from the Ring request map it is passed

--- src/io/aviso/twixt/exceptions.clj
+++ src/io/aviso/twixt/exceptions.clj
@@ -163,38 +163,38 @@
 (defn build-report
   "Builds an HTML exception report (as a string).

-  twixt - Twixt instance, used to resolve client URIs for assets
-  request - Ring request map
+  request - Ring request map, which must contain the :twixt key.
   exception - Exception to report"
-  [twixt request exception]
-  (html5
-    [:head
-     [:title "Exception"]
-     (apply include-css (get-asset-uris twixt
-                                        "bootstrap3/css/bootstrap.css"
-                                        "twixt/exception.less"))]
-    [:body.hide-filtered
-     [:div.container
-      [:div.panel.panel-danger
-       [:div.panel-heading
-        [:h3.panel-title "An unexpected exception has occurred."]]
-       [:div.panel-body
-        [:h3 (h (exception-message exception))]
+  [request exception]
+  (let [twixt (:twixt request)]
+    (html5
+      [:head
+       [:title "Exception"]
+       (apply include-css (get-asset-uris twixt
+                                          "bootstrap3/css/bootstrap.css"
+                                          "twixt/exception.less"))]
+      [:body.hide-filtered
+       [:div.container
+        [:div.panel.panel-danger
+         [:div.panel-heading
+          [:h3.panel-title "An unexpected exception has occurred."]]
+         [:div.panel-body
+          [:h3 (h (exception-message exception))]
+          ]
+         ]
+        (exception->markup exception)
+
+        [:h3 "Request"]
+
+        (to-markup request)
+
+        [:h3 "System Properties"]
+        (to-markup (System/getProperties))
         ]
-       ]
-      (exception->markup exception)
-
-      [:h3 "Request"]
-
-      (to-markup request)
-
-      [:h3 "System Properties"]
-      (to-markup (System/getProperties))
-      ]
-     (apply include-js (get-asset-uris twixt
-                                       "bootstrap3/js/jquery-2.0.3.js"
-                                       "twixt/exception.coffee"))
-     ]))
+       (apply include-js (get-asset-uris twixt
+                                         "bootstrap3/js/jquery-2.0.3.js"
+                                         "twixt/exception.coffee"))
+       ])))

 (defn wrap-with-exception-reporting
   "Wraps the handler to report any uncaught exceptions as an HTML exception report.  This wrapper
@@ -210,7 +210,7 @@
       (catch Throwable t
         ;; TODO: logging?
         (->
-          (build-report (:twixt request) request t)
+          (build-report request t)
           response
           (content-type "text/html")
           (status 500))))))


Tag first-tier resolve tests

Tag first-tier resolve tests

--- test/dependable/resolve_test.clj
+++ test/dependable/resolve_test.clj
@@ -58,7 +58,7 @@
         "d"
         [package-d22]}
        query (map-query repo-info)]
-  (deftest ^:resolve-basic retrieval
+  (deftest ^:resolve-basic ^:resolve-first-tier retrieval
            (testing "Asking for a present package succeeds."
                     (is (= (resolve-dependencies
                              [


++default max pool size

++default max pool size

--- src/poky/kv/jdbc/util.clj
+++ src/poky/kv/jdbc/util.clj
@@ -7,7 +7,7 @@
      [java.sql SQLException Timestamp]))

 (def ^:private default-min-pool-size 3)
-(def ^:private default-max-pool-size 3)
+(def ^:private default-max-pool-size 15)
 (def ^:private default-driver "org.postgresql.Driver")

 (defn create-db-spec


Modify html-parser to return a delay.

Modify html-parser to return a delay.

The delay should return a sequential collection of files.

--- src/incise/parsers/html.clj
+++ src/incise/parsers/html.clj
@@ -33,11 +33,13 @@
     out-file))

 (defn html-parser
-  "Take a function that parses a string into HTML and returns an HTML parser.
+  "Take a function that parses a string into HTML and returns a HTML parser.

    An HTML parser is a function which takes a file, reads it and writes it out
    as html to the proper place under public. If it is a page it should appear at
    the root, if it is a post it will be placed under a directory strucutre based
    on its date."
   [to-html]
-  (comp write-Parse (partial File->Parse to-html)))
+  (fn [file]
+    (let [parse (File->Parse to-html file)]
+      (delay [(write-Parse parse)]))))


Properly delegate to the handler when the validation is succesful

--- src/io/aviso/rook/async.clj
+++ src/io/aviso/rook/async.clj
@@ -133,7 +133,8 @@
   (fn [request]
     (or
       (when-let [schema (-> request :rook :metadata :schema)]
-        (result->channel (sv/validate-against-schema request schema)))
+        (when-let [failure-response (sv/validate-against-schema request schema)]
+          (result->channel failure-response)))
       (handler request))))

 (def default-rook-pipeline


Let files override jars.

Let files override jars.

--- src/klangmeister/macros.clj
+++ src/klangmeister/macros.clj
@@ -23,7 +23,7 @@
 (defn sources* [names]
   (let [in-names? (->> names (map str) set)
         relevant? (fn [[name _]] (in-names? name))]
-    (->> (concat (files) (jars))
+    (->> (concat (jars) (files))
          (map name-val)
          (filter relevant?)
          collate)))


Fix wrong impl of datetime/format function.

--- src/uxbox/util/datetime.cljs
+++ src/uxbox/util/datetime.cljs
@@ -72,7 +72,8 @@
   "
   ([v] (format v :iso))
   ([v fmt]
-   (let [vm (js/moment v)]
+   {:pre [(datetime? v)]}
+   (let [vm (js/moment (.-v v))]
      (case fmt
        :unix (.unix vm)
        :offset (.valueOf vm)


Drag the square

Drag the square

--- src/web_audio_cljs/core.cljs
+++ src/web_audio_cljs/core.cljs
@@ -1,9 +1,12 @@
 (ns ^:figwheel-always web-audio-cljs.core
   (:require [om.core :as om :include-macros true]
             [om.dom :as dom :include-macros true]
+            [goog.dom :as googdom]
+            [goog.events :as events]
             [web-audio-cljs.audio :as audio]
             [web-audio-cljs.utils :refer [l]]
-            [cljs.core.async :refer [put! chan timeout <! >!] :as async])
+            [cljs.core.async :refer [put! chan timeout sliding-buffer <! >!]])
+  (:import [goog.events EventType])
   (:require-macros [cljs.core.async.macros :refer [go go-loop alt!]]))

 (enable-console-print!)
@@ -15,6 +18,12 @@
                           :is-recording false
                           :recorded-buffers []
                           :audio-context audio-context}))
+
+(defn listen [el type]
+  (let [out (chan)]
+    (events/listen el type
+      (fn [e] (put! out e)))
+    out))

 (defn lin-interp [x0 x1 y0 y1]
   (fn [x]
@@ -41,9 +50,14 @@
           (recur (inc i) cur-val)
           (recur (inc i) max-val))))))

-(defn draw-select-rect! [canvas-width canvas-height canvas-context x]
+(defn draw-select-rect! [canvas-width canvas-height canvas-context x mouse-down?]
   (.clearRect canvas-context 0 0 canvas-width canvas-height)
-  (.fillRect canvas-context x 0 100 100))
+  (.fillRect canvas-context x 0 100 100)
+  (when mouse-down?
+      (aset canvas-context "strokeStyle" "aliceblue")
+      (aset canvas-context "lineWidth" 6)
+      (.strokeRect canvas-context x 2 100 96)))
+

 (defn draw-buffer! [width height canvas-context data]
   (let [step (.ceil js/Math (/ (.-length data) width))
@@ -100,42 +114,44 @@
                      :canvas-context nil
                      :canvas-width 400
                      :canvas-height 100
-                     :mouse-chan (chan)
+                     :mouse-down false
                      :x-offset 0})

     om/IDidMount
     (did-mount [_]
-      (let [{:keys [canvas-width canvas-height mouse-chan left-x x-offset]} (om/get-state owner)
+      (let [{:keys [canvas-width canvas-height left-x x-offset]} (om/get-state owner)
             canvas (om/get-node owner "canvas-ref")
             canvas-context (.getContext canvas "2d")
-            x-pos (.-left (.getBoundingClientRect canvas))]
+            x-pos (.-left (.getBoundingClientRect canvas))
+            mouse-move-chan (listen (googdom/getElement js/document) (.-MOUSEMOVE EventType))]
         (go
           (while true
-            (let [[target x y] (<! mouse-chan)
-                  rel-x (- x x-pos)]
-              (.log js/console "!!!target: " target)
-              (.log js/console "!!!X" x)
-              (.log js/console "OFFSET x: " rel-x)
-              (.log js/console "!!!Y" y)
-              (om/update-state! owner #(assoc % :x-offset rel-x)))))
+            (let [e (<! mouse-move-chan)
+                  x (.-clientX e)
+                  rel-x (- (- x x-pos) (/ 100 2))
+                  {:keys [mouse-down]} (om/get-state owner)]
+              (when mouse-down
+                (.log js/console "!!!clientX" x)
+                (.log js/console "OFFSET x: " rel-x)
+                (om/update-state! owner #(assoc % :x-offset rel-x))))))
         (om/update-state! owner #(assoc % :canvas-context canvas-context :canvas canvas))))

     om/IDidUpdate
-    (did-update [_ _ {:keys [canvas-width canvas-height canvas-context x-offset]}]
-      (if canvas-context
-        (draw-select-rect! canvas-width canvas-height canvas-context x-offset)
-        (om/refresh! owner)))
+    (did-update [_ _ _]
+      (let [{:keys [canvas-width canvas-height canvas-context x-offset mouse-down]} (om/get-state owner)]
+        (if canvas-context
+          (draw-select-rect! canvas-width canvas-height canvas-context x-offset mouse-down)
+          (om/refresh! owner))))

     om/IRenderState
-    (render-state [_ {:keys [canvas-width canvas-height mouse-chan]}]
-      (dom/canvas #js {:width canvas-width
-                       :height canvas-height
-                       :style #js {:opacity 0.3 :position "relative" :left (- canvas-width)}
-                       :ref "canvas-ref"
-                       :onMouseMove (fn [e]
-                                      (.stopPropagation e)
-                                      (.preventDefault e)
-                                      (put! mouse-chan [(.-target e) (.-pageX e) (.-pageY e)]))} "no canvas"))))
+    (render-state [_ {:keys [canvas-width canvas-height mouse-down]}]
+      (dom/canvas #js {:width       canvas-width
+                       :height      canvas-height
+                       :style       #js {:opacity 0.3 :position "relative" :left (- canvas-width)}
+                       :ref         "canvas-ref"
+                       :onMouseDown #(om/set-state! owner :mouse-down true)
+                       :onMouseUp   #(om/set-state! owner :mouse-down false)}
+                  "no canvas"))))

 (defn buffer-view [data owner]
   (reify
@@ -145,31 +161,21 @@
     (init-state [_] {:canvas nil
                      :canvas-context nil
                      :canvas-width 400
-                     :canvas-height 100
-                     :mouse-chan (chan)})
+                     :canvas-height 100})

     om/IDidMount
     (did-mount [_]
-      (let [{:keys [canvas-width canvas-height mouse-chan buffer]} (om/get-state owner)
+      (let [{:keys [canvas-width canvas-height buffer]} (om/get-state owner)
             canvas (om/get-node owner "canvas-ref")
             canvas-context (.getContext canvas "2d")]
-        (draw-buffer! canvas-width canvas-height canvas-context buffer)
-        (go
-          (while true
-            (let [target (<! mouse-chan)]
-              (.log js/console "!!!target: " target))))))
+        (draw-buffer! canvas-width canvas-height canvas-context buffer)))

     om/IRenderState
-    (render-state [_ {:keys [canvas-width canvas-height mouse-chan]}]
+    (render-state [_ {:keys [canvas-width canvas-height]}]
       (dom/div nil
         (dom/canvas #js {:width canvas-width
                          :height canvas-height
-                         :ref "canvas-ref"
-                         :onMouseMove (fn [e]
-                                        (.stopPropagation e)
-                                        (.preventDefault e)
-                (.log js/console "Got mouse pageX, pageY: " (.-pageX e) (.-pageY e))
-                                        (put! mouse-chan (.-target e)))} "no canvas")
+                         :ref "canvas-ref"} "no canvas")
                (om/build wave-selector-view data)))))

 (defn buffers-list-view [data owner]


navigation buttons

navigation buttons

--- cljx/plongeur-cljs/src/plongeur/view.cljs
+++ cljx/plongeur-cljs/src/plongeur/view.cljs
@@ -14,12 +14,16 @@
             [kierros.async :refer [debounce]])
   (:require-macros [cljs.core.async.macros :refer [go go-loop]]))

-
 (defn ascii [c] (-> c {\f 70
                        \l 76
                        \s 83} str))

-(defn nav! [url] #(set! (.-location js/window) url))
+(defn nav! [url] (set! (.-location js/window) url))
+
+(defn ->browse-scenes [] (nav! "#/browse"))
+(defn ->create-scene  [] (nav! "#/create"))
+(defn ->edit-scene    [] (nav! "#/scene"))
+(defn ->edit-config   [] (nav! "#/config"))

 ;; Set MDL upgrade interval

@@ -171,12 +175,7 @@
   (html [:ul {:class-name "mdl-menu mdl-list mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect mdl-shadow--2dp account-dropdown"
               :for "more-vert-btn"}

-         [:li {:class-name "mdl-menu__item mdl-list__item"}
-          [:span {:class-name "mdl-list__item-primary-content"
-                  :on-click   (nav! "#/config")}
-           [:i {:class-name "material-icons mdl-list__item-icon"} "settings"] "Configuration"]]
-
-         [:li {:class-name "list__item--border-top"}]
+         #_[:li {:class-name "list__item--border-top"}]

          [:li {:class-name "mdl-menu__item mdl-list__item"}
           [:span {:on-click #(go (>! debug :click))
@@ -190,11 +189,12 @@

          [:li {:class-name "list__item--border-top"}]

-         [:li {:class-name "mdl-menu__item mdl-list__item"}
+         [:a {:class-name "mdl-menu__item mdl-list__item"}
           [:span {:class-name "mdl-list__item-primary-content"}
            [:i {:class-name "material-icons mdl-list__item-icon"} "attach_file"] "Publication"]]

-         [:li {:class-name "mdl-menu__item mdl-list__item"}
+         [:a {:class-name "mdl-menu__item mdl-list__item"
+              :href       "https://github.com/tmoerman/plongeur"}
           [:span {:class-name "mdl-list__item-primary-content"}
            [:i {:class-name "material-icons mdl-list__item-icon"} "link"] "Github"]]]))

@@ -203,15 +203,33 @@
   (html [:header {:class-name "mdl-layout__header"}
          [:div {:class-name "mdl-layout__header-row"}

-          [:div {} (-> state m/current-view str)]
-
-          [:button {:title "Browse scenes"
-                    :class-name "mdl-button mdl-js-button mdl-button--icon"
-                    :on-click   (nav! "#/browse")}
-           [:i {:class-name "material-icons"} "folder_open"]]
+          ;; Nav buttons
+
+          (let [disabled (= :view/browse-scenes (m/current-view state))]
+            [:button {:title      "Browse scenes"
+                      :class-name (if disabled
+                                    "mdl-button mdl-js-button mdl-button--icon mdl-button--disabled"
+                                    "mdl-button mdl-js-button mdl-button--icon")
+                      :on-click   #(->browse-scenes)}
+             [:i {:class-name "material-icons"} (if disabled "folder" "folder_open")]])
+
+          (let [disabled (= :view/create-scene (m/current-view state))]
+            [:button {:title      "Create scene"
+                      :class-name (if disabled
+                                    "mdl-button mdl-js-button mdl-button--icon mdl-button--disabled"
+                                    "mdl-button mdl-js-button mdl-button--icon")
+                      :on-click   #(->create-scene)}
+             [:i {:class-name "material-icons"} (if disabled "insert_drive_file" "note_add")]])
+
+          (let [disabled (= :view/edit-config (m/current-view state))]
+            [:button {:title      "Configuration"
+                      :class-name (if disabled
+                                    "mdl-button mdl-js-button mdl-button--icon mdl-button--disabled"
+                                    "mdl-button mdl-js-button mdl-button--icon")
+                      :on-click   #(->edit-config)}
+             [:i {:class-name "material-icons"} "settings"]])

           [:div {:class-name "mdl-layout-spacer"}]
-

           (when (= :view/edit-scene (m/current-view state))
             [:div {:on-click   #(go (>! add-plot :sigma))
@@ -241,8 +259,8 @@
             :view/create-scene  [:h1 {} "create-scene"]
             :view/edit-scene    (Grid state cmd-chans)
             :view/edit-config   [:h1 {} "edit-config"]
-            [:h1 {} "uh-oh"]
-            )
+
+                                [:h1 {} "uh-oh"])

           ]]))


fix some errors in verify

fix some errors in verify

--- src/staircase/handler.clj
+++ src/staircase/handler.clj
@@ -81,8 +81,8 @@
   (let [resp (client/post verifier {:form-params {:audience audience :assertion assertion} :throw-exceptions false})
         status (:status resp)]
     (if (not (= status 200))
-      {:status 500 :session nil}
-      (let [{email :email} (json/parse-string (:body status))
+      {:status 500 :session (dissoc session :identity)}
+      (let [{email :email} (json/parse-string (:body resp))
             session (assoc session :identity email)]
         (-> (response "ok") (assoc :session session))))))


(MAINT) Convert vectors to sets

(MAINT) Convert vectors to sets

--- src/clj/puppetlabs/puppetserver/certificate_authority.clj
+++ src/clj/puppetlabs/puppetserver/certificate_authority.clj
@@ -130,11 +130,11 @@

 (def required-master-files
   "The set of SSL files that are required on the master."
-  [:hostprivkey :hostcert])
+  #{:hostprivkey :hostcert})

 (def required-ca-files
   "The set of SSL related files that are required on the CA."
-  [:cacert :cacrl :cakey :cert-inventory :serial])
+  #{:cacert :cacrl :cakey :cert-inventory :serial})

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Internal


Rounding done consistently at DB level

Rounding done consistently at DB level

--- src/swanson/models/db.clj
+++ src/swanson/models/db.clj
@@ -104,7 +104,8 @@
   (sha256 (apply str date amount description)))

 (def week-grouping-query
-  "SELECT date_trunc('week', t.date) AS Week , SUM(t.amount) AS total
+  "SELECT date_trunc('week', t.date) AS Week,
+  round(SUM(t.amount)::numeric, 2) AS total
   FROM transactions t
   WHERE t.date > now() - interval '1 year'
   GROUP BY Week
@@ -147,7 +148,9 @@
 (defn recent-transactions
   [limit]
   (jdbc/query db-spec
-              ["SELECT t.id, t.amount, t.date, t.description, c.name
+              ["SELECT t.id,
+               round(t.amount::numeric, 2) AS amount,
+               t.date, t.description, c.name
                FROM transactions t
                INNER JOIN categories c
                ON c.id = t.category_id
@@ -158,7 +161,7 @@
   [category-id]
   (jdbc/query db-spec
               ["SELECT EXTRACT(month FROM transactions.date) AS month,
-               SUM(transactions.amount) AS amount
+               round(SUM(transactions.amount)::numeric, 2) AS amount
                FROM transactions WHERE category_id = ?
                GROUP by month ORDER
                BY month DESC" category-id]))
@@ -179,7 +182,7 @@
   [category-id]
   (jdbc/query db-spec
               ["SELECT EXTRACT(DOY from transactions.date) doy,
-               SUM(transactions.amount)
+               round(SUM(transactions.amount)::numeric, 2) AS amount
                FROM transactions WHERE category_id = ?
                AND EXTRACT(ISOYEAR FROM transactions.date) =
                 EXTRACT(ISOYEAR FROM current_date)


same-author/direction

same-author/direction

Former-commit-id: 357249a49b9e36d6eafb73e219410e6468155306

--- src/syng_im/handlers.cljs
+++ src/syng_im/handlers.cljs
@@ -144,23 +144,35 @@
              :to           "me"})) (range n)))

 (defn store-message!
-  [db [_ {chat-id :from
+  [db [_ {chat-id  :from
           outgoing :outgoing
-          :as msg}]]
-  (let [previous-message (peek (get-in db [:chats chat-id :messages]))
-        msg (merge msg
-                   {:same-author     (if previous-message
-                                       (= (:from previous-message) outgoing)
-                                       true)
-                    :same-direction  (if previous-message
-                                       (= (:outgoing previous-message) outgoing)
-                                       true)})]
+          :as      msg}]]
+  (let [previous-message (first (get-in db [:chats chat-id :messages]))
+        msg              (merge msg
+                                {:same-author    (if previous-message
+                                                   (= (:from previous-message) outgoing)
+                                                   true)
+                                 :same-direction (if previous-message
+                                                   (= (:outgoing previous-message) outgoing)
+                                                   true)})]
     (save-message chat-id msg)))
+
+(defn add-message-to-db
+  [db chat-id {:keys [from outgoing] :as message}]
+  (let [messages         [:chats chat-id :messages]
+        previous-message (first (get-in db [:chats chat-id :messages]))
+        message          (merge message
+                                {:same-author    (if previous-message
+                                                   (= (:from previous-message) from)
+                                                   true)
+                                 :same-direction (if previous-message
+                                                   (= (:outgoing previous-message) outgoing)
+                                                   true)})]
+    (update-in db messages conj message)))

 (defn receive-message
   [db [_ {chat-id :from :as msg}]]
-  (let [messages [:chats chat-id :messages]]
-    (update-in db messages conj msg)))
+  (add-message-to-db db chat-id msg))

 (register-handler :received-msg
   (-> receive-message
@@ -283,7 +295,7 @@

 (defn prepare-message
   [{:keys [identity current-chat-id] :as db} _]
-  (let [text             (get-in db [:chats current-chat-id :input-text])
+  (let [text (get-in db [:chats current-chat-id :input-text])
         {:keys [command]} (check-suggestion db (str text " "))]
     (if command
       (set-chat-command db command)
@@ -303,13 +315,15 @@
   (let [command-key (get-in staged-command [:command :command])
         content     {:command (name command-key)
                      :content (:content staged-command)}]
-    {:msg-id       (random/id)
-     :from         identity
-     :to           chat-id
-     :content      content
-     :content-type content-type-command
-     :outgoing     true
-     :handler      (:handler staged-command)}))
+    {:msg-id         (random/id)
+     :from           identity
+     :to             chat-id
+     :content        content
+     :content-type   content-type-command
+     :outgoing       true
+     :handler        (:handler staged-command)
+     :same-author    false
+     :same-direction false}))

 (defn prepare-staged-commans
   [{:keys [current-chat-id identity] :as db} _]
@@ -321,13 +335,13 @@
 (defn add-message
   [{:keys [new-message current-chat-id] :as db}]
   (if new-message
-    (update-in db [:chats current-chat-id :messages] conj new-message)
+    (add-message-to-db db current-chat-id new-message)
     db))

 (defn add-commands
   [{:keys [new-commands current-chat-id] :as db}]
   (reduce
-    #(update-in %1 [:chats current-chat-id :messages] conj %2)
+    #(add-message-to-db %1 current-chat-id %2)
     db
     new-commands))


Update auth.clj

Update auth.clj

--- src/mailer/service/auth.clj
+++ src/mailer/service/auth.clj
@@ -19,6 +19,7 @@
 					)
 				(generate-string {:status "Username or Password not correct"})
 				)
+			(generate-string {:status "User not present"})
 			)
 		)
 	)


Embedding usage stats

Embedding usage stats

--- src/metabase/util/stats.clj
+++ src/metabase/util/stats.clj
@@ -161,26 +161,56 @@
   []
   {:groups (db/count PermissionsGroup)})

+(defn- card-has-params? [card]
+  (boolean (get-in card [:dataset_query :native :template_tags])))
+
 (defn- question-metrics
   "Get metrics based on questions
   TODO characterize by # executions and avg latency"
   []
-  {:questions (merge-count-maps (for [{query-type :query_type} (db/select [Card :query_type])]
-                                  (let [native? (= (keyword query-type) :native)]
-                                    {:total  1
-                                     :native native?
-                                     :gui    (not native?)})))})
+  (let [cards (db/select [Card :query_type :public_uuid :enable_embedding :embedding_params :dataset_query])]
+    {:questions (merge-count-maps (for [card cards]
+                                    (let [native? (= (keyword (:query_type card)) :native)]
+                                      {:total       1
+                                       :native      native?
+                                       :gui         (not native?)
+                                       :with_params (card-has-params? card)})))
+     :public    (merge-count-maps (for [card  cards
+                                        :when (:public_uuid card)]
+                                    {:total       1
+                                     :with_params (card-has-params? card)}))
+     :embedded  (merge-count-maps (for [card  cards
+                                        :when (:enable_embedding card)]
+                                    (let [embedding-params-vals (set (vals (:embedding_params card)))]
+                                      {:total                1
+                                       :with_params          (card-has-params? card)
+                                       :with_enabled_params  (contains? embedding-params-vals "enabled")
+                                       :with_locked_params   (contains? embedding-params-vals "locked")
+                                       :with_disabled_params (contains? embedding-params-vals "disabled")})))}))

 (defn- dashboard-metrics
   "Get metrics based on dashboards
   TODO characterize by # of revisions, and created by an admin"
   []
-  (let [dashboards (db/select [Dashboard :creator_id])
+  (let [dashboards (db/select [Dashboard :creator_id :public_uuid :parameters :enable_embedding :embedding_params])
         dashcards  (db/select [DashboardCard :card_id :dashboard_id])]
     {:dashboards         (count dashboards)
+     :with_params        (count (filter (comp seq :parameters) dashboards))
      :num_dashs_per_user (medium-histogram dashboards :creator_id)
      :num_cards_per_dash (medium-histogram dashcards :dashboard_id)
-     :num_dashs_per_card (medium-histogram dashcards :card_id)}))
+     :num_dashs_per_card (medium-histogram dashcards :card_id)
+     :public             (merge-count-maps (for [dash  dashboards
+                                                 :when (:public_uuid dash)]
+                                             {:total       1
+                                              :with_params (seq (:parameters dash))}))
+     :embedded           (merge-count-maps (for [dash  dashboards
+                                                 :when (:enable_embedding dash)]
+                                             (let [embedding-params-vals (set (vals (:embedding_params dash)))]
+                                               {:total                1
+                                                :with_params          (seq (:parameters dash))
+                                                :with_enabled_params  (contains? embedding-params-vals "enabled")
+                                                :with_locked_params   (contains? embedding-params-vals "locked")
+                                                :with_disabled_params (contains? embedding-params-vals "disabled")})))}))

 (defn- pulse-metrics
   "Get mes based on pulses


Wrap logging in the request

Wrap logging in the request

--- src/silly_image_store/handler.clj
+++ src/silly_image_store/handler.clj
@@ -20,7 +20,6 @@
   (let [image-names (store/list-images images-dir)
         image-url (str (base-url request) "/images/")
         to-json (fn [n] {:name n :url (str image-url n)})]
-    (log/info "Blah")
     (map to-json image-names)))

 (defn- serve-image-route [{{image :image} :params}]
@@ -33,7 +32,13 @@
   (route/resources "/")
   (route/not-found "Not Found"))

+(defn wrap-request-logging [handler]
+  (fn [{requester :remote-addr uri :uri action :request-method :as request}]
+    (log/info (str action " " uri " from " requester))
+    (handler request)))
+
 (def app
   (-> (handler/site app-routes)
-      (wrap-json-response)))
+      (wrap-json-response)
+      (wrap-request-logging)))


Working modal

Working modal

--- src/om_bootstrap/modal.cljs
+++ src/om_bootstrap/modal.cljs
@@ -23,32 +23,35 @@
   "Component that renders a Modal. Manages it's own toggle state"
   [owner state]
   (init-state [_]
-    {:visible? (-> (om/get-props owner)
-                   :opts
-                   :visible?)})
+    {:visible? (get-in (om/get-props owner) [:opts :visible?])})
+  (will-receive-props [this next-props]
+    (let [last-props (om/get-props owner)
+          last-visible? (om/get-state owner [:visible?])
+          next-visible? (get-in next-props [:opts :visible?])]
+      (when (not= last-visible? next-visible?)
+        (om/set-state! owner [:visible?] next-visible?))))
   (render [_]
     (let [{:keys [opts children]} (om/get-props owner)
           [bs props] (t/separate Modal opts {:bs-class "modal"})
-          visible? (om/get-state owner [:visible?])
           classes {:modal true
                    :fade true
-                   :in visible?}]
+                   :in (om/get-state owner [:visible?])}]
       (d/div (u/merge-props props
                             {:class (d/class-set classes)})
-             (d/div {:class "modal-dialog"}
-                    (d/div {:class "modal-content"}
-                           (d/div {:class "modal-header"}
-                                  (when (:close-button? bs)
-                                    (d/button {:type         "button"
-                                               :class        "close"
-                                               :aria-hidden  true
-                                               :on-click (fn [_] (hide! owner))}
-                                              "×"))
-                                  (u/clone-with-props (:header bs) {:class "modal-title"}))
-                           (d/div {:class "modal-body"}
-                                  children)
-                           (d/div {:class "modal-footer"}
-                                        (:footer bs))))))))
+        (d/div {:class "modal-dialog"}
+          (d/div {:class "modal-content"}
+            (d/div {:class "modal-header"}
+              (when (:close-button? bs)
+                (d/button {:type         "button"
+                           :class        "close"
+                           :aria-hidden  true
+                           :on-click (fn [_] (om/set-state! owner [:visible?] false))}
+                          "×"))
+              (u/clone-with-props (:header bs) {:class "modal-title"}))
+            (d/div {:class "modal-body"}
+              children)
+            (d/div {:class "modal-footer"}
+              (:footer bs))))))))
+
 (sm/defn modal
-  [opts :- Modal & children]
-  (->modal* {:opts opts :children children}))+  [opts :- Modal & children])


Add recover! to outputs.

Add recover! to outputs.

--- src/onyx/plugin/datomic.clj
+++ src/onyx/plugin/datomic.clj
@@ -256,6 +256,9 @@

   (checkpoint [this])

+  (recover! [this replica-version checkpoint]
+    this)
+
   (checkpointed! [this epoch]
     true)

@@ -290,6 +293,9 @@

   (checkpoint [this])

+  (recover! [this replica-version checkpoint]
+    this)
+
   (synced? [this epoch]
     true)

@@ -324,6 +330,9 @@
     true)

   (checkpoint [this])
+
+  (recover! [this replica-version checkpoint]
+    this)

   (checkpointed! [this epoch]
     true)


whitespace

whitespace

--- src/terraboot/cluster.clj
+++ src/terraboot/cluster.clj
@@ -246,7 +246,7 @@
              (asg "MasterServerGroup"
                   {:image_id current-coreos-ami
                    :instance_type "m4.large"
-                   :sgs ["master-security-group", "admin-security-group"]
+                   :sgs ["master-security-group" "admin-security-group"]
                    :role "master-role"
                    :public_ip true
                    :tags {:Key "role"
@@ -333,7 +333,7 @@
              (asg "SlaveServerGroup"
                   {:image_id current-coreos-ami
                    :instance_type "m4.large"
-                   :sgs ["slave-security-group"                         ]
+                   :sgs ["slave-security-group"]
                    :role "slave-role"
                    :tags {:Key "role"
                           :PropagateAtLaunch "true"


While the supersaw is super, 2 of them is too much Removing duplicate supersaw.

--- src/overtone/inst/synth.clj
+++ src/overtone/inst/synth.clj
@@ -53,21 +53,6 @@
         freq    (* freq vib)
         sig     (mix (* env amp (saw [freq (* freq (+ dtune 1))])))]
     sig))
-
-(definst supersaw [freq 440 amp 1]
-  (let [input  (lf-saw freq)
-        shift1 (lf-saw 4)
-        shift2 (lf-saw 7)
-        shift3 (lf-saw 5)
-        shift4 (lf-saw 2)
-        comp1  (> input shift1)
-        comp2  (> input shift2)
-        comp3  (> input shift3)
-        comp4  (> input shift4)
-        output (+ (- input comp1) (- input comp2) (- input comp3) (- input comp4))
-        output (- output input)
-        output (leak-dc:ar (* output 0.25))]
-    (* amp output)))

 (definst supersaw [freq 440 amp 1]
   (let [input  (lf-saw freq)


Double APPLY-HEAD time to 300ms to attempt to reduce perceived jitter when using the metronome

--- src/overtone/time_utils.clj
+++ src/overtone/time_utils.clj
@@ -88,7 +88,7 @@
 ; the instance of the function defined earlier.
 ; (apply-at (+ dur (now)) #'my-melody arg1 arg2 [])

-(def APPLY-AHEAD 150)
+(def APPLY-AHEAD 300)

 (defn apply-at
   "Calls (apply f args argseq) APPLY-AHEAD ms before ms-time."
@@ -98,4 +98,3 @@
     (if (<= delay-time 0)
       (apply f (#'clojure.core/spread args))
       (schedule #(apply f (#'clojure.core/spread args)) delay-time))))
-


Fix to if-some as the docs say

Fix to if-some as the docs say

--- modules/reitit-core/src/reitit/impl.cljc
+++ modules/reitit-core/src/reitit/impl.cljc
@@ -25,7 +25,7 @@
   [f coll]
   (reduce-kv
     (fn [coll k v]
-      (if-let [v' (f v)]
+      (if-some [v' (f v)]
         (assoc coll k v')
         coll))
     coll


trying differnt backtraces

trying differnt backtraces

--- cwsg/src/cwsg/middleware/show_exceptions.clj
+++ cwsg/src/cwsg/middleware/show_exceptions.clj
@@ -16,12 +16,12 @@
   background: lightgrey;
 }

-table td.method {
-  text-align: right;
+span.method {
+  padding-right: 1em;
 }

-table td.source {
-  text-align: left;
+span.source {
+  font-weight: bold;
 }
 ")

@@ -34,7 +34,7 @@
     "(Unknown Source)"))

 (defn- clojure-elem-str [parsed]
-  (str (:ns parsed) "/" (:fn parsed) (if (:annon-fn parsed) "(fn)")))
+  (str (:ns parsed) "/" (:fn parsed) (if (:annon-fn parsed) "[fn]")))

 (defn java-elem-str [parsed]
   (str (:class parsed) "." (:method parsed)))
@@ -61,16 +61,19 @@
                       (if (:clojure parsed)
                         (html
                           [:tr
-                            [:td.method (h (clojure-elem-str parsed))]
-                            [:td.source (h (source-str        parsed))]]
+                            [:td
+                              [:span.source (h (source-str       parsed))]
+                              [:span.method (h (clojure-elem-str parsed))]]]
                           ;[:tr
                            ;[:td
                             ; [:pre "some source\ni has it"]]]
                             )
                         (html
                           [:tr
-                            [:td.method (h (java-elem-str parsed))]
-                            [:td.source (h (source-str    parsed))]]))]))]]]]])])
+                            [:td
+                              [:span.source (h (source-str    parsed))]
+                              [:span.method (h (java-elem-str parsed))]
+                              ]]))]))]]]]])])

 (defn wrap
   "Returns an app corresponding to the given one but for which catches all


replace proxy with reify

replace proxy with reify

--- dada-core/src/main/clojure/org/dada/core.clj
+++ dada-core/src/main/clojure/org/dada/core.clj
@@ -257,8 +257,7 @@
   "make a Getter for the named attribute of the given Class"
   (let [key (keyword (attribute-key name))
 	arg-symbol (with-meta 's {:tag (.getCanonicalName input-type)})]
-    (eval `(proxy [Getter] []
-		  (^{:tag ~output-type} get [~arg-symbol] (~key ~arg-symbol))))))
+    (eval `(reify Getter (get [_ ~arg-symbol] (~key ~arg-symbol))))))

 (defn ^Metadata record-metadata2 [primary-keys version-keys version-comparator attributes]


formatting

formatting

--- test/asset_minifier/core_test.clj
+++ test/asset_minifier/core_test.clj
@@ -6,18 +6,15 @@
 (def input-path "test/resources")
 (def output-path "test/resources/minified/")

-
 (defn clean-output []
   (doseq [f (-> output-path file file-seq rest)]
     (.delete f)))
-

 (defmacro run-test [t result]
   `(do
      (clean-output)
      (is
       (= ~result ~t))))
-

 (deftest test-minification
   (testing "testing CSS minifcation"


Fix cors tests related to headers normalization.

--- test/catacumba/handlers_tests.clj
+++ test/catacumba/handlers_tests.clj
@@ -168,7 +168,7 @@
           (is (= (:body response) "hello world"))
           (is (= (:status response) 200))
           (is (= (get headers "access-control-allow-origin") "*"))
-          (is (= (get headers "access-control-allow-headers") "X-FooBar"))))))
+          (is (= (get headers "access-control-allow-headers") "x-foobar"))))))

   (testing "Options cors request"
     (let [handler (fn [ctx] "hello world")


CMR-2899: Addressed review comments.

CMR-2899: Addressed review comments.

--- access-control-app/src/cmr/access_control/services/acl_service.clj
+++ access-control-app/src/cmr/access_control/services/acl_service.clj
@@ -336,7 +336,7 @@
                               (acl/acl-matches-sids-and-permission? sids (name permission) acl)))
                        acls))

-(defn get-group-permissions
+(defn- get-group-permissions
   "Returns a map of the target group concept ids to the set of permissions
    granted to the given username or user type."
   [context username-or-type target-group-ids]


Remove maven.twttr.com from projects generated with the template

it's not required for any dependencies

--- finagle-clojure-template/src/leiningen/new/finagle_clojure.clj
+++ finagle-clojure-template/src/leiningen/new/finagle_clojure.clj
@@ -37,8 +37,6 @@
   [name]
   (let [module-name (module-name name "core")
         java-source-paths ["src/java"]
-        ;; TODO add comment explaining why checksum warn
-        repositories (str '[["twitter" {:url "http://maven.twttr.com/" :checksum :warn}]])
         dependencies `[{:dependency [finagle-clojure/thrift ~finagle-clojure-version]}
                        {:dependency [com.twitter/scrooge-core_2.10 "3.16.3"]}]]
     {:name name
@@ -46,7 +44,6 @@
      :module-name module-name
      :misc-config [{:key :plugins :value '[[lein-finagle-clojure "0.1.0-SNAPSHOT"]]}
                    {:key :java-source-paths :value java-source-paths}
-                   {:key :repositories :value repositories}
                    {:key :finagle-clojure :value {:thrift-source-path "src/thrift" :thrift-output-path "src/java"}}
                    {:key :profiles :value '{:dev {:dependencies [[org.clojure/clojure "1.6.0"]]}}}]
      :dependencies dependencies


Improve log message for not found overviews

Change-Id: I7bdb1af6b1734cc918c9c980125e5cc096a97c0e

--- src/qcast/infoq/scraper.clj
+++ src/qcast/infoq/scraper.clj
@@ -112,10 +112,11 @@
   ([marker]
      (debug "Fetching overview from index" marker)
      (let [items (log-errors (infoq/presentations marker))]
-       (if (empty? items) ;; Error or last overview page reached?
-         (warn "No items found. HTML/CSS layout changed?")
+       (if (empty? items)
+         (if (> marker 0)
+           (info "No more items found")
+           (warn "No items found. HTML/CSS layout changed?"))
          (lazy-cat items (latest (+ marker (count items))))))))
-

 (defn- cache-updates
   "Scrape the overview sites and collect its oughly 12 items per site until


Add missing indent to test code

Add missing indent to test code

--- test/reagenttest/testreagent.cljs
+++ test/reagenttest/testreagent.cljs
@@ -198,9 +198,9 @@
           child (fn [p]
                   (swap! child-ran inc)
                   [:div (:val p)])
-          parent(fn []
-                  (swap! parent-ran inc)
-                  [:div "child-foo" [child @child-props]])]
+          parent (fn []
+                   (swap! parent-ran inc)
+                   [:div "child-foo" [child @child-props]])]
       (with-mounted-component [parent nil nil]
         (fn [c div]
           (r/flush)


In Node & CJS React, style prop doesn't end in ;

--- test/reagenttest/testreagent.cljs
+++ test/reagenttest/testreagent.cljs
@@ -7,6 +7,8 @@
             [reagent.core :as r]
             [reagent.dom.server :as server]
             [reagent.impl.util :as util]))
+
+(def node? (exists? js/require))

 (def tests-done (atom {}))

@@ -1022,6 +1024,8 @@
     (is (= @node nil))))

 (deftest style-property-names-are-camel-cased
-  (is (= "
foo
"
+  (is (= (if node?
+           "
foo
"
+           "
foo
")
          (server/render-to-static-markup
            [:div {:style {:text-align "center"}} "foo"]))))


(PE-16504) Up default :critical timeout to 5s

--- src/puppetlabs/trapperkeeper/services/status/status_core.clj
+++ src/puppetlabs/trapperkeeper/services/status/status_core.clj
@@ -108,7 +108,7 @@
   a timeout when calling a status function."
   [level :- ServiceStatusDetailLevel]
   (case level
-    :critical 5
+    :critical 30
     :info 60
     :debug 60))


slightly faster test startup

slightly faster test startup

--- test/metabase/test_setup.clj
+++ test/metabase/test_setup.clj
@@ -67,25 +67,27 @@
 (defn load-test-datasets
   "Call `load-data!` on all the datasets we're testing against."
   []
-  (doseq [dataset-name datasets/test-dataset-names]
+  (u/pdoseq [dataset-name datasets/test-dataset-names]
     (log/info (format "Loading test data: %s..." (name dataset-name)))
     (let [dataset (datasets/dataset-name->dataset dataset-name)]
       (datasets/load-data! dataset)

       ;; Check that dataset is loaded and working
       (assert (Table (datasets/table-name->id dataset :venues))
-              (format "Loading test dataset %s failed: could not find 'venues' Table!" dataset-name)))))
+        (format "Loading test dataset %s failed: could not find 'venues' Table!" dataset-name)))))

 (defn test-startup
   {:expectations-options :before-run}
   []
-  (log/info "Setting up test DB and running migrations...")
-  (db/setup-db :auto-migrate true)
-
-  (metabase.models.setting/set :site-name "Metabase Test") ; add any global settings defaults
-  (load-test-datasets)                                     ; Load the test datasets
-  (core/start-jetty)                                       ; startup test web server
-  (task/start-task-runner!))                               ; start the task runner
+  ;; We can shave about a second from unit test launch time by doing the various setup stages in on different threads
+  (let [setup-db           (future (time (do (log/info "Setting up test DB and running migrations...")
+                                             (db/setup-db :auto-migrate true)
+                                             (load-test-datasets)
+                                             (metabase.models.setting/set :site-name "Metabase Test"))))
+        start-task-runner! (future (task/start-task-runner!))]
+    (core/start-jetty)
+    @setup-db
+    @start-task-runner!))

 (defn test-teardown


Adds another test.

Adds another test.

--- test/onyx/log/abort_test.clj
+++ test/onyx/log/abort_test.clj
@@ -21,3 +21,13 @@
   (fact diff => {:aborted :d})
   (fact reactions => []))

+(def old-replica {:pairs {:a :b :b :c :c :a} :accepted {:d :a} :peers [:a :b :c]})
+
+(let [new-replica (f old-replica)
+      diff (rep-diff old-replica new-replica)
+      reactions (rep-reactions old-replica new-replica diff {:id :d})]
+  (fact (:pairs new-replica) => {:a :b :b :c :c :a})
+  (fact (:peers new-replica) => [:a :b :c])
+  (fact diff => {:aborted :d})
+  (fact reactions => []))
+


Fix test from log accuracy change

Fix test from log accuracy change

--- test/runbld/test/process_test.clj
+++ test/runbld/test/process_test.clj
@@ -1,7 +1,8 @@
 (ns runbld.test.process-test
   (:require [clojure.test :refer :all]
             [schema.test])
-  (:require [runbld.process :as proc] :reload-all))
+  (:require [runbld.process :as proc]
+            [runbld.util.data :as data] :reload-all))

 (use-fixtures :once schema.test/validate-schemas)

@@ -29,7 +30,9 @@
                         *err* (java.io.StringWriter.)]
                 (proc/exec "bash" "-e" "test/output.bash" "tmp"))]
       (testing "master process stdout"
-        (is (= (bigdec 1) (:out-accuracy res)))
+        (is (= (bigdec 100)
+               (data/unscaled-percent
+                (:out-accuracy res))))
         (is (= (:out-bytes res) (count
                                  (slurp "tmp/.master.log"))))
         (is (= 10 (count


SER-1338 | fix tests

SER-1338 | fix tests

--- test/vignette/storage/s3_test.clj
+++ test/vignette/storage/s3_test.clj
@@ -37,6 +37,7 @@
 (facts :s3 :put-object
   (put-object (create-s3-storage-system ..creds..) ..resource.. "bucket" "a/ab/image.jpg") => ..response..
   (provided
+    (s3/bucket-exists? ..timeout-creds.. ..bucket..) => true
     (add-timeouts :put ..creds..) => ..timeout-creds..
     (file-stream ..resource..) => ..file..
     (content-type ..resource..) => ..content-type..
@@ -45,10 +46,20 @@
   ; this may not be realistic. we'll probably get an error before we get nil
   (put-object (create-s3-storage-system ..creds..) ..resource.. "bucket" "a/ab/image.jpg") => nil
   (provided
+    (s3/bucket-exists? ..creds.. ..bucket..) => true
     (add-timeouts :put ..creds..) => ..timeout-creds..
     (file-stream ..resource..) => ..file..
     (content-type ..resource..) => ..content-type..
     (s3/put-object ..timeout-creds.. "bucket" "a/ab/image.jpg" ..file.. {:content-type ..content-type..}) => nil))
+
+  (put-object (create-s3-storage-system ..creds..) ..resource.. "bucket" "a/ab/image.jpg") => ..response..
+  (provided
+    (s3/bucket-exists? ..creds.. ..bucket..) => false
+    (s3/create-bucket ..creds.. ..bucket..) => nil
+    (add-timeouts :put ..creds..) => ..timeout-creds..
+    (file-stream ..resource..) => ..file..
+    (content-type ..resource..) => ..content-type..
+    (s3/put-object ..timeout-creds.. "bucket" "a/ab/image.jpg" ..file.. {:content-type ..content-type..}) => ..response..)

 (facts :s3 :object-exists
   (object-exists? (create-s3-storage-system ..creds..) ..bucket.. ..path..) => true


CMR-1589: Addressed review comment.

CMR-1589: Addressed review comment.

--- metadata-db-app/src/cmr/metadata_db/data/oracle/collection_table.clj
+++ metadata-db-app/src/cmr/metadata_db/data/oracle/collection_table.clj
@@ -22,7 +22,7 @@
   entry_id VARCHAR(255) NOT NULL,
   entry_title VARCHAR(1030) NOT NULL,
   delete_time TIMESTAMP WITH TIME ZONE,
-  user_id VARCHAR(200)")
+  user_id VARCHAR(50)")

 (defmethod collection-column-sql true
   [provider]


CMR-1852-2: Another merge commit

CMR-1852-2: Another merge commit

--- umm-spec-lib/src/cmr/umm_spec/xml_to_umm_mappings/echo10.clj
+++ umm-spec-lib/src/cmr/umm_spec/xml_to_umm_mappings/echo10.clj
@@ -116,10 +116,6 @@
                             :EntryId (str (value-of ca "ShortName") "_" (value-of ca "VersionId"))
                             :Version (value-of ca "VersionId")
                             })})
-<<<<<<< HEAD
-=======
-
->>>>>>> d8f86fb... CMR-1852: Added generation code for ECHO10 AssociatedCollections
 (defn echo10-xml-to-umm-c
   "Returns UMM-C collection record from ECHO10 collection XML document."
   [metadata]


More deref in async tests

More deref in async tests

--- test/clojure/clojurewerkz/cassaforte/async_cql_test.clj
+++ test/clojure/clojurewerkz/cassaforte/async_cql_test.clj
@@ -70,24 +70,24 @@
           doall) ;; Better deref before couting, otherwise there's a good chance it's not even inserted yet

      (is (= 3 (perform-count s :users)))
-     (delete-async s :users
+     @(delete-async s :users
                    (where {:name "name1"}))
      (is (= 2 (perform-count s :users)))
      (truncate s :users))

     (th/test-combinations
-     (insert-async s :users {:name "name1" :age (int 19)})
-     (delete-async s :users
-                   (columns :age)
-                   (where {:name "name1"}))
+     @(insert-async s :users {:name "name1" :age (int 19)})
+     @(delete-async s :users
+                    (columns :age)
+                    (where {:name "name1"}))
      (is (nil? (:age @(select-async s :users))))
      (truncate s :users)))

   (deftest test-insert-with-timestamp
     (th/test-combinations
      (let [r {:name "Alex" :city "Munich" :age (int 19)}]
-       (insert-async s :users r
-                     (using :timestamp (.getTime (java.util.Date.))))
+       @(insert-async s :users r
+                      (using :timestamp (.getTime (java.util.Date.))))
        (is (= r (first @(select-async s :users))))
        (truncate s :users))))

@@ -95,7 +95,6 @@
     (th/test-combinations
      (let [r       {:name "Alex" :city "Munich" :age (int 19)}
            success (fn [res]
-                     (is (= r (first res)))
-                     (truncate s :users))]
+                     (is (= r (first res))))]
        (is (= [] @(insert-async s :users r)))
        (client/set-callbacks (select-async s :users) {:success success})))))


cosmetic changes

cosmetic changes

--- test/s7p/slave/core_test.clj
+++ test/s7p/slave/core_test.clj
@@ -52,13 +52,15 @@
   (testing "`auction`"
     (testing "no valid response"
       (let [fp 4.0
-            ret (auction fp [])]
+            arg []
+            ret (auction fp arg)]
        (is (nil? ret))))

     (testing "one valid response with fp, and bidPrice is over the fp"
       (let [fp 4.0
             bid-price 4.1
-            ret (auction fp [{:dsp dsp1 :response {:id "1", :bidPrice bid-price :advertiserId "2"}}])]
+            arg [{:dsp dsp1 :response {:id "1", :bidPrice bid-price :advertiserId "2"}}]
+            ret (auction fp arg)]
        (is ret)
        (is (= dsp1 (:dsp ret)))
        (is (= fp   (:second-price ret)))))
@@ -66,7 +68,8 @@
     (testing "one valid response without fp"
       (let [fp nil
             bid-price 4.1
-            ret (auction fp [{:dsp dsp1 :response {:id "1", :bidPrice bid-price :advertiserId "2"}}])]
+            arg [{:dsp dsp1 :response {:id "1", :bidPrice bid-price :advertiserId "2"}}]
+            ret (auction fp arg)]
        (is ret)
        (is (= dsp1 (:dsp ret)))
-       (is (= bid-price   (:second-price ret)))))))
+       (is (= bid-price (:second-price ret)))))))


(maint) Accept 1006 for connection failure due to authz rules

Sometimes the test related to confirming that connections rejected due
to authorization rules receives a 1006 error code. This may be happening
because we close the connection during the on-connect callback.

I don't see a straight-forward way to reject the connection otherwise,
and failure to connect isn't something we should return detailed
information about, so accept this failure mode.

--- test/integration/puppetlabs/pcp/broker/service_test.clj
+++ test/integration/puppetlabs/pcp/broker/service_test.clj
@@ -243,7 +243,10 @@
                                                   :check-association false)]
                  (testing "cannot associate - closes connection"
                    (let [response (client/recv! client)]
-                     (is (= [4002 "association unsuccessful"] response))))
+                     (is (or (= [4002 "association unsuccessful"] response)
+                             ;; the response can also be 1006; this may happen because we close the connection during the on-connect callback
+                             ;; since this isn't an issue when things are set up correctly, just accept the 1006
+                             (= [1006 "Connection was closed abnormally (that is, with no close frame being sent)."] response)))))
                  (testing "cannot request inventory"
                    (let [request (client/make-message
                                   version


Fix sha1 implementation

Fix sha1 implementation

--- worker/src/worker/repository.clj
+++ worker/src/worker/repository.clj
@@ -2,9 +2,13 @@
   (:require [me.raynes.conch :refer [programs with-programs let-programs]])
   (:import (java.security MessageDigest)))

-(defn sha1 [obj]
-  (let [bytes (.getBytes (with-out-str (pr obj)))]
-    (apply vector (.digest (MessageDigest/getInstance "SHA1") bytes))))
+(defn sha1 [input]
+  (apply str
+         (map (partial format "%02x")
+              (.digest (doto (MessageDigest/getInstance "SHA1")
+                             .reset
+                             (.update
+                               (.getBytes input)))))))

 (defn repo-dir
   [repo-id]


add TODO

add TODO

--- src/babel/ug.cljc
+++ src/babel/ug.cljc
@@ -213,6 +213,9 @@
     {:head {:synsem {:sem semantics}}
      :synsem {:sem semantics}}))

+;; TODO: deprecate this which is
+;; based on an earlier idea of how to do modification
+;; for newer idea see e.g. english.grammar and search for {:rule "nbar"}.
 (def comp-modifies-head
   (let [human (atom :top)
         animate (atom :top)


layout: refactor and simplify some code

layout: refactor and simplify some code

--- src/cfg/core.cljs
+++ src/cfg/core.cljs
@@ -281,30 +281,6 @@
     (prn (str (:type edge) " " (hex-format (:src edge)) " -> " (hex-format (:dst edge))))))

-(defn layout-bbs
-  "
-   Using the given layout, merge the x and y coordinates onto the given basic blocks.
-
-   Params:
-    layout (map): from int basic block address to position map, with keys :x and :y.
-    bbs (sequence): the basic blocks.
-
-
-   Example::
-
-       (let [nodes       (klay/get-nodes result)
-             nodes-by-id (cmn/index-by :id nodes)
-             laid-out    (layout-bbs nodes-by-id basic-blocks)]
-         ...
-
-  "
-  [layout bbs]
-  (for [bb bbs]
-    (let [pos (get layout (:addr bb))]
-      (merge bb {:x (:x pos)
-                 :y (:y pos)}))))
-
-
 (defn layout-cfg-dagre
   [basic-blocks s e]
   (when (< 0 (count (remove nil? basic-blocks)))
@@ -317,7 +293,7 @@
       (doseq [edge edges]
         (dagre/add-edge! g edge))
       (dagre/layout! g)
-      (s {:nodes (cmn/index-by :id (dagre/get-nodes g))
+      (s {:nodes (dagre/get-nodes g)
           :edges (dagre/get-edges g)}))))

@@ -330,10 +306,9 @@
           g (klay/make)
           g (reduce klay/add-node g bbs)
           g (reduce klay/add-edge g edges)]
-      (cmn/d g)
       (klay/layout g
                    (fn [r]
-                     (s {:nodes (cmn/index-by :id (klay/get-nodes r))
+                     (s {:nodes (klay/get-nodes r)
                          :edges (klay/get-edges r)}))
                    (fn [err]
                      (e {:msg "klay: error"
@@ -484,26 +459,12 @@
             (:basic-blocks args))))

-;; TODO: what is this...
-;; why don't i have an `id` prop on these nodes??
-(defn get-node-position
-  [node]
-  {:addr (:addr node)
-   :id (:id node)
-   :x (:x node)
-   :y (:y node)
-   :height (:height node)
-   :width (:width node)})
-
-
 (defmethod action-handler :set-function-layout
   [key model args]
   (let [fva (:function args)
         nodes (:nodes args)
-        ;;node-positions (map get-node-position nodes)
-        ;;node-positions-by-addr (cmn/index-by :addr node-positions)
         edges (:edges args)]
-    (update-in model [:functions fva] assoc :layout {:nodes nodes
+    (update-in model [:functions fva] assoc :layout {:nodes (cmn/index-by :id nodes)
                                                      :edges edges})))


initial ws handlers on backend

initial ws handlers on backend

--- src/pc/server.clj
+++ src/pc/server.clj
@@ -15,6 +15,7 @@
             [pc.stefon]
             [stefon.core :as stefon]
             [taoensso.sente :as sente])
+  (:import java.util.UUID))

 ;; TODO: find a way to restart sente
 (defonce sente-state (atom {}))
@@ -72,15 +73,45 @@
   (start @sente-state))

 (defn user-id-fn [ring-req]
-  (println "calling user-id-fn")
-  (println (get-in ring-req [:params :test]))
-  (get-in ring-req [:params :test]))
+  (UUID/randomUUID))

-(defn ws-handler [req]
+;; hash-map of document-id to set of connected user-ids
+;; Used to keep track of which transactions to send to which user
+;; sente's channel handling stuff is not much fun to work with :(
+(defonce document-subs (atom {}))
+
+(defn ws-handler-dispatch-fn [req]
+  (-> req :event first))
+
+(defmulti ws-handler ws-handler-dispatch-fn)
+
+(defmethod ws-handler :default [req]
   (def req req)
-  (log/info (:event req)))
+  (log/infof "%s for %s" (:event req) (:client-uuid req)))

-(defn setup-ws-handlers [senta-state]
+(defn clean-document-subs [uuid]
+  (swap! document-subs (fn [ds]
+                         ;; Could be optimized...
+                         (reduce (fn [acc [document-id user-ids]]
+                                   (if-not (contains? user-ids uuid)
+                                     acc
+                                     (let [new-user-ids (disj user-ids uuid)]
+                                       (if (empty? new-user-ids)
+                                         (dissoc acc document-id)
+                                         (assoc acc document-id new-user-ids)))))
+                                 ds ds))))
+
+(defmethod ws-handler :chsk/uidport-close [{:keys [client-uuid] :as req}]
+  (clean-document-subs client-uuid))
+
+(defn subscribe-to-doc [document-id uuid]
+  (swap! document-subs update-in [document-id] (fnil conj #{}) uuid))
+
+(defmethod ws-handler :subscribe [{:keys [client-uuid ?data] :as req}]
+  (let [document-id (-> ?data :document-id)]
+    (log/infof "subscribing %s to %s" client-uuid document-id)
+    (subscribe-to-doc document-id client-uuid)))
+
 (defn setup-ws-handlers [sente-state]
   (let [tap (async/chan (async/sliding-buffer 100))
         mult (async/mult (:ch-recv sente-state))]


CMR-807: Modified code to raise 400 error when none of start-date and end-date for temporal parameter search is specified.

--- src/cmr/search/data/complex_to_simple_converters/temporal.clj
+++ src/cmr/search/data/complex_to_simple_converters/temporal.clj
@@ -4,6 +4,7 @@

   (:require [clj-time.core :as t]
             [cmr.common.time-keeper :as tk]
+            [cmr.common.services.errors :as errors]
             [cmr.search.models.query :as qm]
             [cmr.search.models.group-query-conditions :as gc]
             [cmr.search.data.complex-to-simple :as c2s]))
@@ -64,14 +65,18 @@
   "Convert a periodic temporal condition into a combination of simpler conditions
   so that it will be easier to convert into elastic json"
   [temporal]
-  (let [{:keys [start-day end-day start-date end-date]} temporal
-        end-year (if end-date (t/year end-date) (t/year (tk/now)))
-        start-day (if start-day start-day 1)
-        conditions (map
-                     #(simple-conditions-for-year
-                        % start-date end-date start-day end-day end-year)
-                     (range (t/year start-date) (inc end-year)))]
-    (gc/or-conds (remove nil? conditions))))
+  (let [{:keys [start-day end-day start-date end-date]} temporal]
+    (if (or start-date end-date)
+      (let [end-year (if end-date (t/year end-date) (t/year (tk/now)))
+            start-day (if start-day start-day 1)
+            conditions (map
+                         #(simple-conditions-for-year
+                            % start-date end-date start-day end-day end-year)
+                         (range (t/year start-date) (inc end-year)))]
+        (gc/or-conds (remove nil? conditions)))
+      (errors/throw-service-error
+        :bad-request
+        "At least temporal_start or temporal_end must be supplied for each temporal condition."))))

 (defn- temporal->simple-conditions
   "Convert a temporal condition into a combination of simpler conditions so that it will be easier to convert into elastic json"


repl init script fix

repl init script fix

--- script/repl_init.clj
+++ script/repl_init.clj
@@ -1,3 +1,4 @@
-(use '[clojure.contrib.repl-utils :only [show]])
+(ns user
+  (:use [clojure.contrib.repl-utils :only (show)]))
 ;(clojure.contrib/repl-utils/add-break-thread!)


add chat icon to iconpiler

add chat icon to iconpiler


documentation

documentation

--- Clojure-Websockets/MainApp/src/cljs/birdwatch/state/search.cljs
+++ Clojure-Websockets/MainApp/src/cljs/birdwatch/state/search.cljs
@@ -2,11 +2,14 @@
   (:require [birdwatch.util :as util]
             [cljs.core.async :as async :refer [put!]]))

-(defn append-search-text [app s]
+(defn append-search-text
+  "Appends string s to search-text in app, separated by space."
+  [app s]
   (swap! app assoc :search-text (str (:search-text @app) " " s)))

 (defn- load-prev
-  "load previous tweets matching the current search"
+  "Loads previous tweets matching the current search. Search is contructed
+   by calling the util/query-string function with dereferenced app state."
   [app qry-chan]
   (let [chunks-to-load 10
         chunk-size 500
@@ -18,12 +21,13 @@
       (swap! app update-in [:prev-chunks-loaded] inc))))

 (defn- start-percolator
-  "trigger starting of percolation matching of new tweets"
+  "Triggers percolation matching of new tweets on the server side so that
+   future matches will be delivered to the client."
   [app qry-chan]
   (put! qry-chan [:cmd/percolate {:query (util/query-string @app)}]))

 (defn start-search
-  "Initiate new search"
+  "Initiates a new search."
   [app initial-state qry-chan]
   (let [search (:search-text @app)
         s (if (= search "") "*" search)]


CMR-2815 cleans up some lines that were too long

--- access-control-app/src/cmr/access_control/services/acl_validation.clj
+++ access-control-app/src/cmr/access_control/services/acl_validation.clj
@@ -161,7 +161,7 @@
   {:target-id (v/when-present (make-single-instance-identity-target-id-validation context))})

 (defn permissions-granted-by-provider-to-user
-  "Returns permissions granted for sids by ACLs"
+  "Returns permissions granted for sids by the list of ACLs"
   [sids acls target]
   (for [x sids
         y acls
@@ -180,13 +180,25 @@
         sids (acl-util/get-sids context user)
         provider-id (:provider-id acl)
         provider-acls (map #(acl-util/get-acl context %)
-                           (map #(get % "concept_id") (get (json/parse-string (:results (acl-search/search-for-acls context {:provider provider-id} true))) "items")))]
-    (when-not (contains? (set (flatten (permissions-granted-by-provider-to-user sids provider-acls "CATALOG_ITEM_ACL"))) "create")
+                           (map #(get % "concept_id")
+                                (get (json/parse-string
+                                       (:results
+                                         (acl-search/search-for-acls context
+                                                                     {:provider provider-id}
+                                                                     true)))
+                                     "items")))]
+    (when-not (contains? (set
+                           (flatten
+                             (permissions-granted-by-provider-to-user sids
+                                                                      provider-acls
+                                                                      "CATALOG_ITEM_ACL")))
+                         "create")
       {key-path [(format "User [%s] does not have permission to create a catalog item for provider-id [%s]"
                           user provider-id)]})))

 (defn- make-catalog-item-identity-validations
-  "Returns a standard validation for an ACL catalog_item_identity field closed over the given context and ACL to be validated."
+  "Returns a standard validation for an ACL catalog_item_identity field
+   closed over the given context and ACL to be validated."
   [context acl save-flag]
   [catalog-item-identity-collection-or-granule-validation
    catalog-item-identity-collection-applicable-validation


[#818] Remove some old code

[#818] Remove some old code

--- Dashboard/app/cljs/src/org/akvo/flow/dashboard/users/core.cljs
+++ Dashboard/app/cljs/src/org/akvo/flow/dashboard/users/core.cljs
@@ -38,9 +38,6 @@
                :on-change #(on-change "permissionList" (target-value %))}
       [:option {:value "10"} "Admin"]
       [:option {:value "20"} "User"]]])))
-
-(def no-such-user {:title "No such user"
-                   :text "A user with this id has not been loaded yet"})

 (defn user-dialog [{:keys [user close! tag]} owner]
   (reify
@@ -137,18 +134,16 @@
        :access-key (get user "accessKey")})
     om/IRenderState
     (render-state [this {:keys [secret access-key]}]
-      (if-not user
-        (om/build dialog no-such-user)
-        (om/build dialog
-                  {:title "Manage API keys"
-                   :text "You can (re)generate or revoke an api key for this user"
-                   :content-data {:user user
-                                  :secret secret
-                                  :access-key access-key
-                                  :owner owner}
-                   :content manage-apikeys
-                   :buttons [{:caption "Close"
-                              :action close!}]})))))
+      (om/build dialog
+                {:title "Manage API keys"
+                 :text "You can (re)generate or revoke an api key for this user"
+                 :content-data {:user user
+                                :secret secret
+                                :access-key access-key
+                                :owner owner}
+                 :content manage-apikeys
+                 :buttons [{:caption "Close"
+                            :action close!}]}))))

 (def dialogs
   {:add new-user-dialog