insights: "Add Project" button -> <a>

insights: "Add Project" button -> <a>

--- src-cljs/frontend/components/insights.cljs
+++ src-cljs/frontend/components/insights.cljs
@@ -288,7 +288,7 @@
        [:div.header.text-center "No Insights yet"]]
        [:div.details.text-center "Add projects from your Github orgs and start building on CircleCI to view insights."]
       [:div.row.text-center
-       [:button.btn.btn-success {:href (routes/v1-add-projects)} "Add Project"]]]]))
+       [:a.btn.btn-success {:href (routes/v1-add-projects)} "Add Project"]]]]))

 (defrender build-insights [state owner]
   (let [projects (get-in state state/projects-path)]


Give people a better view of welcome animation

--- src/afterglow/controllers/ableton_push.clj
+++ src/afterglow/controllers/ableton_push.clj
@@ -968,7 +968,7 @@
                               (seq (str "version" (version/tag)))))
   (let [counter (atom 0)
         task (atom nil)]
-    (reset! task (at-at/every 30 #(welcome-frame controller counter task)
+    (reset! task (at-at/every 45 #(welcome-frame controller counter task)
                               controllers/pool))))

 (defn clear-interface


Clean up add-sp-child interface

Clean up add-sp-child interface

--- src/angelic/search/implicit/dash_astar.clj
+++ src/angelic/search/implicit/dash_astar.clj
@@ -5,7 +5,7 @@
             [angelic.search.summary :as summary]
             [angelic.search.summaries :as summaries]
             [angelic.search.function-sets :as fs])
-  (:import [java.util HashMap ArrayList]))
+  (:import [java.util HashMap ArrayList IdentityHashMap]))

 ;; A revampting of dash_astar_opt, to move subsumption relationships and caching
 ;; out into a separate class.  This is necessary to keep pessimistic and optimistic
@@ -50,6 +50,7 @@
 ;; This means that TS needs to know about stubs-in-training.

 ;; TODO: wrapping names don't match pair-stub1.  Get rid of norm-name hack?
+;; TODO: subsumptin should be sets, not lists?

@@ -111,15 +112,16 @@

 (defn- make-tree-summarizer [stb]
-  (let [subsuming-sp-list (ArrayList.)
+  (let [subsuming-sp-set (IdentityHashMap.)
         ret (traits/reify-traits [summaries/or-summarizable summaries/simple-cached-node]
               TreeSummarizer
               (ts-stub [ts] stb)
-              (subsuming-sps [ts] (seq subsuming-sp-list))
+              (subsuming-sps [ts] (keys subsuming-sp-set))
               (add-subsuming-sp! [ts subsuming-sp]
                 (util/assert-is (= (norm-name (stub-name stb)) (norm-name (sp-name subsuming-sp))))
-                (.add subsuming-sp-list subsuming-sp)
-                (summaries/connect-subsumed! (sp-ts subsuming-sp) ts)))]
+                (when-not (.containsKey subsuming-sp-set subsuming-sp)
+                  (.put subsuming-sp-set subsuming-sp true)
+                  (summaries/connect-subsumed! (sp-ts subsuming-sp) ts))))]
     (when-not (get-stub-output stb)
       (summaries/connect! ret stb)
       (summaries/connect-subsumed! ret stb))
@@ -185,18 +187,14 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Used on stubs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ;; Just give output directly if subproblem is ready; return true if waiting
-(defn- connect-and-watch-stub! [p c f]
-;  (assert (not (tree-summarizer? p)))
+;; if up?, updates p if c does not produce immediate output.
+(defn- connect-and-watch-stub! [p c up? f]
   (assert (instance? angelic.search.implicit.dash_astar.Stub c))
   (if-let [sp (get-stub-output c)]
-    (do (f sp) false)
+    (f sp)
     (do (summaries/connect! p c)
         (add-watcher! c f)
-        true)))
-
-;; Used when p needs update if c does not produce immediate output.
-(defn- connect-and-watch-stub-up! [p c f]
-  (when (connect-and-watch-stub! p c f) (summaries/summary-changed! p)))
+        (when up? (summaries/summary-changed! p)))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Making stubs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

@@ -216,7 +214,7 @@
               Stub (stub-name       [s] nm)
                    (input-set       [s] in-set)
                    (tree-summarizer [s] (tree-summarizer inner-stub)))]
-    (connect-and-watch-stub! ret inner-stub #(set-derived-stub-output! ret (sp-fn ret %)))
+    (connect-and-watch-stub! ret inner-stub false #(set-derived-stub-output! ret (sp-fn ret %)))
     ret))

@@ -242,24 +240,17 @@
 (defmethod print-method angelic.search.implicit.dash_astar.Subproblem [sp o]
  (print-method (format "#<SP$%8h %s>" (System/identityHashCode (stub sp)) (sp-name sp)) o))

-(defn direct-sp? [sp] (= (ts-stub (sp-ts sp)) (stub sp)))
-
-(defn- add-sp-child!* [sp child-sp]
-  (assert (not (terminal? sp)))
-  (summaries/summary-changed-local! sp)
-  (add-output! sp child-sp))
-
-(defn- add-sp-child! [sp child-sp]
-  (when (direct-sp? sp) #_ ::TODO)
-  (add-sp-child!* sp child-sp))
-
-(defn- add-sp-child-stub! [sp child-stub]
-  (when (direct-sp? sp) #_ ::TODO)
-  (connect-and-watch-stub! sp child-stub #(add-sp-child!* sp %)))
-
-(defn- add-sp-child-stub-up! [sp child-stub]
-  (when (direct-sp? sp) #_ ::TODO)
-  (connect-and-watch-stub-up! sp child-stub #(add-sp-child!* sp %)))
+(defn direct-sp? [sp] )
+
+(defn- add-sp-child-stub! [sp child-stub up?]
+  (when (= (ts-stub (sp-ts sp)) (stub sp)) ;; not a wrapper; don't double-copy!
+    ;; TODO
+    )
+  (connect-and-watch-stub! sp child-stub up?
+    (fn [child-sp]
+      (assert (not (terminal? sp)))
+      (summaries/summary-changed-local! sp)
+      (add-output! sp child-sp))))

 (traits/deftrait simple-subproblem [stb out-set term? ri-fn] [] [watched-node]
@@ -315,9 +306,8 @@
         (if (=-state-sets (output-set inner-sp) (output-set o))
           (do (connect-and-watch! ret o child-watch)
               (summaries/summary-changed! ret))
-          (if (#{:SA :OC} (first (sp-name o)))
-            (add-sp-child! ret o)
-            (add-sp-child-stub! ret (make-output-collecting-stub (stub o)))))))
+          (let [c (if (#{:SA :OC} (first (sp-name o))) (stub o) (make-output-collecting-stub (stub o)))]
+            (add-sp-child-stub! ret c false)))))
     ret))

@@ -367,7 +357,7 @@
         ret (traits/reify-traits
              [summaries/or-summarizable (simple-subproblem stb out (terminal? inner-sp) ri-fn)])]
     (connect-and-watch! ret inner-sp
-      (fn [o] (add-sp-child-stub-up! ret (make-state-abstracted-stub (stub o) in))))
+      (fn [o] (add-sp-child-stub! ret (make-state-abstracted-stub (stub o) in) true)))
     ret))

@@ -418,9 +408,9 @@
         (if-let [subsuming-sps (seq (filter #(not (terminal? %)) (subsuming-sps (tree-summarizer stb))))]
           (connect-and-watch! ret (apply min-key (comp summary/max-reward summaries/summary sp-ts) subsuming-sps)
             (fn [sub-out]
-              (add-sp-child-stub-up! ret (refine-input sub-out inp-set))))
+              (add-sp-child-stub! ret (refine-input sub-out inp-set) true)))
           (doseq [child-name (map make-fs-seq-name (fs/child-seqs (second (stub-name stb)) inp-set))]
-            (add-sp-child-stub! ret (get-stub child-name inp-set))))
+            (add-sp-child-stub! ret (get-stub child-name inp-set) false)))
         ret))))

 ;; Note: this is double-stage to lazily generate children.  Could be simpler single-stage.
@@ -478,7 +468,7 @@
       (add-watcher! watch
         (fn [o]
           (summaries/summary-changed-local! ss)
-          (add-sp-child-stub-up! sp (stub-f o)))))))
+          (add-sp-child-stub! sp (stub-f o) true))))))

 ;; Note: disconnect is needed since blocked trumps live.
 ;; TODO: get rid of disconnect -- just need to kill at the right time ?
@@ -513,7 +503,7 @@
       (make-evaluated-stub nm is #(make-pair-subproblem % left-sp right-sp))
       (let [ret (traits/reify-traits [summaries/sum-summarizable (simple-stub nm is)])]
         (summaries/connect! ret (sp-ts left-sp))
-        (connect-and-watch-stub! ret right-stub
+        (connect-and-watch-stub! ret right-stub false
           #(set-stub-output! ret (make-pair-subproblem ret left-sp %)))
         ret))))

@@ -523,10 +513,11 @@
   (if-let [left-sp (get-stub-output left-stub)]
     (make-pair-stub2 left-sp (right-stub-fn (output-set left-sp)))
     (let [ret (traits/reify-traits [summaries/or-summarizable (simple-stub nm (input-set left-stub))])]
-      (connect-and-watch-stub! ret left-stub
+      (connect-and-watch-stub! ret left-stub false
         (fn [lo]
-          (connect-and-watch-stub-up! ret
+          (connect-and-watch-stub! ret
             (make-pair-stub2 lo (right-stub-fn (output-set lo)))
+            true
             #(set-stub-output! ret %))))
       ret)))


Remove open/show effect when user click on project edit button.

--- src/cljs/hatnik/web/client/components.cljs
+++ src/cljs/hatnik/web/client/components.cljs
@@ -8,7 +8,7 @@
   (js/alert "Hoooo!"))

-(defn accordion-panel [& {:keys [body-id header body]}]
+(defn accordion-panel [& {:keys [body-id header button body]}]
   (dom/div
    #js {:className "panel panel-default panel-primary"}
    (dom/div
@@ -17,11 +17,16 @@
      nil
      (dom/h4
       #js {:className "panel-title"}
-      (dom/a
-       #js {:data-parent "#accrodion"
-            :data-toggle "collapse"
-            :href (str "#" body-id)}
-       header))))
+      (dom/div #js {:className "row"}
+               (dom/div #js {:className "col-sm-8 col-md-8 col-lg-8"}
+                        (dom/a
+                         #js {:data-parent "#accrodion"
+                              :data-toggle "collapse"
+                              :href (str "#" body-id)}
+                         header))
+               (dom/div
+                #js {:className "col-sm-2 col-md-1 col-lg-1 pull-right"}
+                button)))))
    (dom/div #js {:className "panel-collapse collapse in"
                  :id body-id}
             (dom/div #js {:className "panel-body"}
@@ -86,15 +91,6 @@
                  :onClick #(project-menu project)}
             (dom/span #js {:className "glyphicon glyphicon-pencil pull-right"}))))

-(defn project-header [project]
-  (dom/div #js {:className "row"}
-   (dom/div
-    #js {:className "col-sm-8 col-md-8 col-lg-8"}
-    (dom/p nil (get project "name")))
-   (dom/div
-    #js {:className "col-sm-2 col-md-1 col-lg-1 pull-right"}
-    (project-header-menu-button project))))
-
 (defn project-list [data owner]
   (reify
     om/IRender
@@ -103,7 +99,8 @@
        (map
         (fn [prj]
           (accordion-panel
-           :header (project-header prj)
+           :header (dom/p nil (get prj "name"))
+           :button (project-header-menu-button prj)
            :body (actions-table (get prj "id") (get prj "actions"))
            :body-id (str "__PrjList" (get prj "id"))))
         (:projects data))))))


Add docs for new `add-post-event-callback`.  Promote `on-change` to officially being a part of the API.

--- src/re_frame/core.cljs
+++ src/re_frame/core.cljs
@@ -28,17 +28,8 @@
 (def trim-v      middleware/trim-v)
 (def after       middleware/after)
 (def log-ex      middleware/log-ex)
