OO: Fix indentation

OO: Fix indentation

--- src/hatti/map/viewby.cljs
+++ src/hatti/map/viewby.cljs
@@ -49,12 +49,13 @@
         preprocessed-answers (preprocess-answers field raw-answers)
         answer->count (frequencies (flatten preprocessed-answers))
         sorted-answers (cond
-                 (or (form-utils/categorical? field)
-                     (form-utils/text? field)
-                     (form-utils/calculate? field))
-                 (map first (sort-by second > answer->count))
-                (or (form-utils/time-based? field) (form-utils/numeric? field))
-                (-> preprocessed-answers meta :bins))
+                        (or (form-utils/categorical? field)
+                            (form-utils/text? field)
+                            (form-utils/calculate? field))
+                        (map first (sort-by second > answer->count))
+                        (or (form-utils/time-based? field)
+                            (form-utils/numeric? field))
+                        (-> preprocessed-answers meta :bins))
         sorted-answers-with-nil-at-end (move-nil-to-end sorted-answers)
         answer->color-map (answer->color field sorted-answers)
         defaults {:answers sorted-answers-with-nil-at-end


CMR-285: Reset port for search.

CMR-285: Reset port for search.

--- test/cmr/system_int_test/utils/url_helper.clj
+++ test/cmr/system_int_test/utils/url_helper.clj
@@ -22,7 +22,7 @@

 (def indexer-port (config-value :indexer-port 3004))

-(def search-port (config-value :search-port 3000))
+(def search-port (config-value :search-port 3003))

 (def elastic_root (format "http://localhost:%s" elastic-port))


Sleep before checking job text for now

Sleep before checking job text for now

--- test/onyx/peer/dashboard_colors_flow_test.clj
+++ test/onyx/peer/dashboard_colors_flow_test.clj
@@ -298,6 +298,8 @@
   (webdriver/click (second (webdriver/find-elements {:css "tr.job-entry"}))))

 (defn check-job-text []
+  ;; remove this sleep - should perform a wait-until
+  (Thread/sleep 4000)
   (let [[workflow-text catalog-text lifecycles-text]
         (map webdriver/text
              (webdriver/find-elements {:css "div.ace_content"}))]


(maint) fix facts migration test

(maint) fix facts migration test

Currently the schema diff code mishandles columns with multiple indexes.
Remove the new test for fact_paths_trgm pending a fix to that.

--- test/puppetlabs/puppetdb/scf/migrate_test.clj
+++ test/puppetlabs/puppetdb/scf/migrate_test.clj
@@ -836,17 +836,6 @@
   (indexes! (:database *db*))
   (let [idxs (:indexes (schema-info-map *db*))]
     (is (= {:schema "public"
-            :table "fact_paths"
-            :index "fact_paths_path_key"
-            :index_keys ["path"]
-            :type "btree"
-            :unique? true
-            :functional? false
-            :is_partial false
-            :primary? false
-            :user "pdb_test"}
-           (get idxs ["fact_paths" ["path"]])))
-    (is (= {:schema "public"
             :table "facts"
             :index "facts_value_string_trgm"
             :index_keys ["value_string"]


development (def)s

development (def)s

--- test/babel/test/en.cljc
+++ test/babel/test/en.cljc
@@ -649,3 +649,7 @@
 (defn benchmark2 []
   (benchmark spec2 5))

+(def mapping1 (mapping spec1  (medium) 0 6))
+(def good-one (nth mapping1 10))
+(def foo (clojure.math.combinatorics/cartesian-product (vals good-one)))
+


test the match-all query

test the match-all query

--- test/bzzz/core_test.clj
+++ test/bzzz/core_test.clj
@@ -92,6 +92,12 @@
       (is (= 2 (:total ret)))
       (is (= (= (:_score (first (:hits ret))) (:_score (last (:hits ret))))) 10)))

+  (testing "search-match-all"
+    (let [ret (search :index test-index-name
+                      :query {:match-all {}})
+          num-docs (:docs (get (index-stat) test-index-name))]
+      (is (= (:total ret) num-docs))
+      (is (> num-docs 0))))

   (testing "search-no-html"
     (let [ret (search :index test-index-name


delaney.clj: added a partial orientation function; some renaming

--- clojure/org/gavrog/clojure/delaney.clj
+++ clojure/org/gavrog/clojure/delaney.clj
@@ -54,7 +54,15 @@

 (defn dim [ds] (dec (count (indices ds))))

-(defn pretty-traversal [ds indices seeds]
+(defn complete? [ds]
+  (and (every? (comp not nil?)
+               (for [i (indices ds), D (elements ds)]
+                 (s ds i D)))
+       (every? (comp not nil?)
+               (for [i (indices ds), j (indices ds), D (elements ds)]
+                 (v ds i j D)))))
+
+(defn traversal [ds indices seeds]
   (let [stacks (map #(vector % ()) (take 2 indices))
         queues (map #(vector % empty-queue) (drop 2 indices))
         as-root #(vector % :root %)
@@ -84,25 +92,24 @@

 (defn orbit-reps
   ([ds indices seeds]
-    (for [[D i] (pretty-traversal ds indices seeds) :when (= :root i)] D))
+    (for [[D i] (traversal ds indices seeds) :when (= :root i)] D))
   ([ds indices]
     (orbit-reps ds indices (elements ds))))

 (defn orbit [ds indices seed]
-  (distinct (for [[D i] (pretty-traversal ds indices [seed])] D)))
+  (distinct (for [[D i] (traversal ds indices [seed])] D)))

 (defn connected? [ds]
   (> 2 (count (orbit-reps ds (indices ds)))))

-(defn complete? [ds]
-  (and (every? (comp not nil?)
-               (for [i (indices ds), D (elements ds)]
-                 (s ds i D)))
-       (every? (comp not nil?)
-               (for [i (indices ds), j (indices ds), D (elements ds)]
-                 (v ds i j D)))))
-
-(defn- protocol [ds indices traversal]
+(defn partial-orientation [ds]
+  (loop [ori {}
+         [[Di i D] & xs] (traversal ds (indices ds) (elements ds))]
+    (cond (nil? i) ori
+          (or (nil? D) (ori D)) (recur ori xs)
+          :else (recur (assoc ori D (if (= :root i) 1 (- (ori Di)))) xs))))
+
+(defn- protocol [ds indices trav]
   (let [imap (zipmap indices (range (count indices)))
         ipairs (map vector indices (rest indices))
         spins (fn [D] (for [[i j] ipairs] (or (v ds i j D) 0)))
@@ -118,7 +125,7 @@
                            head (if (= i :root) [-1] [(imap i) Ei])
                            tail (if new? (spins D) [])]
                        (concat head [E] tail (step xs emap n)))))))]
-    (step traversal {} 1)))
+    (step trav {} 1)))

 (defn invariant [ds]
   (do
@@ -127,7 +134,7 @@
       (let [idcs (indices ds)]
         (reduce lexicographically-smallest
                 (for [D (elements ds)]
-                  (protocol ds idcs (pretty-traversal ds idcs [D]))))))))
+                  (protocol ds idcs (traversal ds idcs [D]))))))))

 (defn walk [ds D & idxs]
   "Returns the result of applying the D-symbol operators on ds with the
@@ -160,7 +167,7 @@
         :else (recur (walk ds E j i))))))

 (defn orbit-loopless? [ds indices D]
-  (empty? (for [[D i] (pretty-traversal ds indices [D])
+  (empty? (for [[D i] (traversal ds indices [D])
                 :when (and (not= i :root) (or (nil? D) (= D (s ds i D))))]
             D)))


replacing multiple prices on single elem

--- test-cljs/complico/test/prices.cljs
+++ test-cljs/complico/test/prices.cljs
@@ -89,3 +89,12 @@
     (prices/replace-price-on-elem!)
     (dom-helper/get-text-from-node)
     (confirm-text-was-set-to "£XXX trailing text should stay here")))
+
+(defn single-elem-with-multiple-prices []
+  (hipo/create [:div "£0 £0"]))
+
+(deftest should-replace-multiple-prices-on-elem
+  (-> (single-elem-with-multiple-prices)
+    (prices/replace-price-on-elem!)
+    (dom-helper/get-text-from-node)
+    (confirm-text-was-set-to "£XXX £XXX")))


migration regex

migration regex

--- iwaswhere-web/src/clj/iwaswhere_web/migrations.clj
+++ iwaswhere-web/src/clj/iwaswhere_web/migrations.clj
@@ -9,7 +9,7 @@
   (when-let [text (:md entry)]
     (let [
           tags (into [] (re-seq #"(?m)(?!^)#[\w-]+" text))
-          mentions (into [] (re-seq #"@\\w+" text))]
+          mentions (into [] (re-seq #"@\w+" text))]
       (merge entry
              {:tags     tags
               :mentions mentions}))))


Added preconditions to the launch-puppetdb fn

--- test/com/puppetlabs/puppetdb/testutils/repl.clj
+++ test/com/puppetlabs/puppetdb/testutils/repl.clj
@@ -14,6 +14,13 @@
    a map with config keypairs."
   [& {:keys [config config-overrides]
       :or {config "config.sample.ini"}}]
+  {:pre [(or (and (map? config-overrides)
+                  (every? map? (vals config-overrides))
+                  (every? (some-fn string? keyword?) (keys config-overrides))
+                  (every? (some-fn string? keyword?) (mapcat keys (vals config-overrides))))
+             (nil? config-overrides))
+         (string? config)
+         (fs/exists? config)]}
   (let [new-config-file (testutils/temp-file "config" ".ini")
         config-path (fs/absolute-path new-config-file)]
     (println "Writing current config to" config-path)


WIP - need to have this pushed, else cannot work on the weekend!

--- src/toggler/handler.clj
+++ src/toggler/handler.clj
@@ -17,6 +17,12 @@
 (def cfg (atom (read-default-config)))

 (def backup-counter (atom 0))
+
+(comment
+  The following "def" needs to be set by the user of the service
+  on deployment, and then that token needs to be included in the
+  headers of each request)
+(def secret "secret")

 (defn getoggle
   ([] @cfg)
@@ -52,9 +58,6 @@
    (spit (io/resource "config.json") (encode @cfg)))
   ([filename]
    (spit (str "custom-config/" filename ".json") (encode @cfg))))
-
-(defn modify-keys [f m]
-  (zipmap (map f (keys m)) (vals m)))

 (defresource status
   :allowed-methods [:get]


Don't skip-dev when getting deps in jar task.

Memoize: it's your friend!

--- src/leiningen/jar.clj
+++ src/leiningen/jar.clj
@@ -154,10 +154,11 @@
 well as the source .clj files. If project.clj contains a :main symbol, it will
 be used as the main-class for an executable jar."
   ([project jar-name]
-     (binding [compile/*silently* true]
+     (binding [compile/*silently* true
+               deps (memoize deps)]
        (when (zero? (compile/compile project))
          (let [jar-path (get-jar-filename project jar-name)
-               deps-fileset (deps project :skip-dev)]
+               deps-fileset (deps project)]
            (write-jar project jar-path (filespecs project deps-fileset))
            (println "Created" jar-path)
            jar-path))))


Fixup clobbering of `clojure.core/name`

Fixup clobbering of `clojure.core/name`

--- src/pani/clojure/core.clj
+++ src/pani/clojure/core.clj
@@ -1,4 +1,5 @@
 (ns pani.clojure.core
+  (:refer-clojure :exclude [name])
   (:require [clojure.core.async :refer [<! >! chan go go-loop]])
   (:import [com.firebase.client
             Firebase
@@ -17,7 +18,7 @@
     (clojure.walk/keywordize-keys v)
     v))

-;; Make a firebase object ouf the given URL
+;; Make a firebase object out the given URL
 ;;
 (defn root [url]
   "Makes a root reference for firebase"
@@ -29,8 +30,8 @@
 (defn walk-root [root korks]
   "Takes korks and reduces it to a root on which we can perform direct actions"
   (let [path (if (sequential? korks)
-               (clojure.string/join "/" (map name korks))
-               (name korks))]
+               (clojure.string/join "/" (map clojure.core/name korks))
+               (clojure.core/name korks))]
     (.child root path)))

 (defn name [root]


Fix tag-specific RSS feeds

Fix tag-specific RSS feeds

--- src/langnostic/core.clj
+++ src/langnostic/core.clj
@@ -76,8 +76,8 @@

   (GET "/feed" [] (atom-feed (posts/all-posts)))
   (GET "/feed/atom" [] (atom-feed (posts/all-posts)))
-  (GET "/feed/atom/:tag" [tag] (atom-feed (posts/find-by-tag (posts/all-posts))))
-  (GET "/feed/atom/by-tag/:tag" [tag] (atom-feed (posts/find-by-tag (posts/all-posts))))
+  (GET "/feed/atom/:tag" [tag] (atom-feed (posts/find-by-tag tag)))
+  (GET "/feed/atom/by-tag/:tag" [tag] (atom-feed (posts/find-by-tag tag)))

   (route/resources "/static/")
   (route/not-found error-404))


CMR-4581: Minor refactoring.

CMR-4581: Minor refactoring.

--- system-int-test/test/cmr/system_int_test/search/service/collection_service_search_test.clj
+++ system-int-test/test/cmr/system_int_test/search/service/collection_service_search_test.clj
@@ -39,7 +39,7 @@
   "Verify the collection JSON response associations related fields have the correct values"
   [coll has-formats serv-concept-ids var-concept-ids]
   (let [coll-with-extra-fields (merge coll {:has-formats has-formats
-                                            :has-variables (boolean (seq var-concept-ids))
+                                            :has-variables (some? (seq var-concept-ids))
                                             :services serv-concept-ids
                                             :variables var-concept-ids})
         {:keys [entry-title]} coll
@@ -57,7 +57,7 @@
   ([coll has-formats serv-concept-ids]
    (assert-collection-atom-json-result coll has-formats serv-concept-ids nil))
   ([coll has-formats serv-concept-ids var-concept-ids]
-   (assert-collection-atom-result coll has-formats (boolean (seq var-concept-ids)))
+   (assert-collection-atom-result coll has-formats (some? (seq var-concept-ids)))
    (assert-collection-json-result coll has-formats serv-concept-ids var-concept-ids)))

 (deftest collection-service-search-atom-json-test


fix bug with last commit

fix bug with last commit

--- cljs-admin/tourneybot_admin/core.cljs
+++ cljs-admin/tourneybot_admin/core.cljs
@@ -153,11 +153,13 @@
 ;;------------------------------------------------------------------------------

 (defn- fetch-tourney-state-success [new-state]
-  ;; TODO: make sure the version is the latest here
-  ;; merge the tournament state with the page state
-  (swap! page-state merge new-state)
-  ;; set the title tag
-  (aset js/document "title" (str (:title new-state) " - Admin")))
+  ;; FIXME: TOTAL HACK RIGHT HERE
+  (when-not (= "schedule" (:active-page @page-state))
+    ;; TODO: make sure the version is the latest here
+    ;; merge the tournament state with the page state
+    (swap! page-state merge new-state)
+    ;; set the title tag
+    (aset js/document "title" (str (:title new-state) " - Admin"))))

 (defn- fetch-tourney-state! []
   (fetch-json-as-cljs (tournament-state-url) fetch-tourney-state-success))
@@ -729,6 +731,11 @@
 ;; NOTE: this is a hack for the 2017 tournament
 ;;       make sure the game-ids are in descending order of how you want the tournament to run

+(defn- click-save-schedule []
+  (swap! page-state assoc :loading-modal-showing? true
+                          :loading-modal-txt saving-txt)
+  (save-state!))
+
 (defn- on-change-time-input [game-id js-evt]
   (let [new-txt (aget js-evt "currentTarget" "value")]
     (swap! page-state assoc-in [:games game-id :start-time] new-txt)))
@@ -749,10 +756,10 @@
         games-list (sort-by :game-id games-list)]
     [:div
       [:div.time-input-row
-        [:button.btn-primary-7f246 {:on-click (fn [_] (save-state!))} "Save Schedule"]]
+        [:button.btn-primary-7f246 {:on-click click-save-schedule} "Save Schedule"]]
       (map-indexed GameTimeInput games-list)
       [:div.time-input-row
-        [:button.btn-primary-7f246 {:on-click (fn [_] (save-state!))} "Save Schedule"]]]))
+        [:button.btn-primary-7f246 {:on-click click-save-schedule} "Save Schedule"]]]))

 ;;------------------------------------------------------------------------------
 ;; Games Body
@@ -1029,7 +1036,7 @@
     (condp = active-page
       "teams" (TeamsPage teams)
       "schedule" (SchedulePage games)
-      :else (GamesList teams games active-page simulated-scoreA simulated-scoreB))
+      (GamesList teams games active-page simulated-scoreA simulated-scoreB))
     (Footer)
     (when menu-showing?
       (LeftNavMenu))


Improves errors in json-schema/coerce

Improves errors in json-schema/coerce

--- umm-spec-lib/src/cmr/umm_spec/json_schema.clj
+++ umm-spec-lib/src/cmr/umm_spec/json_schema.clj
@@ -187,8 +187,8 @@
   ([x]
    (coerce umm-c-schema x))
   ([schema x]
-   (coerce schema (root-def schema) x))
-  ([schema definition x]
+   (coerce schema (root-def schema) [] x))
+  ([schema definition key-path x]
    (let [type-name (or (-> definition :$ref :type-name)
                        (:root schema))
          [schema definition] (resolve-$refs [schema definition])]
@@ -205,21 +205,22 @@
        "boolean" (= "true" x)

        ;; Return nil instead of empty vectors.
-       "array"   (when-let [coerced (seq (keep #(coerce schema (:items definition) %) x))]
+       "array"   (when-let [coerced (seq (keep #(coerce schema (:items definition) key-path %) x))]
                    (vec coerced))

        "object"  (let [ctor (record-ctor schema type-name)
                        kvs (for [[k v] x]
                              (when v
-                               (let [prop-definition (get-in definition [:properties k])]
-                                 [k (coerce schema prop-definition v)])))
+                               (if-let [prop-definition (get-in definition [:properties k])]
+                                 [k (coerce schema prop-definition (conj key-path k) v)]
+                                 [k v])))
                        m (into {} kvs)]
                    ;; Return nil instead of empty maps/records here.
                    (when (seq m)
                      (ctor m)))

        ;; Otherwise...
-       (throw (IllegalArgumentException. (str "Don't know how to coerce " definition " (" x ")")))))))
+       (throw (IllegalArgumentException. (str "Don't know how to coerce value " (pr-str x) " at key path " (pr-str (vec key-path)) " using JSON schema type [" (pr-str definition) "]")))))))

 (comment
   (coerce {:EntryTitle "This is a test"


[#200] Allow to change the sync API code without (refresh)

--- api/src/clojure/org/akvo/flow_api/endpoint/sync.clj
+++ api/src/clojure/org/akvo/flow_api/endpoint/sync.clj
@@ -26,27 +26,30 @@
 ;; TODO: Express parameter logic via spec?
 (def params-spec (s/keys :opt-un [::initial ::next ::cursor]))

+(defn changes [deps {:keys [alias instance-id params] :as req}]
+  (let [{:keys [initial cursor next]} (spec/validate-params params-spec params)]
+    (if (and initial cursor next)
+      (anomaly/bad-request "Invalid parameters" {})
+      (if (= "true" initial)
+        (let [db-name (get-db-name instance-id)
+              db-spec (-> deps :unilog-db :spec (assoc :db-name db-name))]
+          (response {:next-sync-url (next-sync-url (utils/get-api-root req)
+                                      alias
+                                      (unilog/get-cursor db-spec))}))
+        (if (and next cursor)
+          (let [db-name (get-db-name instance-id)
+                db-spec (-> deps :unilog-db :spec (assoc :db-name db-name))
+                offset (Long/parseLong cursor)]
+            (if (unilog/valid-offset? offset db-spec)
+              (let [changes (unilog/process-unilog-events offset db-spec instance-id (:remote-api deps))]
+                (response {:changes (select-keys changes [:form-instance-changed :form-instance-deleted :form-changed :form-deleted])
+                           :next-sync-url (next-sync-url (utils/get-api-root req) alias (:unilog-id changes))}))
+              (anomaly/bad-request "Invalid cursor" {})))
+          (anomaly/bad-request "Invalid parameters" {}))))))
+
 (defn endpoint* [deps]
-  (GET "/sync" {:keys [alias instance-id params] :as req}
-    (let [{:keys [initial cursor next]} (spec/validate-params params-spec params)]
-      (if (and initial cursor next)
-        (anomaly/bad-request "Invalid parameters" {})
-        (if (= "true" initial)
-          (let [db-name (get-db-name instance-id)
-                db-spec (-> deps :unilog-db :spec (assoc :db-name db-name))]
-            (response {:next-sync-url (next-sync-url (utils/get-api-root req)
-                                                     alias
-                                                     (unilog/get-cursor db-spec))}))
-          (if (and next cursor)
-            (let [db-name (get-db-name instance-id)
-                  db-spec (-> deps :unilog-db :spec (assoc :db-name db-name))
-                  offset (Long/parseLong cursor)]
-              (if (unilog/valid-offset? offset db-spec)
-                (let [changes (unilog/process-unilog-events offset db-spec instance-id (:remote-api deps))]
-                  (response {:changes (select-keys changes [:form-instance-changed :form-instance-deleted :form-changed :form-deleted])
-                             :next-sync-url (next-sync-url (utils/get-api-root req) alias (:unilog-id changes))}))
-                (anomaly/bad-request "Invalid cursor" {})))
-            (anomaly/bad-request "Invalid parameters" {})))))))
+  (GET "/sync" req
+    (#'changes deps req)))

 (defn endpoint [{:keys [akvo-flow-server-config] :as deps}]
   (-> (endpoint* deps)


do not play any beats when tab not in front

--- src/metronome/core.cljs
+++ src/metronome/core.cljs
@@ -44,19 +44,32 @@

 (defn sound [meter owner]
   (reify
+    om/IInitState
+    (init-state [_] {:hidden true
+                     :cb (fn [] (om/set-state! owner :hidden (.-hidden js/document)))})
+
     om/IDidMount
     (did-mount [_]
-               (let [sound-channel (om/get-state owner :sound-channel)]
+               (let [cb            (om/get-state owner :cb)
+                     sound-channel (om/get-state owner :sound-channel)]
+                 (cb)
+                 (.addEventListener js/document "visibilitychange" cb)
                  (go (loop []
                        (let [_     (<! sound-channel)
                              audio (if (zero? (:count @meter))
                                      (om/get-node owner "ding")
                                      (om/get-node owner "dong"))]
-                         (if (.-paused audio)
+                         (if (and
+                               (.-paused audio)
+                               (not (om/get-state owner :hidden)))
                            (.play audio)
                            (set! (.-currentTime audio) 0))
                          (om/transact! meter :count #(mod (inc %) 4))
                          (recur))))))
+
+    om/IWillUnmount
+    (will-unmount [_] (.removeEventListener js/document "visibilitychange" (om/get-state owner :cb)))
+
     om/IRender
     (render [_]
             (dom/div nil


Update more code to use rx bindings. Remove *max-load-records*!

--- pigpen-core/src/main/clojure/pigpen/local.clj
+++ pigpen-core/src/main/clojure/pigpen/local.clj
@@ -30,6 +30,7 @@
             [rx.lang.clojure.blocking :as rx-blocking]
             [pigpen.rx.extensions.core :refer [multicast]]
             [pigpen.extensions.io :refer [list-files]]
+            [pigpen.extensions.core :refer [zipv]]
             [pigpen.pig :as pig])
   (:import [pigpen PigPenException]
            [org.apache.pig EvalFunc]
@@ -93,9 +94,9 @@
                           v)
                         d))]
     (->> data'
-         (graph->local command data')
-         (rx/finally
-           (println id "stop")))))
+      (graph->local command data')
+      (rx/finally
+        (println id "stop")))))

 (defn ^:private find-next-o [observable-lookup]
   (fn [command]
@@ -121,9 +122,9 @@

 (defn dereference-all ^Observable [^Observable o]
   (rx/map #(->> %
-                (map (fn [[k v]]
-                       [k (dereference v)]))
-                (into {}))
+             (map (fn [[k v]]
+                    [k (dereference v)]))
+             (into {}))
           o))

 (defn observable->clj [^Observable o]
@@ -132,16 +133,16 @@
 (defn observable->data
   ^Observable [^Observable o]
   (->> o
-       (dereference-all)
-       (rx/map (comp 'value pig/thaw-values))
-       observable->clj))
+    (dereference-all)
+    (rx/map (comp 'value pig/thaw-values))
+    observable->clj))

 (defn observable->raw-data
   ^Observable [^Observable o]
   (->> o
-       (dereference-all)
-       (rx/map pig/thaw-anything)
-       observable->clj))
+    (dereference-all)
+    (rx/map pig/thaw-anything)
+    observable->clj))

 ;; ********** Util **********

@@ -172,39 +173,32 @@
   (write [this writer value])
   (close-writer [this writer]))

-;; unsubscribe doesn't seem to work with this version of rx
-;; This caps the maximum number of records read from a file/stream
-(def ^:dynamic *max-load-records* nil)
-
 (defmethod graph->local :load
   [{:keys [location], :as command} _]
   (let [local-loader (load command)
         ^Observable o (->> (rx/observable*
-                             (fn [^Subscriber o]
+                             (fn [^Subscriber s]
                                (let [cancel (atom false)
                                      read-count (atom 0)]
-                                 (.add o
-                                       (reify Subscription
-                                         (unsubscribe [this]
-                                           (reset! cancel true))))
+                                 (.add s
+                                   (reify Subscription
+                                     (unsubscribe [this]
+                                       (reset! cancel true))))
                                  (future
                                    (try
                                      (println "Start reading from " location)
                                      (doseq [file (locations local-loader)
-                                             :while (not @cancel)
-                                             :while (< @read-count (or *max-load-records* Double/POSITIVE_INFINITY))]
+                                             :while (not @cancel)]
                                        (let [reader (init-reader local-loader file)]
                                          (doseq [value (read local-loader reader)
-                                                 :while (not @cancel)
-                                                 :while (< @read-count (or *max-load-records* Double/POSITIVE_INFINITY))]
+                                                 :while (not @cancel)]
                                            (swap! read-count inc)
-                                           (.onNext o value))
+                                           (rx/on-next s value))
                                          (close-reader local-loader reader)))
-                                     (.onCompleted o)
-                                     (catch Exception e (.onError o e))))
-                                 )))
-                           (rx/finally
-                             (println "Stop reading from " location)))]
+                                     (rx/on-completed s)
+                                     (catch Exception e (rx/on-error s e)))))))
+                        (rx/finally
+                          (println "Stop reading from " location)))]
     (.observeOn o (Schedulers/io))))

 (defmethod graph->local :store
@@ -217,8 +211,8 @@
       first
       (dereference-all)
       (rx/map (fn [value]
-          (write local-storage @writer value)
-          value))
+                (write local-storage @writer value)
+                value))
       (rx/finally
         (when (realized? writer)
           (println "Stop writing to " location)
@@ -302,11 +296,11 @@
     (rx/flatmap
       (fn [values]
         (->> projections
-             (map (fn [p]
-                    (binding [udf-scope udf-scope']
-                      (graph->local p values))))
-             (cross-product)
-             (rx/seq->o)))
+          (map (fn [p]
+                 (binding [udf-scope udf-scope']
+                   (graph->local p values))))
+          (cross-product)
+          (rx/seq->o)))
       data )))

 (defn ^:private pig-compare [[key order & sort-keys] x y]
@@ -320,130 +314,109 @@
         :desc (int (- r))))))

 (defmethod graph->local :order [{:keys [sort-keys]} data]
-  (let [^Observable data (first data)]
-    (-> data
-      (.toSortedList (rx-interop/fn* (partial pig-compare sort-keys)))
-      (.flatMap (rx-interop/fn* rx/seq->o)))))
+  (->> (first data)
+    (rx/sort (partial pig-compare sort-keys))))

 (defmethod graph->local :rank [{:keys [sort-keys]} data]
-  (let [^Observable data (first data)]
-    (if (not-empty sort-keys)
-      (-> data
-        (.toSortedList (rx-interop/fn* (partial pig-compare sort-keys)))
-        (.flatMap (rx-interop/fn* #(rx/seq->o (map-indexed (fn [i v] (assoc v '$0 i)) %)))))
-      (let [i (atom -1)]
-        (->> data
-             (rx/map (fn [v] (assoc v '$0 (swap! i inc)))))))))
+  (cond->> (first data)
+    (not-empty sort-keys) (rx/sort (partial pig-compare sort-keys))
+    true                  (rx/map-indexed (fn [i v] (assoc v '$0 i)))))

 ;; ********** Filter **********

 (defmethod graph->local :filter [{:keys [code]} data]
-  (let [^Observable data (first data)]
-    (rx/filter (fn [values]
-                 (eval-code code values))
-               data)))
+  (rx/filter (partial eval-code code) (first data)))

 (defmethod graph->local :filter-native [{:keys [fields expr]} data]
-  (if-not expr (first data)
-    (let [^Observable data (first data)
-          f (eval `(fn [{:syms ~fields}] ~expr))]
-      (rx/filter (fn [values] (f values))
-                 data))))
+  (if-not expr
+    (first data)
+    (let [f (eval `(fn [{:syms ~fields}] ~expr))]
+      (rx/filter f (first data)))))

 (defmethod graph->local :distinct [_ data]
-  (let [^Observable data (first data)
-        seen (atom [false #{}])]
-    (rx/filter (fn [values]
-                 (let [[c _] (swap! seen (fn [[_ s]] [(contains? s values)
-                                                      (conj s values)]))]
-                   (not c)))
-               data)))
+  (rx/distinct (first data)))

 (defmethod graph->local :limit [{:keys [n]} data]
-  (let [^Observable data (first data)]
-    (rx/take n data)))
+  (rx/take n (first data)))

 (defmethod graph->local :sample [{:keys [p]} data]
-  (let [^Observable data (first data)]
-    (rx/filter (fn [values] (< (rand) p))
-               data)))
+  (rx/filter (fn [_] (< (rand) p)) (first data)))

 ;; ********** Join **********

 (defmethod graph->local :union [_ ^List data]
   (apply rx/merge data))

+;; TODO break this up. This is way too big
 (defn ^:private graph->local-group [{:keys [ancestors keys join-types fields]} data]
-  (->
-    ^List
-    (mapv (fn [a k ^Observable d j]
-            (.flatMap d (rx-interop/fn [values]
-                          ;; This selects all of the fields that are in this relation
-                          (let [^Iterable result
-                                (for [[[r] v :as f] (next fields)
-                                      :when (= r a)]
-                                  {:values (pig/tuple (values v))
-                                   ;; This is to emulate the way pig handles nils
-                                   ;; This changes a nil values into a relation specific nil value
-                                   :key (mapv #(or (values %) (keyword (name a) "nil")) k)
-                                   :relation f
-                                   :required (= j :required)})]
-                            (rx/seq->o result)))))
-         ancestors keys data join-types)
-    (Observable/merge)
-    (.groupBy (rx-interop/fn* :key))
-    (.flatMap (rx-interop/fn [^Observable o]
-                (-> ^Observable o
-                  (.groupBy (rx-interop/fn* :relation))
-                  (.flatMap (rx-interop/fn [%]
-                              (-> ^Observable %
-                                   (.toList)
-                                   (.map (rx-interop/fn [v]
-                                             [(if (keyword? (.getKey ^GroupedObservable %))
-                                                nil
-                                                (.getKey ^GroupedObservable %))
-                                              (apply pig/bag (mapv :values v))])))))
-                  ;; Start with the group key. If it's a single value, flatten it.
-                  ;; Keywords are the fake nils we put in earlier
-                  (.reduce {(first fields) (let [k (.getKey ^GroupedObservable o)
-                                                 k (if (= 1 (count k)) (first k) k)
-                                                 k (if (keyword? k) nil k)]
-                                             k)}
-                    (rx-interop/fn [values [k v]]
-                      (assoc values k v))))))
+  (->>
+    (zipv [a ancestors
+           k keys
+           d data
+           j join-types]
+      (->> d
+        (rx/flatmap
+          (fn [values]
+            ;; This selects all of the fields that are in this relation
+            (rx/seq->o
+              (for [[[r] v :as f] (next fields)
+                    :when (= r a)]
+                {:values (pig/tuple (values v))
+                 ;; This is to emulate the way pig handles nils
+                 ;; This changes a nil values into a relation specific nil value
+                 :key (mapv #(or (values %) (keyword (name a) "nil")) k)
+                 :relation f
+                 :required (= j :required)}))))))
+    (apply rx/merge)
+    (rx/group-by :key)
+    (rx/flatmap (fn [[k' o]]
+                  (->> o
+                    (rx/group-by :relation)
+                    (rx/flatmap (fn [[r o']]
+                                  (->> o'
+                                    (rx/into [])
+                                    (rx/map (fn [v]
+                                              [(if (keyword? r) nil r)
+                                               (apply pig/bag (mapv :values v))])))))
+                    (rx/reduce
+                      (fn [values [k v]]
+                        (assoc values k v))
+                      ;; Start with the group key. If it's a single value, flatten it.
+                      ;; Keywords are the fake nils we put in earlier
+                      {(first fields) (let [k k'
+                                            k (if (= 1 (count k)) (first k) k)
+                                            k (if (keyword? k) nil k)]
+                                        k)}))))
     ;; TODO This is a bad way to do inner groupings
-    (.filter (rx-interop/fn [g]
-               (every? identity
-                 (map (fn [a [k] j]
-                        (or (= j :optional)
-                            (contains? g [[a] k])))
-                      ancestors
-                      keys
-                      join-types))))))
+    (rx/filter (fn [g]
+                 (every? identity
+                         (zipv [a ancestors
+                                [k] keys
+                                j join-types]
+                           (or (= j :optional)
+                               (contains? g [[a] k]))))))))

 (defn ^:private graph->local-group-all [{:keys [fields]} data]
-  (->
-    ^List
-    (mapv (fn [[r v] ^Observable d]
-            (.map d (rx-interop/fn [values]
-                      ;; TODO clean up pig dereferencing
-                      (let [v' (v values)]
-                        {:values (if (instance? Tuple v') v' (pig/tuple v'))
-                         :relation [r v]}))))
-         (next fields) data)
-    (Observable/merge)
-    (.groupBy (rx-interop/fn* :relation))
-    (.flatMap (rx-interop/fn [^Observable %]
-                (-> %
-                    (.toList)
-                    (.map (rx-interop/fn [v]
-                            [(.getKey ^GroupedObservable %)
-                             (apply pig/bag (mapv :values v))])))))
-    (.reduce {(first fields) nil}
-      (rx-interop/fn [values [k v]]
-        (assoc values k v)))
-    (.filter (rx-interop/fn [v]
-               (< 1 (count v))))))
+  (->>
+    (zipv [[r v] (next fields)
+           d data]
+      (->> d
+        (rx/map (fn [values]
+                  ;; TODO clean up pig dereferencing
+                  (let [v' (v values)]
+                    {:values (if (instance? Tuple v') v' (pig/tuple v'))
+                     :relation [r v]})))))
+    (apply rx/merge)
+    (rx/group-by :relation)
+    (rx/flatmap (fn [[r o]]
+                  (->> o
+                    (rx/into [])
+                    (rx/map (fn [v]
+                              [r (apply pig/bag (mapv :values v))])))))
+    (rx/reduce (fn [values [k v]]
+                 (assoc values k v))
+               {(first fields) nil})
+    (rx/filter (fn [v] (< 1 (count v))))))

 (defmethod graph->local :group [{:keys [keys] :as command} data]
   (if (= keys [:pigpen.raw/group-all])
@@ -451,43 +424,43 @@
     (graph->local-group command data)))

 (defmethod graph->local :join [{:keys [ancestors keys join-types fields]} data]
-  (->
-    ^List
-    (mapv (fn [a k ^Observable d]
-            (.map d (rx-interop/fn [values]
-                      ;; This selects all of the fields that are in this relation
-                      {:values (into {} (for [[[r v] :as f] fields
-                                              :when (= r a)]
-                                          [f (values v)]))
-                       ;; This is to emulate the way pig handles nils
-                       ;; This changes a nil values into a relation specific nil value
-                       :key (mapv #(or (values %) (keyword (name a) "nil")) k)
-                       :relation a})))
-         ancestors keys data)
-    (Observable/merge)
-    (.groupBy (rx-interop/fn* :key))
-    (.flatMap (rx-interop/fn [^Observable key-grouping]
-                (-> key-grouping
-                  (.groupBy (rx-interop/fn* :relation))
-                  (.flatMap (rx-interop/fn [%]
-                              (-> ^Observable %
-                                  (.toList)
-                                  (.map (rx-interop/fn [v]
-                                          [(.getKey ^GroupedObservable %)
-                                           (map :values v)])))))
-                  (.reduce (->>
-                             ;; This seeds the inner/outer joins, by placing a
-                             ;; defualt empty value for inner joins
-                             (zipmap ancestors join-types)
-                             (filter (fn [[_ j]] (= j :required)))
-                             (map (fn [[a _]] [a []]))
-                             (into {}))
-                           (rx-interop/fn [values [k v]]
-                             (assoc values k v)))
-                  (.flatMap (rx-interop/fn [relation-grouping]
-                              (rx/seq->o (cross-product (vals relation-grouping))))))))))
+  (->>
+    (zipv [a ancestors
+           k keys
+           d data]
+      (->> d
+        (rx/map (fn [values]
+                  ;; This selects all of the fields that are in this relation
+                  {:values (into {} (for [[[r v] :as f] fields
+                                          :when (= r a)]
+                                      [f (values v)]))
+                   ;; This is to emulate the way pig handles nils
+                   ;; This changes a nil values into a relation specific nil value
+                   :key (mapv #(or (values %) (keyword (name a) "nil")) k)
+                   :relation a}))))
+    (apply rx/merge)
+    (rx/group-by :key)
+    (rx/flatmap (fn [[_ key-grouping]]
+                  (->> key-grouping
+                    (rx/group-by :relation)
+                    (rx/flatmap (fn [[k o]]
+                                  (->> o
+                                    (rx/into [])
+                                    (rx/map (fn [v]
+                                              [k (map :values v)])))))
+                    (rx/reduce (fn [values [k v]]
+                                 (assoc values k v))
+                               (->>
+                                 ;; This seeds the inner/outer joins, by placing a
+                                 ;; defualt empty value for inner joins
+                                 (zipmap ancestors join-types)
+                                 (filter (fn [[_ j]] (= j :required)))
+                                 (map (fn [[a _]] [a []]))
+                                 (into {})))
+                    (rx/flatmap (fn [relation-grouping]
+                                  (rx/seq->o (cross-product (vals relation-grouping))))))))))

 ;; ********** Script **********

 (defmethod graph->local :script [_ data]
-  (Observable/merge ^List (vec data)))
+  (apply rx/merge (vec data)))


Add dev task for building library contiuously

--- build.boot
+++ build.boot
@@ -17,3 +17,8 @@
        :url "https://github.com/AdamFrey/boot-asset-fingerprint"
        :scm {:url "https://github.com/AdamFrey/boot-asset-fingerprint"}
        :license {"EPL" "http://www.eclipse.org/legal/epl-v10.html"}})
+
+(deftask dev []
+  (comp
+    (watch)
+    (build-jar)))


All working but not composeable

All working but not composeable

--- build.boot
+++ build.boot
@@ -1,66 +1,65 @@
-(set-env!
- :source-paths #{"src" "resources"}
- :asset-paths #{"assets"}
- :dependencies '[[adzerk/boot-cljs "1.7.48-5" :scope "test"]
-                 [adzerk/boot-cljs-repl "0.3.0" :scope "test"]
-                 [adzerk/boot-reload "0.4.0" :scope "test"]
-                 [deraen/boot-less "0.5.0"]
-                 [org.clojure/clojure "1.8.0"]
-                 [org.clojure/clojurescript "1.7.170"]
-                 [org.clojure/tools.nrepl "0.2.12"]
-                 [com.cemerick/piggieback "0.2.1"  :scope "test"]
-                 [weasel                  "0.7.0"  :scope "test"]])
+(deftask server
+  "Develop the server backend"
+  []
+  (set-env! :source-paths #{"src" "resources" "dev"}
+            :dependencies '[[aleph "0.4.1-beta3"]
+                            [bidi "1.24.0"]
+                            [hiccup "1.0.5"]
+                            [org.omcljs/om "1.0.0-alpha28"]
+                            [yada "1.1.0-20160126.014942-13"]

-(require '[adzerk.boot-cljs :refer [cljs]]
-         '[adzerk.boot-cljs-repl :refer [cljs-repl start-repl]]
-         '[adzerk.boot-reload    :refer [reload]]
-         '[clojure.java.shell :as sh]
-         '[deraen.boot-less :refer [less]])
+                            [com.stuartsierra/component "0.3.1"]
+                            [reloaded.repl "0.2.1"]
+                            [prismatic/schema "1.0.4"]
+                            [org.clojure/core.async "0.2.374"]
+                            [org.clojure/tools.reader "0.10.0"]

-(deftask server
-  "Override"
-  []
-  (set-env!
-   :source-paths #(conj % "dev")
-   :dependencies '[;; Infrastructure
-                   [com.stuartsierra/component "0.3.1"]
-                   [reloaded.repl "0.2.1"]
-                   [prismatic/schema "1.0.4"]
-                   [org.clojure/core.async "0.2.374"]
-                   [org.clojure/tools.reader "0.10.0"]
+                            [org.clojure/tools.logging "0.3.1"]
+                            [org.slf4j/jcl-over-slf4j "1.7.13"]
+                            [org.slf4j/jul-to-slf4j "1.7.13"]
+                            [org.slf4j/log4j-over-slf4j "1.7.13"]
+                            [ch.qos.logback/logback-classic "1.1.3" :exclusions [org.slf4j/slf4j-api]]

-                   ;; Logging
-                   [org.clojure/tools.logging "0.3.1"]
-                   [org.slf4j/jcl-over-slf4j "1.7.13"]
-                   [org.slf4j/jul-to-slf4j "1.7.13"]
-                   [org.slf4j/log4j-over-slf4j "1.7.13"]
-                   [ch.qos.logback/logback-classic "1.1.3" :exclusions [org.slf4j/slf4j-api]]
-
-                   ;; Web
-                   [aleph "0.4.1-beta3"]
-                   [bidi "1.24.0"]
-                   [hiccup "1.0.5"]
-                   [org.omcljs/om "1.0.0-alpha28"]
-                   [yada "1.1.0-20160126.014942-13"]])
-  (repl :init-ns 'user :server true))
+                            [org.clojure/tools.namespace "0.2.10"]])
+  (repl :init-ns 'user))

 (deftask frontend
   "Simple alias to run frontend application"
   []
   (set-env! :target-path "target/dev"
-            :source-paths #(conj % "sass")
-            :dependencies #(concat % '[[org.omcljs/om "1.0.0-alpha28"]
-                                       [org.clojure/core.async "0.2.374"]]))
-  (comp
-   (watch)
-   (speak)
-   (less :source-map true)
-   (reload :on-jsload 'edge.main/init)
-   (cljs-repl :nrepl-opts {:init-ns 'user})
-   (cljs :ids #{"edge"} :optimizations :none)
-   (target :dir #{"target/dev"})))
+            :source-paths #{"sass" "src"}
+            :dependencies '[[org.omcljs/om "1.0.0-alpha28"]
+                            [adzerk/boot-cljs "1.7.48-5" :scope "test"]
+                            [adzerk/boot-cljs-repl "0.3.0" :scope "test"]
+                            [adzerk/boot-reload "0.4.0" :scope "test"]
+                            [deraen/boot-less "0.5.0"]
+                            [org.clojure/clojure "1.8.0"]
+                            [org.clojure/clojurescript "1.7.170"]
+                            [org.clojure/tools.nrepl "0.2.12"]
+                            [org.clojure/core.async "0.2.374"]
+                            [com.cemerick/piggieback "0.2.1" :scope "test"]
+                            [weasel "0.7.0" :scope "test"]])

-(deftask build-frontend
+  (require '[adzerk.boot-cljs :refer [cljs]]
+           '[adzerk.boot-cljs-repl :refer [cljs-repl start-repl]]
+           '[adzerk.boot-reload :refer [reload]]
+           '[boot.pod :as pod]
+           '[clojure.java.shell :as sh]
+           '[deraen.boot-less :refer [less]])
+
+  (let [reload (resolve 'adzerk.boot-reload/reload)
+        cljs-repl (resolve 'adzerk.boot-cljs-repl/cljs-repl)
+        cljs (resolve 'adzerk.boot-cljs/cljs)]
+    (comp
+     (watch)
+     (speak)
+     (less :source-map true)
+     (reload :on-jsload 'edge.main/init)
+     (cljs-repl :nrepl-opts {:init-ns 'user})
+     (cljs :ids #{"edge"} :optimizations :none)
+     (target :dir #{"target/dev"}))))
+
+#_(deftask build-frontend
  "Compiles frontend application"
  []
  (set-env! :target-path "target/prod")


rm license

rm license

--- build.boot
+++ build.boot
@@ -31,9 +31,7 @@
  pom {:project 'github-changelog
       :version +version+
       :description "GitHub changelog"
-      :url "https://github.com/raszi/github-changelog"
-      :license {:name "MIT"
-                :url  "http://choosealicense.com/licenses/mit/"}}
+      :url "https://github.com/raszi/github-changelog"}
  jar {:main 'github-changelog.cli}
  aot {:all true})


drop the 2

drop the 2

--- build.boot
+++ build.boot
@@ -10,11 +10,11 @@
 (bootlaces! +version+)

 (task-options!
- pom {:project     'nha/boot-uglify2
+ pom {:project     'nha/boot-uglify
       :version     +version+
       :description "Boot task to uglify js code using UglifyJS2"
       :url         "https://github.com/nha/boot-uglify2"
-      :scm         {:url "https://github.com/nha/boot-uglify2"}
+      :scm         {:url "https://github.com/nha/boot-uglify"}
       :license     {"Eclipse Public License" "http://www.eclipse.org/legal/epl-v10.html"}})

 (deftask dev


Update re-console for parinfer fixe, closes #192

--- build.boot
+++ build.boot
@@ -22,7 +22,7 @@
                  [re-frame                    "0.5.0"]
                  [replumb/replumb             "0.2.2-SNAPSHOT"]
                  [cljsjs/highlight            "8.4-0"]
-                 [re-console                  "0.1.2-SNAPSHOT"]
+                 [re-console                  "0.1.2"]
                  [re-com                      "0.7.0-alpha2"]
                  [cljs-ajax                   "0.5.1"]
                  [hickory                     "0.5.4"]


Implements insert / update

Implements insert / update

--- src/onyx/plugin/sql.clj
+++ src/onyx/plugin/sql.clj
@@ -76,10 +76,6 @@
      {:sql/lower-bound n-min
       :sql/upper-bound n-max}]))

-
-(defn update-partition [content acked]
-  (dissoc content acked))
-
 (defn inject-partition-keys
   [table-partitioner event lifecycle]
   {:sql/table-partitioner table-partitioner})
@@ -105,11 +101,9 @@

   p/Checkpointed
   (checkpoint [this]
-    (println "checkpointing, offset = " (pr-str @offset))
     @offset)

   (recover! [this replica-version checkpoint]
-    (println "partitioner recovering, checkpoint: " (pr-str checkpoint))
     (vreset! completed? false)
     (if (nil? checkpoint)
       (do
@@ -127,7 +121,6 @@
     (if-let [seg (first @rst)]
       (do (vswap! rst rest)
           (vswap! offset inc)
-          (println "emitting partition, offset = " @offset ", seg = " (pr-str seg))
           seg)
       (do (vreset! completed? true)
           nil))))
@@ -158,12 +151,8 @@
                  :from [table]
                  :where [:and
                          [:>= id low]
-                         [:<= id high]]}
-
-        results (jdbc/query pool (sql/format sql-map))]
-    (println "emitting results: " (pr-str results))
-    results
-    ))
+                         [:<= id high]]}]
+    (jdbc/query pool (sql/format sql-map))))

 (defrecord SqlWriter [pool table]
   p/Plugin
@@ -196,7 +185,7 @@
     (doseq [msg (mapcat :leaves (:tree results))]
       (jdbc/with-db-transaction
         [conn pool]
-        (doseq [row (:rows (:message msg))]
+        (doseq [row (:rows msg)]
           (jdbc/insert! conn table row))))
     true))

@@ -234,12 +223,12 @@
     true)

   (write-batch
-    [_ {:keys [onyx.core/results onyx.core/task-map sql/pool]} replica _]
+    [_ {:keys [onyx.core/results]} replica _]
     (doseq [msg (mapcat :leaves (:tree results))]
       (jdbc/with-db-transaction
         [conn pool]
-        (doseq [row (:rows (:message msg))]
-          (jdbc/update! conn (:sql/table task-map) row (sql-dsl/where (:where (:message msg)))))))
+        (doseq [row (:rows msg)]
+          (jdbc/update! conn table row (sql-dsl/where (:where msg))))))
     true))

 (defn upsert-rows [pipeline-data]


Adjusted CSS class.

Adjusted CSS class.

--- web/src/sound_effector/views/sound_effect.clj
+++ web/src/sound_effector/views/sound_effect.clj
@@ -24,11 +24,11 @@
                   (map
                     (fn [sound-effect]
                       [:div {:class "row"}
-                       [:div {:class "col-md-11 col-sm-11 col-xs-11"}
+                       [:div {:class "col-md-11 col-sm-10 col-xs-10"}
                         [:h2 (h (:title sound-effect))]
-                        [:p
+                        [:p {:class "text-left"}
                          [:a {:href (:url sound-effect)} (h (:url sound-effect))]]]
-                       [:div {:class "col-md-1 col-sm-1 col-xs-1"}
+                       [:div {:class "col-md-1 col-sm-2 col-xs-2"}
                         (form/form-to [:delete (str "/sound-effects/" (:id sound-effect))]
                                       (anti-forgery/anti-forgery-field)
                                       [:button {:type "submit" :class "btn btn-default"}


Fix issue with "Compile by" appearing twice in cache

--- planck-cljs/src/planck/repl.cljs
+++ planck-cljs/src/planck/repl.cljs
@@ -1053,10 +1053,7 @@
       (let [source (:source x)
             [file-namespace relpath] (extract-cache-metadata-mem source-text)
             cache (when file-namespace (get-namespace file-namespace))]
-        (write-cache relpath
-          file-namespace
-          (str (form-compiled-by-string (form-build-affecting-options)) "\n" source)
-          cache)))
+        (write-cache relpath file-namespace source cache)))
     (cb {:value nil})))

 (defn- process-execute-source


[#1858] Add core/merge-datasets transformation test

--- backend/test/akvo/lumen/lib/transformation_test.clj
+++ backend/test/akvo/lumen/lib/transformation_test.clj
@@ -483,6 +483,47 @@
           (is (= (:name (nth new-columns 0)) (get after "title")))
           (is (= "d1" (get after "columnName"))))))))

+(defn- replace-column
+  "utility to have same column in other generated dataset"
+  [origin-data target-data column-idx]
+  (-> target-data
+      (assoc-in [:columns column-idx]  (nth (:columns origin-data) column-idx))
+      (assoc :rows (map #(assoc-in % [column-idx] (nth %2 column-idx)) (:rows target-data) (:rows origin-data)))))
+
+(deftest ^:functional merge-datasets-test
+  (let [origin-data (i-c/sample-imported-dataset [:text :number] 2)
+        target-data (replace-column origin-data (i-c/sample-imported-dataset [:text :number :number :text] 2) 0)
+        origin-dataset-id (import-file *tenant-conn* *error-tracker*
+                                       {:dataset-name "origin-dataset"
+                                        :kind "clj"
+                                        :data origin-data})
+        target-dataset-id (import-file *tenant-conn* *error-tracker*
+                                       {:dataset-name "origin-dataset"
+                                        :kind "clj"
+                                        :data target-data})
+        apply-transformation (partial tf/apply {:tenant-conn *tenant-conn*} origin-dataset-id)]
+    (let [[tag _ :as res] (apply-transformation {:type :transformation
+                                                 :transformation {"op" "core/merge-datasets",
+                                                                  "args"
+                                                                  {"source"
+                                                                   {"datasetId" target-dataset-id,
+                                                                    "mergeColumn" "c0",
+                                                                    "aggregationColumn" nil,
+                                                                    "aggregationDirection" "DESC",
+                                                                    "mergeColumns" ["c3" "c2" "c1"]},
+                                                                   "target" {"mergeColumn" "c0"}}}})]
+      (is (= ::lib/ok tag))
+      (let [{:keys [columns transformations table-name]} (latest-dataset-version-by-dataset-id *tenant-conn* {:dataset-id origin-dataset-id})
+            data-db (get-data *tenant-conn* {:table-name table-name})]
+        (is (=  (map (comp name :type) (apply conj
+                                              (:columns origin-data)
+                                              (next (:columns target-data))))
+                (map #(get % "type") columns)))
+        (is (= '(:c0 :c1 :d1 :d2 :d3) (map #(keyword (get % "columnName")) columns)))
+        (is (= 2 (count data-db)))
+        (is (= (map (comp :value first) (:rows origin-data)) (map :c0 data-db)))
+        (is (= (map (comp :value last) (:rows target-data)) (map :d3 data-db)))))))
+
 (deftest ^:functional rename-column-test
   (let [dataset-id (import-file *tenant-conn* *error-tracker* {:has-column-headers? true
                                                                :file "dates.csv"})


Minor require changes in tool system.

Minor require changes in tool system.

--- tool/vault/system.clj
+++ tool/vault/system.clj
@@ -2,22 +2,19 @@
   (:require
     (clj-time
       [core :as time]
-      [format :as ftime])
+      [format :as timef])
     [clojure.java.io :as io]
     [clojure.repl :refer :all]
     [clojure.string :as str]
     [clojure.tools.namespace.repl :refer [refresh]]
     [environ.core :refer [env]]
-    (puget
-      [data]
-      [printer :as puget])
+    [puget.printer :as puget]
     [vault.blob.core :as blob]
-    vault.blob.store
     [vault.data.core :as data]
     [vault.entity.core :as entity]
     [vault.index.core :as index]
     (vault.tool
-      [config :as config])))
+      [config :as conf])))

 ;; GENERAL CONFIG
@@ -32,10 +29,10 @@
 ;; VAULT SYSTEM

 (def config
-  (config/load-configs (env :vault-config "dev/config")))
+  (conf/load-configs (env :vault-config "dev/config")))

 (def blobs
-  (config/select-blob-store
+  (conf/select-blob-store
     (:blob-stores config)
     :default))


Handle verbosity-related options as early as possible in the bootstrap process

--- boot/core/src/boot/main.clj
+++ boot/core/src/boot/main.clj
@@ -104,11 +104,21 @@
                             :else            [nil args*])
         boot?             (contains? #{nil bootscript} arg0)
         [errs opts args]  (if-not boot? [nil {} args] (parse-cli-opts args))
-        arg0              (if (:no-boot-script opts) nil arg0)]
+        arg0              (if (:no-boot-script opts) nil arg0)
+        verbosity         (if (:quiet opts)
+                            (* -1 @util/*verbosity*)
+                            (or (:verbose opts) 0))]

     (when (seq errs)
       (util/exit-error
         (println (apply str (interpose "\n" errs)))))
+
+    (when (:no-colors opts)
+      (reset! util/*colorize?* false))
+    (swap! util/*verbosity* + verbosity)
+    (pod/with-eval-in worker-pod
+      (require '[boot.util :as util])
+      (swap! util/*verbosity* + ~verbosity))

     (binding [*out*               (util/auto-flush *out*)
               *err*               (util/auto-flush *err*)
@@ -116,6 +126,7 @@
               core/*boot-script*  arg0
               core/*boot-version* (boot.App/getBootVersion)
               core/*app-version*  (boot.App/getVersion)]
+
       (util/exit-ok
         (let [userscript  (util/with-let [x (-> (System/getProperty "user.home")
                                                 (io/file ".profile.boot")
@@ -125,9 +136,6 @@
                               (util/warn "** Please use $BOOT_HOME/profile.boot instead.\n")
                               (util/warn "** See: https://github.com/boot-clj/boot/issues/157\n")))
               userscript  (or userscript (exists? (io/file (App/getBootDir) "profile.boot")))
-              verbosity   (if (:quiet opts)
-                            (* -1 @util/*verbosity*)
-                            (or (:verbose opts) 0))
               profile?    (not (:no-profile opts))
               bootforms   (some->> arg0 slurp util/read-string-all)
               userforms   (when profile?
@@ -139,13 +147,6 @@
               scriptforms (emit boot? args userforms bootforms import-ns)
               scriptstr   (binding [*print-meta* true]
                             (str (string/join "\n\n" (map pr-str scriptforms)) "\n"))]
-
-          (when (:no-colors opts)
-            (reset! util/*colorize?* false))
-          (swap! util/*verbosity* + verbosity)
-          (pod/with-eval-in worker-pod
-            (require '[boot.util :as util])
-            (swap! util/*verbosity* + ~verbosity))

           (when (:boot-script opts) (util/exit-ok (print scriptstr)))


More words.

More words.

--- src/re_demo/basics.cljs
+++ src/re_demo/basics.cljs
@@ -553,6 +553,10 @@
                    :gap      "10px"
                    :style    {:font-size "small"}
                    :children [[component-title "[inline-tooltip ... ]"]
+                              [:p {:style {:width "400px" }} "An inline tooltip that doesn't actually hover over anything.
+                              It's actually embeded in the markup.
+                               Useful for permanetly pointing to things that are a problem, without the need for
+                               something hovering over other widgets and possibly obscuring them."]
                               [args-table inline-tooltip-args-desc]]]
                   [v-box
                    :children [[component-title "Demo"]


Match docstring spacing

Match docstring spacing

--- ring-devel/src/ring/middleware/stacktrace.clj
+++ ring-devel/src/ring/middleware/stacktrace.clj
@@ -13,6 +13,7 @@

 (defn wrap-stacktrace-log
   "Wrap a handler such that exceptions are logged to *err* and then rethrown.
+
   Accepts the following options:

   :color? - if true, apply ANSI colors to stacktrace (default false)"


Center posts section

Center posts section

--- template/index.html.clj
+++ template/index.html.clj
@@ -33,10 +33,10 @@
   [:div.text-center
     (img "../img/photon_cannon.png")])

-;; Sample posts
-(page-header "Posts")
-(post-list)
-(prev-next-page-link)
+[:div.text-center
+  (page-header "Posts")
+  (post-list)
+  (prev-next-page-link)]

 ;; Sample post tags
 (page-header "Tags")


default stage position

default stage position

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

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -275,7 +275,7 @@
             last-wake-time (atom (clock-ms))
             start-time (clock-ms)
             init-auto-shutter (. mmc getAutoShutter)
-            default-z-position (get-z-position (. mmc getFocusDevice))]
+            default-z-position (get-z-stage-position (. mmc getFocusDevice))]
     (let [acq-seq (generate-acq-sequence settings)]
        (def acq-sequence acq-seq)
        (execute (mapcat #(make-event-fns % out-queue) acq-seq))


avoid empty stage name error

avoid empty stage name error

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

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -224,9 +224,13 @@
         (core setShutterOpen open?)
         (swap! state assoc-in [:shutter-states shutter] open?)))))

+(defn is-continuous-focus-drive [stage]
+  (when-not (empty? stage)
+    (core isContinuousFocusDrive stage)))
+
 (defn set-z-stage-position [stage pos]
   (when (and (@state :init-continuous-focus)
-             (not (core isContinuousFocusDrive stage))
+             (not (is-continuous-focus-drive stage))
              (core isContinuousFocusEnabled))
     (enable-continuous-focus false))
   (device-best-effort stage (core setPosition stage pos)))
@@ -485,7 +489,7 @@
 (defn z-stage-needs-adjustment [stage-name]
   (not (and (@state :init-continuous-focus)
             (core isContinuousFocusEnabled)
-            (not (core isContinuousFocusDrive stage-name)))))
+            (not (is-continuous-focus-drive stage-name)))))

 (defn update-z-positions [msp-index]
   (when-let [msp (get-msp msp-index)]


RS | #53 | Add username to comments, questions, answers

--- integration/objective8/db/storage_tests.clj
+++ integration/objective8/db/storage_tests.clj
@@ -62,11 +62,7 @@
                             store-result (storage/pg-store! objective)
                             retrieve-result (storage/pg-retrieve {:entity :objective :_id (:_id store-result)})]
                         (first (:result retrieve-result)) => (contains {:created-by-id user-id
-<<<<<<< HEAD
                                                                         :username "username"
-=======
-                                                                        :display-name "twitter-TWITTER_ID"
->>>>>>> RS & MG | #53 | Add username to user table and api handler
                                                                         :end-date "2015-01-01T00:00:00Z"
                                                                         :title "title"})))
                 ;;COMMENTS
@@ -84,11 +80,7 @@
                             store-result (storage/pg-store! comment)
                             retrieve-result (storage/pg-retrieve {:entity :comment :_id (:_id store-result)})]
                         (first (:result retrieve-result)) => (contains {:created-by-id user-id
-<<<<<<< HEAD
                                                                         :username "username"
-=======
-                                                                        :display-name "twitter-TWITTER_ID"
->>>>>>> RS & MG | #53 | Add username to user table and api handler
                                                                         :objective-id objective-id})))

                 ;;QUESTIONS
@@ -106,11 +98,7 @@
                             store-result (storage/pg-store! question)
                             retrieve-result (storage/pg-retrieve {:entity :question :_id (:_id store-result)})]
                         (first (:result retrieve-result)) => (contains {:created-by-id user-id
-<<<<<<< HEAD
                                                                         :username "username"
-=======
-                                                                        :display-name "twitter-TWITTER_ID"
->>>>>>> RS & MG | #53 | Add username to user table and api handler
                                                                         :objective-id objective-id})))
                 (fact "questions can be retrieved by objective ID"
                       (let [stored-user (store-a-user)


--- integration/objective8/db/storage_tests.clj
+++ integration/objective8/db/storage_tests.clj
@@ -62,7 +62,11 @@
                             store-result (storage/pg-store! objective)
                             retrieve-result (storage/pg-retrieve {:entity :objective :_id (:_id store-result)})]
                         (first (:result retrieve-result)) => (contains {:created-by-id user-id
+<<<<<<< HEAD
                                                                         :username "username"
+=======
+                                                                        :display-name "twitter-TWITTER_ID"
+>>>>>>> RS & MG | #53 | Add username to user table and api handler
                                                                         :end-date "2015-01-01T00:00:00Z"
                                                                         :title "title"})))
                 ;;COMMENTS
@@ -80,7 +84,11 @@
                             store-result (storage/pg-store! comment)
                             retrieve-result (storage/pg-retrieve {:entity :comment :_id (:_id store-result)})]
                         (first (:result retrieve-result)) => (contains {:created-by-id user-id
+<<<<<<< HEAD
                                                                         :username "username"
+=======
+                                                                        :display-name "twitter-TWITTER_ID"
+>>>>>>> RS & MG | #53 | Add username to user table and api handler
                                                                         :objective-id objective-id})))

                 ;;QUESTIONS
@@ -98,7 +106,11 @@
                             store-result (storage/pg-store! question)
                             retrieve-result (storage/pg-retrieve {:entity :question :_id (:_id store-result)})]
                         (first (:result retrieve-result)) => (contains {:created-by-id user-id
+<<<<<<< HEAD
                                                                         :username "username"
+=======
+                                                                        :display-name "twitter-TWITTER_ID"
+>>>>>>> RS & MG | #53 | Add username to user table and api handler
                                                                         :objective-id objective-id})))
                 (fact "questions can be retrieved by objective ID"
                       (let [stored-user (store-a-user)


Fixed bad require in dev.

Fixed bad require in dev.

--- dev-resources/src/cmr/opendap/dev.clj
+++ dev-resources/src/cmr/opendap/dev.clj
@@ -10,7 +10,7 @@
     [clojure.tools.namespace.repl :as repl]
     [clojusc.dev.system.core :as system-api]
     [clojusc.twig :as logger]
-    [cmr.opendap.components.caching :as caching]
+    [cmr.authz.components.caching :as auth-caching]
     [cmr.opendap.components.config :as config]
     [cmr.opendap.components.core]
     [cmr.opendap.errors :as errors]


Trying another style of writing type-dispatched procedures -- the "big extend-protocol".  This looks like it's actually reasonably "Clojure way", and also plausibly pleasant.  I'll hang on to the type test infrastructure too, just in case I decide I need it (for, e.g.  the second argument).

--- jlad/jlad.clj
+++ jlad/jlad.clj
@@ -78,9 +78,6 @@

 (declare jl-eval)

-(defprotocol Zeroable
-  (zero [self]))
-
 (defprotocol Applicable
   (jl-apply [self arg]))

@@ -88,19 +85,14 @@
   JLPrimitive
   (primitive? [self] true)
   Applicable
-  (jl-apply [self arg] (implementation arg))
-  Zeroable
-  (zero [self] self))
+  (jl-apply [self arg] (implementation arg)))

 (defrecord closure [formal body env]
   JLClosure
   (closure? [self] true)
   Applicable
   (jl-apply [self arg]
-	    (jl-eval body (extend-env (jl-destructure formal arg) env)))
-  Zeroable
-  ;; TODO zero out the constants too
-  (zero [self] (new closure formal body (map-env zero env))))
+	    (jl-eval body (extend-env (jl-destructure formal arg) env))))

 (defprotocol Evaluable
   (jl-eval [self env]))
@@ -142,16 +134,25 @@
 			   (jl-eval cdr env)))
   Destructurable
   (jl-destructure [self arg] (merge (jl-destructure car (:car arg))
-				    (jl-destructure cdr (:cdr arg))))
-  Zeroable
-  (zero [self] (new pair (zero car) (zero cdr))))
+				    (jl-destructure cdr (:cdr arg)))))

 (defrecord empty-list []
   JLEmptyList
   (empty-list? [self] true))

-(extend-type Number
-  Zeroable
+(defprotocol Zeroable
+  (zero [self]))
+
+(extend-protocol Zeroable
+  primitive
+  (zero [self] self)
+  closure
+  ;; TODO zero out the constants too
+  (zero [self] (new closure (:formal self) (:body self)
+		    (map-env zero (:env self))))
+  pair
+  (zero [self] (new pair (zero (:car self)) (zero (:cdr self))))
+  Number
   (zero [self] 0))

 ;;;; Syntax


Upgrade clojure dependency versions

Upgrade clojure dependency versions

--- clojure/cljsearch/project.clj
+++ clojure/cljsearch/project.clj
@@ -4,8 +4,8 @@
   :license {:name "Eclipse Public License"
             :url "http://www.eclipse.org/legal/epl-v10.html"}
   :dependencies [
-                  [org.clojure/clojure "1.9.0"]
-                  [org.clojure/data.json "0.2.6"]
+                  [org.clojure/clojure "1.10.1"]
+                  [org.clojure/data.json "1.0.0"]
                 ]
   :main ^:skip-aot cljsearch.cljsearch
   :target-path "target/%s"


Bug fix - missing score on minis

Bug fix - missing score on minis

--- desktop/src-common/ds3/enemy.clj
+++ desktop/src-common/ds3/enemy.clj
@@ -61,7 +61,7 @@
                     :x x :y y
                     :translate-x (- (c/screen-to-world 4)) :translate-y (- (c/screen-to-world 6.6))
                     :width mini-size :height mini-size
-                    :id :mini-enemy :mini? true :render-layer 70
+                    :id :mini-enemy :mini? true :render-layer 70 :score 200
                     :movement-state :falling
                     :bonus-group bonus-group
                     :ticks-to-bomb (rand-int default-ticks-first-bomb))]


gen-tests: remove midje

gen-tests: remove midje

--- test/euler/gen_test.clj
+++ test/euler/gen_test.clj
@@ -1,44 +1,40 @@
 (ns euler.gen-test
   (:require [clojure.edn :as edn]
-            [clojure.test :refer [deftest]]
+            [clojure.test.check.clojure-test :refer [defspec]]
             [clojure.test.check.generators :as gen]
-            [euler.core-test :refer [fact-qc]]
+            [clojure.test.check.properties :as prop]
             [euler.euler001 :as e001]
             [euler.helper :as helper]))

-(deftest generative-tests
+(defspec p002 100
+  (prop/for-all [n gen/nat] ;; always returns an even result
+                (= (even? (e001/p002 n)) true)))

-  (fact-qc "Problem 2: always returns an even result"
-           [n gen/nat]
-           (e001/p002 n) => even?)
+(defspec p004 100
+  (prop/for-all [n (gen/such-that #(> % 1) gen/nat)]
+                (let [res (str (e001/p004 n))]
+                ;; each returned value is indeed a palindrome
+                  (= res (apply str (reverse res))))))

-  (fact-qc "Problem 4: each returned value is indeed a palindrome"
-           [n (gen/such-that #(> % 1) gen/nat)]
-           (let [res (str (e001/p004 n))]
-             res => (apply str (reverse res))))
+(defspec p005 100
+  (prop/for-all [n (gen/such-that #(> 23 %) gen/int)]
+                (let [res (e001/p005 n)
+                      nums (range 2 (+ 1 n))
+                      not-div-by? (fn [x] (not (= 0 (rem res x))))]
+                  (= (filter not-div-by? nums) '()))))

-  (fact-qc "Problem 5: e001/p005-quickcheck"
-           [n gen/int]
-           (let [res (e001/p005 n)
-                 nums (range 2 (+ 1 n))
-                 not-div-by? (fn [x] (not (= 0 (rem res x))))]
-             (filter not-div-by? nums) => '()))
+(defspec p009 100
+  ;; all Pythagorean triplets up to 300
+  (prop/for-all [[a b c] (->> "resources/p009_triplets.txt"
+                              slurp
+                              edn/read-string
+                              gen/elements)]
+                (= (* a b c) (e001/p009 (+ a b c)))))

-  (fact-qc "Problem 9: all Pythagorean triplets up to 300"
-           [[a b c] (->> "resources/p009_triplets.txt"
-                         slurp
-                         edn/read-string
-                         gen/elements)]
-           (= (* a b c) (e001/p009 (+ a b c))))
+(defspec factors-vs-count-divisors 100
+  (prop/for-all [n gen/nat]
+                (= (count (helper/factors n)) (helper/count-divisors n))))

-  (fact-qc "factors vs count-divisors"
-           [n gen/nat]
-           (count (helper/factors n)) => (helper/count-divisors n))
-
-  (fact-qc "factors vs count-divisors"
-           [n gen/nat]
-           (count (helper/factors n)) => (helper/count-divisors n))
-
-  (fact-qc "parse-grid: return a vector of vectors"
-           [n gen/nat]
-           (helper/parse-grid (str n) 1) => [[n]]))
+(defspec parse-grid-vector-of-vectors 100
+  (prop/for-all [n gen/nat]
+                (= (helper/parse-grid (str n) 1) [[n]])))


Add difference and quotient rules

Add difference and quotient rules

--- src/main/cljc/clojure_club/x121_universal_computation_engine/mgrimm.cljc
+++ src/main/cljc/clojure_club/x121_universal_computation_engine/mgrimm.cljc
@@ -4,10 +4,13 @@
 (defn f' [e dvar]
   (cond
     (list? e)
-    (let [[op u v] e]
+    (let [[op u v] e
+          u' (f' u dvar) v' (f' v dvar)]
       (case op
-        + (list '+ (f' u dvar) (f' v dvar))
-        * (list '+ (list '* u (f' v dvar)) (list '* v (f' u dvar)))))
+        + (list '+ u' v')
+        - (list '- u' v')
+        * (list '+ (list '* u v') (list '* v u'))
+        / (list '/ (list '- (list '* v u') (list '* u v')) (list '* v v))))
     (number? e) 0
     (and (symbol? e) (= e dvar)) 1
     :else 0))
@@ -49,6 +52,7 @@
 (assert (= 0 ((calc '(f' 2 x)) nil)))
 (assert (= 1 ((calc '(f' x x)) nil)))
 (assert (= 0 ((calc '(f' y x)) nil)))
-(assert (= 3 ((calc '(f' (* x y) x)) '{x 1 y 3})))
+(assert (= 3 ((calc '(f' (* x y) x)) '{x -1 y 3})))
 (assert (= 10 ((calc '(f' (* x x) x)) '{x 5})))
-(assert (= 40 ((calc '(f' (+ (* x x) (* 3 y)) x)) '{x 20 y 99})))
+(assert (= 40 ((calc '(f' (+ (* x x) (* 3 y)) x)) '{x 20 y -1})))
+(assert (= 1/8 ((calc '(f' (/ x (* 2 y)) x)) '{x -1 y 4})))


use transmit-lib/config's urs username & password

--- mock-echo-app/src/cmr/mock_echo/api/urs.clj
+++ mock-echo-app/src/cmr/mock_echo/api/urs.clj
@@ -10,16 +10,9 @@
    [cmr.common.services.errors :as errors]
    [cmr.common.xml :as cx]
    [cmr.mock-echo.data.urs-db :as urs-db]
+   [cmr.transmit.config :as transmit-config]
    [compojure.core :refer :all]
    [ring.util.response :as rsp]))
-
-(defconfig cmr-urs-username
-  "A default username for the mock-echo dev environment"
-  {:default "mock_urs_username"})
-
-(defconfig cmr-urs-password
-  "A default username for the mock-echo dev environment"
-  {:default "mock_urs_password"})

 (defn get-user
   "Processes a request to get a user."
@@ -134,7 +127,7 @@
   sent include this information."
   [request]
   (let [{:keys [username password]} (decode-basic-auth request)]
-    (when-not (and (= username cmr-urs-username) (= password cmr-urs-password))
+    (when-not (and (= username (transmit-config/urs-username)) (= password (transmit-config/urs-password)))
       (errors/throw-service-error :unauthorized "Bad URS authentication info"))))

 (defn build-routes [system]


Port yesterday's clone workspace hotfix to develop (#892)

* port clone workspace hotfix to dev

--- src/cljs/main/broadfcui/page/workspace/create.cljs
+++ src/cljs/main/broadfcui/page/workspace/create.cljs
@@ -31,7 +31,7 @@
         {:header (if workspace-id "Clone Workspace" "Create New Workspace")
          :ok-button {:text (if workspace-id "Clone Workspace" "Create Workspace")
                      :data-test-id (config/when-debug "create-workspace-button")
-                     :onClick #(this :-create-workspace)}
+                     :onClick (if workspace-id #(this :-do-clone) #(this :-create-workspace))}
          :dismiss (:dismiss props)
          :get-first-element-dom-node #(@refs "project")
          :content
@@ -104,6 +104,33 @@
                         (do (modal/pop-modal)
                             (nav/go-to-path :workspace-summary {:namespace project :name name}))
                         (swap! state assoc :server-error (get-parsed-response false))))}))))
+   :-do-clone
+   (fn [{:keys [props refs state]}]
+     (swap! state dissoc :server-error :validation-errors)
+     (if-let [fails (input/validate refs "wsName")]
+       (swap! state assoc :validation-errors fails)
+       (let [name (input/get-text refs "wsName")
+             project (nth (:billing-projects props) (int (:selected-project @state)))
+             desc (common/get-text refs "wsDescription")
+             attributes (if (or (:description props) (not (clojure.string/blank? desc)))
+                          {:description desc}
+                          {})
+             selected-auth-domain-index (int (:selected-auth-domain @state))
+             auth-domain {:authorizationDomain (map
+                                                (fn [group-name]
+                                                  {:membersGroupName group-name})
+                                                (:selected-groups @state))}]
+         (swap! state assoc :creating-ws true)
+         (endpoints/call-ajax-orch
+          {:endpoint (endpoints/clone-workspace (:workspace-id props))
+           :payload (conj {:namespace project :name name :attributes attributes} auth-domain)
+           :headers utils/content-type=json
+           :on-done (fn [{:keys [success? get-parsed-response]}]
+                      (swap! state dissoc :creating-ws)
+                      (if success?
+                        (do (modal/pop-modal)
+                          (nav/go-to-path :workspace-summary {:namespace project :name name}))
+                        (swap! state assoc :server-error (get-parsed-response false))))}))))
    :-auth-domain-builder
    (fn [{:keys [state props]}]
      (let [{:keys [all-groups selected-groups]} @state
@@ -141,7 +168,8 @@
                :data-test-id (config/when-debug "workspace-auth-domain-select")
                :onChange #(swap! state update :selected-groups conj (-> % .-target .-value))}
               (set/difference all-groups (set selected-groups))
-              (str "Select " (if (empty? selected-groups) "a" "another") " Group..."))])])))})
+              (str "Select " (if (empty? selected-groups) "a" "another") " Group..."))])
+          (common/clear-both)])))})

 (react/defc Button


update version

update version

--- auth/project.clj
+++ auth/project.clj
@@ -1,4 +1,4 @@
-(defproject com.sixsq.slipstream/auth "3.1-SNAPSHOT"
+(defproject com.sixsq.slipstream/auth "3.2-SNAPSHOT"
   :description  "Authentication Service"
   :url          "http://sixsq.com"


Added a sleep to avoid preemption during a buffer test

--- test/ctia/events_test.clj
+++ test/ctia/events_test.clj
@@ -73,6 +73,7 @@
     (send-create-event "tester" {} "TestModelType" {:id "1"})
     (send-create-event "tester" {} "TestModelType" {:id "2"})
     (send-create-event "tester" {} "TestModelType" {:id "3"})
+    (Thread/sleep 100)
     (is (= ["1" "2" "3"] (map (comp :id :model) (recent-events))))
     (send-create-event "tester" {} "TestModelType" {:id "4"})
     (send-create-event "tester" {} "TestModelType" {:id "5"})


Privatise function + attribute

Privatise function + attribute

--- src/atom/core.cljs
+++ src/atom/core.cljs
@@ -4,9 +4,9 @@
 (def browser-window (js/require "browser-window"))
 (def crash-reporter (js/require "crash-reporter"))

-(def main-window (atom nil))
+(def ^:private main-window (atom nil))

-(defn init-browser []
+(defn- init-browser []
   (reset! main-window (browser-window.
                         (clj->js {:width 800
                                   :height 600})))


optionally return after hitting an error

--- test/osmium/core_test.clj
+++ test/osmium/core_test.clj
@@ -1,5 +1,4 @@
 (ns osmium.core-test
-  (:import [clojure.test.check.generators Generator])
   (:require [clojure.test :refer :all]
             [clj-webdriver.taxi :as taxi]
             [osmium.core :as o]
@@ -94,8 +93,9 @@
        (if-let [action (rand-nth (seq (find-actions d)))]
          (let [action' (expand-action d action)]
            (eval! d action')
-           (f action')
-           (recur (dec n) (conj actions action')))
+           (if (= ::stop (f action'))
+             (conj actions action')
+             (recur (dec n) (conj actions action'))))
          actions)))))

 ;; ======================================================================
@@ -110,6 +110,13 @@

 (defonce replay (atom {:actions [] :step 0}))

+(defn error-page? [page-source]
+  (or (boolean (re-find #"error-page" page-source))
+      (boolean (re-find #"not-found" page-source))))
+
+(defn login-button-rendered? [page-source]
+  (boolean (re-find #"login" page-source)))
+
 (deftest users
   (testing "All created users are valid"
     (o/start!)
@@ -118,9 +125,14 @@
       (eval! driver [:to "localhost:3005"])
       (let [actions (walk-n-steps! driver 10
                                    (fn [a]
-                                     (println a)
                                      (doseq [user (user/all-users db)]
-                                       (is (s/valid? ::user/user user)))))]
+                                       (is (s/valid? ::user/user user)))
+                                     (let [source (taxi/page-source driver)
+                                           error-page? (error-page? source)]
+                                       (is (not error-page?))
+                                       (is (login-button-rendered? source))
+                                       (when error-page?
+                                         ::stop))))]
         (reset! replay {:actions actions :step 0}))
       (taxi/quit driver))
     (o/stop!)))


off-by-one

off-by-one

--- org-mode/src/com/gfredericks/org_agenda.clj
+++ org-mode/src/com/gfredericks/org_agenda.clj
@@ -267,7 +267,7 @@
                          (if (and deadline (compare/<= (to-local-date deadline) today))
                            {:deadlines #{item}}
                            (if-let [d (relevant-date item)]
-                             (if-not (compare/<= today+10 d)
+                             (if-not (compare/< today+10 d)
                                {(compare/max today d) #{item}})
                              {:triage #{item}}))))
                  (apply merge-with into))


Refactor for cleanliness and add a bit of joint test code

--- breakout/desktop/src-common/breakout/core.clj
+++ breakout/desktop/src-common/breakout/core.clj
@@ -4,7 +4,8 @@
   (:require [play-clj.core :refer :all]
             [play-clj.g2d :refer :all]
             [play-clj.g2d-physics :refer :all]
-            [play-clj.ui :refer :all]))
+            [play-clj.ui :refer :all]
+            [play-clj.math :as m]))

 (declare breakout main-screen text-screen)

@@ -13,8 +14,9 @@
 (defn create-ball-body!
   [screen x y radius]
   (->> (circle radius)
-       (fixture :density 1 :friction 0 :restitution 1 :shape)
-       (create-body! screen :dynamic :set-transform x y 0 :create-fixture)))
+       (fixture-def :density 1 :friction 0 :restitution 1 :shape)
+       (create-body! screen (body-def :dynamic)
+                     :set-transform x y 0 :create-fixture)))

 (defn create-rect-body!
   [screen x y width height]
@@ -25,8 +27,29 @@
         0 0]
        float-array
        (chain :create-chain)
-       (fixture :density 1 :shape)
-       (create-body! screen :static :set-transform x y 0 :create-fixture)))
+       (fixture-def :density 1 :shape)
+       (create-body! screen (body-def :static)
+                     :set-transform x y 0 :create-fixture)))
+
+(defn create-ball-entity!
+  [screen]
+  (let [ball (texture "ball.png")
+        x (/ 100 pixels-per-tile)
+        y (/ 100 pixels-per-tile)
+        width (/ (texture! ball :get-region-width) pixels-per-tile)
+        height (/ (texture! ball :get-region-height) pixels-per-tile)]
+    (assoc ball
+           :body (doto (create-ball-body! screen x y (/ width 2))
+                   (body! :set-linear-velocity 10 10))
+           :x x :y y
+           :width width :height height)))
+
+(defn create-rect-entity!
+  [screen block x y width height]
+  (assoc block
+         :body (create-rect-body! screen x y width height)
+         :x 0 :y 0
+         :width width :height height))

 (defn move-paddle!
   [entities]
@@ -43,42 +66,36 @@
           game-w (/ (game :width) pixels-per-tile)
           game-h (/ (game :height) pixels-per-tile)
           floor-h (/ 1 pixels-per-tile)
-          ball (texture "ball.png")
-          ball-x (/ 100 pixels-per-tile)
-          ball-y (/ 100 pixels-per-tile)
-          ball-w (/ (texture! ball :get-region-width) pixels-per-tile)
-          ball-h (/ (texture! ball :get-region-height) pixels-per-tile)
           block (texture "block.png")
           block-w (/ (texture! block :get-region-width) pixels-per-tile)
           block-h (/ (texture! block :get-region-height) pixels-per-tile)
           block-cols (int (/ game-w block-w))
-          block-rows (int (/ game-h 2 block-h))]
+          block-rows (int (/ game-h 2 block-h))
+          ball (create-ball-entity! screen)
+          paddle (create-rect-entity! screen block 0 0 block-w block-h)
+          wall {:body (create-rect-body! screen 0 0 game-w game-h)}
+          floor {:body (create-rect-body! screen 0 0 game-w floor-h)}]
       ; set the screen width in tiles
       (width! screen game-w)
+      ; attach the ball to the paddle so it can't reach the blocks
+      ; (this is only meant to test that joints work)
+      (comment create-joint! screen
+               (joint-def :rope
+                          :body-a (:body ball)
+                          :body-b (:body paddle)
+                          :max-length 5
+                          :collide-connected true))
       ; return the entities
-      [(assoc ball
-              :ball? true
-              :body (doto (create-ball-body! screen ball-x ball-y (/ ball-w 2))
-                      (body! :set-linear-velocity 10 10))
-              :x ball-x :y ball-y
-              :width ball-w :height ball-h)
-       (assoc block
-              :paddle? true
-              :body (create-rect-body! screen 0 0 block-w block-h)
-              :x 0 :y 0
-              :width block-w
-              :height block-h)
-       {:wall? true :body (create-rect-body! screen 0 0 game-w game-h)}
-       {:floor? true :body (create-rect-body! screen 0 0 game-w floor-h)}
+      [(assoc ball :ball? true)
+       (assoc paddle :paddle? true)
+       (assoc wall :wall? true)
+       (assoc floor :floor? true)
        (for [col (range block-cols)
              row (range block-rows)
              :let [x (* col block-w)
                    y (+ (* row block-h) (- game-h (* block-h block-rows)))]]
-         (assoc block
-                :block? true
-                :body (create-rect-body! screen x y block-w block-h)
-                :x x :y y
-                :width block-w :height block-h))]))
+         (assoc (create-rect-entity! screen block x y block-w block-h)
+                :block? true))]))
   :on-render
   (fn [screen entities]
     (clear!)


support for visualization in gorrila repl

--- src/grape/core.clj
+++ src/grape/core.clj
@@ -53,7 +53,8 @@

 (defnp dbquery
   ([q p]
-   (let [_ (println "DBQuery: " q)
+   (let [
+         ;_ (println "DBQuery: " q)
          res (nt/execute conn (eval 'tx) [(nt/statement q)])
          els (:els (second p))
          eids (map name (map get-id (filter-elem 'edge els)))
@@ -324,7 +325,8 @@
   [steps mps iter]
   (begintx)
   (intern *ns* '_ret {})
-  (let [_ (println "Transact-iteration: " iter)
+  (let [
+        ;_ (println "Transact-iteration: " iter)
         ;_ (println "mps: " (map (fn [s] [(:name s) (:btp s) (:max s)]) mps))
         ;_ (Thread/sleep 500)
         [res r-mps ctr] (run-transaction steps mps -1)]
@@ -483,7 +485,8 @@
        (intern *ns* s (fn [& par] (attempt (transact (cons s par) ))))

        (intern *ns* (symbol (str (name n) "-dot")) (fn [] (rule->dot n)))
-       ((intern *ns* (symbol (str (name n) "-show")) (fn [] (dot->image (rule->dot n))))))))
+       ((intern *ns* (symbol (str (name n) "-show")) (fn [] (show (rule->dot n)))))
+       )))
   ([n prop]
    (rule n [] prop)))


add comments

add comments

--- kafka-clj/src/kafka_clj/consumer/work_organiser.clj
+++ kafka-clj/src/kafka_clj/consumer/work_organiser.clj
@@ -8,6 +8,21 @@
      [kafka-clj.consumer :refer [get-broker-offsets]]
      [group-redis.core :refer [persistent-get persistent-set]]
      ))
+
+;;; This namespace requires a running redis and kafka cluster
+;;;;;;;;;;;;;;;;;; USAGE ;;;;;;;;;;;;;;;
+;(use 'kafka-clj.consumer.work-organiser :reload)
+;(def org (create-organiser!
+;{:bootstrap-brokers [{:host "localhost" :port 9092}]
+; :redis-conf {:host "localhost" :max-active 5 :timeout 1000} :working-queue "working" :complete-queue "complete" :work-queue "work" :conf {}}))
+; (calculate-new-work org ["ping"])
+;
+;
+;(use 'kafka-clj.consumer.consumer :reload)
+;(def consumer (consumer-start {:redis-conf {:host "localhost" :max-active 5 :timeout 1000} :working-queue "working" :complete-queue "complete" :work-queue "work" :conf {}}))
+;
+;(def res (do-work-unit! consumer (fn [state status resp-data] state)))
+;

 (defn calculate-work-units
   "Returns '({:topic :partition :offset :len}) Len is exclusive"


check-type? => type-check?

check-type? => type-check?

--- src/latte/core.clj
+++ src/latte/core.clj
@@ -297,7 +297,7 @@
     (let [ty (ty/type-of def-env ctx t)]
       (list 'quote ty))))

-(defmacro check-type? [& args]
+(defmacro type-check? [& args]
   (let [def-env {}
         t (stx/parse def-env (last (butlast args)))
         ty (stx/parse def-env (last args))


giving up...

giving up...

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

--- clojure/sequence_generator.clj
+++ clojure/sequence_generator.clj
@@ -13,7 +13,7 @@
 ;               IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 ;               CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 ;               INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES.
-; CVS:          $Id: sequence_generator.clj 5857 2010-12-09 21:42:12Z arthur $
+; CVS:          $ $
 ;

 (ns sequence-generator)


Updated policies

Updated policies

--- src/aws_overlord/tasks/security.clj
+++ src/aws_overlord/tasks/security.clj
@@ -29,34 +29,44 @@

 (def ^:private power-user-policy
   {
-   "Version" "2012-10-17"
    "Statement" [{"Effect" "Allow"
-                 "Action" [
+                 "Resource" "*"
+                 "Action" ["iam:CreateRole"
+                           "iam:CreateInstanceProfile"
                            "iam:AddRoleToInstanceProfile"
-                           "iam:CreateInstanceProfile"
-                           "iam:CreateRole"
-                           "iam:DeleteInstanceProfile"
-                           "iam:DeleteRole"
+                           "iam:PassRole"
+                           "iam:ListVirtualMFADevices"
+                           "iam:ListUsers"
+                           "iam:ListUserPolicies"
+                           "iam:ListSigningCertificates"
+                           "iam:ListServerCertificates"
+                           "iam:ListSAMLProviders"
+                           "iam:ListRoles"
+                           "iam:ListRolePolicies"
+                           "iam:ListMFADevices"
+                           "iam:ListInstanceProfilesForRole"
+                           "iam:ListInstanceProfiles"
+                           "iam:ListGroupsForUser"
+                           "iam:ListGroups"
+                           "iam:ListGroupPolicies"
+                           "iam:ListAccountAliases"
+                           "iam:ListAccessKeys"
+                           "iam:GetAccountSummary"
                            "iam:GetInstanceProfile"
-                           "iam:ListRolePolicies"
-                           "iam:ListRoles"
-                           "iam:ListServerCertificates"
-                           "iam:PassRole"
+                           "iam:GetLoginProfile"
                            ; FIXME: PutRolePolicy allows privilege escalation!
-                           "iam:PutRolePolicy"
-                           "iam:RemoveRoleFromInstanceProfile"
-                           ]
-                 "Resource" "*"}
+                           "iam:PutRolePolicy"]}
                 {"Effect" "Allow"
-                 "Action" "ec2:*"
+                 "Resource" "*"
                  "Condition" {"ForAnyValue:StringLike" {"ec2:Region" ["eu-central-1"
                                                                       "eu-west-1"]}}
-                 "Resource" "*"}
+                 "Action" "ec2:*"}
                 {"Effect" "Allow"
                  "NotAction" ["ec2:*"
                               "iam:*"]
                  "Resource" "*"}
                 {"Effect" "Deny"
+                 "Resource" "*"
                  "Action" ["ec2:DeleteNetworkAcl"
                            "ec2:DeleteRoute"
                            "ec2:DeleteRouteTable"
@@ -65,8 +75,8 @@
                            "ec2:DeleteVpcPeeringConnection"
                            "ec2:DeleteVpnConnection"
                            "ec2:DeleteVpnConnectionRoute"
-                           "ec2:DeleteVpnGateway"]
-                 "Resource" "*"}]
+                           "ec2:DeleteVpnGateway"]}]
+   "Version" "2012-10-17"
    })

 (def ^:private read-only-policy
@@ -142,11 +152,11 @@
       false)))

 (defn- role-policy-document [account-id]
-  {"Version" "2012-10-17",
-   "Statement" [{"Sid" "",
-                 "Effect" "Allow",
-                 "Principal" {"Federated" (str "arn:aws:iam::" account-id ":saml-provider/Shibboleth")},
-                 "Action" "sts:AssumeRoleWithSAML",
+  {"Version" "2012-10-17"
+   "Statement" [{"Sid" ""
+                 "Effect" "Allow"
+                 "Principal" {"Federated" (str "arn:aws:iam::" account-id ":saml-provider/Shibboleth")}
+                 "Action" "sts:AssumeRoleWithSAML"
                  "Condition" {"StringEquals" {"SAML:aud" "https://signin.aws.amazon.com/saml"}}}]
    })


Or you could do that

Or you could do that

--- src/lt/object.cljs
+++ src/lt/object.cljs
@@ -47,7 +47,8 @@
     (doseq [x xs]
       (.push arr #js [(count (string/split (str x) ".")) (str x) x]))
     (.sort arr)
-    (amap arr i _ (aget arr (- (.-length arr) i 1) 2))))
+    (.reverse arr)
+    (amap arr i _ (aget arr i 2))))

 (defn tags->behaviors [ts]
   (let [duped (apply concat (map @tags (specificity-sort ts)))


lein-release plugin: bumped version from 0.4.0 to 0.4.1-SNAPSHOT for next development cycle

--- re_view/project.clj
+++ re_view/project.clj
@@ -1,4 +1,4 @@
-(defproject re-view "0.4.0"
+(defproject re-view "0.4.1-SNAPSHOT"
   :description "ClojureScript React Library"
   :url "https://www.github.com/braintripping/re-view/tree/master/re_view"
   :license {:name "Eclipse Public License"


lein-release plugin: bumped version from 0.4.9 to 0.4.10-SNAPSHOT for next development cycle

--- re_view/project.clj
+++ re_view/project.clj
@@ -1,4 +1,4 @@
-(defproject re-view "0.4.9"
+(defproject re-view "0.4.10-SNAPSHOT"
   :description "ClojureScript React Library"
   :url "https://www.github.com/braintripping/re-view/tree/master/re_view"
   :license {:name "Eclipse Public License"