Rename a variable

Rename a variable

--- src/env_logger/db.clj
+++ src/env_logger/db.clj
@@ -203,34 +203,34 @@
   "Inserts a observation to the database."
   [db-con observation]
   (if (= 6 (count observation))
-    (jdbc/with-transaction [t-con db-con]
+    (jdbc/with-transaction [tx db-con]
       (try
-        (let [obs-id (insert-plain-observation t-con
+        (let [obs-id (insert-plain-observation tx
                                                (merge observation
                                                       {:image-name
-                                                       (get-yc-image t-con)}))]
+                                                       (get-yc-image tx)}))]
           (when (pos? obs-id)
             (if (every? pos?
-                        (insert-beacons t-con obs-id observation))
+                        (insert-beacons tx obs-id observation))
               (let [weather-data (:weather-data observation)]
                 (if (nil? weather-data)
                   true
-                  (if (pos? (insert-wd t-con obs-id weather-data))
+                  (if (pos? (insert-wd tx obs-id weather-data))
                     true
                     (do
                       (log/info (str "Database insert: rolling back "
                                      "transaction after weather data insert"))
-                      (.rollback t-con)
+                      (.rollback tx)
                       false))))
               (do
                 (log/info (str "Database insert: rolling back "
                                "transaction after beacon scan insert"))
-                (.rollback t-con)
+                (.rollback tx)
                 false))))
         (catch PSQLException pe
           (log/error "Database insert failed:"
                      (.getMessage pe))
-          (.rollback t-con)
+          (.rollback tx)
           false)))
     (do
       (log/error "Wrong number of parameters provided to insert-observation")


resources

resources

--- src/evalback/core.clj
+++ src/evalback/core.clj
@@ -145,8 +145,8 @@

 (defn provide-examples []
   (str "example_list = "
-    (json/write-str {"b" (mk-example-map "examples/b")
-                     "tla" (mk-example-map "examples/tla") })))
+    (json/write-str {"b" (mk-example-map "public/examples/b")
+                     "tla" (mk-example-map "public/examples/tla") })))

 (defroutes app
   (GET "/" [] (resp/redirect "index.html"))


Minor formatting fixes to fit everything to 80 columns.

--- src/guangyin/core.clj
+++ src/guangyin/core.clj
@@ -223,10 +223,10 @@

 (defn period
   "Coerce to period.
-   Notice that period is only for days and larger time units. If you want to work
-   with time you should use duration instead. Can also be used to create a period
-   from start and end date. See also functions years, months, weeks and days,
-   they all return a period.
+   Notice that period is only for days and larger time units. If you want to
+   work with time you should use duration instead. Can also be used to create a
+   period from start and end date. See also functions years, months, weeks and
+   days, they all return a period.
    Examples:

      => (period \"P2Y\")


Revert "Makes inline result address more specific to fix #1213 LightTable/Clojure#32"

This reverts commit 2b0e9086927f5870966b9937efbf1c0e6ae47d95. And addresses #2004

--- src/lt/objs/eval.cljs
+++ src/lt/objs/eval.cljs
@@ -305,14 +305,13 @@
                       (let [ed (:ed @this)
                             type (or (:type opts) :inline)
                             line (ed/line-handle ed (:line loc))
-                            ch (:ch loc)
                             res-obj (object/create ::inline-result {:ed this
                                                                     :class (name type)
                                                                     :opts opts
                                                                     :result res
                                                                     :loc loc
                                                                     :line line})]
-                        (when-let [prev (get (@this :widgets) [line ch type])]
+                        (when-let [prev (get (@this :widgets) [line type])]
                           (when (:open @prev)
                             (object/merge! res-obj {:open true}))
                           (object/raise prev :clear!))
@@ -320,7 +319,7 @@
                           (doseq [widget (map #(get (@this :widgets) [(ed/line-handle ed %) type]) (range (:start-line loc) (:line loc)))
                                   :when widget]
                             (object/raise widget :clear!)))
-                        (object/update! this [:widgets] assoc [line ch type] res-obj))))
+                        (object/update! this [:widgets] assoc [line type] res-obj))))

 ;;****************************************************
 ;; underline result