-
-
-;; ALPHA - EXPERIMENTAL MIDDLEWARE
 (def on-changes  middleware/on-changes)

-
-;; -- Event Procssing Callbacks
-
-(defn add-post-event-callback
-  [f]
-  (router/add-post-event-callback re-frame.router/event-queue f))

 ;; --  Logging -----
 ;; re-frame uses the logging functions: warn, log, error, group and groupEnd
@@ -60,3 +51,18 @@

+;; -- Event Procssing Callbacks
+
+(defn add-post-event-callback
+  "Normal users of re-frame can ignore this part of the API. Only
+  needs to be used by libraries providing, so called, Isomorphic rendering.
+
+  Registers a callback function 'f'.
+  f will be called after each dispatched event is proce
+  f will be called with two parameters:
+    - the event's vector. That which was dispatched orignally.
+    - the further event queue - what is still to be processed.
+  "
+  [f]
+  (router/add-post-event-callback re-frame.router/event-queue f))
+


Added more information to the exception (#73)

* Clearer error output for network batching

* Clearer error output for network batching

--- compute/src/think/compute/batching_system.clj
+++ compute/src/think/compute/batching_system.clj
@@ -42,10 +42,15 @@
             (->> necessary-buffers
                  (map (fn [[stream {:keys [batch-buffers size]}]]
                         (let [{:keys [device-array host-buffer]} batch-buffers]
-                          (dtype/copy-raw->item! (get batch-map stream) host-buffer 0)
-                          (drv/copy-host->device (drv/get-stream backend) host-buffer 0
-                                                 (math/device-buffer device-array) 0
-                                                 (m/ecount host-buffer))
+                          (try
+                           (dtype/copy-raw->item! (get batch-map stream) host-buffer 0)
+                           (drv/copy-host->device (drv/get-stream backend) host-buffer 0
+                                                  (math/device-buffer device-array) 0
+                                                  (m/ecount host-buffer))
+                           (catch Exception e (throw (ex-info "Network batching - Raw Copy Failed: "
+                                                              {:buffer-size (m/ecount host-buffer)
+                                                               :incoming-stream-size (m/ecount (get batch-map stream))
+                                                               :stream stream}))))
                           [stream device-array])))
                  (into {})))
           batch-map-sequence))))


request debugging

request debugging

--- src/smallblog/core.clj
+++ src/smallblog/core.clj
@@ -99,6 +99,7 @@
                 (redirect redirect-url)))))

 (defn ensure-secure [request]
+    (println "request" request)
     (= :https (:scheme request)))

 (defn -get-posts-with-pagination


hoist up default-sgs and use it for asg too

--- src/terraboot/core.clj
+++ src/terraboot/core.clj
@@ -6,6 +6,8 @@
             [clojure.pprint :refer [pprint]]))

 (def account-id "12345")
+(def default-sgs ["allow_outbound" "allow_ssh"])
+
 (letfn [(merge-in* [a b]
           (if (map? a)
             (merge-with merge-in* a b)
@@ -111,8 +113,7 @@
          rule])))))

 (defn aws-instance [name spec]
-  (let [default-sgs ["allow_outbound"]
-        default-sg-ids (map (partial id-of "aws_security_group") default-sgs)]
+  (let [default-sg-ids (map (partial id-of "aws_security_group") default-sgs)]
     (resource "aws_instance" name (-> {:tags {:Name name}
                                        :instance_type "t2.micro"
                                        :key_name "ops-terraboot"
@@ -175,6 +176,8 @@
                                 (assoc map :ebs_block_device ebs_block_device)
                                 map))
         root_block_device (get spec :root_block_device {})
+
+        security-groups (map #(id-of "aws_security_group" %) (concat default-sgs sgs))
         asg-config
         (merge-in
          (resource "aws_iam_instance_profile" name
@@ -190,7 +193,7 @@
                                          :user_data user_data
                                          :lifecycle { :create_before_destroy true }
                                          :key_name (get spec :key_name "ops-terraboot")
-                                         :security_groups (map #(id-of "aws_security_group" %) sgs)
+                                         :security_groups security-groups
                                          :associate_public_ip_address (or public_ip false)
                                          :root_block_device root_block_device}


Add pure + deeppure tests

Add pure + deeppure tests

--- test/deepfns/core_test.cljc
+++ test/deepfns/core_test.cljc
@@ -127,7 +127,7 @@
     (map? m) {:a f}))

 (def gen-coll-ints
-  "Generates a collection of ints for testing"
+  "Generates vector of collections of ints for testing"
   (gen/one-of
     [(gen/vector (gen/map (gen/return :a) gen/int {:min-elements 1}) 1 5)
      (gen/vector (gen/vector gen/int 1) 1 5)
@@ -174,7 +174,7 @@
         (is (= out expected)
           (format "deepfapply homomorphism not equal: op - %s, args - %s" f args))))))

-;; TODO: get some coverage variadic interchange
+;; TODO: get some coverage for variadic interchange
 ;; test for interchange (4)
 (defspec deepfapply-interchange
   (prop/for-all [args gen-coll-ints]
@@ -217,3 +217,45 @@
     [{:a #{18} :b {:c {:d [28]}}}]
     [{:a #{*} :b {:c {:d [*]}}}]
     [{:a #{1 2}}] [{:a #{3} :b {:c {:d [4 5]}}}] [{:a #{6} :b {:c {:d [7]}}}]))
+
+(deftest pure-types
+  (are [expected coll x]
+      (is (= expected (pure coll x)))
+
+    nil nil nil
+    [nil] [] nil
+    '(nil) '() nil
+    {nil nil} {} nil
+
+    [[1]] [] [1]
+    '("foo") '() "foo"
+    {nil {:a 1}} {} {:a 1}
+
+    [1] [[1]] 1
+    '("foo") '(["bar"]) "foo"
+    {nil '(1)} {"foo" "bar"} '(1)
+    {nil 1} {:a ["foo"]} 1))
+
+(deftest deeppure-types
+  (are [expected coll x]
+      (is (= expected (deeppure coll x)))
+    nil nil nil
+    [nil] [] nil
+    '(nil) '() nil
+    {nil nil} {} nil
+
+    [[1]] [] [1]
+    '("foo") '() "foo"
+    {nil {:a 1}} {} {:a 1}
+
+    [[1]] [[1]] 1
+    '(["foo"]) '(["bar"]) "foo"
+    {"foo" '(1)} {"foo" "bar"} '(1)
+
+    [1 [1] 1] ["foo" [] "bar"] 1
+
+    (list 1 {:b [{nil 1} 1 (list 1)]} 1)
+    (list "foo" {:b [{} "bar" (list "fizz")]} "buzz") 1
+
+    {:a "test" :b ["test" '("test")]}
+    {:a 10 :b [1 '()]} "test"))


Add test for user data query function

Add test for user data query function

--- test/env_logger/db_test.clj
+++ test/env_logger/db_test.clj
@@ -13,6 +13,7 @@
                                    get-observations
                                    get-weather-obs-interval
                                    get-weather-obs-days
+                                   get-user-data
                                    validate-date
                                    make-date-dt]]
             [clojure.java.jdbc :as j]))
@@ -52,8 +53,17 @@
                                   (t/days 4)))
               :brightness 5
               :temperature 20})
+  (let [user-id (:user_id (first (j/insert! test-postgres
+                                            :users
+                                            {:username "test-user"
+                                             :pw_hash "myhash"})))]
+    (j/insert! test-postgres
+               :yubikeys
+               {:user_id user-id
+                :yubikey_id "mykeyid"}))
   (test-fn)
-  (j/execute! test-postgres "DELETE FROM observations"))
+  (j/execute! test-postgres "DELETE FROM observations")
+  (j/execute! test-postgres "DELETE FROM users"))

 ;; Fixture run at the start and end of tests
 (use-fixtures :once clean-test-database)
@@ -195,3 +205,10 @@
             :cloudiness 2
             :o_temperature 20.0}
            (first (get-weather-obs-days test-postgres 1))))))
+
+(deftest user-data-query
+  (testing "Querying for a users' password hash and Yubikey ID"
+    (is (nil? (get-user-data test-postgres "notfound")))
+    (is (= {:pw-hash "myhash"
+            :yubikey-ids (set ["mykeyid"])}
+           (get-user-data test-postgres "test-user")))))


Handle bigints, remove unused type hints

--- src/main/clojure/clojure/data/json_new.clj
+++ src/main/clojure/clojure/data/json_new.clj
@@ -12,7 +12,7 @@
   clojure.data.json-new
   (:require [clojure.pprint :as pprint])
   (:import (java.io PrintWriter PushbackReader StringWriter
-                    StringReader EOFException)))
+                    Writer StringReader EOFException)))

 ;;; JSON READER

@@ -125,25 +125,34 @@
           (do (.append buffer (char c))
               (recur)))))))

+(defn- parse-integer [^String string]
+  (if (< (count string) 18)  ; definitely fits in a Long
+    (Long/valueOf string)
+    (or (try (Long/valueOf string)
+             (catch NumberFormatException e nil))
+        (bigint string))))
+
+(defn- parse-decimal [^String string]
+  (if *bigdec*
+    (bigdec string)
+    (Double/valueOf string)))
+
 (defn- parse-number [^PushbackReader stream]
   (let [buffer (StringBuilder.)
-        floating-point?
-        (loop [float? false]
-          (let [c (.read stream)]
-            (codepoint-case c
-              (\- \+ \0 \1 \2 \3 \4 \5 \6 \7 \8 \9)
-              (do (.append buffer (char c))
-                  (recur float?))
-              (\e \E \.)
-              (do (.append buffer (char c))
-                  (recur true))
-              (do (.unread stream c)
-                  float?))))]
-    (if floating-point?
-      (if *bigdec*
-        (bigdec (str buffer))
-        (Double/valueOf (str buffer)))
-      (Long/valueOf (str buffer)))))
+        decimal? (loop [decimal? false]
+                   (let [c (.read stream)]
+                     (codepoint-case c
+                       (\- \+ \0 \1 \2 \3 \4 \5 \6 \7 \8 \9)
+                       (do (.append buffer (char c))
+                           (recur decimal?))
+                       (\e \E \.)
+                       (do (.append buffer (char c))
+                           (recur true))
+                       (do (.unread stream c)
+                           decimal?))))]
+    (if decimal?
+      (parse-decimal (str buffer))
+      (parse-integer (str buffer)))))

 (defn- -parse
   [^PushbackReader stream eof-error? eof-value]
@@ -243,7 +252,7 @@
     "Print object to PrintWriter out as JSON"))

 (defn- write-json-string [^CharSequence s ^PrintWriter out]
-  (let [sb (StringBuilder. ^Integer (count s))]
+  (let [sb (StringBuilder. (count s))]
     (.append sb \")
     (dotimes [i (count s)]
       (let [cp (int (.charAt s i))]
@@ -310,7 +319,7 @@
 (defn- write-json-null [x ^PrintWriter out]
   (.print out "null"))

-(defn- write-json-named [x ^PrintWriter out]
+(defn- write-json-named [x out]
   (write-json-string (name x) out))

 (defn- write-json-generic [x out]
@@ -355,7 +364,7 @@

     :escape-slash false
         to turn of escaping / as \\/"
-  [x writer & options]
+  [x ^Writer writer & options]
   (let [{:keys [escape-unicode escape-slash]
          :or {escape-unicode true
               escape-slash true}} options]


Slightly more clear test.

Slightly more clear test.

--- test/midje/t_semi_sweet.clj
+++ test/midje/t_semi_sweet.clj
@@ -160,17 +160,6 @@
               (fake (other-function 12) => 1))
       @reported => (just pass)))

-  (fact "call that matches none of the expected arguments falls through to existing function"
-    (after-silently
-      (expect (+ (mocked-function 33)) => "result irrelevant because of failure"
-              (fake (mocked-function 12) => "hi"))
-     ;; At the moment, this does not produce a :mock-argument-match-failure. What it does
-     ;; is call the "unfinished" function, which blows up, producing a `bad-result` (the exception
-     ;; object). That's not horrible, especially at the semi-sweet level, but it does suggest
-     ;; that the implementation of the sweet behavior (where an unfinished function produces
-     ;; an argument-match failure) is fragile.
-     @reported =future=> (just (contains {:type :mock-argument-match-failure :actual '(33)})
-                        bad-result)))

   (fact "failure because one variant of multiply-mocked function is not called"
     (after-silently
@@ -217,7 +206,13 @@
             :expected-result expected
             (fake (mocked-function 1) => 5 :result-supplier "IGNORED"
                   :result-supplier (fn [] expected)))))
-
+
+
+(defn backing-function [s] s)
+
+(fact "mocks are partial: they fall through to any previously defined function"
+  (expect (str (backing-function "returned") " " (backing-function "overridden")) => "returned new value"
+          (fake (backing-function "overridden") => "new value")))

 (facts "about checkers"
   (fact "expected results can be functions"


move! and mover! operate on a piece or a list respectively

--- src/tile_game/core.clj
+++ src/tile_game/core.clj
@@ -135,17 +135,16 @@
                          (paint [g]
                                 (dorun (for [x (range dim) y (range dim)]
                                          (render-tile g @*board* [x y])))))
-        move! (fn
-                ([piece]
-                   (dosync (when (can-move? @*board* piece)
-                             (alter *board* move piece)))
-                   (.repaint panel))
-                ([piece & moves]
-                   (prn piece moves)
-                   (move! piece)
-                   (send (agent moves) #(do
-                                         (Thread/sleep 500)
-                                         (apply move! %1)))))]
+        move! (fn ([piece]
+                    (dosync (when (can-move? @*board* piece)
+                              (alter *board* move piece)))
+                    (.repaint panel)))
+        mover! (fn [& moves]
+                (send (agent moves)
+                      (fn [moves]
+                        (doseq [m moves]
+                          (move! m)
+                          (Thread/sleep 500)))))]
     (doto panel
       (.setPreferredSize (Dimension. size size))
       (.setFocusable true)
@@ -159,10 +158,10 @@
                            KeyEvent/VK_UP    (dir-move :up)
                            KeyEvent/VK_DOWN  (dir-move :down)
                            KeyEvent/VK_Q     (.dispose #^JFrame frame)
-                           KeyEvent/VK_S     (apply move! (path-to @*board* [0 0]))
+                           KeyEvent/VK_S     (apply mover! (path-to @*board* [0 0]))
                            true))))))
     (doto frame (.setContentPane panel) .pack .show)
-    move!))
+    mover!))

 (comment
   (def move! (main)))


CMR-3968: changed the migration-down sequence.

--- ingest-app/src/migrations/005_create_bulk_update_tables.clj
+++ ingest-app/src/migrations/005_create_bulk_update_tables.clj
@@ -30,6 +30,6 @@
   "Migrates the database down from version 5."
   []
   (println "migrations.005-create-bulk-update-tables down...")
+  (j/db-do-commands (config/db) "DROP TABLE CMR_INGEST.bulk_update_coll_status")
   (j/db-do-commands (config/db) "DROP TABLE CMR_INGEST.bulk_update_task_status")
-  (j/db-do-commands (config/db) "DROP TABLE CMR_INGEST.bulk_update_coll_status")
   (j/db-do-commands (config/db) "DROP SEQUENCE CMR_INGEST.task_id_seq"))


lein-release plugin: preparing 0.4.1 release

--- re_view/project.clj
+++ re_view/project.clj
@@ -1,4 +1,4 @@
-(defproject re-view "0.4.1-SNAPSHOT"
+(defproject re-view "0.4.1"
   :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.5 to 0.4.6-SNAPSHOT for next development cycle

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


Disable the latest test.

Disable the latest test.

I'm not sure how best to override config for testing- which is what's
failing here. Looking into it.

--- test/shale/test/handler.clj
+++ test/shale/test/handler.clj
@@ -16,7 +16,7 @@
       (is (= (:status response) 200))
       (is (= (:body response) "[]"))))

-  (testing "requesting a session with an empty node list throws a 500"
+  #_(testing "requesting a session with an empty node list throws a 500"
     (with-redefs [configurer/config (override-config :node-list [])]
       (let [response (app (-> (mock/request :post "/sessions")
                               (mock/body "{}")))]


Update ns docstring to match ClojureScript

--- planck-cljs/src/planck/repl_resources.cljs
+++ planck-cljs/src/planck/repl_resources.cljs
@@ -19,18 +19,26 @@
     * :import is available for importing Google Closure classes
       - ClojureScript types and records should be brought in with :use
         or :require :refer, not :import ed
-    * Macros are written in Clojure, and are referenced via the new
-      :require-macros / :use-macros options to ns
+    * Macros must be defined in a different compilation stage than the one
+      from where they are consumed. One way to achieve this is to define
+      them in one namespace and use them from another. They are referenced
+      via the :require-macros / :use-macros options to ns
       - :require-macros and :use-macros support the same forms that
         :require and :use do

   Implicit macro loading: If a namespace is required or used, and that
   namespace itself requires or uses macros from its own namespace, then
   the macros will be implicitly required or used using the same
-  specifications. This oftentimes leads to simplified library usage,
-  such that the consuming namespace need not be concerned about
+  specifications. Furthermore, in this case, macro vars may be included
+  in a :refer or :only spec. This oftentimes leads to simplified library
+  usage, such that the consuming namespace need not be concerned about
   explicitly distinguishing between whether certain vars are functions
-  or macros.
+  or macros. For example:
+
+  (ns testme.core (:require [cljs.test :as test :refer [test-var deftest]]))
+
+  will result in test/is resolving properly, along with the test-var
+  function and the deftest macro being available unqualified.

   Inline macro specification: As a convenience, :require can be given
   either :include-macros true or :refer-macros [syms...]. Both desugar
@@ -48,7 +56,18 @@
   (:require [foo.core :as foo :refer [foo-fn]]
             [woz.core :as woz :refer [woz-fn]])
   (:require-macros [foo.core :as foo]
-                   [woz.core :as woz :refer [app jx]]))"}
+                   [woz.core :as woz :refer [app jx]]))
+
+  Auto-aliasing clojure namespaces: If a non-existing clojure.* namespace
+  is required or used and a matching cljs.* namespace exists, the cljs.*
+  namespace will be loaded and an alias will be automatically established
+  from the clojure.* namespace to the cljs.* namespace. For example:
+
+  (ns testme.core (:require [clojure.test]))
+
+  will be automatically converted to
+
+  (ns testme.core (:require [cljs.test :as clojure.test]))"}
     def   {:forms [(def symbol doc-string? init?)]
            :doc   "Creates and interns a global var with the name
   of symbol in the current namespace (*ns*) or locates such a var if


Added condense-depth for debugging logging in guides.

--- src/zprint/zprint.cljc
+++ src/zprint/zprint.cljc
@@ -139,6 +139,33 @@
       (if (and (= caller (first debug-vector))
                (= (:depth options) (second debug-vector)))
         (nth debug-vector 2)))))
+
+(defn condense
+  [depth [out accumulated-string current-depth] [s _ what :as element]]
+  (let [new-depth (cond (= what :left) (inc current-depth)
+                        (= what :right) (dec current-depth)
+                        :else current-depth)
+        accumulating? (> current-depth depth)
+        start-accumulating? (> new-depth depth)
+        new-accumulated-string (if (or accumulating? start-accumulating?)
+                                 (str accumulated-string s)
+                                 accumulated-string)
+        next-accumulated-string
+          (if start-accumulating? new-accumulated-string "")]
+
+    [(cond (and accumulating? (not start-accumulating?))
+             (conj out new-accumulated-string)
+           (and accumulating? start-accumulating?) out
+           (and (not accumulating?) (not start-accumulating?)) (conj out
+                                                                     element)
+           (and (not accumulating?) start-accumulating?) out
+           :else (println "shouldn't be an else")) next-accumulated-string
+     new-depth]))
+
+(defn condense-depth
+  "Take a style vec, and condense everything above the given depth."
+  [depth coll]
+  (first (reduce (partial condense depth) [[] "" 1] coll)))

 ;;
 ;; # Use pmap when we have it
@@ -4469,16 +4496,27 @@
         param-map (if (or comment? (and previous-comment? newline?))
                     param-map
                     (dissoc param-map :spaces))]