@@ -481,10 +480,8 @@
               :desc "Eval: Clear inline results"
               :exec (fn []
                       (when-let [ed (pool/last-active)]
-                        (let [widgets (:widgets @ed)]
-                          (object/merge! ed {:widgets {}})
-                          (doseq [[_ w] widgets]
-                            (object/raise w :clear!)))))})
+                        (doseq [[_ w] (:widgets @ed)]
+                          (object/raise w :clear!))))})

 (cmd/command {:command :eval-editor
               :desc "Eval: Eval editor contents"


maintain misaki.server

maintain misaki.server

--- src/misaki/server.clj
+++ src/misaki/server.clj
@@ -6,19 +6,19 @@
   "
   (:use
     [misaki core config template]
-    [misaki.util.file :only [add-path-slash has-extension? file?]]
+    [misaki.util.file   :only [add-path-slash has-extension? file?]]
     [misaki.util.string :only [blue red]]
     watchtower.core
-    [compojure.core :only [routes]]
-    [compojure.route :only [files]]
+    [compojure.core     :only [routes]]
+    [compojure.route    :only [files]]
     [ring.adapter.jetty :only [run-jetty]]))

 ; =print-result
 (defn print-compile-result
   "Print colored compile result."
-  [#^String message result]
+  [#^String message, result]
   (let [text (case result
-               true (blue "DONE")
+               true  (blue "DONE")
                false (red "FAIL")
                (blue "SKIP"))]
     (println (str " * compiling " message ": ... " text))))
@@ -29,8 +29,8 @@
 (defn do-all-compile
   "Compile all templates"
   []
-  (print-compile-result "all templates" (compile-all-templates))
-  (print-compile-result "all tags" (compile-all-tags))
+  (print-compile-result "all templates"  (compile-all-templates))
+  (print-compile-result "all tags"       (compile-all-tags))
   (print-compile-result "clojurescripts" (compile-clojurescripts)))

 ; =do-compile


s/when-note/when-not

s/when-note/when-not

--- src/overtone/core.clj
+++ src/overtone/core.clj
@@ -4,7 +4,7 @@
 (overtone.api/immigrate-overtone-api)

 (defonce __PRINT-CONNECT-HELP__
-  (when-note (server-connected?)
+  (when-not (server-connected?)
     (println "--> Please boot a server to start making noise:
     * (boot-server)             ; boot default server (honours config)
     * (boot-internal-server)    ; boot an internal server


harden conversion fns

harden conversion fns

--- src/java_time/defconversion.clj
+++ src/java_time/defconversion.clj
@@ -63,8 +63,9 @@
                    (catch Exception e#
                      (throw
                        (ex-info "Conversion failed"
-                                {:path (:path path#), :arguments ~args, :to ~tp} e#))))]
-       (if (instance? clojure.lang.ISeq ~tp)
+                                {:path (:path path#), :arguments ~args, :to ~tp}
+                                e#))))]
+       (if (seq? ~tp)
          result#
          (first result#))
        (throw (ex-info
@@ -86,8 +87,13 @@
                 (g/types (to-seq to)))]
     (select-keys p [:path :cost])))

-(defmacro deffactory [nm docstring _ tp _ implicit-arities & fn-bodies]
-  (let [fn-name (with-meta nm {:tag tp})
+(defmacro deffactory [nm docstring returnskw tp implicit-arities-kw implicit-arities & fn-bodies]
+  (assert (= :returns returnskw))
+  (assert (= :implicit-arities implicit-arities-kw))
+  (let [tp (resolve tp)
+        _ (assert (class? tp) (str tp " is not resolvable"))
+        tp (-> ^Class tp .getName symbol)
+        fn-name (with-meta nm {:tag tp})
         explain-fn-name (symbol (str "path-to-" nm))
         predicate-name (symbol (str nm "?"))]
     `(do (defn ~fn-name ~docstring


(fix) remove debug tag

(fix) remove debug tag

--- src/papaline/core.clj
+++ src/papaline/core.clj
@@ -248,7 +248,7 @@

 (defn abort
   ([] (throw (ex-info "Aborted" {:abort true})))
-  ([ret] (throw #break (ex-info "Aborted" {:abort true :args ret}))))
+  ([ret] (throw (ex-info "Aborted" {:abort true :args ret}))))

 (defn fork [ret]
   (when-not (sequential? ret)


get rid of whites for cursor colors

get rid of whites for cursor colors

--- src/pc/http/sente.clj
+++ src/pc/http/sente.clj
@@ -90,11 +90,12 @@
     "#f1c40f"
     "#e67e22"
     "#e74c3c"
-    "#ecf0f1"
     "#f39c12"
     "#d35400"
     "#c0392b"
-    "#bdc3c7"})
+    ;;"#ecf0f1"
+    ;;"#bdc3c7"
+    })

 (defn subscribe-to-doc [document-id uuid]
   (swap! document-subs update-in [document-id]


Stylistic changes.

Stylistic changes.

--- src/pubhouse/core.clj
+++ src/pubhouse/core.clj
@@ -95,9 +95,8 @@
     (fs/file (str url ".html"))))

 (defn compile-file!
-  [options site [file-info page-info]]
-  (let [{:keys [site-path build-path]} options
-        page (make-page file-info page-info)
+  [{:keys [site-path build-path]} site [file-info page-info]]
+  (let [page (make-page file-info page-info)
         input (input-file site-path (:path file-info))
         output (output-file build-path (:url page))]
     (with-io input output


differentiate between not-found and forbidden for GCS file download preview

--- src/cljs/org/broadinstitute/firecloud_ui/common/gcs_file_preview.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/common/gcs_file_preview.cljs
@@ -18,7 +18,7 @@
              [modal/OKCancelForm
               {:header "File Details"
                :content
-               (let [{:keys [data error]} (:response @state)
+               (let [{:keys [data error status]} (:response @state)
                      data-size (when data (data "size"))
                      labeled (fn [label & contents]
                                [:div {}
@@ -56,7 +56,10 @@
                   (when error
                     [:div {:style {:marginTop "1em"}}
                      [:span {:style {:color (:exception-red style/colors)}} "Error! "]
-                     "This file was not found."
+                     (case status
+                       404 "This file was not found."
+                       403 "You do not have access to this file."
+                       "See details below.")
                      (if (:show-error-details? @state)
                        [:div {}
                         [:pre {} error]
@@ -72,12 +75,13 @@
              (swap! state assoc :loading? true)
              (endpoints/call-ajax-orch
                {:endpoint (endpoints/get-gcs-stats (:bucket-name props) (:object props))
-                :on-done (fn [{:keys [success? get-parsed-response xhr]}]
+                :on-done (fn [{:keys [success? get-parsed-response xhr status-code]}]
                            (swap! state assoc
                                   :loading? false
                                   :response (if success?
                                               {:data (get-parsed-response)}
-                                              {:error (.-responseText xhr)})))}))})]
+                                              {:error (.-responseText xhr)
+                                               :status status-code})))}))})]
     {:render
      (fn [{:keys [props]}]
        (assert (:bucket-name props) "No bucket name provided")


allow reflinks in namespace descriptions

--- src/main/cljs_api_gen/write.clj
+++ src/main/cljs_api_gen/write.clj
@@ -530,6 +530,9 @@
                                                           :library (:description-library ns-item)
                                                           :compiler (:description-compiler ns-item)
                                                           nil))
+                                     description (when description
+                                                   (binding [*reflink-prefix* "../"]
+                                                     (resolve-reflinks description)))
                                      symbols (if (= ns- "syntax")
                                                (sort-symbols :full-name syms)
                                                syms)


CMR-2165: Addressing code review comments.

--- common-lib/test/cmr/common/test/api/web_server.clj
+++ common-lib/test/cmr/common/test/api/web_server.clj
@@ -6,6 +6,8 @@
             [clj-http.client :as h]
             [clojure.string :as str]
             [cmr.common.util :as u]))
+
+(def PORT 3123)

 (def long-body
   "A body long enough that it should be compressed"
@@ -34,7 +36,7 @@
     ;; We remove all middleware so we can get the raw input stream body back
     [clj-http.client/wrap-url
      clj-http.client/wrap-method]
-    (h/get (str "http://localhost:3123" path)
+    (h/get (str "http://localhost:" PORT path)
            {:headers {"Accept-encoding" accept-encoding}})))

 (defn assert-compressed-response
@@ -49,7 +51,7 @@
   (is (= expected-body (-> response :body slurp))))

 (deftest test-gzip-compression
-  (let [server (l/start (s/create-web-server 3123 routes-fn true false) nil)]
+  (let [server (l/start (s/create-web-server PORT routes-fn true false) nil)]
     (try
       (testing "A large body is compressed"
         (assert-compressed-response (get-uri "/long" "gzip") long-body))


Remove unused :require in metabase.core :racing_car:

--- src/metabase/core.clj
+++ src/metabase/core.clj
@@ -26,8 +26,7 @@
                       [setup :as setup]
                       [task :as task]
                       [util :as u])
-            (metabase.models [setting :refer [defsetting]]
-                             [user :refer [User]])))
+            [metabase.models.user :refer [User]]))

 ;;; CONFIG


Pull time step code into own fn

Pull time step code into own fn

--- src/playmary/one.cljs
+++ src/playmary/one.cljs
@@ -194,6 +194,13 @@
   [canvas-id]
   (async/merge [(util/listen (dom/getElement canvas-id) :touchstart)
                 (util/listen (dom/getElement canvas-id) :touchend)]))
+(defn step-time
+  [instrument]
+  (let [now (.getTime (js/Date.))]
+    (-> instrument
+        (assoc :playhead (+ (instrument :playhead)
+                            (- now (instrument :previous-time))))
+        (assoc :previous-time now))))

 (let [canvas-id "canvas"
       c-instrument (chan)
@@ -218,9 +225,5 @@
        (condp = c
          c-orientation-change (recur (update-size instrument canvas-id))
          c-touch (recur (fire-touch-data-on-instrument instrument data))
-         (recur (let [now (.getTime (js/Date.))]
-                  (-> instrument
-                      (assoc :playhead (+ (instrument :playhead)
-                                          (- now (instrument :previous-time))))
-                      (assoc :previous-time now))))))))
+         (recur (step-time instrument))))))
   )


fix indentation

fix indentation

--- src/quoridor/core.clj
+++ src/quoridor/core.clj
@@ -121,10 +121,10 @@
             (cond
               (= move "q") (println "Thanks for playing!")
               (allowed-pawn-move? state move) (let [next-player (first next)]
-                                           (recur next-player
-                                                  (rest next)
-                                                  (-> state
-                                                      (assoc (keyword current) move)
-                                                      (assoc :current next-player))))
+                                                (recur next-player
+                                                       (rest next)
+                                                       (-> state
+                                                           (assoc (keyword current) move)
+                                                           (assoc :current next-player))))
               :else (do (println (str "Sorry, " move " is not a valid move"))
                         (recur current next state))))))))


Add config option to cli.

Add config option to cli.

--- src/incise/core.clj
+++ src/incise/core.clj
@@ -23,12 +23,11 @@
 (defn- with-args*
   "A helper function to with-args macro which does all the work.

-  1.  Load in the config
-  2.  Parse arguments
-  3.  Merge into config
-  4.  Handle help or continue"
+  1.  Parse arguments
+  2.  Load in the config
+  3.  Merge some options into config
+  4.  Handle help or call body-fn with options and cli arguments"
   [args body-fn]
-  (conf/load)
   (let [uri-root-desc (str "The path relative to the domain root where the "
                            "generated site will be hosted.")
         [options cli-args banner]
@@ -37,10 +36,13 @@
              ["-h" "--help" "Print this help." :default false :flag true]
              ["-m" "--method" "serve, once, or deploy"
               :default :serve :parse-fn parse-method]
+             ["-c" "--config" (str "The path to an edn file acting as "
+                                   "configuration for incise")]
              ["-i" "--in-dir" "The directory to get source from"]
              ["-o" "--out-dir" "The directory to put content into"]
              ["-u" "--uri-root" uri-root-desc])]
-    (conf/merge options)
+    (conf/load (options :config))
+    (conf/merge (dissoc options :config :help))
     (if (:help options)
       (do (println banner)
           (System/exit 0))


Simplify

Simplify

--- src/reagent/core.cljs
+++ src/reagent/core.cljs
@@ -200,7 +200,7 @@
   ([] (util/merge-props))
   ([defaults] (util/merge-props defaults))
   ([defaults props] (util/merge-props defaults props))
-  ([defaults props & others] (apply util/merge-props (concat [defaults props] others))))
+  ([defaults props & others] (apply util/merge-props defaults props others)))

 (defn flush
   "Render dirty components immediately to the DOM.


xymon.clj: event->enable: service default value is now '*'

--- src/riemann/xymon.clj
+++ src/riemann/xymon.clj
@@ -49,7 +49,7 @@

   "
   [{:keys [host service]
-    :or {host "" service ""}}]
+    :or {host "" service "*"}}]
   (let [host (host->xymon host)
         service (service->xymon service)]
     (format "enable %s.%s" host service)))


Use unchecked-aget/aset in with-let macro

--- src/reagent/ratom.clj
+++ src/reagent/ratom.clj
@@ -14,6 +14,25 @@
      (deref co#)
      co#))

+; taken from cljs.core
+; https://github.com/binaryage/cljs-oops/issues/14
+(defmacro unchecked-aget
+  ([array idx]
+   (list 'js* "(~{}[~{}])" array idx))
+  ([array idx & idxs]
+   (let [astr (apply str (repeat (count idxs) "[~{}]"))]
+     `(~'js* ~(str "(~{}[~{}]" astr ")") ~array ~idx ~@idxs))))
+
+; taken from cljs.core
+; https://github.com/binaryage/cljs-oops/issues/14
+(defmacro unchecked-aset
+  ([array idx val]
+   (list 'js* "(~{}[~{}] = ~{})" array idx val))
+  ([array idx idx2 & idxv]
+   (let [n (dec (count idxv))
+         astr (apply str (repeat n "[~{}]"))]
+     `(~'js* ~(str "(~{}[~{}][~{}]" astr " = ~{})") ~array ~idx ~idx2 ~@idxv))))
+
 (defmacro with-let [bindings & body]
   (assert (vector? bindings)
           (str "with-let bindings must be a vector, not "
@@ -27,8 +46,8 @@
                                   x
                                   (let [j (quot i 2)]
                                     `(if ~init
-                                       (aset ~v ~j ~x)
-                                       (aget ~v ~j)))))
+                                       (unchecked-aset ~v ~j ~x)
+                                       (unchecked-aget ~v ~j)))))
                               bindings))
         [forms destroy] (let [fin (last body)]
                           (if (and (list? fin)


Add missing atom deref to properly close kafka client

--- src/riemann/kafka.clj
+++ src/riemann/kafka.clj
@@ -73,7 +73,7 @@
       (try
         (info "Subscribing to " topics "...")
         (client/subscribe! consumer topics)
-        (while running?
+        (while @running?
           (let [msgs (client/poll! consumer (:poll.timeout.ms opts))
                 msgs-by-topic (get msgs :by-topic)]
             (doseq [records msgs-by-topic


Make drones

Make drones

--- src/korhal/core.clj
+++ src/korhal/core.clj
@@ -53,7 +53,7 @@
   ;; spawn a drone
   (for [unit (.getMyUnits (:api @this))]
     (when (= (.getTypeID unit) (.getID jnibwapi.types.UnitType$UnitTypes/Zerg_Larva))
-      (when (and (< 50 (.. (:api @this) getSelf getMinerals)) (not (:morphed-drone this)))
+      (when (and (>= (.. (:api @this) getSelf getMinerals) 50) (not (:morphed-drone this)))
         (.morph (:api @this) (.getID unit) (.getID jnibwapi.types.UnitType$UnitTypes/Zerg_Drone))
         (swap-keys (.state this) :morphed-drone true))))


Try mining again

Try mining again

--- src/korhal/core.clj
+++ src/korhal/core.clj
@@ -63,7 +63,7 @@
       (when (and (.isIdle unit) (not (= (.getID unit) (:pool-drone @(.state this)))))
         (let [mineral? (fn [unit] (= (.getTypeID unit) (.getID jnibwapi.types.UnitType$UnitTypes/Resource_Mineral_Field)))
               mineral (first (filter mineral? (.getNeutralUnits (:api @(.state this)))))]
-        (.rightClick (.getID unit) (.getID mineral)))))))
+        (.rightClick (:api @(.state this)) (.getID unit) (.getID mineral)))))))


use | for pitch bend, make env handle lists of size 1 or 0

--- src/semitone/core.clj
+++ src/semitone/core.clj
@@ -35,14 +35,18 @@
   (clojure.lang.Numbers/toRatio value))

 (defn env [num-points values & [type options]]
-  (let [values (vec values)
-        type (or type (if (= 2 (count values)) :linear :cubic))
-        interp (apply interpolate-parametric values type :range [0 (- num-points 1)] options)
-        fix-type (cond
-                   (every? ratio? values) ratio
-                   (every? integer? values) #(int (Math/round %))
-                   :else double)]
-    (map #(fix-type (interp %)) (range num-points))))
+  (if (= 0 (count values))
+    '()
+    (if (= 1 (count values))
+      (repeat num-points (first values))
+      (let [values (vec values)
+            type (or type (if (= 2 (count values)) :linear :cubic))
+            interp (apply interpolate-parametric values type :range [0 (- num-points 1)] options)
+            fix-type (cond
+                       (every? ratio? values) ratio
+                       (every? integer? values) #(int (Math/round %))
+                       :else double)]
+        (map #(fix-type (interp %)) (range num-points))))))

 (defn vec-rest [coll]
   (if (vector? coll)
@@ -146,8 +150,8 @@
                             :prog (mod (Integer. (get m 1)) 128)
                             :notes (vec-rest notes)})
               ;; channel pressure, pitch bend, note on/off / key pressure by key number
-              (if-let [m (re-matches #"(\*|\^|\*k|k|_k)(>+|<+|)(-?(?:[0-9]+|[0-9]*\.[0-9]+|[0-9]+\.[0-9]*)(?:[eE]-?[0-9]+)?|)(_|)" note)]
-                (let [param ({"*" :channel-pressure "^" :pitch-bend "*k" :key-pressure "k" :key} (get m 1))
+              (if-let [m (re-matches #"(\*|\||\*k|k|_k)(>+|<+|)(-?(?:[0-9]+|[0-9]*\.[0-9]+|[0-9]+\.[0-9]*)(?:[eE]-?[0-9]+)?|)(_|)" note)]
+                (let [param ({"*" :channel-pressure "|" :pitch-bend "*k" :key-pressure "k" :key} (get m 1))
                       [min-value max-value double-min double-max]
                       (get {:channel-pressure [0 128 0.0 1.0]
                             :key-pressure [0 128 0.0 1.0]
@@ -174,7 +178,7 @@
                               :else value)]
                   (merge state
                          (cond
-                           (= "^" (get m 1))
+                           (= "|" (get m 1))
                            {:message-type ShortMessage/PITCH_BEND
                             param value
                             :param param}


update citizen_cljs

update citizen_cljs

--- citizen_cljs/rrm/citizen.cljs
+++ citizen_cljs/rrm/citizen.cljs
@@ -284,10 +284,10 @@
                               :list "combo1"
                               :placeholder "Name of P.O"}[datalist1]]]
        [:div.col-sm-2
-        [:label "Title"]
+        [:label "Nature of Case"]
         [:input.form-control {:id "stitle"
                               :type "text"
-                              :placeholder "Title"}]]
+                              :placeholder "Nature of Case"}]]
        [:div.col-sm-2
         [:label "Khasra Number"]
         [:input.form-control {:id "skhasranumber"
@@ -325,17 +325,15 @@
         [:th "O2 Number"]
         [:th "O4 Number"]
         [:th "O6 Number"]
+        [:th "Nature of Case"]
         [:th "Khasra Number"]
         [:th "Khata khatuni Number"]
-        [:th "Rack Number"]
-        [:th "Sent Date"]
-        [:th "Received Date "]
         ]]
       [:tbody
        (doall (for [mt mutations]
                 ^{:key (.-id mt)} [:tr
-                                   (when  (.-senddate mt)
-                                     {:style {:background-color  "#fbcfd1"}})
+                                   (when (and  (.-senddate mt) (not (.-receiveddate mt)))
+                                     {:style {:background-color "#fbcfd1"}})
                                    [:td (.-mutationnumber (.-numbers mt))]
                                    [:td (.-nameofthefirstparty mt)]
                                    [:td (.-nameofthesecondparty mt)]
@@ -347,11 +345,9 @@
                                    [:td (.-o2number (.-numbers  mt))]
                                    [:td (.-o4number (.-numbers mt))]
                                    [:td (.-o6number (.-numbers mt))]
+                                   [:td (.-title mt)]
                                    [:td (.-khasranumber (.-numbers mt))]
                                    [:td (.-khatakhatuninumber (.-numbers mt))]
-                                   [:td (.-racknumber (.-numbers mt))]
-                                   [:td (.-senddate mt)]
-                                   [:td (.-receiveddate mt)]
                                    ]))]]]
     [:div{:class "col-xs-6 col-centered col-max"}] [shared-state 0]]])


Add a test for seq within seq [IMMUTANT-549]

--- web/test-integration/immutant/web/integ_test.clj
+++ web/test-integration/immutant/web/integ_test.clj
@@ -463,11 +463,11 @@
            (fn [request]
              (async/as-channel request
                :on-open (fn [ch]
-                          (async/send! ch (list "ham" (.getBytes "biscuit"))
+                          (async/send! ch (list "ham" (.getBytes "biscuit") (list "gravy"))
                             {:close? true
                              :on-complete #(deliver @client-state (or % :complete!))})))))]
     (replace-handler handler)
-    (is (= "hambiscuit" (String. (get-body (cdef-url)))))
+    (is (= "hambiscuitgravy" (String. (get-body (cdef-url)))))
     (is (= :complete! (read-string (get-body (str (cdef-url) "state")))))

     (replace-handler handler)
@@ -479,8 +479,9 @@
                                         (swap! results conj m)
                                         (deliver done? true)))]
         (is (deref done? 5000 nil))
-        (is (= ["ham" (into [] (.getBytes "biscuit"))]
-              [(first @results) (into [] (last @results))]))))
+        (let [[h b g] @results]
+          (is (= ["ham" (into [] (.getBytes "biscuit")) "gravy"]
+                [h (into [] b) g])))))
     (is (= :complete! (read-string (get-body (str (cdef-url) "state")))))))

 (deftest send!-an-empty-sequence


make sure :reload-namespaces is never nil

--- src/main/shadow/cljs/repl.clj
+++ src/main/shadow/cljs/repl.clj
@@ -273,7 +273,7 @@
             action
             {:type :repl/require
              :sources build-sources
-             :reload :reload}]
+             :reload-namespaces #{ns}}]

         (output/flush-sources state build-sources)
         (update-in state [:repl-state :repl-actions] conj action)
@@ -310,7 +310,8 @@

         ns-requires
         {:type :repl/require
-         :sources build-sources}
+         :sources build-sources
+         :reload-namespaces #{}}

         ns-provide
         {:type :repl/invoke


Remove key-value-processor's dependency on transducing-processor.

...as a step to remove transducing-processor, which is a funny
abstraction.

--- clstreams/src/clstreams/processor.clj
+++ clstreams/src/clstreams/processor.clj
@@ -32,11 +32,28 @@
    (.forward context key value)
    context))

+
+(deftype KeyValueProcessor [reducer
+                            ^:volatile-mutable context]
+
+  Processor
+
+  (init [this ctx]
+    (set! context ctx))
+
+  (process [this key value]
+    (reducer context [key value]))
+
+  (punctuate [this timestamp] nil)
+
+  (close [this]
+    (reducer context)))
+
 (defn key-value-processor
   ([xform]
-   (transducing-processor
-    (fn [context] (xform forward-reducer))
-    identity))
+   (reify
+     ProcessorSupplier
+     (get [this] (->KeyValueProcessor (xform forward-reducer) nil))))
   ([xform1 xform2 & xforms]
    (key-value-processor (apply comp xform1 xform2 xforms))))


fix indentation on reify

fix indentation on reify

--- src/subrosa/netty.clj
+++ src/subrosa/netty.clj
@@ -25,13 +25,13 @@

 (defn upstream-stage [handler]
   (reify ChannelUpstreamHandler
-         (handleUpstream [_ ctx evt]
-                         (.sendUpstream ctx (or (handler evt) evt)))))
+    (handleUpstream [_ ctx evt]
+                    (.sendUpstream ctx (or (handler evt) evt)))))

 (defn downstream-stage [handler]
   (reify ChannelDownstreamHandler
-         (handleDownstream [_ ctx evt]
-                           (.sendDownstream ctx (or (handler evt) evt)))))
+    (handleDownstream [_ ctx evt]
+                      (.sendDownstream ctx (or (handler evt) evt)))))

 (defn message-stage [handler]
   (upstream-stage


Verify closing a ws from the server-side triggers :on-close.

--- web/test/immutant/web/async_test.clj
+++ web/test/immutant/web/async_test.clj
@@ -158,3 +158,13 @@
 (deftest as-channel-should-throw-with-invalid-callback
   (is (thrown? IllegalArgumentException
         (as-channel {:handler-type :test} {:on-fire nil}))))
+
+(deftest on-close-should-be-invoked-when-closing-on-server-side
+  (let [reason (promise)]
+    (run (fn [req]
+           (as-channel req
+             :on-open close
+             :on-close (fn [_ r] (deliver reason r)))))
+    (let [socket (ws/connect "ws://localhost:8080")]
+        (ws/send-msg socket "hello"))
+    (is (deref reason 5000 nil))))


changed unnecesary underscores in fn name

--- src/metabase/models/pulse.clj
+++ src/metabase/models/pulse.clj
@@ -168,7 +168,7 @@
   `PulseCards`, `PulseChannels`, and `PulseChannelRecipients`.

    Returns the newly created `Pulse` or throws an Exception."
-  [pulse-name creator-id card-ids channels skip_if_empty]
+  [pulse-name creator-id card-ids channels skip-if-empty?]
   {:pre [(string? pulse-name)
          (integer? creator-id)
          (sequential? card-ids)
@@ -180,7 +180,7 @@
     (let [{:keys [id] :as pulse} (db/insert! Pulse
                                    :creator_id creator-id
                                    :name pulse-name
-                                   :skip_if_empty skip_if_empty)]
+                                   :skip_if_empty skip-if-empty?)]
       ;; add card-ids to the Pulse
       (update-pulse-cards! pulse card-ids)
       ;; add channels to the Pulse


(TK-82) Removed queue-max-size-tests

(TK-82) Removed queue-max-size-tests

This commit removes the queue-max-size-tests.  The tests were very
fragile to begin with because of the timing-related logic in them and
proved to fail in Travis runs.  "Unit-level" coverage around the
Trapperkeeper setting and the Jetty Server setup is still in this PR.

--- test/clj/puppetlabs/trapperkeeper/services/webserver/jetty9_core_test.clj
+++ test/clj/puppetlabs/trapperkeeper/services/webserver/jetty9_core_test.clj
@@ -1,16 +1,13 @@
 (ns puppetlabs.trapperkeeper.services.webserver.jetty9-core-test
   (:import
-    (org.eclipse.jetty.server.handler ContextHandlerCollection)
-    (org.apache.http ConnectionClosedException)
-    (java.util.concurrent ExecutionException))
+    (org.eclipse.jetty.server.handler ContextHandlerCollection))
   (:require [clojure.test :refer :all]
             [clojure.java.jmx :as jmx]
             [ring.util.response :as rr]
             [puppetlabs.http.client.sync :as http-sync]
             [puppetlabs.trapperkeeper.services.webserver.jetty9-core :as jetty]
             [puppetlabs.trapperkeeper.testutils.webserver
-              :refer [with-test-webserver with-test-webserver-and-config]]
-            [puppetlabs.kitchensink.core :as ks]))
+              :refer [with-test-webserver with-test-webserver-and-config]]))

 (deftest handlers
   (testing "create-handlers should allow for handlers to be added"
@@ -246,57 +243,4 @@
         (is (= jetty/default-queue-min-threads (.getCapacity queue))
             "Unexpected initial capacity for queue")
         (is (= queue-min-size (.getMaxCapacity queue))
-            "Unexpected max capacity for queue")))))
-
-(defn get-responses
-  [num-requests port]
-  (doall (for [_ (range num-requests)]
-           (future
-             (http-sync/get
-               (str "http://localhost:"
-                    port
-                    "/hello")
-               {:as :text})))))
-
-(deftest queue-max-size-tests
-  (testing "queue-max-size"
-    (let [response-body  "hello world"
-          app            (fn [_]
-                           (Thread/sleep 5000)
-                           (-> response-body
-                               (rr/response)
-                               (rr/status 200)
-                               (rr/content-type "text/plain")
-                               (rr/charset "UTF-8")))
-          ;; Jetty needs at least num-cpus entries (and likely a bit more) in
-          ;; the queue in order to boot up successfully.  Jetty does some
-          ;; priming of selector threads using the queue independently of
-          ;; any incoming requests, for example.
-          queue-max-size (* (ks/num-cpus) 2)
-          ;; For the fail case, need to generate some number of concurrent
-          ;; requests in excess of the size of the queue in order for the queue
-          ;; to be completely filled and for some requests to start being
-          ;; dropped
-          num-requests   (+ queue-max-size 30)]
-      (testing "of default (infinite) size doesn't lead to any request fails"
-        (with-test-webserver-and-config
-          app port {:shutdown-timeout-seconds 0}
-          (let [responses (get-responses num-requests port)]
-            (doseq [response responses]
-              (is (= 200 (:status @response))
-                  "Unsuccessful response status for one request")
-              (is (= response-body (:body @response))
-                  "Unsuccessful response body for one request")))))
-      (testing "of sufficiently low queue-max-size causes some requests to fail"
-        (with-test-webserver-and-config
-          app port {:queue-max-size queue-max-size
-                    :shutdown-timeout-seconds 0}
-          (let [responses (doall (get-responses num-requests port))]
-            (is (some #(try
-                        @%
-                        false
-                        (catch ExecutionException e
-                          (instance? ConnectionClosedException
-                                     (.. e getCause))))
-                      responses)
-                "Didn't encounter connection close for any requests")))))))+            "Unexpected max capacity for queue")))))


抽象出create-server方法

抽象出create-server方法

--- src/my_ring/adapter/jetty.clj
+++ src/my_ring/adapter/jetty.clj
@@ -2,6 +2,24 @@
   (:import (org.eclipse.jetty.server Server)
            (org.eclipse.jetty.server.handler AbstractHandler))
   (:use my-ring.util.servlet))
+
+#_(defn- add-ssl-connector!
+  [server options]
+  (let [ssl-connector (SslSocketConnector.)]
+    (doto ssl-connector
+      (.setPort (options :ssl-port 443))
+      (.setKeystore (options :keystore))
+      (.setKeyPassword (options :key-password)))
+    (when-let [truststroe (options :truststroe)]
+      (.setTrustStroe ssl-connector truststore))
+    (when-let [trust-password (options :trust-password)]
+      (.setTrustPassword ssl-connector trust-password))))
+
+(defn- create-server
+  [options]
+  (let [port (options :port 3000)]
+    (doto
+      (Server. port))))

 (defn- proxy-handler
   [handler]
@@ -14,12 +32,10 @@

 (defn run-jetty
   ([app options]
-    (let [port (or (:port options) 3000)
-          server (Server. port)
-          handler (proxy-handler app)]
-      (.setHandler server handler)
-      (.start server)
-      (.join server)))
+    (doto (create-server options)
+      (.setHandler (proxy-handler app))
+      (.start)
+      (.join)))
   ([app]
    (run-jetty app {})))


www/render.clj: load StringTemplateGroup from directory

--- src/org/altlaw/www/render.clj
+++ src/org/altlaw/www/render.clj
@@ -1,16 +1,13 @@
 (ns org.altlaw.www.render
-  (:require [org.altlaw.util.context :as context])
+  (:require [org.altlaw.util.context :as context]
+            [clojure.contrib.java-utils :as java]
+            [clojure.contrib.classpath :as cp]
+            [clojure.contrib.singleton :as sing])
   (:use [clojure.contrib.test-is :only (with-test is testing)]
-        [clojure.contrib.duck-streams :only (reader)]
         [clojure.contrib.walk :only (stringify-keys)])
   (:import (org.antlr.stringtemplate StringTemplate StringTemplateGroup)
            (org.antlr.stringtemplate.language DefaultTemplateLexer)
            (org.apache.commons.lang StringEscapeUtils)))
-
-(defn- string [x]
-  (if (keyword? x)
-    (name x)
-    (str x)))

 (with-test
  (defn- render-template
@@ -53,14 +50,24 @@
                                    "Foo: $user:{f$it.foo$}$")
                                   {:user [{:foo 1} {:foo 2} {:foo 3}]})))))

+(defn www-templates-dir []
+  (some
+   (fn [dir]
+     (let [template-dir
+           (java/file dir "org" "altlaw" "www" "templates")]
+       (when (.exists template-dir) template-dir)))
+   (cp/classpath-directories)))
+
 (def #^{:private true} template-group
-     (memoize (fn []
-                (let [page-templates (StringTemplateGroup. "org.altlaw.www.templates")]
-                  ;; By default, templates are never refreshed.
-                  ;; In development mode, always refresh.
-                  (when (= (context/altlaw-env) "development")
-                    (.setRefreshInterval page-templates 0))
-                  page-templates))))
+     (sing/global-singleton
+      (fn []
+        (let [page-templates (StringTemplateGroup. "org.altlaw.www.templates"
+                                                   (str (www-templates-dir)))]
+          ;; By default, templates are never refreshed.
+          ;; In development mode, always refresh.
+          (when (= (context/altlaw-env) "development")
+            (.setRefreshInterval page-templates 0))
+          page-templates))))

 (with-test
  (defn render
@@ -69,7 +76,7 @@
    render-template."
    [name & attrs]
    (-> (template-group)
-       (.getInstanceOf (str "org/altlaw/www/templates/" (string name)))
+       (.getInstanceOf (java/as-str name))
        (render-template (if (map? (first attrs))
                           (if (next attrs)
                             (apply conj (first attrs) (next attrs))


Whitespace fix

Whitespace fix

--- src/useful/string.clj
+++ src/useful/string.clj
@@ -6,9 +6,9 @@
              #"[-_](\w)"
              (comp s/upper-case second)))

- (defn classify [string]
-   (apply str (map s/capitalize
-                   (s/split string #"[-_]"))))
+(defn classify [string]
+  (apply str (map s/capitalize
+                  (s/split string #"[-_]"))))

 (defn- from-camel-fn [separator]
   (fn [string]


Include version.properties in the build

Include version.properties in the build

--- build.boot
+++ build.boot
@@ -98,6 +98,15 @@
                :cljs-opts prod-compiler-options
                :namespaces test-namespaces}})

+(deftask version-file
+  "A task that includes the version.properties file in the fileset."
+  []
+  (boot.util/info "Add version.properties...\n")
+  (with-pre-wrap [fileset]
+    (-> fileset
+        (add-resource (java.io.File. ".") :include #{#"^version\.properties$"})
+        commit!)))
+
 (deftask build
   "Build the final artifact, if no type is passed in, it builds production."
   [t type VAL kw "The build type, either prod or dev"]
@@ -106,6 +115,7 @@
     (boot.util/info "Building %s profile...\n" (:type options))
     (apply set-env! (reduce #(into %2 %1) [] (:env options)))
     (comp (apply cljs (reduce #(into %2 %1) [] (:cljs options)))
+          (version-file)
           (target))))

 (deftask dev


cleanups

cleanups

--- build.boot
+++ build.boot
@@ -26,7 +26,6 @@
 (deftask build
   "Build blog."
   [d dev  bool "Don't build rss, sitemap, deploy to S3"]
-  (println "temp logs" (System/getenv "AWS_ACCESS_KEY") (System/getenv "AWS_SECRET_KEY"))
   (comp (markdown)
         (draft)
         (ttr)


Add dev-server to stop Hyphenator errors

--- build.boot
+++ build.boot
@@ -3,25 +3,27 @@
 #tailrecursion.boot.core/version "2.3.1"

 (set-env!
-  :dependencies  [['tailrecursion/boot.task   "2.1.2"]
-                  ['tailrecursion/hoplon      "5.7.0"]
-                  ['markdown-clj              "0.9.41"]
-                  ['org.clojure/clojurescript "0.0-2156"]]
+  :dependencies  '[[tailrecursion/boot.task   "2.1.2"]
+                   [tailrecursion/hoplon      "5.7.0"]
+                   [markdown-clj              "0.9.41"]
+                   [tailrecursion/boot.ring   "0.1.0-SNAPSHOT"]
+                   [org.clojure/clojurescript "0.0-2156"]]
   :src-paths     #{"src"}
   :out-path      "resources/public")

 (add-sync! (get-env :out-path) #{"resources/assets"})

 (require
-  ['tailrecursion.boot.task   :refer :all]
-  ['tailrecursion.hoplon.boot :refer :all])
+  '[tailrecursion.boot.task   :refer :all]
+  '[tailrecursion.boot.task.ring   :refer [dev-server]]
+  '[tailrecursion.hoplon.boot :refer :all])

 (deftask dev
   "Build hoplon.io for local development."
   []
   (comp (watch) (hoplon {:pretty-print  true
                          :prerender     false
-                         :optimizations :whitespace})))
+                         :optimizations :whitespace}) (dev-server)))

 (deftask prod
   "Build hoplon.io for production deployment."


Post-release version bump

Post-release version bump

--- build.boot
+++ build.boot
@@ -26,7 +26,7 @@
          '[crisptrutski.boot-cljs-test :refer [test-cljs exit!]]
          '[pandeiro.boot-http :refer [serve]])

-(def version "0.2.2")
+(def version "0.2.3-SNAPSHOT")

 (bootlaces! version :dont-modify-paths? true)


Increment version number

Increment version number

--- build.boot
+++ build.boot
@@ -29,7 +29,7 @@
 (task-options!
   sift {:include #{#"\.jar$"}}
   pom {:project 'nightcode
-       :version "2.5.2-SNAPSHOT"
+       :version "2.5.2"
        :description "An IDE for Clojure"
        :url "https://github.com/oakes/Nightcode"
        :license {"Public Domain" "http://unlicense.org/UNLICENSE"}}


Don't speak (in the "dev" task)

Don't speak (in the "dev" task)

--- build.boot
+++ build.boot
@@ -45,7 +45,6 @@
   []
   (comp
     (watch)
-    (speak)
     (reload)
     (build-dev)
     (serve :dir "target")))


Bump version: 2.0.0 :cake:

Bump version: 2.0.0 :cake:

--- build.boot
+++ build.boot
@@ -11,7 +11,7 @@
          '[adzerk.boot-cljs   :refer [cljs]]
          '[pandeiro.boot-http :refer [serve]])

-(def +version+ "1.7.228-3-SNAPSHOT")
+(def +version+ "2.0.0-SNAPSHOT")

 (task-options!
   pom {:project     'adzerk/boot-cljs


going line-by-line if line is empty print @state otherwise map the line to @state

--- src/trend_compliance/core.clj
+++ src/trend_compliance/core.clj
@@ -1,7 +1,7 @@
 (ns trend-compliance.core
   (:require [clojure.java.io :as io]
+            [clojure.pprint :as pp]
             [clojure.string :as str]
-            [clojure.pprint :as pp]
             [clojure-csv.core :as csv])
   (:gen-class))

@@ -37,11 +37,6 @@
      :ping ping
      :platform platform}))

-(defn parse-line
-  "parse each line of a large file"
-  [line]
-  (str/split line #" = "))
-
 (def state (atom {}))

 (defn line-to-map
@@ -57,7 +52,7 @@
 (defn compare-ip
   "compare the ip held in log to the ips on compliance list"
   [wireless-ip]
-  (if
+  ;; (if
   )

 (defn get-ip
@@ -65,13 +60,14 @@
   [item]
   (get item :ip))

-(defn read-detail
+(defn read-large-file
   "read in a large detail file"
   [file-name]
   (with-open [rdr (io/reader file-name)]
-    (let [split-lines (doall (map parse-line (line-seq rdr)))]
-      ;; (println split-lines))))
-      (map line-to-map split-lines))))
+    (doseq [line (line-seq rdr)]
+      (if (empty? line)
+        (println @state) ;; need to compare ip here
+        (line-to-map (str/split line #" = "))))))

 (defn read-csv
   "read in a csv file"


Handling case of empty title, we were considering just nil

--- src/ui/relevance/display.cljs
+++ src/ui/relevance/display.cljs
@@ -176,10 +176,12 @@
         (let [url     (:url tab)
               favicon (:favIconUrl (get site-data (host-key (hostname url))))
               title   (:title tab)
-              display (if (< 100 (count title))
-                        (apply str (concat(take 100 title) "..."))
-                        title
-                        )]
+              label   (if (empty? title)
+                        url
+                        title)
+              display (if (< 100 (count label))
+                        (apply str (concat(take 100 label) "..."))
+                        label)]
           ^{:key i}
           [:tr
            [:td {:class "col-sm-2"} (time-display (:time tab))]


Fix use of yada.context without require (#269)

Exception without this patch:

❯ lein run -m clojure.main -e "(require 'yada.security)"
Exception in thread "main" java.lang.ClassNotFoundException: yada.context.Context, compiling:(yada/security.clj:1:1)

--- src/yada/security.clj
+++ src/yada/security.clj
@@ -7,6 +7,7 @@
    [clojure.tools.logging :refer :all]
    [yada.authorization :as authorization]
    [yada.syntax :as syn]
+   yada.context
    [clojure.tools.logging :as log]
    [manifold.deferred :as d])
   (:import


Adds test for fetching a job with no name (#685)

--- scheduler/test/cook/test/mesos/api.clj
+++ scheduler/test/cook/test/mesos/api.clj
@@ -35,7 +35,7 @@
            com.google.protobuf.ByteString
            java.io.ByteArrayOutputStream
            java.net.ServerSocket
-           java.util.UUID
+           (java.util Date UUID)
            java.util.concurrent.ExecutionException
            (javax.servlet ServletOutputStream ServletResponse)
            org.apache.curator.test.TestingServer))
@@ -165,10 +165,10 @@

     (testing "delete of invalid instance"
       (let [delete-response (h {:request-method :delete
-                      :scheme :http
-                      :uri "/rawscheduler"
-                      :authorization/user "dgrnbrg"
-                      :query-params {"job" (str (UUID/randomUUID))}})]
+                                :scheme :http
+                                :uri "/rawscheduler"
+                                :authorization/user "dgrnbrg"
+                                :query-params {"job" (str (UUID/randomUUID))}})]
         (is (<= 400 (:status delete-response) 499))
         (is (str/includes? (response->body-data delete-response) "didn't correspond to a job"))))

@@ -1568,3 +1568,19 @@
   (is ((api/name-filter-str->name-filter-fn "a*c") "abc"))
   (is ((api/name-filter-str->name-filter-fn "a*c") "ac"))
   (is (not ((api/name-filter-str->name-filter-fn "a*c") "zacd"))))
+
+(deftest test-fetch-job-with-no-name
+  (let [conn (restore-fresh-database! "datomic:mem://test-fetch-job-with-no-name")
+        job-uuid (UUID/randomUUID)
+        job-txn-no-name {:db/id (d/tempid :db.part/user)
+                         :job/max-retries 1
+                         :job/state :job.state/waiting
+                         :job/uuid job-uuid}]
+    @(d/transact conn [job-txn-no-name])
+    (let [db (db conn)
+          job-entity (d/entity db [:job/uuid job-uuid])
+          job-map-for-api (api/fetch-job-map db nil nil job-uuid)]
+      (is (= job-uuid (:job/uuid job-entity)))
+      (is (nil? (:job/name job-entity)))
+      (is (= job-uuid (:uuid job-map-for-api)))
+      (is (= "cookjob" (:name job-map-for-api))))))


Simplify the `hello-world` exercise's stub. The goal of this is to make things easier for students to get started and to introduce as little syntax as possible.

--- exercises/practice/hello-world/src/hello_world.clj
+++ exercises/practice/hello-world/src/hello_world.clj
@@ -1,5 +1,4 @@
 (ns hello-world)

-(defn hello [] ;; <- arglist goes here
-  ;; your code goes here
-)
+(defn hello []
+  "Goodbye, Mars!")


Add tests for /data/dataset/slice

Add tests for /data/dataset/slice

--- test/cfpb/qu/handler_test.clj
+++ test/cfpb/qu/handler_test.clj
@@ -37,3 +37,23 @@

              (app (request :get "/data/bad-dataset"))
              => (contains {:status 404})))
+
+(facts "about /data/dataset/slice"
+       (fact "it returns successfully when the dataset and slice exist"
+             (prerequisite (#'cfpb.qu.data/get-metadata "good-dataset") => {:slices {:whoa {}}}
+                           (#'cfpb.qu.query/execute "good-dataset" anything anything)
+                           => {:total 0 :size 0 :data []})
+
+             (app (request :get "/data/good-dataset/whoa"))
+             => (contains {:status 200
+                           :headers {"Content-Type" "text/html;charset=UTF-8"}})
+
+             (app (request :get "/data/good-dataset/whoa.xml"))
+             => (contains {:status 200
+                           :headers {"Content-Type" "application/xml;charset=UTF-8"}}))
+
+       (fact "it returns a 404 when the slice does not exist"
+             (prerequisite (#'cfpb.qu.data/get-metadata "good-dataset") => {:slices {}})
+
+             (app (request :get "/data/good-dataset/what"))
+             => (contains {:status 404})))


Refactor tests

Refactor tests

--- test/desdemona/query_test.clj
+++ test/desdemona/query_test.clj
@@ -3,13 +3,16 @@
    [desdemona.query :as q]
    [clojure.test :refer [deftest is are testing]]))

+(defn ^:private fn-call
+  "Expected parse tree for a function call."
+  [f arg]
+  [:fn-call [:identifier f] [:identifier arg]])
+
 (deftest infix-parser-tests
   (is (= [:expr [:ipv4-address "10" "0" "0" "1"]]
          (#'q/infix-parser "10.0.0.1"))
       "ipv4 addresses")
-  (is (= [:expr [:fn-call
-                 [:identifier "ip"]
-                 [:identifier "x"]]]
+  (is (= [:expr (fn-call "ip" "x")]
          (#'q/infix-parser "ip(x)"))
       "simple fn calls")
   (is (= [:expr [:eq
@@ -18,28 +21,18 @@
          (#'q/infix-parser "a = b"))
       "equality between identifiers")
   (is (= [:expr [:eq
-                 [:fn-call
-                  [:identifier "ip"]
-                  [:identifier "x"]]
+                 (fn-call "ip" "x")
                  [:ipv4-address "10" "0" "0" "1"]]]
          (#'q/infix-parser "ip(x) = 10.0.0.1"))
       "equality between fn call and IP address literal")
   (is (= [:expr [:eq
-                 [:fn-call
-                  [:identifier "ip"]
-                  [:identifier "x"]]
-                 [:fn-call
-                  [:identifier "ip"]
-                  [:identifier "y"]]]]
+                 (fn-call "ip" "x")
+                 (fn-call "ip" "y")]]
          (#'q/infix-parser "ip(x) = ip(y)"))
       "equality between two fn calls")
   (is (= [:expr [:eq
-                 [:fn-call
-                  [:identifier "ip"]
-                  [:identifier "x"]]
-                 [:fn-call
-                  [:identifier "ip"]
-                  [:identifier "y"]]
+                 (fn-call "ip" "x")
+                 (fn-call "ip" "y")
                  [:ipv4-address "10" "0" "0" "1"]]]
          (#'q/infix-parser "ip(x) = ip(y)"))
       "equality between two fn calls & literal"))


check if log table exists

check if log table exists

before deleting it or else server doesn’t start

--- src/webapp/framework/server/systemfns.clj
+++ src/webapp/framework/server/systemfns.clj
@@ -624,7 +624,14 @@

 ; deletes the realtime log every time the file is reloaded, or the server is restarted
-(korma.core/exec-raw ["delete from coils_realtime_log" []] [])
+(let [coils-admin-tables      (korma.core/exec-raw
+                                   [" select * from pg_tables where schemaname='public' and tablename='coils_realtime_log'" []]
+                                   :results)
+
+        coils-admin-table-exists   (pos? (count coils-admin-tables))
+      ]
+  (if coils-admin-table-exists
+    (korma.core/exec-raw ["delete from coils_realtime_log" []] [])))


Tests for proper parsing special float values and bad input

--- test/hurvinek/config_test.clj
+++ test/hurvinek/config_test.clj
@@ -151,3 +151,18 @@
         -1e10 (parse-float "-10000000000")
         -1e10 (parse-float "-1e10")))

+(deftest test-parse-float-min-value
+    "Check the behaviour of function emender-jenkins.config/parse-int."
+    (is (== Float/MIN_VALUE (parse-float "0x0.000002P-126f"))))
+
+(deftest test-parse-float-max-value
+    "Check the behaviour of function emender-jenkins.config/parse-int."
+    (is (== Float/MAX_VALUE (parse-float "0x1.fffffeP+127f"))))
+
+(deftest test-parse-float-bad-input
+    "Check the behaviour of function emender-jenkins.config/parse-float."
+    (are [x] (thrown? NumberFormatException x)
+        (parse-float "")
+        (parse-float "xyzzy")
+        (parse-float "-1xyzzy")))
+


Add trial to plan header (#1761)

Add trial to plan header (#1761)

--- src-cljs/frontend/components/org_settings.cljs
+++ src-cljs/frontend/components/org_settings.cljs
@@ -1439,12 +1439,14 @@
                                                                 :vcs_type plan-vcs-type
                                                                 :_fragment "osx-pricing"})} "Choose an OS X plan"]] "."]])])))))

-(defn displayed-linux-plan-info [current-linux-cost containers in-student-trial?]
-  (gstring/format "Current Linux plan: %s - $%s/month"
-                  (cond
-                    in-student-trial? (gstring/format "Student (%s)" (plural-multiples containers "container"))
-                    (= current-linux-cost 0) "Hobbyist (1 container)"
-                    :else (plural-multiples containers " container"))
+(defn displayed-linux-plan-info [current-linux-cost containers trial-containers in-student-trial?]
+  (gstring/format "Current Linux plan: %s (%s) - $%s/month"
+                  (if in-student-trial?
+                    "Student"
+                    (gstring/format "%s%s"
+                      (if (= current-linux-cost 0) "Hobbyist" "Paid")
+                      (if (> trial-containers 0) " + Trial " " ")))
+                  (plural-multiples containers "container")
                   current-linux-cost))

 (defn displayed-linux-paid-info [paid-linux-containers]
@@ -1469,7 +1471,8 @@
           containers (pm/linux-containers plan)
           piggiebacked? (pm/piggieback? plan org-name vcs_type)
           current-linux-cost (pm/current-linux-cost plan)
-          in-student-trial? (pm/in-student-trial? plan)]
+          in-student-trial? (pm/in-student-trial? plan)
+          trial-containers (pm/trial-containers plan)]
       [:div.split-plan-block
        [:div.explanation
         (when piggiebacked?
@@ -1483,7 +1486,7 @@
         (if (config/enterprise?)
           [:p "Your organization currently uses a maximum of " containers " containers. If your fleet size is larger than this, you should raise this to get access to your full capacity."]
           [:p
-           [:h1 (displayed-linux-plan-info current-linux-cost containers in-student-trial?)]
+           [:h1 (displayed-linux-plan-info current-linux-cost containers trial-containers in-student-trial?)]
            (if (> current-linux-cost 0)
              [:div
               (displayed-linux-paid-info paid-linux-containers)
@@ -1511,7 +1514,7 @@
         (when (and (> (pm/trial-containers plan) 0)
                    (not in-student-trial?))
           [:p
-           (str (pm/trial-containers plan) " of these are provided by a trial. They'll be around for "
+           (str trial-containers " of these are provided by a trial. They'll be around for "
                 (pluralize (pm/days-left-in-trial plan) "more day")
                 ".")])

@@ -1531,7 +1534,8 @@
           containers (pm/linux-containers plan)
           piggiebacked? (pm/piggieback? plan org-name vcs_type)
           current-linux-cost (pm/current-linux-cost plan)   ; why linux-container-cost then current-linux-cost?
-          in-student-trial? (pm/in-student-trial? plan)]
+          in-student-trial? (pm/in-student-trial? plan)
+          trial-containers (pm/trial-containers plan)]
       [:div.overview-cards-container
        [:legend "Plan Overview"]
        (when piggiebacked?
@@ -1551,7 +1555,7 @@
                   [:p "Your organization currently uses a maximum of " containers " containers. If your fleet size is larger than this, you should raise this to get access to your full capacity."]

                   [:div
-                   [:h1 (displayed-linux-plan-info current-linux-cost containers in-student-trial?)]
+                   [:h1 (displayed-linux-plan-info current-linux-cost containers trial-containers in-student-trial?)]
                    (when (and (= current-linux-cost 0) (not piggiebacked?))
                      [:div
                       [:p (gstring/format "%s. %s." (displayed-linux-paid-info paid-linux-containers) (displayed-linux-free-info in-student-trial?))]
@@ -1562,10 +1566,10 @@
                                                                  :_fragment "linux-pricing"})}
                          "Add more containers to update your plan"]]
                        " and gain access to concurrent builds, parallelism, engineering support, insights, build timings, and other cool stuff."]])])
-                (when (and (> (pm/trial-containers plan) 0)
+                (when (and (> trial-containers 0)
                            (not in-student-trial?))
                   [:p
-                   (str (pm/trial-containers plan) " of these are provided by a trial. They'll be around for "
+                   (str trial-containers " of these are provided by a trial. They'll be around for "
                         (pluralize (pm/days-left-in-trial plan) "more day")
                         ".")])
                 (when (and (not (config/enterprise?))


bumping releases

bumping releases

--- moebius/project.clj
+++ moebius/project.clj
@@ -6,9 +6,9 @@
   :license {:name "Apache License 2.0"
             :url "http://www.apache.org/licenses/LICENSE-2.0"}

-  :dependencies [[org.clojure/clojure "1.6.0"]
+  :dependencies [[org.clojure/clojure "1.7.0"]
                  [prismatic/schema "0.4.3"]                ;; schema validation
-                 [com.taoensso/timbre "4.0.1"]             ;; logging
+                 [com.taoensso/timbre "4.0.2"]             ;; logging
                  ;;[samsara/trackit "0.2.0"]
                  [org.clojure/core.match "0.3.0-alpha4"]   ;; pattern-matching
                  [potemkin "0.3.13"]                       ;; import-var
@@ -16,7 +16,7 @@
                  [rhizome "0.2.5"]                         ;; graphviz
                  ]

-  :profiles {:dev {:dependencies [[midje "1.6.3"]]
+  :profiles {:dev {:dependencies [[midje "1.7.0"]]
                    :plugins [[lein-midje "3.1.3"]]}}

   :deploy-repositories [["clojars" {:url "https://clojars.org/repo/"


(SERVER-1148) Dump thread traces when a jruby-pool-int-test times out

This commit adds stack traces for all running threads to the assertion
message which is displayed when a jruby-pool-int-test encounters a time
out.

--- test/integration/puppetlabs/services/jruby/jruby_pool_int_test.clj
+++ test/integration/puppetlabs/services/jruby/jruby_pool_int_test.clj
@@ -45,6 +45,42 @@
   [ref]
   (deref ref 240000 :timed-out))

+(defn get-stack-trace-for-thread-as-str
+  [stack-trace-elements]
+  (reduce
+   (fn [acc stack-trace-element]
+     (str acc
+          "  "
+          (.getClassName stack-trace-element)
+          "."
+          (.getMethodName stack-trace-element)
+          "("
+          (.getFileName stack-trace-element)
+          ":"
+          (.getLineNumber stack-trace-element)
+          ")"
+          "\n"))
+   ""
+   stack-trace-elements))
+
+(defn get-all-stack-traces-as-str
+  []
+  (reduce
+   (fn [acc thread-stack-element]
+     (let [thread (key thread-stack-element)]
+       (str acc
+            "\""
+            (.getName thread)
+            "\" id="
+            (.getId thread)
+            " state="
+            (.getState thread)
+            "\n"
+            (get-stack-trace-for-thread-as-str
+             (val thread-stack-element)))))
+   ""
+   (Thread/getAllStackTraces)))
+
 (def script-to-check-if-constant-is-defined
   "! $instance_id.nil?")

@@ -156,7 +192,8 @@
         (let [flush-complete (add-watch-for-flush-complete pool-context)]
           (is (true? (trigger-flush ssl-request-options)))
           (is (true? (timed-deref flush-complete))
-              "timed out waiting for the flush to complete"))
+              (str "timed out waiting for the flush to complete, stack:\n"
+                   (get-all-stack-traces-as-str))))
         ;; now the pool is flushed, so the constants should be cleared
         (is (true? (verify-no-constants pool-context 4)))))))

@@ -183,7 +220,8 @@
           (jruby-protocol/return-instance jruby-service instance :hold-instance-while-pool-flush-in-progress-test)
           ;; wait until the flush is complete
           (is (true? (timed-deref flush-complete))
-              "timed out waiting for the flush to complete"))
+              (str "timed out waiting for the flush to complete, stack:\n"
+                   (get-all-stack-traces-as-str))))
         ;; now the pool is flushed, and the constants should be cleared
         (is (true? (verify-no-constants pool-context 4)))))))

@@ -221,7 +259,8 @@
           (jruby-protocol/return-instance jruby-service instance :hold-instance-while-pool-flush-in-progress-test)
           ;; wait until the flush is complete
           (is (true? (timed-deref flush-complete))
-              "timed out waiting for the flush to complete"))
+              (str "timed out waiting for the flush to complete, stack:\n"
+                   (get-all-stack-traces-as-str))))
         ;; now the pool is flushed, and the constants should be cleared
         (is (true? (verify-no-constants pool-context 2)))))))

@@ -309,7 +348,8 @@

               ;; wait until the flush is complete
               (is (true? (timed-deref flush-complete))
-                  "timed out waiting for the flush to complete"))
+                  (str "timed out waiting for the flush to complete, stack:\n"
+                       (get-all-stack-traces-as-str))))

             ;; we should have three instances with the constant and one without.
             (is (true? (check-jrubies-for-constant-counts pool-context 3 1)))))))))
@@ -384,7 +424,8 @@
           (is (= 503 (:status (ping-environment)))))
          (jruby-protocol/return-instance jruby-service jruby-instance :i-want-this-instance)
          (is (not= :timed-out (timed-deref stop-complete?))
-             "timed out waiting for the stop to complete")
+             (str "timed out waiting for the stop to complete, stack:\n"
+                  (get-all-stack-traces-as-str)))
          (logging/with-test-logging
           (is (= 503 (:status (ping-environment))))))))))

@@ -408,7 +449,8 @@
         (is (= 503 (:status (ping-environment)))))
        (jruby-protocol/return-instance jruby-service jruby-instance :i-want-this-instance)
        (is (not= :timed-out (timed-deref stop-complete?))
-           "timed out waiting for the stop to complete")
+           (str "timed out waiting for the stop to complete, stack:\n"
+                (get-all-stack-traces-as-str)))
        (let [app-context (tk-app/app-context app)]
          ;; We have to re-initialize the JRubyPuppetService here because
          ;; otherwise the tk-app/stop that is included in the


Adding sqrt test.

Adding sqrt test.

--- test/sic/sqrt_newton_test.clj
+++ test/sic/sqrt_newton_test.clj
@@ -2,6 +2,6 @@
   (:require [clojure.test :refer :all]
             [sic.sqrt-newton :refer :all]))

-(deftest a-test
-  (testing "FIXME, I fail."
-    (is (= 0 0))))
+(deftest sqrt-test
+  (testing "Square root of 4 should be 2."
+    (is (= 2.0 (sqrt 4)))))


update to new api

update to new api

--- labs/architecture-examples/om/src/todomvc/app.cljs
+++ labs/architecture-examples/om/src/todomvc/app.cljs
@@ -106,7 +106,7 @@
     dom/IWillMount
     (-will-mount [_ owner]
       (let [comm (chan)]
-        (dom/set-state! owner :comm comm)
+        (dom/set-state! owner [:comm] comm)
         (go (while true
               (handle-event app (<! comm))))))
     dom/IDidUpdate
@@ -116,7 +116,7 @@
     (-render [_ owner]
       (let [active    (count (remove :completed todos))
             completed (- (count todos) active)
-            comm      (dom/get-state owner :comm)]
+            comm      (dom/get-state owner [:comm])]
         (dom/div nil
           (dom/header #js {:id "header"}
             (dom/h1 nil "todos")


update deps

update deps

--- geom/project.clj
+++ geom/project.clj
@@ -3,12 +3,12 @@
   :url          "https://github.com/thi-ng/demos"
   :license      {:name "Apache Software License"
                  :url "http://www.apache.org/licenses/LICENSE-2.0"}
-  :dependencies [[org.clojure/clojure "1.7.0-alpha5"]
-                 [org.clojure/clojurescript "0.0-3117"]
-                 [thi.ng/geom "0.0.777"]
+  :dependencies [[org.clojure/clojure "1.7.0"]
+                 [org.clojure/clojurescript "1.7.145"]
+                 [thi.ng/geom "0.0.881"]
                  [thi.ng/domus "0.1.0"]]

-  :plugins [[lein-cljsbuild "1.0.5"]]
+  :plugins [[lein-cljsbuild "1.1.0"]]

   :clean-targets ^{:protect false} ["resources/public/js"]


Bind clojure.tools.reader/*data-readers* to *data-readers*

--- src/refactor_nrepl/analyzer.clj
+++ src/refactor_nrepl/analyzer.clj
@@ -5,6 +5,7 @@
             [clojure.tools.analyzer.jvm :as aj]
             [clojure.tools.analyzer.jvm.utils :as ajutils]
             [clojure.tools.namespace.parse :refer [read-ns-decl]]
+            [clojure.tools.reader :as reader]
             [refactor-nrepl
              [util :as util]
              [config :as config]])
@@ -55,7 +56,8 @@
   [ns aliases]
   (when (ns-on-cp? ns)
     (binding [ana/macroexpand-1 noop-macroexpand-1
-              *file* (-> ns ajutils/ns-resource ajutils/source-path)]
+              *file* (-> ns ajutils/ns-resource ajutils/source-path)
+              reader/*data-readers* *data-readers*]
       (assoc-in (aj/analyze-ns ns) [0 :alias-info] aliases))))

 (defn- cachable-ast [file-content]


link to tags on results page

link to tags on results page

--- src/semtag_web/client/main.cljs
+++ src/semtag_web/client/main.cljs
@@ -1,5 +1,6 @@
 (ns semtag-web.client.main
-  (:require [crate.core :as crate])
+  (:require [crate.core :as crate]
+            [clojure.string :as string])
   (:use [jayq.core :only [$ append bind] :as jq])
   (:use-macros [crate.def-macros :only [defpartial]]))

@@ -28,7 +29,10 @@
            [:td (:namespace %)]
            [:td [:a {:href (:url %)} (shorten-to (:url %) 40)]]
            [:td (:desc %)]
-           [:td (:tags %)]])
+           [:td
+            (map
+              (fn [tag] (vec [:a {:style "display: block" :href (str "/tag/" tag)} tag]))
+              (string/split (:tags %) #";"))]])
       data) ])

 (defn- update-table [parent data]


only allow one edit state at a time

only allow one edit state at a time

this allows the user to edit the same cell multiple times and get
the current accurate state

--- src/semtag_web/client/main.cljs
+++ src/semtag_web/client/main.cljs
@@ -25,13 +25,11 @@
   (apply inner args)
   (add-sort-to (first args)))

-(defn- mark-in-progress [event]
+(defn- set-edit-state [klass event]
   (let [$elem ($ (.-target event))]
-    (jq/add-class $elem "edit-in-progress")))
-
-(defn- mark-completed [event]
-  (let [$elem ($ (.-target event))]
-    (jq/add-class $elem "edit-completed")))
+    (doseq [c (->> (jq/attr $elem :class) (re-seq #"\S+") (filter #(re-find #"^edit-" %)))]
+      (jq/remove-class $elem c))
+    (jq/add-class $elem klass)))

 (defn- saves-edit [event]
   (.preventDefault event)
@@ -45,9 +43,9 @@
       (fn [data]
         (log "Received from server:")
         (log-clj data)
-        (mark-completed event))
+        (set-edit-state "edit-completed" event))
       (fn [& args]
-        (jq/add-class $elem "edit-failed")
+        (set-edit-state "edit-failed" event)
         (apply alert-error args)
         ))))

@@ -63,7 +61,7 @@
   (let [editable-cells ($ :td.editable)]
     (.attr editable-cells "contentEditable" true)
     (.attr (jq/find editable-cells "a") "contentEditable" false)
-    (bind editable-cells "click" (juxt expand-editable-text mark-in-progress))
+    (bind editable-cells "click" (juxt expand-editable-text (partial set-edit-state "edit-in-progress")))
     (bind editable-cells :keypress (return-key-pressed saves-edit))))

 (defn- create-search-table [parent data]


fix stroke-width

fix stroke-width

--- src/pc/svg.clj
+++ src/pc/svg.clj
@@ -16,7 +16,7 @@
      :fill          "none"
      :key           (:layer/id layer)
      :stroke        (if invert-colors? "#ccc" "black")
-     :strokeWidth   2
+     :stroke-width   2
      :rx            (:layer/rx layer)
      :ry            (:layer/ry layer)     }))

@@ -24,7 +24,7 @@
   {:x (:layer/start-x layer)
    :y (:layer/start-y layer)
    :fill (if invert-colors? "#ccc" "black")
-   :strokeWidth 0
+   :stroke-width 0
    :font-family (:layer/font-family layer "Helvetica")
    :font-size   (:layer/font-size layer 20)})

@@ -34,10 +34,10 @@
    :x2          (:layer/end-x layer)
    :y2          (:layer/end-y layer)
    :stroke (if invert-colors? "#ccc" "black")
-   :strokeWidth 2})
+   :stroke-width 2})

 (defn layer->svg-path [layer {:keys [invert-colors?]}]
   {:d (:layer/path layer)
    :stroke (if invert-colors? "#ccc" "black")
    :fill "none"
-   :strokeWidth 2})
+   :stroke-width 2})


Store tiles as coordinates and image refs rather than the actual sub-image to prevent space explosion when step-size is much smaller than tile-size

--- src/mosaic/core.clj
+++ src/mosaic/core.clj
@@ -16,10 +16,11 @@

 (defn- gen-tiles
   "Generate tiles of size n from image b.
-   Returns a list of BufferedImages."
+   Returns a list of coordinate, image pairs
+   rather than subimages for space efficiency."
   ([n ^BufferedImage b] (gen-tiles n b n))
   ([n ^BufferedImage b s]
-     (map img/sub-image
+     (map #(hash-map :coord %1 :image %2)
 	  (grid n (.getWidth b) (.getHeight b) s)
 	  (repeat b))))

@@ -36,18 +37,24 @@

 (defn- sample-tiles [n tiles]
   "Get average RGB in regions n-by-n for tiles.
-   Output format: {:tile :sample}"
-  (for [t tiles] {:tile t
-		  :samples (img/get-samples (img/rescale n n t))}))
+   Output format: {:tile :samples}"
+  (for [t tiles]
+    (let [i (img/sub-image (:coord t) (:image t))
+	  s (img/get-samples (img/rescale n n i))]
+      {:tile t :samples s} )))

 (defn- best-match [n samples ^BufferedImage b]
-  "Find the best matching tile to image b."
-  (let [s (img/get-samples (img/rescale n n b))]
-    (reduce #(if (< (delta s (:samples %1))
-		    (delta s (:samples %2)))
-	       %1 %2)
-	    (first samples)
-	    (rest samples))))
+  "Find the best matching tile to image b.
+   Applies sub-image to the resulting tile
+   to return a BufferedImage."
+  (let [s (img/get-samples (img/rescale n n b))
+	t (reduce #(if (< (delta s (:samples %1))
+			  (delta s (:samples %2)))
+		     %1 %2)
+		  (first samples)
+		  (rest samples))
+	i (:tile t)]
+    (img/sub-image (:coord i) (:image i))))

 (defn- gen-canvas [n w ^BufferedImage b]
   "Rescale and crop image b to evenly fit tiles of
@@ -65,7 +72,7 @@
 	tiles (sample-tiles s (gen-tiles-coll n tiles ns))]
     ; Replace each tile in canvas with the best match from tiles coll.
     (dorun (map #(img/insert!
-		  (:tile (best-match n tiles (img/sub-image % canvas)))
+		  (best-match n tiles (img/sub-image % canvas))
 		  canvas (first %) (second %))
 		(grid n (.getWidth canvas) (.getHeight canvas))))
     canvas))


Add explicit validation of order-by fields in event-counts

Prior to this commit, we weren't validating the order-by
fields for the event-counts endpoint.  This meant that if
you specified a bad field name, it was getting passed
all the way down to the SQL layer and failing there,
so you'd get a 500 rather than a 400 with a clear error
message.

This adds in the validation and ensures we get the 400.

--- src/com/puppetlabs/puppetdb/query/event_counts.clj
+++ src/com/puppetlabs/puppetdb/query/event_counts.clj
@@ -1,8 +1,9 @@
 (ns com.puppetlabs.puppetdb.query.event-counts
   (:require [com.puppetlabs.puppetdb.query.events :as events]
             [clojure.string :as string])
-  (:use [com.puppetlabs.jdbc :only [valid-jdbc-query? dashes->underscores]]
+  (:use [com.puppetlabs.jdbc :only [valid-jdbc-query? dashes->underscores underscores->dashes]]
         [com.puppetlabs.puppetdb.query :only [compile-term execute-query]]
+        [com.puppetlabs.puppetdb.query.paging :only [validate-order-by!]]
         [com.puppetlabs.utils :only [contains-some]]
         [clojure.core.match :only [match]]))

@@ -52,11 +53,11 @@
   IllegalArgumentException is thrown."
   [summarize-by]
   {:pre  [(string? summarize-by)]
-   :post [(string? %)]}
+   :post [(vector? %)]}
   (condp = summarize-by
-    "certname" "certname"
-    "containing-class" "containing_class"
-    "resource" "resource_type, resource_title"
+    "certname" ["certname"]
+    "containing-class" ["containing_class"]
+    "resource" ["resource_type" "resource_title"]
     (throw (IllegalArgumentException. (format "Unsupported value for 'summarize-by': '%s'" summarize-by)))))

 (defn- get-counts-filter-where-clause
@@ -77,20 +78,27 @@
   [sql count-by group-by]
   {:pre  [(string? sql)
           (string? count-by)
-          (string? group-by)]
+          (vector? group-by)]
    :post [(string? %)]}
   (condp = count-by
     "resource"  sql
-    "certname"  (let [field-string (if (= group-by "certname") "" (str ", " group-by))]
+    "certname"  (let [field-string (if (= group-by ["certname"]) "" (str ", " (string/join ", " group-by)))]
                   (format "SELECT DISTINCT certname, status%s FROM (%s) distinct_events" field-string sql))
     (throw (IllegalArgumentException. (format "Unsupported value for 'count-by': '%s'" count-by)))))
+
+(defn- event-counts-columns
+  [group-by]
+  {:pre [(vector? group-by)]}
+  (concat
+    ["failures" "successes" "noops" "skips"]
+    (map underscores->dashes group-by)))

 (defn- get-event-count-sql
   "Given the `event-sql` and value to `group-by`, return a SQL string that
   will sum the results of `event-sql` grouped by the provided value."
   [event-sql group-by]
   {:pre  [(string? event-sql)
-          (string? group-by)]
+          (vector? group-by)]
    :post [(string? %)]}
   (format "SELECT %s,
               SUM(CASE WHEN status = 'failure' THEN 1 ELSE 0 END) AS failures,
@@ -99,9 +107,9 @@
               SUM(CASE WHEN status = 'skipped' THEN 1 ELSE 0 END) AS skips
             FROM (%s) events
             GROUP BY %s"
-          group-by
+          (string/join ", " group-by)
           event-sql
-          group-by))
+          (string/join ", " group-by)))

 (defn- get-filtered-sql
   "Given a `sql` string and optional `where` clause, return the appropriate filtered
@@ -182,5 +190,7 @@
    {:pre  [(string? sql)]
     :post [(map? %)
            (vector? (:result %))]}
+    (let [group-by (get-group-by summarize-by)]
+      (validate-order-by! (event-counts-columns group-by) paging-options))
     (-> (execute-query (apply vector sql params) paging-options)
       (update-in [:result] (partial munge-subjects summarize-by)))))


Fix container constructor

Fix container constructor

--- src/play_clj/ui.clj
+++ src/play_clj/ui.clj
@@ -191,7 +191,7 @@

 (defn container*
   [child]
-  (ActorEntity. (Table. child)))
+  (ActorEntity. (Container. (u/get-obj child :object))))

 (defmacro container
   "Returns an entity based on [Container](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/Container.html).


Moved to only having the Python client enabled by default

--- src/tricks/core.clj
+++ src/tricks/core.clj
@@ -19,8 +19,8 @@
 (defn -main
   [& args]
   (tricks.server/run [
-                      ["Clojure1" ["java" "-jar" "clojure_client-0.1.0-SNAPSHOT-standalone.jar" "Clojure1"] (java.io.File. "clients")]
-                      ;["Python_1" ["python" "simple_client.py" "Python_1"] (java.io.File. "clients")]
+                      ;["Clojure1" ["java" "-jar" "clojure_client-0.1.0-SNAPSHOT-standalone.jar" "Clojure1"] (java.io.File. "clients")]
+                      ["Python_1" ["python" "simple_client.py" "Python_1"] (java.io.File. "clients")]
                       ["Python_4" ["python" "simple_client.py" "Python_4"] (java.io.File. "clients")]
                       ["Python_2" ["python" "simple_client.py" "Python_2"] (java.io.File. "clients")]
                       ["Python_3" ["python" "simple_client.py" "Python_3"] (java.io.File. "clients")]]))


use slimmer icons for container pills

use slimmer icons for container pills

--- frontend/components/build.cljs
+++ frontend/components/build.cljs
@@ -61,11 +61,11 @@
             :class (container-model/status->classes status)}
            (str (:index container))
            (case status
-             :failed [:i.fa.fa-times]
-             :success [:i.fa.fa-check]
-             :cancelled [:i.fa.fa-exclamation]
-             :running [:i.fa.fa-clock-o]
-             :waiting [:i.fa.fa-clock-o]
+             :failed (common/ico :fail-light)
+             :success (common/ico :pass-light)
+             :canceled (common/ico :fail-light)
+             :running (common/ico :logo-light)
+             :waiting (common/ico :none-light)
              nil)]])))))

 (defn container-pills [data owner]


Fix flaky test by hacking bad cleanup code.

Proper fix forthcoming with other Om-state cleanup.

--- frontend/components/forms.cljs
+++ frontend/components/forms.cljs
@@ -32,7 +32,8 @@
     {:channel channel :uuid uuid}))

 (defn deregister-channel! [owner uuid]
-  (om/update-state! owner [:registered-channel-uuids] #(disj % uuid))
+  ;;XXX The `when is a hack to silently ignore updates to unmounted component state.
+  (om/update-state! owner [:registered-channel-uuids] #(when % (disj % uuid)))
   (when-let [channel (get @registered-channels uuid)]
     (swap! registered-channels dissoc uuid)
     (close! channel)))
@@ -57,6 +58,7 @@
     (append-cycle owner :loading)
     (let [{:keys [uuid channel]} (register-channel! owner)]
       (binding [frontend.async/*uuid* uuid]
+        ;;XXX Async mutation of state may execute after dismount!
         (go (append-cycle owner (<! channel))
             (deregister-channel! owner uuid))
         (apply handler args)))))


image drawing for person

image drawing for person

--- src-cljs/jasons-game/thing/person.cljs
+++ src-cljs/jasons-game/thing/person.cljs
@@ -11,13 +11,13 @@
   (d/translate (:location person)
                {:stroke 0, :fill [0 255 0]}
                (fn []
-                 (s/ellipse 0 0 diameter diameter))))
-
-;    (s/push-matrix)
-;    (s/scale 2.0)
-;    (if-let [img (load-image "logo-color-255x75.png")]
-;      (s/image img 100 100))
-;    (s/pop-matrix)
+                 (s/ellipse 0 0 diameter diameter)
+
+                 (if-let [img (d/load-image "logo-color-255x75.png")]
+                   (d/translate
+                     [(- (/ (.-width img) 2)) (- (/ (.-height img) 2))]
+                     (fn []
+                       (s/image img 0 0)))))))

 (defmethod t/bounds-in-local :person
   [person]


Implement all core predicates,

Implement all core predicates,

--- src/spec_tools/json_schema.cljc
+++ src/spec_tools/json_schema.cljc
@@ -21,21 +21,33 @@
 (defn- spec-dispatch [dispatch spec children] dispatch)
 (defmulti accept-spec spec-dispatch :default ::default)

+;;
 ;; predicate list taken from https://github.com/clojure/clojure/blob/master/src/clj/clojure/spec/gen.clj
+;;

 ; any? (one-of [(return nil) (any-printable)])
+(defmethod accept-spec 'clojure.core/any? [_ _ _] {:type "object"})
+
 ; some? (such-that some? (any-printable))
+(defmethod accept-spec 'clojure.core/some? [_ _ _] {:type "object"})
+
 ; number? (one-of [(large-integer) (double)])
+(defmethod accept-spec 'clojure.core/number? [_ _ _] {:type "double"})

 ; integer? (large-integer)
 (defmethod accept-spec 'clojure.core/integer? [_ _ _] {:type "integer"})

 ; int? (large-integer)
-(defmethod accept-spec 'clojure.core/int? [_ _ _] {:type "integer"})
+(defmethod accept-spec 'clojure.core/int? [_ _ _] {:type "integer" :format "int64"})

 ; pos-int? (large-integer* {:min 1})
+(defmethod accept-spec 'clojure.core/pos-int? [_ _ _] {:type "integer", :format "int64", :minimum 1})
+
 ; neg-int? (large-integer* {:max -1})
+(defmethod accept-spec 'clojure.core/neg-int? [_ _ _] {:type "integer", :format "int64", :maximum -1})
+
 ; nat-int? (large-integer* {:min 0})
+(defmethod accept-spec 'clojure.core/nat-int? [_ _ _] {:type "integer",, :format "int64" :minimum 0})

 ; float? (double)
 (defmethod accept-spec 'clojure.core/float? [_ _ _] {:type "number"})
@@ -50,53 +62,111 @@
 (defmethod accept-spec 'clojure.core/string? [_ _ _] {:type "string"})

 ; ident? (one-of [(keyword-ns) (symbol-ns)])
+(defmethod accept-spec 'clojure.core/ident? [_ _ _] {:type "string"})
+
 ; simple-ident? (one-of [(keyword) (symbol)])
+(defmethod accept-spec 'clojure.core/simple-ident? [_ _ _] {:type "string"})
+
 ; qualified-ident? (such-that qualified? (one-of [(keyword-ns) (symbol-ns)]))
+(defmethod accept-spec 'clojure.core/qualified-ident? [_ _ _] {:type "string"})

 ; keyword? (keyword-ns)
 (defmethod accept-spec 'clojure.core/keyword? [_ _ _] {:type "string"})

 ; simple-keyword? (keyword)
+(defmethod accept-spec 'clojure.core/simple-keyword? [_ _ _] {:type "string"})
+
 ; qualified-keyword? (such-that qualified? (keyword-ns))
+(defmethod accept-spec 'clojure.core/qualified-keyword? [_ _ _] {:type "string"})
+
 ; symbol? (symbol-ns)
+(defmethod accept-spec 'clojure.core/symbol? [_ _ _] {:type "string"})
+
 ; simple-symbol? (symbol)
+(defmethod accept-spec 'clojure.core/simple-symbol? [_ _ _] {:type "string"})
+
 ; qualified-symbol? (such-that qualified? (symbol-ns))
+(defmethod accept-spec 'clojure.core/qualified-symbol? [_ _ _] {:type "string"})
+
 ; uuid? (uuid)
+(defmethod accept-spec 'clojure.core/uuid? [_ _ _] {:type "string" :format "uuid"})
+
 ; uri? (fmap #(java.net.URI/create (str "http://" % ".com")) (uuid))
+(defmethod accept-spec 'clojure.core/uri? [_ _ _] {:type "string" :format "uri"})
+
 ; bigdec? (fmap #(BigDecimal/valueOf %)
 ;               (double* {:infinite? false :NaN? false}))
+(defmethod accept-spec 'clojure.core/bigdec? [_ _ _] {:type "double"})
+
+
 ; inst? (fmap #(java.util.Date. %)
 ;             (large-integer))
+(defmethod accept-spec 'clojure.core/bigdec? [_ _ _] {:type "double"})
+
 ; seqable? (one-of [(return nil)
 ;                   (list simple)
 ;                   (vector simple)
 ;                   (map simple simple)
 ;                   (set simple)
 ;                   (string-alphanumeric)])
+(defmethod accept-spec 'clojure.core/seqable? [_ _ _] {:type "array"})
+
 ; indexed? (vector simple)
+(defmethod accept-spec 'clojure.core/map? [_ _ _] {:type "array"})
+
 ; map? (map simple simple)
+(defmethod accept-spec 'clojure.core/map? [_ _ _] {:type "object"})
+
 ; vector? (vector simple)
+(defmethod accept-spec 'clojure.core/vector? [_ _ _] {:type "array"})
+
 ; list? (list simple)
+(defmethod accept-spec 'clojure.core/list? [_ _ _] {:type "array"})
+
 ; seq? (list simple)
+(defmethod accept-spec 'clojure.core/seq? [_ _ _] {:type "array"})
+
 ; char? (char)
+(defmethod accept-spec 'clojure.core/char? [_ _ _] {:type "string"})
+
 ; set? (set simple)
+(defmethod accept-spec 'clojure.core/set? [_ _ _] {:type "array" :uniqueItems true})

 ; nil? (return nil)
 (defmethod accept-spec 'clojure.core/nil? [_ _ _] {:type "null"})

 ; false? (return false)
+(defmethod accept-spec 'clojure.core/false? [_ _ _] {:type "boolean"})
+
 ; true? (return true)
+(defmethod accept-spec 'clojure.core/true? [_ _ _] {:type "boolean"})
+
 ; zero? (return 0)
+(defmethod accept-spec 'clojure.core/zero? [_ _ _] {:type "integer"})
+
 ; rational? (one-of [(large-integer) (ratio)])
+(defmethod accept-spec 'clojure.core/coll? [_ _ _] {:type "double"})
+
 ; coll? (one-of [(map simple simple)
 ;                (list simple)
 ;                (vector simple)
 ;                (set simple)])
+(defmethod accept-spec 'clojure.core/coll? [_ _ _] {:type "object"})
+
 ; empty? (elements [nil '() [] {} #{}])
+(defmethod accept-spec 'clojure.core/coll? [_ _ _] {:type "array" :maxItems 0 :minItems 0})
+
 ; associative? (one-of [(map simple simple) (vector simple)])
+(defmethod accept-spec 'clojure.core/associative? [_ _ _] {:type "object"})
+
 ; sequential? (one-of [(list simple) (vector simple)])
+(defmethod accept-spec 'clojure.core/sequential? [_ _ _] {:type "array"})
+
 ; ratio? (such-that ratio? (ratio))
+(defmethod accept-spec 'clojure.core/ratio? [_ _ _] {:type "integer"})
+
 ; bytes? (bytes)
+(defmethod accept-spec 'clojure.core/ratio? [_ _ _] {:type "string" :format "byte"})

 (defmethod accept-spec 'clojure.core/pos? [_ _ _] {:minimum 0 :exclusiveMinimum true})
 (defmethod accept-spec 'clojure.core/neg? [_ _ _] {:maximum 0 :exclusiveMaximum true})


CMR-4774: Fixed a bug caused the Sort params not logged. (#491)

--- common-app-lib/src/cmr/common_app/services/search/elastic_search_index.clj
+++ common-app-lib/src/cmr/common_app/services/search/elastic_search_index.clj
@@ -122,7 +122,7 @@
 (defmethod send-query-to-elastic :default
   [context query]
   (let [elastic-query (q2e/query->elastic query)
-        {sort-params :sort-params
+        {sort-params :sort
          aggregations :aggs
          highlights :highlight :as execution-params} (query->execution-params query)
         concept-type (:concept-type query)


[Header] Don't recapitalize Organisation or Project names

--- src-cljs/frontend/components/header.cljs
+++ src-cljs/frontend/components/header.cljs
@@ -17,7 +17,7 @@
             [frontend.utils :as utils]
             [frontend.utils.github :refer [auth-url]]
             [frontend.utils.vcs-url :as vcs-url]
-            [goog.string :refer [format capitalize]]
+            [goog.string :refer [format]]
             [om.core :as om :include-macros true])
   (:require-macros [frontend.utils :refer [html]]))

@@ -133,7 +133,9 @@
               (if (and (:current-build-data app) (feature/enabled? "show-demo-label"))
                 [:ul.nav.navbar-nav
                     [:li [:span.demo-label " "
-                          (when first-build (format "You are viewing the CircleCI open source dashboard with builds from %s's %s repo" (capitalize (:username first-build)) (capitalize (:reponame first-build))))]]]
+                          (when first-build (format "You are viewing the CircleCI open source dashboard with builds from %s's %s repo"
+                                                    (:username first-build)
+                                                    (:reponame first-build)))]]]
                 [:ul.nav.navbar-nav
                  (when (config/show-marketing-pages?)
                    (list


bug fix to feature for now

bug fix to feature for now

--- src-cljs/frontend/components/issues.cljs
+++ src-cljs/frontend/components/issues.cljs
@@ -420,7 +420,7 @@
            [:p.issue-foot
             [:span (str comment-count " comment" (when (not= 1 comment-count) "s"))]
             [:span " for "]
-            [:span "bugfix"]
+            [:span "feature"]
             [:span " in "]
             [:span "development."]]]
           (om/build vote-box {:issue issue})])))))


Fix the stripe-checkout code loading for 'Adjust containers' non-paid plans.

--- frontend/components/org_settings.cljs
+++ frontend/components/org_settings.cljs
@@ -297,11 +297,31 @@

 (defn containers [app owner]
   (reify
+    ;; I stole the stateful "did we load stripe checkout code" stuff
+    ;; from the billing-info component; is there some nice way to
+    ;; abstract it out?
+    om/IInitState
+    (init-state [_]
+      {:checkout-loaded? (stripe/checkout-loaded?)
+       :checkout-loaded-chan (chan)})
+    om/IWillMount
+    (will-mount [_]
+      (let [ch (om/get-state owner [:checkout-loaded-chan])
+            checkout-loaded? (om/get-state owner [:checkout-loaded?])]
+        (when-not checkout-loaded?
+          (go (<! ch)
+              (utils/mlog "Stripe checkout loaded")
+              (om/set-state! owner [:checkout-loaded?] true))
+          (utils/mlog "Loading Stripe checkout")
+          (stripe/load-checkout ch))))
     om/IDidMount
     (did-mount [_]
       (utils/tooltip "#grandfathered-tooltip-hack") {:animation false})
-    om/IRender
-    (render [_]
+    om/IWillUnmount
+    (will-unmount [_]
+      (close! (om/get-state owner [:checkout-loaded-chan])))
+    om/IRenderState
+    (render-state [_ {:keys [checkout-loaded?]}]
       (let [org-name (get-in app state/org-name-path)
             plan (get-in app state/org-plan-path)
             selected-containers (or (get-in app state/selected-containers-path)
@@ -363,16 +383,18 @@
                                                     {:containers selected-paid-containers}])
                                      false)}
                      "Update plan"])
-                   (forms/managed-button
-                    [:button.btn.btn-large.btn-primary.center
-                     {:data-success-text "Paid!",
-                      :data-loading-text "Paying...",
-                      :data-failed-text "Failed!",
-                      :on-click #(raise! owner [:new-plan-clicked {:containers selected-containers
-                                                                   :paid {:template (:id plan-model/default-template-properties)}
-                                                                   :price new-total
-                                                                   :description (str "$" new-total "/month, includes " (pluralize selected-containers "container"))}])}
-                     "Update plan"]))
+                   (if-not checkout-loaded?
+                     [:div.loading-spinner common/spinner [:span "Loading Stripe checkout"]]
+                     (forms/managed-button
+                      [:button.btn.btn-large.btn-primary.center
+                       {:data-success-text "Paid!",
+                        :data-loading-text "Paying...",
+                        :data-failed-text "Failed!",
+                        :on-click #(raise! owner [:new-plan-clicked {:containers selected-containers
+                                                                     :paid {:template (:id plan-model/default-template-properties)}
+                                                                     :price new-total
+                                                                     :description (str "$" new-total "/month, includes " (pluralize selected-containers "container"))}])}
+                       "Update plan"])))
                  (when (< old-total new-total)
                    [:span.help-block
                     "We'll charge your card today, for the prorated difference between your new and old plans."])


More tests for changes stream.

More tests for changes stream.


adding bash require

adding bash require

--- src/celestial/common.clj
+++ src/celestial/common.clj
@@ -12,6 +12,7 @@
 (ns celestial.common
   (:import java.util.Date)
   (:require
+     pallet.stevedore.bash
     [pallet.stevedore :refer  [script with-source-line-comments]])
   (:use
     [slingshot.slingshot :only  [throw+ try+]]


friday! test main function args

friday! test main function args

--- src/codeitlater/core.clj
+++ src/codeitlater/core.clj
@@ -22,8 +22,9 @@
         (list lineNum comment))
       )))

-(defn -main []
+(defn -main [& args]
+  (println args)
   (println (read-comments-inline (make-pattern testMark) "aaa//test"))
-  (println (read-comments-in-file "/Users/cchen386/Desktop/log"
+  (println (read-comments-in-file "/Users/ccQ/Desktop/log"
                                   (partial read-comments-inline (make-pattern testMark)))))


Update Jetty to 9.4.24.v20191120

Update Jetty to 9.4.24.v20191120

--- ring-jetty-adapter/project.clj
+++ ring-jetty-adapter/project.clj
@@ -7,7 +7,7 @@
   :dependencies [[org.clojure/clojure "1.7.0"]
                  [ring/ring-core "1.8.0"]
                  [ring/ring-servlet "1.8.0"]
-                 [org.eclipse.jetty/jetty-server "9.4.22.v20191022"]]
+                 [org.eclipse.jetty/jetty-server "9.4.24.v20191120"]]
   :aliases {"test-all" ["with-profile" "default:+1.8:+1.9:+1.10" "test"]}
   :profiles
   {:dev  {:dependencies [[clj-http "3.10.0"]]


add function to parse session and return true if all actions successful or false if not

--- integration/src/dda/pallet/dda_user_crate/app/instantiate_existing.clj
+++ integration/src/dda/pallet/dda_user_crate/app/instantiate_existing.clj
@@ -19,15 +19,33 @@
     [dda.pallet.core.app :as core-app]
     [dda.pallet.dda-user-crate.app :as app]))

+(defn- get-results-of-session
+  "gets the results of the session in some form"
+  [session]
+  (let [results (:results session)
+        phases (map #(-> % :result) results)
+        exit-codes (map #(-> % :exit) (flatten phases))
+        every-exit-code (every? #(or (= 0 %) (= nil %)) exit-codes)]
+    (spit "phases.edn" (prn-str phases))
+    (spit "results.edn" (prn-str results))
+    (spit "exit-codes.edn" (prn-str exit-codes))
+    (println every-exit-code)))
+
+
 (defn install
   [& options]
   (let [{:keys [domain targets summarize-session]
          :or {domain "user.edn"
               targets "targets.edn"
               summarize-session true}} options]
-    (core-app/existing-install app/crate-app
-                          {:domain domain
-                           :targets targets})))
+    (let [session (get-results-of-session
+                    (core-app/existing-install
+                                            app/crate-app
+                                            {:domain domain
+                                             :targets targets}))])))
+
+
+

 (defn configure
  [& options]


started adding data to xml model

started adding data to xml model

--- src/clj_hypergraph_db/xml_model_parsing_functions.clj
+++ src/clj_hypergraph_db/xml_model_parsing_functions.clj
@@ -11,6 +11,12 @@
   [name]
   {:attribute (list name)})

+
 (defn with-def-token
   [name & attributes]
   {:attribute (list (apply def-token (cons name attributes)))})
+
+
+(defn def-data
+  [name]
+  {:data (def-item :data name nil)})