-    (dbg-s options
-           :guide
-           "guided-output: ------ incoming out:"
-           #_out
-           ((:dzprint options) {} (into [] out)))
+    (dbg-s
+      options
+      :guide
+      "guided-output: ------ incoming out:"
+      #_out
+      ((:dzprint options)
+        {}
+        (into []
+              #_out
+              (let [out-len (count out)
+                    out-drop (int (* 0.8 out-len))
+                    out-drop
+                      (if (< (- out-len out-drop) 10) (- out-len 10) out-drop)]
+                #_(concat [(str "dropped " out-drop " elements")]
+                          (drop out-drop out))
+                (condense-depth 1 out)))))
     (dbg-s-pr options :guide "guided-output; ------ next-guide:" next-guide)
     (dbg-s options
            :guide
            "guided-output: ------ next-seq:"
-           ((:dzprint options) {} next-seq))
+           ((:dzprint options) {} (condense-depth 1 next-seq)))
     (dbg-s-pr options :guide "guided-output: ------ mark-map:" mark-map)
     ;"(first cur-seq)" (first cur-seq)
     (dbg-s
@@ -4532,25 +4570,22 @@
      ; out
      ;
      (let [guided-output-out
-             (concat
-               out
-               (if fit?
-                 ; Note that newlines don't fit
-                 (if (not (zero? index))
-                   ; Separate from previous thing by one space.
-                   ; Of course, this might now not fit?  We did check
-                   ; before.
-                   #_(concat-no-nil [[" " :none :whitespace 15]] next-seq)
-                   ; spaces from align have precedence over just random spaces
-                   (concat-no-nil
-                     ; Ensure that despite alignment, we don't let two things
-                     ; run
-                     ; together!
-                     [[(blanks
-                         (max
-                           1
-                           (or
-                             (when align-spaces
+             (if fit?
+               ; Note that newlines don't fit
+               (if (not (zero? index))
+                 ; Separate from previous thing by one space.
+                 ; Of course, this might now not fit?  We did check
+                 ; before.
+                 #_(concat-no-nil [[" " :none :whitespace 15]] next-seq)
+                 ; spaces from align have precedence over just random spaces
+                 (concat-no-nil
+                   ; Ensure that despite alignment, we don't let two things
+                   ; run
+                   ; together!
+                   [[(blanks
+                       (max
+                         1
+                         (or (when align-spaces
                                (if previous-newline? align-ind align-spaces))
                              ; If spaces come after a newline, they are beyond
                              ; the indent, and do not replace the indent.
@@ -4570,61 +4605,62 @@
                                  (+ indent ind))
                                1)
                              #_1))) :none :whitespace 25]]
+                   next-seq)
+                 ; This might be nil, but that's ok
+                 next-seq)
+               (if newline?
+                 (concat-no-nil
+                   ; If we have excess-guided-newline-count, then
+                   ; output it now.  These newlines have no spaces
+                   ; after them, so they should not be used to start
+                   ; a line with something else on it!  We dec because
+                   ; the next thing is a guarenteed newline.
+                   (if (and excess-guided-newline-count
+                            (pos? (dec excess-guided-newline-count)))
+                     (repeat (dec excess-guided-newline-count)
+                             ["\n" :indent 22])
+                     :noseq)
+                   [[(str "\n"
+                          #_(blanks
+                              ; Figure out what the next thing is
+                              ; If this is a pair, that's a bit dicey?
+                              (let [next-seq-next (first (next cur-seq))
+                                    newline-next?
+                                      (when next-seq-next
+                                        (= (nth (first next-seq-next) 2)
+                                           :newline))]
+                                ; If the next thing is a newline,
+                                ; don't put any blanks on this line
+                                (if newline-next? 0 (dec new-ind))))) :none
+                     :indent 21]])
+                 ; This doesn't fit, and isn't a newline
+                 ; Do we need a newline, or do we already have one
+                 ; we could use?
+                 ;
+                 ; This will be a problem, as the simple case says
+                 ; "Sure, we can use a guided newline here."
+                 ; Don't let a comment come after a guided-newline
+                 (if (and previous-newline?
+                          (not (and comment? previous-guided-newline?)))
+                   ; We have just done a newline that we can use.
+                   #_(concat-no-nil [[" " :none :whitespace 16]] next-seq)
+                   (concat-no-nil
+                     [[(blanks (if previous-newline? #_ind (+ indent ind) 1))
+                       #_" " :none :whitespace 16]]
                      next-seq)
-                   ; This might be nil, but that's ok
-                   next-seq)
-                 (if newline?
-                   (concat-no-nil
-                     ; If we have excess-guided-newline-count, then
-                     ; output it now.  These newlines have no spaces
-                     ; after them, so they should not be used to start
-                     ; a line with something else on it!  We dec because
-                     ; the next thing is a guarenteed newline.
-                     (if (and excess-guided-newline-count
-                              (pos? (dec excess-guided-newline-count)))
-                       (repeat (dec excess-guided-newline-count)
-                               ["\n" :indent 22])
-                       :noseq)
-                     [[(str "\n"
-                            #_(blanks
-                                ; Figure out what the next thing is
-                                ; If this is a pair, that's a bit dicey?
-                                (let [next-seq-next (first (next cur-seq))
-                                      newline-next?
-                                        (when next-seq-next
-                                          (= (nth (first next-seq-next) 2)
-                                             :newline))]
-                                  ; If the next thing is a newline,
-                                  ; don't put any blanks on this line
-                                  (if newline-next? 0 (dec new-ind))))) :none
-                       :indent 21]])
-                   ; This doesn't fit, and isn't a newline
-                   ; Do we need a newline, or do we already have one
-                   ; we could use?
-                   ;
-                   ; This will be a problem, as the simple case says
-                   ; "Sure, we can use a guided newline here."
-                   ; Don't let a comment come after a guided-newline
-                   (if (and previous-newline?
-                            (not (and comment? previous-guided-newline?)))
-                     ; We have just done a newline that we can use.
-                     #_(concat-no-nil [[" " :none :whitespace 16]] next-seq)
-                     (concat-no-nil
-                       [[(blanks (if previous-newline? #_ind (+ indent ind) 1))
-                         #_" " :none :whitespace 16]]
-                       next-seq)
-                     ; Do we already have a newline at the beginning of a bunch
-                     ; of
-                     ; output?
-                     (if indent?
-                       ; Yes, don't prepend another newline
-                       next-seq
-                       (prepend-nl options (+ indent ind) next-seq))))))]
-       (dbg-s options
-              :guide
-              "guided-output returned out:"
-              ((:dzprint options) {} (into [] guided-output-out)))
-       guided-output-out)]))
+                   ; Do we already have a newline at the beginning of a bunch
+                   ; of
+                   ; output?
+                   (if indent?
+                     ; Yes, don't prepend another newline
+                     next-seq
+                     (prepend-nl options (+ indent ind) next-seq)))))]
+       (dbg-s
+         options
+         :guide
+         "guided-output returned additional out:"
+         ((:dzprint options) {} (into [] (condense-depth 1 guided-output-out))))
+       (concat out guided-output-out))]))

 (defn comment-or-newline?
   "Is this element in the output from fzprint-seq a comment or a newline?"
@@ -4733,7 +4769,7 @@
         (do (dbg-s options
                    :guide
                    "fzprint-guide: out:"
-                   ((:dzprint options) {} (into [] out)))
+                   ((:dzprint options) {} (into [] (condense-depth 1 out))))
             #_(prn "fzprint-guide out:" out)
             out)
         (if (> index 50)


Tests all pass, just comments in list doesn't yet work.

But the comments are there at least, though too many blank lines.

--- src/zprint/zprint.cljc
+++ src/zprint/zprint.cljc
@@ -2230,6 +2230,7 @@
     (let [zloc-seq (nthnext zloc-seq (inc next-count))]
       (dbg-pr "get-zloc-seq-right:" (map zstring zloc-seq))
       zloc-seq)))
+

 ;;
 ;; # Indent-only support
@@ -3466,10 +3467,11 @@
         (concat-no-nil
           l-str-vec
           pre-arg-1-style-vec
-	  (do (prn "pre-arg-1-style-vec:" pre-arg-1-style-vec "r-str-vec:" r-str-vec) :noseq)
+	  (do #_(prn "pre-arg-1-style-vec:" pre-arg-1-style-vec "r-str-vec:" r-str-vec "arg-1-zloc:" (zstring arg-1-zloc)) :noseq)
+          (if arg-1-zloc
+	    (fzprint* loptions (+ l-str-len ind) arg-1-zloc)
+	    :noseq)
 	  (if arg-1-zloc
-	  (do
-          (fzprint* loptions (+ l-str-len ind) arg-1-zloc)
           (let [zloc-seq-right-first (get-zloc-seq-right first-data)]
             (if zloc-seq-right-first
               ; We have something else to format after arg-1-zloc
@@ -3504,7 +3506,7 @@
                                       :newline-first))))
               ; Nothing else after arg-1-zloc
               :noseq)
-	      ))
+	      )
 	      :noseq)
           r-str-vec))))

@@ -3830,7 +3832,7 @@
          previous-comment? nil]
     (if (empty? coll)
       (let [result (persistent! out)]
-        (prn "precede-w-nl: exit:" result)
+        #_(prn "precede-w-nl: exit:" result)
         (if previous-comment? (butlast result) result))
       (let [[[s color what] :as element] (first coll)
             ; This element may have many things in it, or sometimes
@@ -3846,7 +3848,7 @@
             ; Let's make sure about the last
             last-what (nth (last element) 2)
             comment? (or (= last-what :comment) (= last-what :comment-inline))]
-        (prn "precede-w-nl: element:" element
+        #_(prn "precede-w-nl: element:" element
                "what:" what
                "comment?:" comment?)
         (recur (next coll)


minor: removed implicit dependency.

minor: removed implicit dependency.

--- ssclj/tools/build.boot
+++ ssclj/tools/build.boot
@@ -34,7 +34,6 @@

                     [com.sixsq.slipstream/SlipStreamPersistence nil :scope "compile"]
                     [com.sixsq.slipstream/SlipStreamDbSerializers-jar nil :scope "compile"]
-                    #_[com.sixsq.slipstream/SlipStreamCljResources-jar nil :scope "compile"]

                     [superstring]
                     [me.raynes/fs]


finished first pass of swagger api. will populate more descriptions and bad status codes later

--- src/restaurant_inspections_api/schemas.clj
+++ src/restaurant_inspections_api/schemas.clj
@@ -14,6 +14,110 @@
                      :countynumber s/Int
                      :countyname s/Str
                      :inspections s/Int})
+
+;; "id": 1,
+;; "description": "Approved source",
+;; "is_risk_factor": true,
+;; "is_primary_concern": false
+(s/defschema Violation
+  {:id s/Int
+   :description s/Str
+   :is_risk_factor Boolean
+   :is_primary_concern Boolean})
+
+;; "county_number": 11,
+;; "location_address": "2500 NE 39 AVE",
+;; "noncritical_violations_before_2013": null,
+;; "license_type_code": "2015",
+;; "location_city": "GAINESVILLE",
+;; "business_name": "DOUBLE ENVELOP 71099",
+;; "license_number": 1100012,
+;; "location_zipcode": "32609",
+;; "critical_violations_before_2013": null,
+;; "location_latitude": null,
+;; "location_longitude": null
+(s/defschema Business
+  {:county_number s/Int
+   :location_address s/Str
+   :noncritical_violations_before_2013 s/Int
+   :license_type_code s/Str
+   :location-city s/Str
+   :business_name s/Str
+   :license_number Long
+   :location_zipcode s/Str
+   :critical_violations_before_2013 s/Int
+   :location_latitude s/Num
+   :location_longitude s/Num})
+
+;; "intermediateViolations": null,
+;; "locationCity": "MARCO ISLAND",
+;; "locationAddress": "250 S BEACH DR",
+;; "countyName": "Collier",
+;; "licenseTypeCode": "2010",
+;; "businessName": "HIDEAWAY BCH THE POOL BAR",
+;; "locationZipcode": "34145",
+;; "totalViolations": 0,
+;; "type": "inspections",
+;; "inspectionDisposition": "Call Back - Complied",
+;; "inspectionNumber": 2158023,
+;; "basicViolations": null,
+;; "id": "4598476",
+;; "countyNumber": 21,
+;; "licenseNumber": 2101212,
+;; "visitNumber": 2,
+;; "inspectionType": "Routine - Food",
+;; "inspectionDate": "2016-06-15",
+;; "highPriorityViolations": null,
+;; "district": "D7"
+(s/defschema Inspection
+  {:intermediateViolations s/Int,
+   :locationCity s/Str,
+   :locationAddress s/Str,
+   :countyName s/Str,
+   :licenseTypeCode s/Str,
+   :businessName s/Str,
+   :locationZipcode s/Str,
+   :totalViolations s/Int,
+   :type s/Str,
+   :inspectionDisposition s/Str,
+   :inspectionNumber Long,
+   :basicViolations s/Int,
+   :id s/Str,
+   :countyNumber s/Int,
+   :licenseNumber Long,
+   :visitNumber s/Int,
+   :inspectionType s/Str,
+   :inspectionDate java.util.Date,
+   :highPriorityViolations s/Int,
+   :district s/Str})
+
+;; Has a little bit more info than normal inspection used in listings
+(s/defschema InspectionDetail
+  {:intermediateViolations s/Int,
+   :locationCity s/Str,
+   :locationAddress s/Str,
+   :countyName s/Str,
+   :licenseTypeCode s/Str,
+   :businessName s/Str,
+   :locationZipcode s/Str,
+   :totalViolations s/Int,
+   :type s/Str,
+   :inspectionDisposition s/Str,
+   :inspectionNumber Long,
+   :basicViolations s/Int,
+   :nonCriticalViolationsBefore2013 s/Int,
+   :id s/Str,
+   :countyNumber s/Int,
+   :licenseNumber Long,
+   :pdaStatus Boolean
+   :visitNumber s/Int,
+   :inspectionType s/Str,
+   :inspectionDate java.util.Date,
+   :violations [Violation]
+   :highPriorityViolations s/Int,
+   :criticalViolationsBefore2013 s/Int,
+   :district s/Str})
+

 (defn wrap-data
   ""
@@ -42,32 +146,30 @@
                                                         :description "Counties description here..."}}
                                        :summary "counties summary here"}}

-                   "/inspections" {:get {:responses {200 {:schema User
+                   "/inspections" {:get {:responses {200 {:schema Inspection
                                                           :description "Found it!"}}
-
                                          :parameters {:query {(s/optional-key :countyNumber) s/Int
                                                               (s/optional-key :districtCode) s/Int
                                                               (s/optional-key :zipCodes) s/Str
                                                               (s/optional-key :startDate) s/Str
                                                               (s/optional-key :endDate) s/Str
                                                               (s/optional-key :businessName) s/Str}}
-
                                          :summary "adds two numbers together"}}

-                   "/inspections/:id" {:get {:responses {200 {:schema User
+                   "/inspections/:id" {:get {:responses {200 {:schema InspectionDetail
                                                               :description "Found it!"}}
+                                             :parameters {:path {:id Long}}
                                              :summary "adds two numbers together"}}

-                   "/businesses" {:get {:responses {200 {:schema User
+                   "/businesses" {:get {:responses {200 {:schema Business
                                                          :description "Found it!"}}
                                         :summary "adds two numbers together"}}

-                   "/businesses/:licenseNumber" {:get {:responses {200 {:schema User
+                   "/businesses/:licenseNumber" {:get {:responses {200 {:schema Business
                                                                         :description "Found it!"}}
+                                                       :parameters {:path {:licenseNumber Long}}
                                                        :summary "adds two numbers together"}}

-                   "/violations" {:get {:responses {200 {:schema User
+                   "/violations" {:get {:responses {200 {:schema Violation
                                                          :description "Found it!"}}
-                                        :summary "adds two numbers together"}}
-
-                   }}}})
+                                        :summary "adds two numbers together"}}}}}})


Don't worry about dtd when updating meta data on an ncc file

--- src/mdr2/dtb/xml.clj
+++ src/mdr2/dtb/xml.clj
@@ -82,7 +82,7 @@
   [production]
   (let [manifest (path/manifest-path production)
         updated (with-open [r (io/reader manifest)]
-                  (update-meta-data (xml/parse r)
+                  (update-meta-data (xml/parse r :support-dtd false)
                                     production handle-manifest-node))]
     (with-open [w (io/writer manifest)]
       (xml-new/emit updated w :doctype manifest-doctype))))


render only the selected tab

render only the selected tab

--- src-cljs/core.cljs
+++ src-cljs/core.cljs
@@ -29,6 +29,7 @@
               :results []
               }
      :player-queue []
+     :tab-on-view [:search]
      }))

 (defn search-results []
@@ -36,6 +37,9 @@

 (defn player-queue []
   (om/ref-cursor (:player-queue (om/root-cursor app-state))))
+
+(defn tab-on-view []
+  (om/ref-cursor (:tab-on-view (om/root-cursor app-state))))

 (defn enqueue-track [track]
   (om/transact! (player-queue) #(conj % track)))
@@ -163,8 +167,8 @@
                         (dom/span #js {:className "duration"} "Length")
                         (dom/button #js {:onClick #(dequeue-all)} "-"))
                (map #(om/build queue-track-view
-                             %1
-                             {:state {:index %2}})
+                               %1
+                               {:state {:index %2}})
                     queue (range 0 999))
                )))))

@@ -222,16 +226,23 @@
     om/IRender
     (render [this]
       (let [queue (om/observe owner (player-queue))
-        bits (best-media-url (first queue))]
-        (dom/div nil
-                 (dom/h2 nil "queue")
-                 (om/build queue-view app)
-                 (dom/audio #js {:controls "controls"
+            on-view (om/observe owner (tab-on-view))
+            bits (best-media-url (first queue))
+            player (dom/audio #js {:controls "controls"
                                  :autoPlay "true"
                                  :ref "player"
                                  :src bits
-                                 })
-                 )))))
+                                 })]
+        (if (= (first on-view) :player-queue)
+          (dom/div nil
+                   (dom/h2 nil "player")
+                   (dom/h3 nil "queued")
+                   (om/build queue-view app)
+                   player)
+          (dom/div nil
+                   player))))))
+
+

 (defn update-term [[command new-terms] previous]
   (case command
@@ -253,11 +264,16 @@
                 (recur))))))
     om/IRender
     (render [this]
-      (dom/div nil
-               (om/build search-entry-view (:term search)
-                         {:init-state {:string ""}})
-               (dom/h2 nil "results")
-               (om/build results-view (:results search))))))
+      (let [on-view (om/observe owner (tab-on-view))]
+        (if (= (first on-view) :search)
+          (dom/div nil
+                   (dom/h2 nil "library")
+                   (om/build search-entry-view (:term search)
+                             {:init-state {:string ""}})
+                   (om/build results-view (:results search))))))))
+
+(defn show-tab [cursor tab-name]
+  (om/update! cursor [:tab-on-view] [tab-name]))

 (defn tab-selector-view [app owner]
   (reify
@@ -265,9 +281,9 @@
     (render [this]
       (dom/nav nil
                (dom/ul nil
-                       (dom/li {:onClick #(show-tab :library)}
+                       (dom/li #js {:onClick #(show-tab app :search)}
                                "library")
-                       (dom/li  {:onClick #(show-tab :player)}
+                       (dom/li  #js {:onClick #(show-tab app :player-queue)}
                                 "player"))))))


Add comment

Add comment

--- src/yada/methods.clj
+++ src/yada/methods.clj
@@ -37,6 +37,9 @@
   (try
     (f ctx)
     (catch clojure.lang.ArityException e
+      ;; TODO: This might not be the arity exception you are looking
+      ;; for (it might be a real arity-exception thrown up by the code
+      ;; in question. This should still mean that the code works, but it doesn't seem to.
       (let [ar (util/arity f)]
         (case ar
           0 (f)


use form for workspace ACL editor

use form for workspace ACL editor

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/summary_tab.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/summary_tab.cljs
@@ -29,6 +29,48 @@
     (fn [k] {:userId k :accessLevel (acl-map k)})
     (keys acl-map)))

+(defn- render-acl-content [props state this]
+  [comps/OKCancelForm
+   {:header
+    (let [workspace-id (:workspace-id props)]
+      (str "Permissions for " (:namespace workspace-id) ":" (:name workspace-id)))
+    :content
+    (react/create-element
+      [:div {}
+       (when (:saving? @state)
+         [comps/Blocker {:banner "Updating..."}])
+       [:div {:style {:padding "0.5em 0" :fontSize "90%"}}
+        [:div {:style {:float "left" :width column-width}} "User or Group ID"]
+        [:div {:style {:float "right" :width column-width}} "Access Level"]
+        (common/clear-both)]
+       (map-indexed
+         (fn [i acl-entry]
+           [:div {}
+            (style/create-text-field
+              {:ref (str "acl-key" i)
+               :style {:float "left" :width column-width :color "black"
+                       :backgroundColor (when (< i (:count-orig @state)) (:background-gray style/colors))}
+               :disabled (< i (:count-orig @state))
+               :spellCheck false
+               :defaultValue (:userId acl-entry)})
+            (style/create-select
+              {:ref (str "acl-value" i)
+               :style {:float "right" :width column-width :height 33}
+               :defaultValue (:accessLevel acl-entry)}
+              access-levels)
+            (common/clear-both)])
+         (:acl-vec @state))
+       [comps/Button {:text "Add new" :style :add
+                      :onClick #(do
+                                 (react/call :capture-ui-state this)
+                                 (swap! state update-in [:acl-vec] conj {:userId "" :accessLevel "READER"}))}]])
+    :dismiss-self (:dismiss-self props)
+    :ok-button
+    [comps/Button {:text "Save"
+                   :onClick #(do
+                              (react/call :capture-ui-state this)
+                              (react/call :persist-acl this))}]}])
+
 (react/defc AclEditor
   {:render
    (fn [{:keys [props state this]}]
@@ -37,52 +79,12 @@
        :dismiss-self (:dismiss-self props)
        :content
        (react/create-element
-         [:div {:style {:padding "2em"}}
-          (cond
-            (:acl-vec @state)
-            [:div {}
-             (when (:saving? @state)
-               [comps/Blocker {:banner "Updating..."}])
-             [:div {:style {:fontWeight 500}}
-              (let [workspace-id (:workspace-id props)]
-                (str "Permissions for " (:namespace workspace-id) ":" (:name workspace-id)))]
-             [:div {:style {:padding "0.5em 0" :fontSize "90%"}}
-              [:div {:style {:float "left" :width column-width}} "User or Group ID"]
-              [:div {:style {:float "right" :width column-width}} "Access Level"]
-              (common/clear-both)]
-             (map-indexed
-               (fn [i acl-entry]
-                 [:div {}
-                  (style/create-text-field
-                    {:ref (str "acl-key" i)
-                     :style {:float "left" :width column-width
-                             :backgroundColor (when (< i (:count-orig @state)) (:background-gray style/colors))}
-                     :disabled (< i (:count-orig @state))
-                     :spellCheck false
-                     :defaultValue (:userId acl-entry)})
-                  (style/create-select
-                    {:ref (str "acl-value" i)
-                     :style {:float "right" :width column-width :height 33}
-                     :defaultValue (:accessLevel acl-entry)}
-                    access-levels)
-                  (common/clear-both)])
-               (:acl-vec @state))
-             [comps/Button {:text "Add new" :style :add
-                            :onClick #(do
-                                       (react/call :capture-ui-state this)
-                                       (swap! state update-in [:acl-vec] conj {:userId "" :accessLevel "READER"}))}]
-             [:div {:style {:textAlign "center" :marginTop "1em"}}
-              [:a {:href "javascript:;"
-                   :style {:textDecoration "none" :color (:button-blue style/colors) :marginRight "1.5em"}
-                   :onClick #((:dismiss-self props))}
-               "Cancel"]
-              [comps/Button {:text "Save"
-                             :onClick #(do
-                                        (react/call :capture-ui-state this)
-                                        (react/call :persist-acl this))}]]]
-
-            (:error @state) (style/create-server-error-message (:error @state))
-            :else [comps/Spinner {:text "Loading Permissions..."}])])}])
+         (if (:acl-vec @state)
+           (render-acl-content props state this)
+           [:div {:style {:padding "2em"}}
+            (if (:error @state)
+              (style/create-server-error-message (:error @state))
+              [comps/Spinner {:text "Loading Permissions..."}])]))}])
    :capture-ui-state
    (fn [{:keys [state refs]}]
      (swap! state assoc :acl-vec


Add a test to see if a keystream is repeating

--- test/caesium/magicnonce/secretbox_test.clj
+++ test/caesium/magicnonce/secretbox_test.clj
@@ -86,3 +86,23 @@
           c2 (ms/secretbox-rnd st/ptext st/secret-key)]
       (is (u/array-eq c1 c2))
       (is (= (range s/noncebytes) (take s/noncebytes c1) (take s/noncebytes c2))))))
+
+(defn repeated-keystream?
+  "Does given scheme repeat the keystream when applied to given
+  plaintexts?
+
+  This compares the XORd ciphertexts to the XORd plaintexts. This will
+  only be the same when the keystream repeats, and should not happen
+  in an NMR scheme, or in a randomized scheme."
+  [ptexts scheme]
+  (let [just-ctext (fn [^bytes ptext]
+                     (->> (scheme ptext)
+                          (drop s/noncebytes)
+                          (take (alength ptext))))
+        ctexts (map just-ctext ptexts)
+        shortest (apply min alength ptexts)
+        xord-ptexts (byte-array shortest)
+        xord-ctexts (byte-array shortest)]
+    (apply #'ms/xor! xord-ptexts ptexts)
+    (apply #'ms/xor! xord-ctexts ctexts)
+    (u/array-eq xord-ptexts xord-ctexts)))


ARM: shmobile: uImage load address rework

This is V2 of the mach-shmobile uImage load address rework patch.

Rework the mach-shmobile uImage load address calculation by storing
the per-board load addresses in Makefile.boot. This removes the
CONFIG_MEMORY_START dependency from Makefile.boot, and it also makes
it possible to create safe kernel images that boot on multiple boards.

This is one of several series of code that reworks code not to rely on
CONFIG_MEMORY_START/SIZE which in turn is needed for ARCH_MULTIPLATFORM.

Signed-off-by: Magnus Damm <2336f5729424d0c84d319e991b3648cafa2c3c5b@opensource.se>
Reviewed-by: Laurent Pinchart <3ded2f39a78f0d7044839546f95841842b4d7c96@ideasonboard.com>
Reviewed-by: Kuninori Morimoto <a3b51ccb87d18302c1692defcfbf83319d1737eb@renesas.com>
Signed-off-by: Simon Horman <9662bddcc379be37df16f02a449c344b4718c1a1@verge.net.au>

--- arch/arm/mach-shmobile/Makefile.boot
+++ arch/arm/mach-shmobile/Makefile.boot
@@ -1,6 +1,22 @@
-__ZRELADDR	:= $(shell /bin/bash -c 'printf "0x%08x" \
-		     $$[$(CONFIG_MEMORY_START) + 0x8000]')
+# per-board load address for uImage
+loadaddr-y	:=
+loadaddr-$(CONFIG_MACH_AG5EVM) += 0x40008000
+loadaddr-$(CONFIG_MACH_AP4EVB) += 0x40008000
+loadaddr-$(CONFIG_MACH_APE6EVM) += 0x40008000
+loadaddr-$(CONFIG_MACH_ARMADILLO800EVA) += 0x40008000
+loadaddr-$(CONFIG_MACH_ARMADILLO800EVA_REFERENCE) += 0x40008000
+loadaddr-$(CONFIG_MACH_BOCKW) += 0x60008000
+loadaddr-$(CONFIG_MACH_BONITO) += 0x40008000
+loadaddr-$(CONFIG_MACH_KOTA2) += 0x41008000
+loadaddr-$(CONFIG_MACH_KZM9D) += 0x40008000
+loadaddr-$(CONFIG_MACH_KZM9G) += 0x41008000
+loadaddr-$(CONFIG_MACH_KZM9G_REFERENCE) += 0x41008000
+loadaddr-$(CONFIG_MACH_LAGER) += 0x40008000
+loadaddr-$(CONFIG_MACH_MACKEREL) += 0x40008000
+loadaddr-$(CONFIG_MACH_MARZEN) += 0x60008000
+loadaddr-$(CONFIG_MACH_MARZEN_REFERENCE) += 0x60008000

+__ZRELADDR	:= $(sort $(loadaddr-y))
    zreladdr-y   += $(__ZRELADDR)

 # Unsupported legacy stuff


minor style refactor

minor style refactor

--- solutions/day09/solution.clj
+++ solutions/day09/solution.clj
@@ -42,23 +42,23 @@
   (->> cities
        (filter (complement (set path))) ; remove any cities that are already on the path
        (map #(conj path %))
-       ; put cost alongside path for easy use with priority-map conj
-       (map #(vector % (path->cost % distance-map cities)))
-       (reduce concat)))
+       (map #(hash-map % (path->cost % distance-map cities)))
+       (reduce merge)))

 (defn A*
   [distance-map cities]
-  (loop [q (apply pm/priority-map (path->children [] distance-map cities))
-         best-cost nil]
+  (loop [q (merge (pm/priority-map) (path->children [] distance-map cities))
+         best-path nil]
     (if-let [[path cost] (peek q)]
-      (if (and best-cost (< best-cost cost))
+      (if (and best-path (< (:cost best-path) cost))
         ; if the best path available on the q costs more than the best solution we've found so far, we're done
-        best-cost
+        best-path
         (let [children (path->children path distance-map cities)
               q (pop q)]
           (if (empty? children)
-            (recur q cost) ; complete path - if we've gotten here, it's also the lowest-cost complete path
-            (recur (apply assoc q children) best-cost)))))))
+            ; complete path - if we've gotten here, it's also the lowest-cost complete path
+            (recur q {:path path :cost cost})
+            (recur (merge q children) best-path)))))))

 (defn part1
   [distance-map cities]
@@ -67,9 +67,11 @@
 (defn part2
   [distance-map cities]
   ; invert the city-to-city distance map, effectively making A* maximize the cost
-  (let [neg-distances (map #(* -1 %) (vals distance-map))
-        neg-distance-map (zipmap (keys distance-map) neg-distances) ]
-    (* -1 (A* neg-distance-map cities))))
+  (let [inv-distances (map #(/ 1.0 %) (vals distance-map))
+        inv-distance-map (zipmap (keys distance-map) inv-distances)
+        longest-path (A* inv-distance-map cities)
+        true-cost (path->cost (:path longest-path) distance-map cities)]
+    (assoc longest-path :cost true-cost)))

 (println "part 1:" (part1 distance-map cities))
 (println "part 2:" (part2 distance-map cities))


expanding error handling

expanding error handling

--- internal/machina/src/samsara/machina/core.clj
+++ internal/machina/src/samsara/machina/core.clj
@@ -374,3 +374,132 @@

     ))
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;                                                                            ;;
+;;       ---==| E X P A N D I N G   F O U R T H   A T T E M P T |==----       ;;
+;;                                                                            ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;
+;; same as before just now expanding the capabilities
+;; of generic wrappers and common pattern/policies for
+;; error handling (WORK IN PROGRESS)
+;;
+
+(comment
+
+  (defn log-state-change [handler]
+    (fn [sm1]
+      (let [sm2 (handler sm1)]
+        (println "transition: " (:state sm1) "->" (:state sm2))
+        sm2)))
+
+  (defn epoch-counter
+    [handler]
+    (fn [sm]
+      (handler (update sm :epoch (fnil inc 0)))))
+
+  ;; not sure about this
+  (defn error-state
+    [handler]
+    (fn [sm]
+      (try
+        (handler sm)
+        (catch Throwable x
+          (assoc sm :last-error
+                 {:from-state  (:state sm)
+                  :error-epoch (:epoch sm)
+                  :error       x}
+                 :state :error)))))
+
+
+  (defn- wrapper
+    ([] identity)
+    ([f] f)
+    ([f g] (g f))
+    ([f g & fs]
+     (reduce wrapper (concat [f g] fs))))
+
+  (comment
+    (defn mh [n]
+      (fn [h]
+        (fn [sm]
+          (println n)
+          (h sm))))
+
+    (def f1 (mh 1))
+    (def f2 (mh 2))
+    (def f3 (mh 3))
+    (def f4 (mh 4))
+
+    ((wrapper identity f4 f3 f2 f1) {}))
+
+
+  ;; write to file example
+  (def sm
+    {:state :machine/start
+     :epoch 0
+     :data nil
+
+     :dispatch
+     {:machine/stop identity
+      :machine/start
+      (fn
+        [sm]
+        (assoc sm
+               :data "/tmp/1/2/3/4/5/file.txt"
+               :state :write-to-file))
+
+      :write-to-file
+      (fn
+        [{f :data :as sm}]
+        (write-to-file f)
+        (assoc sm :state :sleep))
+
+      :sleep
+      (fn
+        [sm]
+        (Thread/sleep 1000)
+        (assoc sm :state :write-to-file))}
+
+     :error-policies
+     {:machine/default {:type        :retry
+                        :max-retry   :forever
+                        :retry-delay [:random-exp-backoff :base 3000 :+/- 0.35 :max 25000]}
+
+      :write-to-file   {:type        :retry
+                        :max-retry   :forever
+                        :retry-delay [:random 3000 :+/- 0.35]}}
+
+     :wrappers
+     [#'epoch-counter #'log-state-change #'error-state]})
+
+
+  (defn bad-state [sm]
+    (throw (ex-info "Invalid state" sm)))
+
+  (defn transition
+    [{:keys [state data dispatch wrappers] :as sm}]
+    (let [f0 (get dispatch state bad-state)
+          f  (apply wrapper (cons f0 (reverse wrappers)))]
+      (f sm)))
+
+
+  (comment
+
+    (-> sm
+        transition
+        transition
+        ;;transition
+        )
+
+    (->> sm
+         (iterate transition)
+         (take-while #(not= :machine/stop (:state %)))
+         (last))
+
+
+    ))


Remove extra prn

Remove extra prn

Fix #88

--- ClojureScript/replete/src/replete/core.cljs
+++ ClojureScript/replete/src/replete/core.cljs
@@ -145,7 +145,6 @@
     :clj))

 (defn- pre-compiled-callaback-data [path]
-  (prn path)
   (when-let [js-source (js/REPLETE_LOAD (str path ".js"))]
     (when-let [cache (js/REPLETE_LOAD (str path ".cljs.cache.edn"))]
       {:lang   :js


Task parameters must be strings, not keywords. Thanks to Brian Gruber for pointing out the bug.

--- src/appengine_magic/services/task_queues.clj
+++ src/appengine_magic/services/task_queues.clj
@@ -47,10 +47,12 @@
       (.header opts header-name header-value))
     ;; params
     (doseq [[param-name param-value] params]
-      (.param opts param-name (cond
-                               (string? param-value) param-value
-                               (instance? (class (byte-array 0)) param-value) param-value
-                               :else (str param-value))))
+      (.param opts
+              (name param-name)
+              (cond
+               (string? param-value) param-value
+               (instance? (class (byte-array 0)) param-value) param-value
+               :else (str param-value))))
     ;; HTTP method for hitting task
     (.method opts (*task-http-methods* method))
     ;; payload


textual corrections

textual corrections

--- web/src/web/index.clj
+++ web/src/web/index.clj
@@ -67,7 +67,7 @@
 var Model = _.module(
     {},

-    //add a new todo entry
+    //Add a new todo entry
     function add_todo (state, title) {
         //check that it's not empty before creating a new todo.
         var trimmed_title = title.trim();
@@ -75,7 +75,7 @@
         return { todos: state.todos.concat({title: title, completed: false}) };
     },

-    //mark a todo either active or complete
+    //Mark a todo either active or complete
     function toggle_status (state, data) {
         return { todos: _.map(state.todos, function (todo) {
             if (todo === data.todo) return _.assoc(todo, 'completed', data.completed);
@@ -83,16 +83,18 @@
         }) };
     },

-    //clear completed todos
+    //Clear completed todos
     function clear_completed (state) {
         return { todos: _.reject(state.todos, _.flippar(_.at, 'completed')) };
     },

+    //Save the entire app to localStorage
     function save_app (state) {
         localStorage.setItem('pasta-todo', JSON.stringify(state));
         return {};
     },

+    //Recover the app from localStorage
     function load_app (state) {
         return localStorage.getItem('pasta-todo')
             || { todos: [] };
@@ -222,7 +224,7 @@
      [:h2 "Pasta Is Simple"]
      [:p [:strong "Simple"] " in the sense Rich Hickey told us in his talk " [:a {:href "http://www.infoq.com/presentations/Simple-Made-Easy"} "Simple Made Easy"] ". Pasta lets you treat " [:span.important "data as data"] " and it turns " [:span.important "uncontrolled global state into a concrete first-class value"] ". Pasta is mostly functional. The model is a collection of pure functions. The application itself is a pure function that maps an application state to an UI state."]
      [:p "Pasta is simple because Pasta apps are not object oriented. Objects should be avoided where possible because they introduce implicit global state, makes it hard to inspect data (you know, \"" [:i "information hiding"] "\") and makes it so easy to corrupt data."]
-     [:p "Pasta is simple because it doesn't do anything that it isn't supporsed to do. There are good data manipulation libraries already, namely Underscore (or lodash). There are good UI manipulation libraries already, namely jQuery (or Zepto). No point reinventing the wheel is there?"]]
+     [:p "Pasta is simple because it doesn't do anything that it isn't supporsed to do. There are good data manipulation libraries already, namely Underscore. There are good UI manipulation libraries already, namely jQuery. No point reinventing the wheel is there?"]]
     [:hr]
     [:section#mvc
      [:h2 "MVC the Pasta way"]
@@ -231,23 +233,23 @@
       [:h3 "Model"]
       [:pre.prettyprint code-model-js]
       [:p "The Model is a hashmap mapping signal names to binary functions. " [:span.code "_.module()"] " provides a nice way to write hashmap-of-functions prettily. Each function receives the current state as its first argument. The second is whatever is passed in via a signal which we will come to later. The state is just a plain hashmap which you mustn't mutate yourself. The role of each function is to return a patch. Patches are, again, just a plain hashmap."]
-      [:p "Since it is advised to prefer primitive types over user-defined objects, we can do some crazy stuff like serializing it into JSON and save somewhere and recover it later. Because the state passed is a immutable value, we can store it into the state itself, meaning implementing a full `undo` functionality is easy peasy."]]
+      [:p "Since it is advised to prefer primitive types over user-defined objects, we can do some crazy stuff like serializing it into JSON and save somewhere and recover it later. Because the state passed is a immutable value, we can store it into the state itself, meaning implementing a full `undo` functionality is a piece of cake."]]
      [:section
       [:h3 "View"]
       [:pre.prettyprint code-view-js]
-      [:p "The view is a hashmap mapping field names of the state to ternary functions. Each function gets called whenever the field that the function is responsible for. The first argument is the UI module which we will see next. The second is the new state after the change. The last argument is the value of the field before the change. The role of each function is to call functions (uh, ahem) subroutines in the UI module. Although the functions receive the state, mutating it is no use since it is a fresh copy. Don't try."]]
+      [:p "The view is a hashmap mapping field names of the state to ternary functions. Each function gets called whenever the field the function is responsible for changes. The first argument is the UI module which we will see next. The second is the new state after the change. The last argument is the value of the field before the change. The role of each function is to call functions (uh, ahem, subroutines) in the UI module. Although the functions receive the state, mutating it is no use since it is a fresh copy. Don't try."]]
      [:section
       [:h3 "UI"]
       [:pre.prettyprint code-ui-js]
-      [:p "No description is needed for the UI module because it isn't really a part of Pasta. Pasta does not care how you manage the UI, making Pasta portable accross different platforms. In fact Pasta initily targeted Titanium Mobile as a platform and it probably runs still."]]
+      [:p "No description is needed for the UI module because it isn't really a part of Pasta. Pasta does not care how you manage the UI. this makes Pasta portable accross different platforms. In fact Pasta initialy targeted Titanium Mobile as a platform and it probably still runs."]]
      [:section
       [:h3 "Generation of An App"]
       [:pre.prettyprint "var pasta_signal = Pasta(Model, UI, View);"]
-      [:p "Throw all of the above three modules at " [:span.code "Pasta"] " to generate the app. " [:span.code "Pasta"] " leaves a function behind which is the only one connection we have to the running app. We will make heavy use of this function in controllers."]]
+      [:p "Throw all of the above three modules at " [:span.code "Pasta"] " to generate the app. " [:span.code "Pasta"] " leaves a function behind which is the only connection we have to the running app. We will make heavy use of this function in our controllers."]]
      [:section
       [:h3 "Controller"]
       [:pre.prettyprint code-controller-js]
-      [:p "Controllers are not grouped into a module because there's no need to. Controllers can be anything that " [:span.code "signal"] "s. A signal invokes a model function and whatever you feed to " [:span.code "signal"] " becomes the second argumentof the functions in the model."]]]
+      [:p "Controllers are not grouped into a module because there's no need to. Controllers can be anything that " [:span.code "signal"] "s. A signal invokes a model function and whatever you feed to " [:span.code "signal"] " becomes the second argument to the function."]]]
     [:hr]
     [:section#diagram
      [:h2 "A Diagram"]


proper xhr-select scroller

proper xhr-select scroller

--- src/cljs/re_form/inputs/select_xhr_impl.cljs
+++ src/cljs/re_form/inputs/select_xhr_impl.cljs
@@ -63,6 +63,20 @@
   (when-not (empty? query)
     (go (>! ch query))))

+(defn scroll [container elem direction]
+  (let [elem-top (.-offsetTop elem)
+        elem-bot (+ elem-top (.-clientHeight elem))
+        view-top (.-scrollTop container)
+        view-bot (+ view-top (.-clientHeight container))]
+    (case direction
+          :down (when (> elem-bot view-bot)
+                  (set! (.-scrollTop container)
+                        (- elem-bot (.-clientHeight container))))
+          :up (when (< elem-top view-top)
+                  (set! (.-scrollTop container)
+                        elem-top))
+          nil)))
+
 (defn select-xhr-input [{:keys [suggest-fn on-change]}]
   (let [state (r/atom {:current-text nil
                        :focused false
@@ -86,19 +100,17 @@
               (lookup-suggestions on-change-ch text))))
         arrow-handler (fn [e]
                         (if-let [s (:selected @state)]
-                          (let [upd (fn [x]
+                          (let [upd (fn [x direction]
                                       (.. s -classList (remove "active"))
                                       (.. x -classList (add "active"))
                                       (swap! state assoc :selected x)
                                       (let [sugs (:suggestions-container @state)]
-                                        (set! (.-scrollTop sugs)
-                                              (- (.-offsetTop x) (.-clientHeight sugs)
-                                                 (- (.-clientHeight x))))))]
+                                        (scroll sugs x direction)))]
                             (case (.-keyCode e)
                               38 (when-let [prev-sibl (.-previousSibling s)]
-                                   (upd prev-sibl))
+                                   (upd prev-sibl :up))
                               40 (when-let [next-sibl (.-nextSibling s)]
-                                   (upd next-sibl))
+                                   (upd next-sibl :down))
                               13 (do (.click (:selected @state))
                                      (swap! state dissoc :selected)
                                      (.blur (:node @state)))


log error handling

log error handling

#120

--- src/cljs/swarmpit/component/service/log.cljs
+++ src/cljs/swarmpit/component/service/log.cljs
@@ -30,7 +30,8 @@
      :on-success (fn [response]
                    (state/update-value [:initialized] true cursor)
                    (state/update-value [:fetching] false cursor)
-                   (state/update-value [:data] response cursor))}))
+                   (state/update-value [:data] response cursor))
+     :on-error   #(state/update-value [:error] true cursor)}))

 (defn log-append-handler
   [service from-timestamp]
@@ -49,7 +50,8 @@
   (state/set-value {:filter      {:predicate ""}
                     :initialized false
                     :fetching    false
-                    :autoscroll  true
+                    :autoscroll  false
+                    :error       false
                     :timestamp   false
                     :data        []} cursor))

@@ -79,7 +81,7 @@
                  refresh-state-mixin
                  {:did-mount  (fn [state] (auto-scroll!) state)
                   :did-update (fn [state] (auto-scroll!) state)} [service]
-  (let [{:keys [filter data autoscroll timestamp initialized]} (state/react cursor)
+  (let [{:keys [filter data autoscroll timestamp initialized error]} (state/react cursor)
         filtered-items (filter-items data
                                      (:predicate filter))]
     [:div
@@ -107,7 +109,8 @@
                      (state/update-value [:autoscroll] v cursor))})]]
      [:div.log#service-log
       (cond
-        (and (empty? filtered-items) initialized) [:span "There are no logs available for the service."]
+        error [:span "Logs for this service couldn't be fetched."]
+        (and (empty? filtered-items) initialized) [:span "Log is empty in this service."]
         (not initialized) [:span "Loading..."]
         :else (map
                 (fn [item]


log auto-scroll fixed, optimization (added keys)

--- src/cljs/swarmpit/component/service/log.cljs
+++ src/cljs/swarmpit/component/service/log.cljs
@@ -12,7 +12,7 @@
 (defn- auto-scroll!
   []
   (when (true? (:autoscroll (state/get-value state/form-state-cursor)))
-    (let [el (.getElementById js/document "service-log")]
+    (let [el (.getElementById js/document "autoscroll")]
       (.scrollTo js/window 0 (.-scrollHeight el)))))

 (defn form-search-fn
@@ -36,6 +36,15 @@
     (filter #(= taskId (:task %)) log)
     log))

+
+(def line-num (atom 0))
+
+(defn- filter-logs
+  [taskId log]
+  (->> log
+       (filter-by-task taskId)
+       (map #(assoc-in % [:key] (swap! line-num inc)))))
+
 (defn- log-handler
   [service-id task-id]
   (ajax/get
@@ -43,7 +52,7 @@
     {:state      [:fetching]
      :on-success (fn [{:keys [response]}]
                    (state/update-value [:initialized] true state/form-state-cursor)
-                   (state/set-value (filter-by-task task-id response) state/form-value-cursor))
+                   (state/set-value (filter-logs task-id response) state/form-value-cursor))
      :on-error   #(state/update-value [:error] true state/form-state-cursor)}))

 (defn- log-append-handler
@@ -54,7 +63,7 @@
      :params     {:from from-timestamp}
      :on-success (fn [{:keys [response]}]
                    (state/set-value (-> (state/get-value state/form-value-cursor)
-                                        (concat (filter-by-task task-id response))) state/form-value-cursor))}))
+                                        (concat (filter-logs task-id response))) state/form-value-cursor))}))

 (defn- init-form-state
   []
@@ -80,7 +89,7 @@
       (service-handler id)
       (log-handler id taskId))))

-(rum/defc line < rum/static [service item timestamp]
+(rum/defc line < rum/static [service item]
   [:div
    [:a.log-info {:href (routes/path-for-frontend :service-task-log {:id (:serviceName service) :taskId (:task item)})}
     (str (subs (:task item) 0 7))]
@@ -91,7 +100,7 @@
                  mixin-refresh-form
                  {:did-mount  (fn [state] (auto-scroll!) state)
                   :did-update (fn [state] (auto-scroll!) state)} [{{:keys [id]} :params}]
-  (let [{:keys [filter autoscroll timestamp initialized error service]} (state/react state/form-state-cursor)
+  (let [{:keys [filter autoscroll initialized error service]} (state/react state/form-state-cursor)
         logs (state/react state/form-value-cursor)
         filtered-logs (filter-items logs (:predicate filter))]
     (comp/mui
@@ -104,14 +113,15 @@
              :mini    true
              :onClick #(state/update-value [:autoscroll] (not autoscroll) state/form-state-cursor)}
             icon/scroll-down)]
-         [:div.Swarmpit-form-context.Swarmpit-log
+         [:div#autoscroll.Swarmpit-form-context.Swarmpit-log
           (cond
             error [:span "Logs for this service couldn't be fetched."]
             (and (empty? logs) initialized) [:span "Log is empty in this service."]
             (not initialized) [:span "Loading..."]
             :else (map
                     (fn [item]
-                      (line service item timestamp)) filtered-logs))]]))))
+                      (rum/with-key (line service item) (:key item)))
+                    filtered-logs))]]))))

 (rum/defc form-task < form [params]
   (form params))


Added tests for collection AQL search on addtionalAttributeNames.

--- test/cmr/system_int_test/search/collection_psa_search_test.clj
+++ test/cmr/system_int_test/search/collection_psa_search_test.clj
@@ -76,6 +76,21 @@
            [coll1] [{:type :string :name "alpha" :value "a%" :pattern true}]
            [coll1] [{:type :string :name "alpha" :value "a_" :pattern true}]))

+    (testing "search collections by additionalAttributeNames with AQL."
+      (are [items attrib-names options]
+           (let [condition (merge {:additionalAttributeNames attrib-names} options)]
+             (d/refs-match? items
+                            (search/find-refs-with-aql :collection [condition])))
+           [coll1] "alpha" {}
+           [coll1 coll2] "bravo" {}
+           [coll2] "charlie" {}
+           [coll3] "case" {}
+           [] "BLAH" {}
+           [coll1 coll3] ["alpha" "case"] {}
+           [coll1 coll2 coll3] ["alpha" "charlie" "case"] {}
+           [coll2 coll3] "c%" {:pattern true}
+           [coll3] "cas_" {:pattern true}))
+
     (testing "searching with multiple attribute conditions"
       (are [v items operation]
            (d/refs-match?


no need for a snapshot anymore

no need for a snapshot anymore

--- riffle-hadoop/project.clj
+++ riffle-hadoop/project.clj
@@ -1,4 +1,4 @@
-(defproject factual/riffle-hadoop "0.1.0-SNAPSHOT"
+(defproject factual/riffle-hadoop "0.1.0"
   :description "FIXME: write description"
   :url "http://example.com/FIXME"
   :license {:name "Eclipse Public License"


persistence: refactor watching code

persistence: refactor watching code

--- contrib/persistence/src/carry_persistence/core.cljs
+++ contrib/persistence/src/carry_persistence/core.cljs
@@ -1,10 +1,14 @@
 (ns carry-persistence.core
   (:require [cljs.core.match :refer-macros [match]]))

+(defn -whitelist
+  "Removes blacklisted keys from the specified map."
+  [m blacklist]
+  (apply dissoc m blacklist))
+
 (defn -save
-  [storage key blacklist model]
-  (let [save-whitelist (clojure.set/difference (set (keys model)) blacklist)]
-    (assoc! storage key (select-keys model save-whitelist))))
+  [storage key model]
+  (assoc! storage key model))

 (defn -wrap-control
   [app-control storage key blacklist load-wrapper]
@@ -25,13 +29,14 @@
                      ((load-wrapper load-from-storage) model loaded-model dispatch-signal))))

                ; save for the first time and on every future change
-               (-save storage key blacklist @model)
+               (-save storage key (-whitelist @model blacklist))
                (add-watch model
                           [::persistence-watcher key]       ; unique key
                           (fn [_key _atom old-state new-state]
-                            ; TODO: optimize: compare using blacklist
-                            (when (not= old-state new-state)
-                              (-save storage key blacklist new-state)))))
+                            (let [old-state (-whitelist old-state blacklist)
+                                  new-state (-whitelist new-state blacklist)]
+                              (when (not= old-state new-state)
+                                (-save storage key new-state))))))

              [::on-load-from-storage key loaded-model]
              (dispatch-action [::load-from-storage key loaded-model])


Sorting keys of generated maps in output

This has no computational value since javascript map keys are unsorted,
but it should make diffs between different generated externs a little
easier to read.

--- src/javascript_externs_generator/extern.cljs
+++ src/javascript_externs_generator/extern.cljs
@@ -25,14 +25,14 @@
   ([obj name seen]
    {:name      name
     :type      (prop-type obj)
-    :props     (for [prop-name (js-keys obj)
+    :props     (for [prop-name (-> obj js-keys sort)
                      :let [child (obj/get obj prop-name)]]
                  (if (and (parent-type? child)
                           (not (contains? seen child))
                           (not (.-nodeType child)))
                    (generate-object-tree child prop-name (conj seen child))
                    {:name prop-name :type (prop-type child)}))
-    :prototype (for [prop-name (js-keys (.-prototype obj))]
+    :prototype (for [prop-name (-> obj .-prototype js-keys sort)]
                  {:name prop-name :type :function})}))

 (defn emit-props-extern
@@ -93,5 +93,3 @@
     (when (nil? js-object)
       (throw (str "Namespace '" name "' was not found. Make sure the library is loaded and the name is spelled correctly.")))
     (wrap-extern name (extract name js-object))))
-
-


[PDOK-1976] no extra visualization tables

--- src/main/clojure/pdok/featured/geoserver.clj
+++ src/main/clojure/pdok/featured/geoserver.clj
@@ -18,13 +18,6 @@
       (conj! target x)
       (recur (conj! target x) (first xs) (rest xs)))))

-(def visualization-table
-  {:bgt {:wegdeel$kruinlijn "kruinlijn"}})
-
-(defn visualization [dataset collection]
-  (let [k-collection (keyword collection)
-        k-dataset (keyword dataset)]
-    (or (get-in visualization-table [k-dataset k-collection] collection))))

 (defn do-visualization? [options]
   (if (some #{"visualization"} options) true))
@@ -37,12 +30,12 @@
   (pg/create-schema db dataset))

 (defn- gs-collection-exists? [db dataset collection]
-  (let [table (visualization dataset collection)]
+  (let [table collection]
     (pg/table-exists? db dataset table)))

 (defn- gs-create-collection [db ndims srid dataset collection]
   "Create table with default fields"
-  (let [table (visualization dataset collection)]
+  (let [table collection]

       (pg/create-table db dataset table
                 [:gid "serial" :primary :key]
@@ -61,7 +54,7 @@

 (defn- gs-collection-attributes [db dataset collection]
   ;(println "attributes")
-  (let [table (visualization dataset collection)
+  (let [table collection
         columns (pg/table-columns db dataset table)
         no-defaults (filter #(not (some #{(:column_name %)} ["gid"
                                                              "_id"
@@ -74,7 +67,7 @@
     attributes))

 (defn- gs-add-attribute [db dataset collection attribute-name attribute-type]
-  (let [table (visualization dataset collection)]
+  (let [table collection]
     (try
       (pg/add-column db dataset table attribute-name attribute-type)
       (catch java.sql.SQLException e
@@ -136,8 +129,9 @@
                                  (map #(feature-to-sparse-record proj-fn % (all-fields-constructor all-attributes)) grouped-features))]
               (if (not (empty? records))
                 (let [fields (concat [:_id :_version :_geometry_point :_geometry_line :_geometry_polygon :_geo_group]
-                                   (map pg/quoted all-attributes))]
-                  (apply (partial j/insert! c (str dataset "." (pg/quoted (visualization dataset collection))) fields)
+                                   (map pg/quoted all-attributes))
+                      table collection]
+                  (apply (partial j/insert! c (str dataset "." (pg/quoted table)) fields)
                        records)))))))
      (catch java.sql.SQLException e
        (log/with-logs ['pdok.featured.projectors :error :error] (j/print-sql-exception-chain e))))))
@@ -150,7 +144,8 @@

 (defn- execute-update-sql [db dataset collection columns update-vals]
   (try
-    (let [sql (gs-update-sql dataset (visualization dataset collection) (map name columns))]
+    (let [table collection
+          sql (gs-update-sql dataset table (map name columns))]
       (j/execute! db (cons sql update-vals) :multi? true :transaction? false))
     (catch java.sql.SQLException e
       (log/with-logs ['pdok.featured.projectors :error :error] (j/print-sql-exception-chain e)))))
@@ -178,7 +173,8 @@
     (let [selector (juxt :dataset :collection)
           per-dataset-collection (group-by selector features)]
        (doseq [[[dataset collection] collection-features] per-dataset-collection]
-        (let [sql (gs-delete-sql dataset (visualization dataset collection))
+        (let [table collection
+              sql (gs-delete-sql dataset table)
               ids (map #(vector (:id %1) (:current-version %1)) collection-features)]
           (j/execute! db (cons sql ids) :multi? true :transaction? false))))
     (catch java.sql.SQLException e


And a test

And a test

--- test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
+++ test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
@@ -370,4 +370,12 @@

   (is (= "TRUNCATE b.a;"
          (truncate :a :b)))
+
+  (println (batch
+            [(select "table-name"
+                      (column "asd"))
+              (select "table-name"
+                      (column "asd"))
+              (select "table-name"
+                      (column "asd"))]))
   )


removed :gen-class from simple-application

--- src/maqueta/tutorials/simple_application.clj
+++ src/maqueta/tutorials/simple_application.clj
@@ -2,8 +2,7 @@
   (:use (maqueta application assets))
   (:import com.jme3.scene.Geometry
            com.jme3.scene.shape.Box
-           (com.jme3.math ColorRGBA Vector3f))
-  (:gen-class))
+           (com.jme3.math ColorRGBA Vector3f)))

 (def geom (let [b (Box. Vector3f/ZERO 1 1 1)
                 geom (Geometry. "Box" b)


update rabble dep

update rabble dep

--- server/project.clj
+++ server/project.clj
@@ -23,7 +23,7 @@
                  [org.clojure/data.json "0.2.2"]
                  [me.raynes/cegdown "0.1.0"]
                  [twitter-api "0.7.5"]
-                 [rabble "0.2.0"]
+                 [rabble "0.2.2"]
                  [com.flyingmachine/webutils "0.1.6"]
                  [flyingmachine/cartographer "0.1.1"]
                  [com.flyingmachine/datomic-junk "0.1.3"]


use cloning for nginx request map

use cloning for nginx request map

--- src/open_company/api/stakeholder_updates.clj
+++ src/open_company/api/stakeholder_updates.clj
@@ -101,10 +101,11 @@

   ;; Create a new stakeholder update
   :post-to-missing? false ; 404 if company doesn't exist
-  :post! (fn [ctx] (let [ctx' (assoc ctx :stakeholder-update (create-stakeholder-update conn ctx))]
+  :post! (fn [ctx] (let [su   (create-stakeholder-update conn ctx)
+                         ctx' (assoc (common/clone ctx) :stakeholder-update su)]
                      (when (-> ctx :data :slack)
                        (bot/send-trigger! (bot/ctx->trigger :stakeholder-update ctx')))
-                     ctx'))
+                     {:stakeholder-update su}))

   ;; Handlers
   :handle-not-acceptable (common/only-accept 406 su-rep/collection-media-type)


Fixed version of evermind.core in evermind.web project.

--- evermind.web/project.clj
+++ evermind.web/project.clj
@@ -16,7 +16,7 @@
                            [cljsjs/react-dom "15.4.2-1"]
                            [sablono "0.7.7"]
                            [org.omcljs/om "1.0.0-alpha46"]
-                           [evermind.core "0.1.0-SNAPSHOT"]]
+                           [evermind.core :version]]

             :source-paths ["src"]


add more benchmark cases

add more benchmark cases

--- scripts/benchmarks.clj
+++ scripts/benchmarks.clj
@@ -66,7 +66,6 @@
       (fn [structure]
         (afn structure curr)))
     [identity (get-k :c) (get-k :b) (get-k :a)]))
-

 (let [data {:a {:b {:c 1}}}
       p (comp-paths :a :b :c)]
@@ -86,6 +85,7 @@
     (select-any [(keypath :a) (keypath :b) (keypath :c)] data)))

+
 (let [data {:a {:b {:c 1}}}]
   (run-benchmark "set value in nested map" 2500000
     (assoc-in data [:a :b :c] 1)
@@ -334,3 +334,22 @@
   (run-benchmark "multi-transform vs. consecutive transforms, three shared navs" 150000
     (->> data (transform [ALL ALL number? even?] mult-10) (transform [ALL ALL number? odd?] dec))
     (multi-transform [ALL ALL number? (multi-path [even? (terminal mult-10)] [odd? (terminal dec)])] data)))
+
+(let [data {:a 1 :b 2 :c 3 :d 4}]
+  (run-benchmark "namespace qualify keys of a small map" 1000000
+    (into {}
+      (map (fn [[k v]] [(keyword (str *ns*) (name k)) v]))
+      data)
+    (reduce-kv (fn [m k v] (assoc m (keyword (str *ns*) (name k)) v)) {} data)
+    (setval [MAP-KEYS NAMESPACE] (str *ns*) data)
+    ))
+
+
+(let [data (->> (for [i (range 1000)] [(keyword (str i)) i]) (into {}))]
+  (run-benchmark "namespace qualify keys of a large map" 1200
+    (into {}
+      (map (fn [[k v]] [(keyword (str *ns*) (name k)) v]))
+      data)
+    (reduce-kv (fn [m k v] (assoc m (keyword (str *ns*) (name k)) v)) {} data)
+    (setval [MAP-KEYS NAMESPACE] (str *ns*) data)
+    ))


refactor adler32

refactor adler32

--- src/cellophane/checksums.clj
+++ src/cellophane/checksums.clj
@@ -6,40 +6,41 @@

 (def MOD 65521)

-;; TODO: refactor this into more idiomatic Clojure. ATM it's a simple port of
-;; https://github.com/facebook/react/blob/3b96650/src/shared/utils/adler32.js
-(defn- adler32 [data]
-  (let [a (atom 1)
-        b (atom 0)
-        l (count data)
-        m (bit-and l (bit-not 0x3))
-        i
-        (loop [i 0]
-          (if (< i m)
-            (let [n (Math/min (+ i 4096) m)]
-              (run!
-                (fn [idx]
-                  (let [a0 (swap! a + (nth data idx))
-                        a1 (swap! a + (nth data (+ idx 1)))
-                        a2 (swap! a + (nth data (+ idx 2)))
-                        a3 (swap! a + (nth data (+ idx 3)))]
-                    (swap! b + a0 a1 a2 a3)))
-                (range i n 4))
-              (swap! a mod MOD)
-              (swap! b mod MOD)
-              (recur (+ (last (range i n 4)) 4)))
-            i))]
-    (loop [i i]
-      (if (< i l)
-        (let [a' (swap! a + (nth data i))]
-          (swap! b + a')
-          (recur (inc i)))))
-    (swap! a mod MOD)
-    (swap! b mod MOD)
-    (bit-or @a (unchecked-int (bit-shift-left @b 16)))))
+;; Adapted from https://github.com/tonsky/rum
+(defn adler32 [sb]
+  (let [l (.length sb)
+        m (bit-and l -4)]
+    (loop [a (int 1)
+           b (int 0)
+           i 0
+           n (min (+ i 4096) m)]
+      (cond
+        (< i n)
+        (let [c0 (int (.charAt sb i))
+              c1 (int (.charAt sb (+ i 1)))
+              c2 (int (.charAt sb (+ i 2)))
+              c3 (int (.charAt sb (+ i 3)))
+              b  (+ b a c0
+                   a c0 c1
+                   a c0 c1 c2
+                   a c0 c1 c2 c3)
+              a  (+ a c0 c1 c2 c3)]
+          (recur (rem a MOD) (rem b MOD) (+ i 4) n))
+
+        (< i m)
+        (recur a b i (min (+ i 4096) m))
+
+        (< i l)
+        (let [c0 (int (.charAt sb i))]
+          (recur (+ a c0) (+ b a c0) (+ i 1) n))
+
+        :else
+        (let [a (rem a MOD)
+              b (rem b MOD)]
+          (bit-or (int a) (unchecked-int (bit-shift-left b 16))))))))

 (defn checksum [data]
-  (adler32 (.getBytes data)))
+  (adler32 data))

 (defn assign-react-checksum [markup]
   (->> (str/split markup #">" 2)