Use sets from internals

Use sets from internals

--- test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
+++ test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
@@ -185,9 +185,7 @@
                  (value "a" 123)
                  (value "b" (java.net.InetAddress/getByName "127.0.0.1"))
                  (value (quote* "C") "foo'bar")
-                 (value "d" (doto (java.util.TreeMap.)
-                              (.put "x" 3)
-                              (.put "y" 2)))
+                 (value "d" (array-map "x" 3 "y" 2))
                  (using (array-map :timestamp 42
                                    :ttl       24))

@@ -205,22 +203,14 @@
   (is (= "INSERT INTO foo(a,b) VALUES ({2,3,4},3.4) USING TIMESTAMP 42 AND TTL 24;"
          (insert :foo
                  (values ["a" "b"]
-                         [(doto (java.util.TreeSet.)
-                            (.add 2)
-                            (.add 3)
-                            (.add 4))
-                          3.4])
+                         [(sorted-set 2 3 4) 3.4])
                  (using (array-map :timestamp 42
                                    :ttl       24)))))

   (is (= "INSERT INTO foo(a,b) VALUES ({2,3,4},3.4) USING TTL ? AND TIMESTAMP ?;"
          (insert :foo
                  (values [:a :b]
-                         [(doto (java.util.TreeSet.)
-                            (.add 2)
-                            (.add 3)
-                            (.add 4))
-                          3.4])
+                         [(sorted-set 2 3 4) 3.4])
                  (using (array-map :ttl       (?)
                                    :timestamp (?))))))

@@ -228,11 +218,7 @@
          (insert :foo
                  (value :c 123)
                  (values [:a :b]
-                         [(doto (java.util.TreeSet.)
-                            (.add 2)
-                            (.add 3)
-                            (.add 4))
-                          3.4]
+                         [(sorted-set 2 3 4) 3.4]
                          )
                  (using {:timestamp 42}))))


refactor to separate atom manipulation/reading

--- cartagena-web/src/cartagena_web/main.cljs
+++ cartagena-web/src/cartagena_web/main.cljs
@@ -119,26 +119,35 @@
 (defn on-new-game [response]
   (reset! app-state response))

-(defn new-game! []
+(defn new-game [state]
   (let [players (cond-> []
                         (get-name :black) (conj {:name (get-name :black) :color :black})
                         (get-name :blue) (conj {:name (get-name :blue) :color :blue})
                         (get-name :green) (conj {:name (get-name :green) :color :green})
                         (get-name :orange) (conj {:name (get-name :orange) :color :orange})
                         (get-name :red) (conj {:name (get-name :red) :color :red}))]
-  (reset! app-state (dissoc @app-state :select-players))
+    (dissoc state :selected-players)))
+
+(defn new-game! []
+  (swap! app-state new-game)
   (swap! names empty-names)
   (ajax/POST "http://localhost:3000/new-game"
              {:params {:players (shuffle players)}
               :handler on-new-game
-              :error-handler on-error})))
+              :error-handler on-error}))
+
+(defn select-players [state]
+  (assoc state :select-players true))

 (defn select-players! []
-  (reset! app-state (assoc @app-state :select-players true)))
+  (swap! app-state select-players))
+
+(defn update-active-player [state response]
+  (assoc state :actions-remaining (:actions-remaining response)
+         :current-player (:current-player response)))

 (defn on-update-active-player [response]
-  (reset! app-state (assoc @app-state :actions-remaining (:actions-remaining response)
-                                     :current-player (:current-player response))))
+  (swap! app-state update-active-player response))

 (defn update-active-player! [{:keys [actions-remaining current-player player-order]}]
   (ajax/POST "http://localhost:3000/update-active-player"
@@ -157,15 +166,22 @@
         pirate-counts-by-color (frequencies (:pirates ship))]
     (some #(>= (second %) 6) pirate-counts-by-color)))

+(defn end-game [state]
+  (assoc state :game-over true))
+
 (defn end-game! []
-  (reset! app-state (assoc @app-state :game-over true)))
+  (swap! app-state end-game))
+
+(defn play-card [state response]
+  (-> state
+      (assoc :board (:board response)
+             :discard-pile (:discard-pile response)
+             :players (conj (remove #{(active-player state)} (:players state)) (:player response)))
+      (dissoc state :selected-card)))

 (defn on-play-card [response]
   (let [board (:board response)]
-    (reset! app-state (assoc @app-state :board (:board response)
-                                        :discard-pile (:discard-pile response)
-                                        :players (conj (remove #{(active-player @app-state)} (:players @app-state)) (:player response))))
-    (reset! app-state (dissoc @app-state :selected-card))
+    (swap! app-state play-card response)
     (if (game-over? board)
       (end-game!)
       (update-active-player! @app-state))))
@@ -180,12 +196,15 @@
               :handler on-play-card
               :error-handler on-error}))

+(defn move-back [state response]
+  (assoc state :board board
+         :draw-pile (:draw-pile response)
+         :discard-pile (:discard-pile response)
+         :players (conj (remove #{(active-player state)} (:players state)) (:player response))))
+
 (defn on-move-back [response]
   (when-let [board (:board response)]
-    (reset! app-state (assoc @app-state :board board
-                                        :draw-pile (:draw-pile response)
-                                        :discard-pile (:discard-pile response)
-                                        :players (conj (remove #{(active-player @app-state)} (:players @app-state)) (:player response))))
+    (swap! app-state move-back response)
     (update-active-player! @app-state)))

 (defn move-back! [player from-space board draw-pile discard-pile]


fix typo

fix typo

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

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -307,7 +307,7 @@
   (core setExposure (@state :init-exposure))
   (core setPosition (core getFocusDevice) (@state :init-z-position))
   (when (and (@state :init-continuous-focus)
-             (not (core isContinuousFocusEnabled))
+             (not (core isContinuousFocusEnabled)))
     (core enableContinuousFocus true))
   (return-config))


create a new album if current one has been closed

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

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -454,7 +454,9 @@
                  :task :snap, :z-drive (core getFocusDevice), :wait-time-ms 0}
         state   {:init-width w :init-height h}
         tagged-image (annotate-image (collect-snap-image) event state)]
-	  (if-not (and @current-album (compatible-image? @current-album tagged-image))
+	  (if-not (and @current-album
+	               (compatible-image? @current-album tagged-image)
+	               (not (.isClosed (:display @current-album))))
 	    (create-new-album tagged-image))
 	  (let [{:keys [display cache]} @current-album
 	        myTaggedImage (make-TaggedImage


loop if more than 1 thing

loop if more than 1 thing

--- src/om_next_datascript_localisation_demo/components/looper.cljs
+++ src/om_next_datascript_localisation_demo/components/looper.cljs
@@ -27,7 +27,7 @@
       (js/clearInterval timer))
     (let [things (:things new-props)
           length (count things)]
-      (if (> length 0)
+      (if (> length 1)
         (om/set-state! this {:current-index 0 :timer (make-timer this)})
         (om/set-state! this {:current-index 0 :timer 0}))))


removing the tabs

removing the tabs

--- cljs/sledge/core.cljs
+++ cljs/sledge/core.cljs
@@ -20,6 +20,7 @@
               :results []
               }
      :player-queue []
+     :viewing-queue? false
      :tab-on-view [:search]
      :player {:track-number 0
               :playing true
@@ -236,7 +237,7 @@
                     (map (partial get urls) ["ogg" "mp3" "wma" "wav"])))
      "href")))

-(defn player-view [app owner]
+(defn minimised-queue-view [app owner]
   (reify
     om/IDidMount
     (did-mount [this]
@@ -284,12 +285,10 @@
                 (recur))))))
     om/IRender
     (render [this]
-      (let [on-view (om/observe owner (tab-on-view))]
-        (if (= (first on-view) :search)
-          (dom/div nil
-                   (om/build search-entry-view (:term search)
-                             {:init-state {:string ""}})
-                   (om/build results-view (:results search))))))))
+      (dom/div nil
+               (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]))
@@ -356,29 +355,17 @@
       (.pause actual))))

-(defn app-view [app owner]
-  (reify
-    om/IRender
-    (render [this]
-      (dom/div nil
-               (dom/header
-                #js {:id "sledge"
-                     :className "default-primary-color"
-                     }
-                "sledge"
-                (om/build tab-selector-view app))
-               (dom/div #js {:className "scrolling"}
-                        (om/build search-view (:search app))
-                        (om/build queue-view app))
-               (dom/footer #js {}
-                           #_#_#_
-                           (dom/span #js {:onClick print-debuggy-stuff }
-                                     "debug")
-                           "  "
-                           (dom/span #js {:onClick sync-transport }
-                                     "sync")
-                           (om/build player-view app))
-               ))))
+(defn app-view [state owner]
+  (reify
+    om/IRender
+    (render [this]
+      (html
+       [:div
+        [:header {:className "default-primary-color" } "sledge"]
+        (om/build search-view (:search state))
+        (if (:viewing-queue? state)
+          (om/build queue-view state)
+          (om/build minimised-queue-view state))]))))

 (defn init []
   (add-watch app-state :transport sync-transport)


Extend PParameters and PIntrospection to IFn

This allows cp/parameters, cp/update-parameters, and cp/get-state to
work (minimally) on functions acting as optimisers *before*
cp/compute-parameters has been called for the first time.

--- cortex/src/cortex/optimise/optimisers.clj
+++ cortex/src/cortex/optimise/optimisers.clj
@@ -15,9 +15,9 @@
   the reason that APersistentMap rather than IPersistentMap is
   used.

-  (Note that the PParameters protocol is also implemented by
-  pure functions, so it is not done here, but rather in the
-  shared namespace cortex.optimise.parameters.)
+  (Note that, for maps, the PParameters protocol is also implemented
+  by pure functions, so it is not done here, but rather in the shared
+  namespace cortex.optimise.parameters.)

   A Clojure function representing a gradient optimiser must
   take parameter and gradient vectors and return an updated
@@ -39,19 +39,28 @@

 ;;;; Protocol extensions

+(defn fn->map
+  [function]
+  {:update (fn [state gradient]
+             (let [state (update state :params function gradient)]
+               ;; This makes it much easier to debug a common mistake:
+               (when (map? (:params state))
+                 (throw (IllegalStateException.
+                          "fn acting as optimiser must return vector: did you need to call the fn to produce an optimiser map or fn?")))
+               state))})
+
 (extend-type clojure.lang.IFn
+  cp/PParameters
+  (parameters [this])
+  (update-parameters [this params]
+    (cp/update-parameters (fn->map this) params))
+
   cp/PGradientOptimiser
-  (compute-parameters [this gradient parameters]
-    (cp/compute-parameters
-      {:update (fn [state gradient]
-                 (let [state (update state :params this gradient)]
-                   ;; This makes it much easier to debug a common mistake:
-                   (when (map? (:params state))
-                     (throw (IllegalStateException.
-                              "fn acting as optimiser must return vector: did you need to call the fn to produce an optimiser map or fn?")))
-                   state))}
-      gradient
-      parameters)))
+  (compute-parameters [this gradient params]
+    (cp/compute-parameters (fn->map this) gradient params))
+
+  cp/PIntrospection
+  (get-state [this]))

 (extend-type clojure.lang.APersistentMap
   cp/PGradientOptimiser


have defnav generate every method as a helper function as well (with name <name>-<method-name>, takes params as initial arguments followed by regular method arguments (except for 'this')

--- src/clj/com/rpl/specter/macros.clj
+++ src/clj/com/rpl/specter/macros.clj
@@ -255,9 +255,19 @@
                   (let [afn# (fn [~structure-sym] ~@impl)]
                     (i/filter-transform afn# structure# next-fn#)))))

-
-(defmacro defnav [name & body]
-  `(def ~name (nav ~@body)))
+(defn- helper-name [name method-name]
+  (symbol (str name "-" method-name)))
+
+(defmacro defnav [name params & impls]
+  ;; remove the "this" param for the helper
+  (let [helpers (for [[mname [_ & mparams] & mbody] impls]
+                  `(defn ~(helper-name name mname) [~@params ~@mparams] ~@mbody))
+        decls (for [[mname & _] impls]
+                `(declare ~(helper-name name mname)))]
+    `(do
+       ~@decls
+       ~@helpers
+       (def ~name (nav ~params ~@impls)))))

 (defmacro defcollector [name & body]
   `(def ~name (collector ~@body)))


Broke out empty-val for clearer code.

Broke out empty-val for clearer code.

--- src/clj/forma/hadoop/predicate.clj
+++ src/clj/forma/hadoop/predicate.clj
@@ -249,9 +249,9 @@
     (apply u/thrush
            gen
            (for [[dim inpos] (map-indexed vector in-syms)
-                 :let [aggr (->> (get-length (max 0 (dec dim)))
-                                 (matrix-of sparse-val dim)
-                                 (vals->sparsevec (get-length dim)))]]
+                 :let [empty-val (->> (get-length (max 0 (dec dim)))
+                                      (matrix-of sparse-val dim))
+                       aggr (vals->sparsevec (get-length dim) empty-val)]]
              (fn [src]
                (construct (swap-syms gen [inpos val] [outpos outval])
                           [[src :>> (get-out-fields gen)]


remove docker client unsused deps

remove docker client unsused deps

--- src/clj/swarmpit/docker/client.clj
+++ src/clj/swarmpit/docker/client.clj
@@ -3,7 +3,6 @@
   (:require [ring.util.codec :refer [form-encode]]
             [cheshire.core :refer [generate-string]]
             [swarmpit.base64 :as base64]
-            [swarmpit.config :refer [config]]
             [swarmpit.docker.http :refer :all]))

 (defn- registry-token


remove circular dep

remove circular dep

--- src/clj/traveler/datomic/utils.clj
+++ src/clj/traveler/datomic/utils.clj
@@ -4,7 +4,6 @@
             [hatch]
             [traveler.conf :as t-conf]
             [traveler.schema :as t-schema]
-            [traveler.system :as s]
             [traveler.datomic.output-models :refer :all]))

 (defn conf []


Refactor examples frontend

Refactor examples frontend

--- src/cljs/clojuredocs/examples.cljs
+++ src/cljs/clojuredocs/examples.cljs
@@ -8,88 +8,198 @@
             [clojure.string :as str]
             [cljs.reader :as reader]
             [sablono.core :as sab :refer-macros [html]]
-            [clojuredocs.util :as util])
+            [clojuredocs.util :as util]
+            [clojuredocs.schemas :as schemas]
+            [clojure.data :refer [diff]])
   (:require-macros [dommy.macros :refer [node sel1]]))

-(defn validate-and-submit [owner {:keys [text var]}]
+(defn client-call [comp context payload success error]
+  (let [{:keys [api-root]} comp
+        {:keys [http-method]} (-> comp :contexts context)]
+    (ajax
+      {:path (str "/api" api-root)
+       :method http-method
+       :data-type :edn
+       :data payload
+       :success success
+       :error error})))
+
+(defn validate-and-submit [app owner payload]
   (om/set-state! owner :loading? true)
   (om/set-state! owner :error-message nil)
-  (ajax
-    {:path "/api/examples"
-     :method :post
-     :data-type :edn
-     :data {:body text
-            :var var}
-     :success (fn []
-                (.reload js/location))
-     :error (fn [{:keys [status body]}]
-              (om/set-state! owner :loading? false)
-              (cond
-                (= 422 status)
-                (om/set-state! owner :error-message (:error-message body))
-
-                :else
-                (om/set-state! owner :error-message "There was a problem contacting the server.")))})
-  false)
-
-(defn set-expanded [owner expanded?]
-  (om/set-state! owner :expanded? expanded?)
-  (om/set-state! owner :should-focus? true)
-  false)
-
-(defn update-text [e owner]
-  (om/set-state! owner :text (.. e -target -value))
-  false)
-
-(defn cancel-clicked [e owner]
-  (set-expanded owner (not (om/get-state owner :expanded?)))
-  (om/set-state! owner :text nil)
-  false)
-
-(defn $toggle-controls [owner {:keys [expanded?]}]
+  (client-call schemas/ExampleComp :create
+    (-> payload
+        (update-in [:var] #(select-keys % [:ns :name :library-url]))
+        (assoc :history []))
+    (fn [data]
+      (om/transact! app (fn [app]
+                          (update-in app [:examples] (fn [es] (vec
+                                                                (concat
+                                                                  es
+                                                                  [(assoc (:body data)
+                                                                     :new? true)]))))))
+      (om/set-state! owner :loading? false)
+      (om/set-state! owner :text nil)
+      (om/set-state! owner :expanded? false))
+    (fn [{:keys [status body]}]
+      (om/set-state! owner :loading? false)
+      (cond
+        (= 422 status)
+        (om/update-state! owner #(merge % body))
+
+        :else
+        (om/set-state! owner :error-message "There was a problem contacting the server."))))
+  false)
+
+(defn update-example [{:keys [_id var]} owner text]
+  (om/set-state! owner :loading? true)
+  (om/set-state! owner :error-message nil)
+  (client-call schemas/ExampleComp :update
+    {:var (select-keys var [:ns :name :library-url])
+     :example-id _id
+     :body text}
+    (fn [data]
+      (om/transact! app (fn [app]
+                          (update-in app [:examples] (fn [es] (concat es [(assoc (:body data)
+                                                                            :new? true)])))))
+      (om/set-state! owner :loading? false)
+      (om/set-state! owner :text nil)
+      (om/set-state! owner :expanded? false))
+    (fn [{:keys [status body]}]
+      (om/set-state! owner :loading? false)
+      (cond
+        (= 422 status)
+        (om/update-state! owner #(merge % body))
+
+        :else
+        (om/set-state! owner :error-message "There was a problem contacting the server."))))
+  false)
+
+(defn update-text [e owner on-text]
+  (let [new-text (.. e -target -value)]
+    (om/set-state! owner :text new-text)
+    (when on-text (on-text new-text)))
+  false)
+
+(defn cancel-clicked [e example]
+  (om/update! example [:editing?] false)
+  false)
+
+(defn $toggle-controls [{:keys [editing?] :as example}]
   [:div.toggle-controls
-   [:a.toggle-link {:href "#" :on-click #(set-expanded owner (not expanded?))}
-    (if-not expanded? "Add an Example" "Collapse")]])
-
-(defn $editor [{:keys [var]} owner {:keys [expanded? text loading? error-message] :as state}]
-  [:div {:class (str "add-example-content" (when-not expanded? " hidden"))}
-   [:h5 "New Example"]
-   [:div.add-example-preview
-    [:div.live-preview {:ref "live-preview"}]]
-   [:form
-    {:on-submit #(validate-and-submit
-                   owner
-                   {:body text
-                    :var var})}
-    [:textarea
-     {:class "form-control"
-      :cols 80 :on-input #(update-text % owner)
-      :ref "textarea"
-      :disabled (when loading? "disabled")}]
-    [:p.instructions
-     "See our "
-     [:a {:href "/examples-styleguide"} "examples style guide"]
-     " for content and formatting guidelines. "
-     "Examples submitted to ClojureDocs are licensed under the "
-     [:a {:href "https://creativecommons.org/publicdomain/zero/1.0/"}
-      "Creative Commons CC0 license"]
-     "."]
-    (when error-message
-      [:div.form-group
-       [:div.error-message.text-danger
-        [:i.fa.fa-exclamation-circle]
-        error-message]])
-    [:div.add-example-controls.form-group.clearfix
-     [:button.btn.btn-default
-      {:disabled (when loading? "disabled")
-       :on-click #(cancel-clicked % owner)}
-      "Cancel"]
-     [:button.btn.btn-success.pull-right
-      {:disabled (when loading? "disabled")}
-      "Add Example"]
-     [:img.loading.pull-right
-      {:class (when-not loading? " hidden")
-       :src "/img/loading.gif"}]]]])
+   [:a.toggle-link {:href "#"
+                    :on-click (fn []
+                                (om/transact!
+                                  example
+                                  #(assoc %
+                                     :editing? (not editing?)
+                                     :should-focus? true))
+                                false)}
+    (if-not editing? "Add an Example" "Collapse")]])
+
+(defn $editor [{:keys [var body loading?] :as app} owner]
+  (reify
+    om/IInitState
+    (init-state [_]
+      {:text body})
+    om/IDidMount
+    (did-mount [_]
+      (dommy/append!
+        (om/get-node owner "live-preview")
+        (node [:div.empty-live-preview "Live Preview"]))
+      (update-preview owner)
+      (dommy/set-value!
+        (om/get-node owner "textarea")
+        (om/get-state owner :text)))
+
+    om/IDidUpdate
+    (did-update [this prev-props prev-state]
+      (let [{:keys [should-focus? expanded? text]} (om/get-state owner)]
+        (when (and should-focus? expanded?)
+          (om/set-state! owner :should-focus? false)
+          (.focus (om/get-node owner "textarea"))))
+      (update-preview owner))
+
+    om/IRenderState
+    (render-state [_ {:keys [text on-text]}]
+      (html
+        [:div.example-editor
+         [:div.live-preview {:ref "live-preview"}]
+         [:textarea
+          {:class "form-control"
+           :cols 80 :on-input #(update-text % owner on-text)
+           :ref "textarea"
+           :disabled (when loading? "disabled")}]
+         [:p.instructions
+          "See our "
+          [:a {:href "/examples-styleguide"} "examples style guide"]
+          " for content and formatting guidelines. "
+          "Examples submitted to ClojureDocs are licensed under the "
+          [:a {:href "https://creativecommons.org/publicdomain/zero/1.0/"}
+           "Creative Commons CC0 license"]
+          "."]]))))
+
+(defn $add-example-editor [{:keys [var loading? body] :as example} owner]
+  (reify
+    om/IRenderState
+    (render-state [_ {:keys [error-message] :as state}]
+      (html
+        [:div.add-example-content
+         [:h5 "New Example"]
+         [:form
+          {:on-submit #(validate-and-submit
+                         example
+                         owner
+                         {:body body
+                          :var @var})}
+          (om/build $editor example {:init-state {:on-text #(om/update! example [:body] %)} :state state})
+          (when error-message
+            [:div.form-group
+             [:div.error-message.text-danger
+              [:i.fa.fa-exclamation-circle]
+              error-message]])
+          [:div.add-example-controls.form-group.clearfix
+           [:button.btn.btn-default
+            {:disabled (when loading? "disabled")
+             :on-click #(cancel-clicked % example)}
+            "Cancel"]
+           [:button.btn.btn-success.pull-right
+            {:disabled (when loading? "disabled")}
+            "Add Example"]
+           [:img.loading.pull-right
+            {:class (when-not loading? " hidden")
+             :src "/img/loading.gif"}]]]]))))
+
+(defn $update-example-editor [{:keys [var loading? body] :as example} owner]
+  (reify
+    om/IRenderState
+    (render-state [_ {:keys [error-message text] :as state}]
+      (html
+        [:div.add-example-content
+         [:h5 "Edit Example"]
+         [:form
+          {:on-submit #(validate-and-submit
+                         example
+                         owner
+                         {:body body
+                          :var @var})}
+          (om/build $editor example {:init-state {:on-text #(om/set-state! owner text %)} :state state})
+          (when error-message
+            [:div.form-group
+             [:div.error-message.text-danger
+              [:i.fa.fa-exclamation-circle]
+              error-message]])
+          [:div.add-example-controls.form-group.clearfix
+           [:button.btn.btn-default
+            {:disabled (when loading? "disabled")
+             :on-click #(cancel-clicked % example)}
+            "Cancel"]
+           [:button.btn.btn-success.pull-right
+            {:disabled (when loading? "disabled")}
+            "Update Example"]
+           [:img.loading.pull-right
+            {:class (when-not loading? " hidden")
+             :src "/img/loading.gif"}]]]]))))

 (defn update-preview [owner]
   (let [text (om/get-state owner :text)
@@ -106,81 +216,156 @@
           (catch js/Error e (prn "Error highlighting example"))))
       (dommy/append! preview (node [:div.empty-live-preview "Live Preview"])))))

-(defn $add [app owner]
+(defn $add [{:keys [editing? should-focus?] :as example} owner]
+  (reify
+    om/IDidUpdate
+    (did-update [this prev-props prev-state]
+      (when (and should-focus? editing?)
+        (om/transact! example #(assoc % :should-focus? false))
+        (anim/scroll-to (om/get-node owner "wrapper") {:pad 10})))
+    om/IRenderState
+    (render-state [this {:keys [text loading?] :as state}]
+      (sab/html
+        [:div.add-example {:ref "wrapper"}
+         ($toggle-controls example)
+         [:div.add-example-content {:class (when-not editing? " hidden")}
+          (om/build $add-example-editor example {:state state})]]))))
+
+(defn user-can-delete? [user {:keys [author]}]
+  (= (select-keys user [:login :account-source])
+     (select-keys author [:login :account-source])))
+
+(defn update-example-body [owner {:keys [body]}]
+  (let [el (om/get-node owner "example-body")
+        pre (node [:pre.raw-example {:class "brush: clojure"}
+                   body])]
+    (dommy/clear! el)
+    (dommy/append! el pre)
+    (try
+      (.highlight js/SyntaxHighlighter pre)
+      ;; Not handling this error prevents subsequent
+      ;; highlights from succeeding
+      (catch js/Error e (prn "Error highlighting example")))))
+
+(defn delete-example [owner ex del-fn]
+  (om/set-state! owner :delete-state :loading)
+  (ajax
+    {:path (str "/api/examples")
+     :method :delete
+     :data-type :edn
+     :data @ex
+     :success (fn [data]
+                (om/set-state! owner :delete-state :none)
+                (del-fn @ex))
+     :error (fn [resp]
+              (om/set-state! owner :delete-state :error))})
+  false)
+
+(defn $example-meta [{:keys [editing? author editors can-delete?] :as ex} owner]
+  (reify
+    om/IRenderState
+    (render-state [_ {:keys [delete-ex delete-state]}]
+      (let [authors (distinct
+                      (concat
+                        [author]
+                        editors))
+            num-to-show 7]
+        (html
+          [:div.example-meta
+           [:div.contributors
+            (->> authors
+                 (take num-to-show)
+                 (map util/$avatar))
+            (when (> (count authors) num-to-show)
+              [:div.contributors
+               "+ "
+               (- (count authors) num-to-show)
+               " more"])]
+           [:div.links
+            [:a {:href (str "#example_" _id)}
+             "permalink"]
+            " / "
+            [:a {:href (str "/ex/" _id)}
+             "history"]
+            " / "
+            (if editing?
+              [:a {:href "#"
+                   :on-click #(do
+                                (om/update! ex [:editing?] false)
+                                false)}
+               "cancel edit"]
+              [:a {:href "#"
+                   :on-click #(do
+                                (om/update! ex [:editing?] true)
+                                false)}
+               "edit"])
+            (when (and can-delete? (not editing?))
+              [:span
+               " / "
+               (if (get #{:confirm :loading} delete-state)
+                 (if (= :loading delete-state)
+                   [:img.loading {:src "/img/loading.gif"}]
+                   [:span
+                    [:a {:href "#"
+                         :on-click #(do
+                                      (om/set-state! owner :delete-state :none)
+                                      false)}
+                     "cancel"]
+                    " | "
+                    [:a {:href "#"
+                         :on-click #(delete-example owner ex delete-ex)}
+                     "confirm delete?"]
+                    ])
+                 [:span
+                  {:class (when (= :error delete-state) "error-deleting bg-danger")}
+                  [:a {:href "#"
+                       :on-click #(do
+                                    (om/set-state! owner :delete-state :confirm)
+                                    false)}
+                   "delete"]])])
+            [:span.edit-example-widget]]])))))
+
+(defn $example-body [ex owner]
   (reify
     om/IDidMount
     (did-mount [_]
-      (dommy/append!
-        (om/get-node owner "live-preview")
-        (node [:div.empty-live-preview "Live Preview"]))
-      (update-preview owner)
-      (dommy/set-value!
-        (om/get-node owner "textarea")
-        (om/get-state owner :text)))
-
+      (update-example-body owner ex))
     om/IDidUpdate
-    (did-update [this prev-props prev-state]
-      (let [{:keys [should-focus? expanded? text]} (om/get-state owner)]
-        (when (and should-focus? expanded?)
-          (om/set-state! owner :should-focus? false)
-          (.focus (om/get-node owner "textarea"))
-          (anim/scroll-to (om/get-node owner "wrapper") {:pad 10})))
-      (update-preview owner))
-
-    om/IRenderState
-    (render-state [this {:keys [expanded? text loading?] :as state}]
-      (sab/html
-        [:div.add-example {:ref "wrapper"}
-         ($toggle-controls owner state)
-         ($editor app owner state)]))))
-
-(defn $example-body [{:keys [body]}]
-  [:div.example-body
-   [:pre.raw-example {:class "brush: clojure"} body]])
-
-(defn $example [{:keys [body _id user history created-at updated-at] :as ex}]
-  [:div.var-example
-   [:div
-    (let [users (distinct
-                  (concat
-                    [user]
-                    (->> history
-                         (map :user)
-                         reverse)))
-          num-to-show 7]
-      [:div.example-meta
-       [:div.contributors
-        (->> users
-             (take num-to-show)
-             (map util/$avatar))
-        (when (> (count users) 10)
-          [:div.contributors
-           "+ "
-           (- (count users) num-to-show)
-           " more"])]
-
-       [:div.links
-        [:a {:href (str "#example_" _id)}
-         "permalink"]
-        " / "
-        [:a {:href (str "/ex/" _id)}
-         "history"]
-        [:span.edit-example-widget]]])]
-   [:div
-    [:a {:id (str "example_" _id)}]
-    ($example-body ex)]])
-
-(defn $examples [{:keys [examples var user] :as app} owner]
-  (reify
+    (did-update [_ _ _]
+      (update-example-body owner ex))
     om/IRender
     (render [_]
-      (sab/html
+      (html
+        [:div.example-body {:ref "example-body" :class (when new? "just-created")}]))))
+
+(defn $example [{:keys [editing? body _id author history created-at updated-at new? can-delete?] :as ex} owner]
+  (reify
+    om/IRenderState
+    (render-state [_ {:keys [delete-ex]}]
+      (html
+        [:div.var-example
+         [:a {:id (str "example_" _id)}]
+         [:div
+          (om/build $example-meta ex {:init-state {:delete-ex delete-ex}})]
+         (if editing?
+           (om/build $update-example-editor ex)
+           (om/build $example-body ex))]))))
+
+(defn $examples [{:keys [examples var user] :as app} owner]
+  (reify
+    om/IRenderState
+    (render-state [_ {:keys [delete-ex]}]
+      (html
         [:div.var-examples
          [:h5 (util/pluralize (count examples) "Example" "Examples")]
          (if (empty? examples)
            [:div.null-state
             "No examples for " (:ns var) "/" (:name var) "."]
-           (map $example examples))
+           (om/build-all
+             $example
+             (->> (:examples app)
+                  (map #(assoc % :can-delete? (user-can-delete? user %))))
+             {:init-state {:delete-ex delete-ex}}))
          (if user
            (om/build $add app)
            [:div.login-required-message


Change to table view on forms with no-geodata only if mapview is being loaded.

--- src/cljs/hatti/views/dataview.cljs
+++ src/cljs/hatti/views/dataview.cljs
@@ -79,12 +79,12 @@
     (init-state [_]
       (let [form (om/get-shared owner :flat-form)
             geopoints? (-> app-state :dataset-info :instances_with_geopoints)
-            has-geodata? (if (some f/geopoint? form)
-                           geopoints?
-                           (some f/geofield? form))]
-        (when-not has-geodata?
+            no-geodata? (not (if (some f/geopoint? form)
+                               geopoints?
+                               (some f/geofield? form)))]
+        (when (and no-geodata? (= :map (-> app-state :views :selected)))
           (om/update! app-state [:views :selected] :table))
-        {:no-geodata? (not has-geodata?)}))
+        {:no-geodata? no-geodata?}))
     om/IRenderState
     (render-state [_ {:keys [no-geodata?]}]
       (let [active-view (-> app-state :views :selected)


modify mousehover behavior on line.

modify mousehover behavior on line.

--- src/cljs/om_next_leaflet/core.cljs
+++ src/cljs/om_next_leaflet/core.cljs
@@ -98,7 +98,7 @@
     (om/transact! this `[(app/update-mapstate {:new-mapstate ~mapstate})])))

 (def init-center [34.6964898 135.4930235])
-(def init-zoom 15)
+(def init-zoom 12)

 (def leaflet-map-fn (om/factory leaflet/Leaflet))

@@ -125,11 +125,16 @@
   (let [lines-layer (get-lines-layer this)
         {:keys [app/lines]} (om/props this)]
     (doseq [[id name bounding-box geometry] lines]
-      (let [polyline (leaflet/create-polyline geometry :color "#666666" :weight 6 :opacity 0.7)]
+      (let [line-color "#666666"
+            polyline (leaflet/create-polyline geometry :color line-color :weight 6 :opacity 0.7)]
         (doto polyline
-          (.bindPopup name)
-          (.on "mouseover" #(.setStyle polyline (clj->js {:color "#ff0000"})))
-          (.on "mouseout" #(.setStyle polyline (clj->js {:color "#666666"})))
+          (.bindTooltip (str "<b>" name "</b>"))
+          (.on "mouseover" (fn [e]
+                             (.setStyle polyline (clj->js {:color "#ff0000" :weight 8}))
+                             (.openTooltip polyline (.-latlng e))))
+          (.on "mouseout" (fn [e]
+                            (.setStyle polyline (clj->js {:color line-color :weight 6}))
+                            (.closeTooltip polyline)))
           (.addTo lines-layer))))))

 (defui Root


Remove trailing whitespace

Remove trailing whitespace

--- src/leiningen/new/mies/project.clj
+++ src/leiningen/new/mies/project.clj
@@ -9,7 +9,7 @@

   :source-paths ["src"]

-  :cljsbuild {
+  :cljsbuild {
     :builds [{:id "{{name}}"
               :source-paths ["src"]
               :compiler {


Shorten bench: this shit is waaaay slow on my debian box for some reason.

--- reimann/test/reimann/test/bench.clj
+++ reimann/test/reimann/test/bench.clj
@@ -11,7 +11,7 @@
                core (core)
                server (tcp-server core)
                stream (sum (register final))
-               n 1000
+               n 100
                threads 10
                events (take n (repeatedly (fn []
                         (event {:metric_f 1}))))]


replaced two functions with one

replaced two functions with one

--- src/midje/internal_ideas/fakes.clj
+++ src/midje/internal_ideas/fakes.clj
@@ -33,11 +33,9 @@
   (some true? (map (partial first-named? form)
                    ["fake" "data-fake"])))

-(defn- fake-form-funcall [[fake funcall => value & overrides]]
-  funcall)
-
-(defn- fake-form-funcall-arglist [fake-form]
-  (rest (fake-form-funcall fake-form)))
+(defn- fake-form-funcall-arglist
+  [[fake funcall => value & overrides :as _fake-form_]]
+  (rest funcall))

 ;;; Creation


(PCP-496) Set inventory_response message expiration last

Without this change, serializing a list of clients to json can cause the
message to expire before it's sent if that serialization takes a
significant amount of time. Ensure setting the expiration time is the
last thing we do before attempting to send the message.

--- src/puppetlabs/pcp/broker/core.clj
+++ src/puppetlabs/pcp/broker/core.clj
@@ -151,8 +151,8 @@
                                            :targets [sender]
                                            :sender "pcp:///server"
                                            :in-reply-to in-reply-to)
-                     (message/set-expiry 3 :seconds)
-                     (message/set-json-data response_data))]
+                     (message/set-json-data response_data)
+                     (message/set-expiry 3 :seconds))]
     response))

 (s/defn process-expired-message :- Capsule
@@ -208,15 +208,17 @@
   [broker :- Broker message :- Message targets :- [p/Uri]]
   (when (:destination_report message)
     (let [report {:id (:id message)
-                  :targets targets}
-          reply (-> (message/make-message :targets [(:sender message)]
-                                          :message_type "http://puppetlabs.com/destination_report"
-                                          :in-reply-to (:id message)
-                                          :sender "pcp:///server")
-                    (message/set-expiry 3 :seconds)
-                    (message/set-json-data report))]
+                  :targets targets}]
       (s/validate p/DestinationReport report)
-      (accept-message-for-delivery broker (capsule/wrap reply)))))
+      (accept-message-for-delivery
+        broker
+        (-> (message/make-message :targets [(:sender message)]
+                                  :message_type "http://puppetlabs.com/destination_report"
+                                  :in-reply-to (:id message)
+                                  :sender "pcp:///server")
+            (message/set-json-data report)
+            (message/set-expiry 3 :seconds)
+            (capsule/wrap))))))

 ;; ActiveMQ queue consumers
 (s/defn deliver-message
@@ -309,8 +311,8 @@
                                                     :targets [uri]
                                                     :in-reply-to id
                                                     :sender "pcp:///server")
-                              (message/set-expiry 3 :seconds)
-                              (message/set-json-data response))]
+                              (message/set-json-data response)
+                              (message/set-expiry 3 :seconds))]
               (websockets-client/send! ws (encode message)))
             (if reason
               (do
@@ -342,15 +344,19 @@
           data (message/get-json-data message)]
       (s/validate p/InventoryRequest data)
       (let [uris (doall (filter (partial get-websocket broker) ((:find-clients broker) (:query data))))
-            response-data {:uris uris}
-            response (-> (message/make-message :message_type "http://puppetlabs.com/inventory_response"
-                                               :targets [(:sender message)]
-                                               :in-reply-to (:id message)
-                                               :sender "pcp:///server")
-                         (message/set-expiry 3 :seconds)
-                         (message/set-json-data response-data))]
+            response-data {:uris uris}]
         (s/validate p/InventoryResponse response-data)
-        (accept-message-for-delivery broker (capsule/wrap response)))))
+        (accept-message-for-delivery
+          broker
+          (-> (message/make-message :message_type "http://puppetlabs.com/inventory_response"
+                                    :targets [(:sender message)]
+                                    :in-reply-to (:id message)
+                                    :sender "pcp:///server")
+              (message/set-json-data response-data)
+              ;; set expiration last so if any of the previous steps take significant time
+              ;; the message doesn't expire
+              (message/set-expiry 3 :seconds)
+              (capsule/wrap))))))
   connection)

 (s/defn process-server-message :- Connection


pass less data to the sidebar

pass less data to the sidebar

--- frontend/components/dashboard.cljs
+++ frontend/components/dashboard.cljs
@@ -18,7 +18,11 @@
          ;; XXX logic for trial notices
          ;; XXX logic for show_build_table
          [:div#dashboard
-          (om/build sidebar/sidebar data {:opts opts})
+          (om/build sidebar/sidebar
+                    {:current-user (:current-user data)
+                     :projects (:projects data)
+                     :settings (:settings data)}
+                    {:opts opts})
           [:section
            (om/build builds-table/builds-table
                      {:builds builds


Stream

Stream

--- src/sns_beanstalk_chat/handler.clj
+++ src/sns_beanstalk_chat/handler.clj
@@ -21,7 +21,7 @@
 (defn handle-topic-post [req]
   (log/info req)
   (-> req
-      (update :body json/decode true)
+      (update :body json/parse-stream true)
       handle-sns-request))

 (defn handle-topic-get [{:keys [topic-mult] :as req}]
@@ -61,5 +61,5 @@
     (eulalie.creds/periodically-refresh! current iam-role)
     (let [hostname (instance-data/retrieve!! :public-hostname)
           events      (async/chan)]
-      (http/run-server (make-internal-app events) {:port 8080})
+      (http/run-server (make-internal-app events) {:port 80})
       (subscribe-sns!! creds hostname topic))))


Improved color collections color lightbox.

--- src/uxbox/ui/dashboard/colors.cljs
+++ src/uxbox/ui/dashboard/colors.cljs
@@ -265,14 +265,7 @@
        [:div.lightbox-body
         [:h3 "New color"]
         [:form
-         [:div.row-flex
-          [:input#color-hex.input-text
-           {:placeholder "#"
-            :class (form/error-class local :hex)
-            :on-change on-change
-            :value (or (:hex @local) color "")
-            :type "text"}]]
-         [:div.row-flex.center.color-picker-default
+         [:div.row-flex.center
           (colorpicker
            :value (or (:hex @local) color "#00ccff")
            :on-change #(swap! local assoc :hex %))]


add note about where the middleware goes

--- src/yeller_clojure_client/ring.clj
+++ src/yeller_clojure_client/ring.clj
@@ -19,9 +19,15 @@
    Optional:
    {:environment \"development\"} ; the name of the environment this ring app is running in

-   if you attach a :yeller/context key in your request map (that contains a further map) in your ring request,
-   then this middleware will send that off to yeller upon exceptions as well (useful for e.g. user ids, current
-   datomic T etc)."
+   if you attach a :yeller/context key in your request map (that contains a
+   further map) in your ring request, then this middleware will send that off to
+   yeller upon exceptions as well (useful for e.g. user ids, current datomic T
+   etc).
+   Note, you should put this middleware as far on the inside of the middleware
+   stack as possible, so it gets full access to params, session data, etc.
+   On the other hand, it should probably sit outside of any middleware you have
+   that does e.g. authentication, so it can track errors that happen in that
+   middleware"
   (let [client (yeller/client options)]
     (fn [request]
       (try


Use underscores in example-piggieback-plan keys

--- test-cljs/frontend/test_utils.cljs
+++ test-cljs/frontend/test_utils.cljs
@@ -123,7 +123,7 @@
 (def example-piggieback-plan
   (-> (example-plan :paid)
       (dissoc :org_name)
-      (assoc :piggieback-orgs ["circleci"]
+      (assoc :piggieback_orgs ["circleci"]
              :org_name "test-org")))

 (defn- make-example-user-plans [plans]


valid-word? still has the case qu and gi to deal with

--- test/bogo_clojure/bg_word_test.clj
+++ test/bogo_clojure/bg_word_test.clj
@@ -13,5 +13,26 @@

 (deftest test-normalize
   (is (= "meo" (normalize "mèo")))
-  (is (= "meoconrahồca" (normalize "mÈocoNrahỒcá")))
+  (is (= "meoconrahôca" (normalize "mÈocoNrahỒcá")))
   )
+
+(deftest test-valid-word?
+  (let [test-cases {
+                    "meo" true
+                    "me" true
+                    "qua" true
+                    "mèo" true
+                    "ôin" false
+                    "ôN" true
+                    "chuyên" true
+                    "chuyêm" true
+                    "chuyêch" false
+                    "quôx" false
+                    "quên" true
+                    "quuên" false
+                    }]
+    (dorun (map #(is  (let [correct? (= %2 (valid-word? %1))]
+                        (when (not correct?) (println %1 "false"))
+                        correct?))
+                (keys test-cases)
+                (vals test-cases)))))


cd/cs|better tests for start/stop

cd/cs|better tests for start/stop

--- test/de/otto/tesla/system_test.clj
+++ test/de/otto/tesla/system_test.clj
@@ -1,6 +1,8 @@
 (ns de.otto.tesla.system-test
   (:require [clojure.test :refer :all]
+            [com.stuartsierra.component :as c]
             [de.otto.tesla.util.test-utils :as u]
+
             [de.otto.tesla.system :as system]))

 (defn- serverless-system [runtime-config]
@@ -9,8 +11,13 @@
     :server))

 (deftest ^:unit should-start-empty-system-and-shut-it-down
-  (u/with-started
-    [started (system/empty-system {:server-port 56798})]
+  (let [started (system/start-system (serverless-system {}))
+        stopped (system/stop started) ]
+    (is (= "look ma, no exceptions" "look ma, no exceptions"))))
+
+(deftest ^:unit should-start-empty-system-and-shut-it-down-using-lib
+  (let [started (system/start-system (serverless-system {}))
+        stopped (c/stop started) ]
     (is (= "look ma, no exceptions" "look ma, no exceptions"))))

 (deftest should-lock-application-on-shutdown


Restore tests to :verbose false

Restore tests to :verbose false

--- library/test/clj/test/doo/core.clj
+++ library/test/clj/test/doo/core.clj
@@ -90,7 +90,7 @@

 (deftest integration
   (testing "We can compile a cljs project"
-    (let [doo-opts {:verbose true
+    (let [doo-opts {:verbose false
                     :paths {:karma "karma"}}
           compiler-opts {:output-to "out/testable.js"
                          :output-dir "out"


json logging and time

json logging and time

--- src/main.clj
+++ src/main.clj
@@ -1,5 +1,5 @@
 (ns main
-
+  (:require [cheshire.core :refer :all])
   (:gen-class
    :methods [^:static
              [handler
@@ -16,8 +16,8 @@
         request_id (.getAwsRequestId ctx)]

     (print (str request_id ": "))
-    (println query)
+    (println (generate-string {"query" query}))

-    {"res" (athena-cmd.core/exec query :folder request_id)
-     "request_id" request_id}))
+    (time {"res" (athena-cmd.core/exec query :folder request_id)
+     "request_id" request_id})))


add helper fn to build query str from map

--- src/braid/server/util.clj
+++ src/braid/server/util.clj
@@ -1,5 +1,7 @@
 (ns braid.server.util
-  (:import org.apache.commons.validator.UrlValidator))
+  (:require [clojure.string :as string])
+  (:import java.net.URLEncoder
+           org.apache.commons.validator.UrlValidator))

 (defn valid-url?
   "Check if the string is a valid http(s) url.  Note that this will *not*
@@ -8,3 +10,9 @@
   ([s schemes]
    (and (string? s)
      (.isValid (UrlValidator. (into-array schemes)) s))))
+
+(defn map->query-str
+  [m]
+  (->> m
+       (map (fn [[k v]] (str (name k) "=" (URLEncoder/encode (str v)))))
+       (string/join "&")))


Fix calculate-authtag method on crypto ns.

Now returns the number of bytes written instead
of the output buffer.

--- src/buddy/core/crypto.clj
+++ src/buddy/core/crypto.clj
@@ -134,8 +134,7 @@
     (.getOutputSize engine length))

   (calculate-authtag [engine output outoffset]
-    (.doFinal engine output outoffset)
-    output)
+    (.doFinal engine output outoffset))

   IBlockCipher
   (get-block-size* [engine]


Reworked the way option destructuring works in order to make sure that it's safe in the face of cake's task extensibility. Also, destructuring forms are wrapped in a vector now, since maps are going to be used for task metadata.

--- src/cake/core.clj
+++ src/cake/core.clj
@@ -75,7 +75,7 @@
    be broken up among multiple deftask calls and even multiple files:
    (deftask foo #{bar baz} ; a set of prerequisites for this task
      \"Documentation for task.\"
-     {foo :foo} ; destructuring of *opts*
+     [{foo :foo}] ; destructuring of *opts*
      (do-something)
      (do-something-else))"
   [name & body]
@@ -84,10 +84,10 @@
                       [(first body) (rest body)]
                       [#{} body])
         [doc body] (split-with string? body)
-        [destruct actions] (if (map? (first body))
-                             [(first body) (rest body)]
+        [destruct actions] (if (vector? (first body))
+                             [(ffirst body) (rest body)]
                              [{} body])
-        actions (vec (map #(list 'fn [destruct] %) actions))]
+        actions (vec (map #(list 'fn [] (list 'let [destruct '*opts*] %)) actions))]
     `(swap! tasks update '~name update-task '~deps '~doc ~actions)))

 (defmacro undeftask [& names]
@@ -107,7 +107,7 @@
           (set! run? (assoc run? name :in-progress))
           (doseq [dep (:deps task)] (run-task dep))
           (binding [*current-task* name]
-            (doseq [action (:actions task)] (action *opts*)))
+            (doseq [action (:actions task)] (action)))
           (set! run? (assoc run? name true)))))))

 (defmacro invoke [name & [opts]]


use gensym on task names - allows a task to be reopened in the same ns

--- src/cake/task.clj
+++ src/cake/task.clj
@@ -91,11 +91,12 @@
            (into (default-tasks) (:tasks *project*)))))

 (defn to-taskname [taskname]
-  (symbol
-   (name (ns-name *ns*))
-   (if (string? taskname)
-     (str "file-" (.replaceAll taskname "/" "-"))
-     (str "task-" (name taskname)))))
+  (gensym
+   (str (name (ns-name *ns*))
+        "/"
+        (if (string? taskname)
+          (str "file-" (.replaceAll taskname "/" "-"))
+          (str "task-" (name taskname))))))

 (defn task-run-file [taskname]
   (file ".cake" "run" taskname))


No longer used

No longer used

--- core/src/immutant/internal/util.clj
+++ core/src/immutant/internal/util.clj
@@ -101,18 +101,6 @@
     (apply deref v args)
     v))

-(defmacro backoff
-  "A simple backoff strategy that retries body in the event of error.
-   The first retry occurs after sleeping start milliseconds, the next
-   after start*2 ms, and so on, until the sleep time exceeds end ms,
-   at which point the caught error is tossed."
-  [start end & body]
-  `(loop [x# ~start]
-     (let [result# (try
-                    ~@body
-                    (catch Exception e# (if (> x# ~end) (throw e#))))]
-       (or result# (do (Thread/sleep x#) (recur (* 2 x#)))))))
-
 (defmacro with-tccl
   "Evaluates `body` with the tccl set to `cl`, restoring the original
    tccl when done."


The markup for schedules in cineplex changed, and so the code for fetching schedules changed too.

--- src/cine/core.clj
+++ src/cine/core.clj
@@ -46,7 +46,6 @@
 (def schedules-root-divs (-> schedule-markup
                              (enlive/select [:div#main_body :> [:div (enlive/nth-of-type 2)]])
                              (enlive/select [enlive/root :>  [:div (enlive/nth-of-type 2)]])
-                             (enlive/select [enlive/root :> [:div (enlive/nth-of-type 1)]])
                              (enlive/select [enlive/root :> [:div]])))

 (defn extract-date-markup [single-schedule-markup]
@@ -86,6 +85,7 @@
                                    (map #(enlive/select % [:td.time]))
                                    (flatten))))))

+
 (defn make-single-movie-schedule-wo-date [single-schedule-markup]
   (let [movielist (extract-movielist-from-schedule single-schedule-markup)
         timelist (extract-timeschedule-from-schedule single-schedule-markup)]
@@ -99,3 +99,38 @@

 (defn get-weekly-movie-schedule []
   (map make-single-movie-schedule schedules-root-divs))
+
+
+;; (def url-list ["http://www.sjjcc.org/event/tuesday-lectures-2/2015-09-01",
+;;                "http://www.sjjcc.org/event/calm-your-spirit/2015-09-01",
+;;                "http://www.sjjcc.org/event/its-a-knitzvah/2015-09-02",
+;;                "http://www.sjjcc.org/event/in2-it-fitness-with-rhonda-johnson/2015-09-02",
+;;                "http://www.sjjcc.org/event/conversational-hebrew-ulpan-advanced-2/2015-09-02",
+;;                "http://www.sjjcc.org/event/taste-of-torah/2015-09-02",
+;;                "http://www.sjjcc.org/event/conversational-hebrew-ulpan-intermediate-2/2015-09-02",
+;;                "http://www.sjjcc.org/event/conversational-hebrew-ulpan-advanced-beginners-2/2015-09-03"])
+;;
+;; (def markup-list (doall (map #(fetch-url %) url-list)))
+;;
+;; (->> markup-list
+;;      (map #(enlive/select % [:div.tribe-events-schedule :span.date-start :span.value-title]))
+;;      (flatten)
+;;      (map #(:title (:attrs %))))
+;;
+;; (first markup-list)
+;;
+;;
+;;
+;; (def schedules-root-divs (-> schedule-markup
+;;                              (enlive/select [:div#main_body :> [:div (enlive/nth-of-type 2)]])
+;;                              (enlive/select [enlive/root :>  [:div (enlive/nth-of-type 2)]])
+;;                              (enlive/select [enlive/root :> [:div (enlive/nth-of-type 1)]])
+;;                              (enlive/select [enlive/root :> [:div]])))
+;;
+;; (def schedules (-> schedule-markup
+;;     (enlive/select [:div#main_body :> [:div (enlive/nth-of-type 2)]])
+;;     (enlive/select [enlive/root :>  [:div (enlive/nth-of-type 2)]])
+;;     (enlive/select [enlive/root :> [:div ]])
+;;     ;; (enlive/select [enlive/root :> [:div]])
+;; ))
+;;


fix unselect by drop

fix unselect by drop

--- src/chessground/ctrl.cljs
+++ src/chessground/ctrl.cljs
@@ -8,8 +8,8 @@
   "A move initiated through the UI"
   (or (when (data/can-move? app orig dest)
         (-> app
-          (data/move-piece orig dest)
-          data/unselect))
+            (data/move-piece orig dest)
+            data/unselect))
       (when (data/can-premove? app orig dest)
         (-> app
             (data/set-premovable-current [orig dest])
@@ -37,7 +37,6 @@
         app)))

 (defn drop-on [app dest]
-  (data/unselect
-    (if-let [orig (:selected app)]
-      (move-piece app [orig dest])
-      (drop-off app))))
+  (if-let [orig (:selected app)]
+    (move-piece app [orig dest])
+    (drop-off app)))


add Reader pre-condition to cljs.analyzer/forms-seq*

--- src/clj/cljs/analyzer.clj
+++ src/clj/cljs/analyzer.clj
@@ -1963,6 +1963,7 @@
   accepts a filename argument which will be used in any emitted errors."
   ([^Reader rdr] (forms-seq* rdr nil))
   ([^Reader rdr filename]
+   {:pre [(instance? Reader rdr)]}
    (let [pbr (readers/indexing-push-back-reader
                (PushbackReader. rdr) 1 filename)
          data-readers tags/*cljs-data-readers*


should fix bug in json schema

should fix bug in json schema

--- src/clj/datasplash/bq.clj
+++ src/clj/datasplash/bq.clj
@@ -182,7 +182,7 @@
    {:schema {:docstr "Specifies bq schema."
              :action (fn [transform schema] (.withSchema transform (->schema schema)))}
     :json-schema {:docstr "Specifies bq schema in json"
-                  :action (fn [transform schema] (.withJsonSchema transform schema))}
+                  :action (fn [transform json-schema] (.withJsonSchema transform json-schema))}
     :write-disposition {:docstr "Choose write disposition."
                         :enum write-disposition-enum
                         :action (select-enum-option-fn


added change-tuples and chang-maps

added change-tuples and chang-maps

--- src/clj/gitomic/query.clj
+++ src/clj/gitomic/query.clj
@@ -73,6 +73,47 @@
                                 [?a :person/name ?n]]
                               db repo-name))))

+(defn change-tuples [db repo-name]
+  (q '[:find ?sha ?time ?an ?ae ?subject ?p ?added ?deleted ?lines
+       :in $ ?r-name
+       :where
+       [?r :repo/name ?r-name]
+       [?r :repo/commits ?c]
+       [?c :commit/sha ?sha]
+       [?c :commit/time ?time]
+       [?c :commit/subject ?subject]
+       [?c :commit/author ?a]
+       [?a :person/name ?an]
+       [?a :person/email ?ae]
+       [?c :commit/changes ?ch]
+       [(get-else $ ?ch :change/added 0) ?added]
+       [(get-else $ ?ch :change/deleted 0) ?deleted]
+       [(- ?added ?deleted) ?lines]
+       [?ch :change/file ?f]
+       [?f :file/path ?p]]
+     db repo-name))
+
+(defn change-maps [db repo-name]
+  ;?sha ?time ?an ?ae ?subject ?p ?added ?deleted ?lines
+  (q '[:find [(pull ?ch [{:commit/_changes [{:commit/author [:person/name :person/email]}
+                                            :commit/sha
+                                            :commit/time
+                                            :commit/subject]}
+                         (default :change/added 0)
+                         (default :change/deleted 0)
+                         {:change/file [:file/path]}])
+              ...]
+       :in $ ?r-name
+       :where
+       [?r :repo/name ?r-name]
+       [?r :repo/commits ?c]
+       [?c :commit/changes ?ch]]
+     db repo-name))
+
+
+
+
+
 ;; for query example ONLY.  Could run FOREVER on big commits
 (defn file-commit-pair [db r file-path]
   (q '[:find ?p2 (count ?c)


Cleaned up code in tree.clj.

Cleaned up code in tree.clj.

--- src/clj/minijava/tree.clj
+++ src/clj/minijava/tree.clj
@@ -5,7 +5,7 @@
 (defmulti tree type)

 (defn binop [op x]
-  (BinaryOp op (unEx (tree (.e1 x))) (unEx (tree (.e2 x)))))
+  (BinaryOp op (-> x .e1 tree unEx) (-> x .e2 tree unEx)))

 (defmethod tree minijava.ast.And
   [x] (let [t1   (label)
@@ -36,14 +36,15 @@
 ;;   [x] )

 (defmethod tree minijava.ast.Block
-  [x] (Seq (for [s ($ (.statements x))] (tree s))))
+  [x] (Seq (map tree ($ (.statements x)))))

 (defmethod tree minijava.ast.BooleanLiteral
   [x] (if (.value x) (Const 1) (Const 0)))

 (defmethod tree minijava.ast.Call
-  [x] (Call (Name (label (.name x)))
-            (for [a ($ (.rargs x))] (unEx (tree a)))))
+  [x] (Call (Name (.name x))
+            (cons (-> x .receiver tree unEx)
+                  (map (comp unEx tree) ($ (.rargs x))))))

 ;; (defmethod tree minijava.ast.ClassDecl
 ;;   [x] )
@@ -55,12 +56,12 @@
   [x] (let [t (label)
             f (label)
             d (label)]
-        (Seq [(unCx (tree (.tst x)) (Name t) (Name f))
+        (Seq [(-> x .tst tree (unCx (Name t) (Name f)))
               (Label t)
-              (unNx (tree (.thn x)))
+              (-> x .thn tree unNx)
               (Jump d)
               (Label f)
-              (unNx (tree (.els x)))
+              (-> x .els tree unNx)
               (Label d)])))

 (defmethod tree minijava.ast.IntegerLiteral
@@ -78,8 +79,8 @@
 (defmethod tree minijava.ast.Minus
   [x] (binop :- x))

-;; (defmethod tree minijava.ast.NewArray
-;;   [x] )
+(defmethod tree minijava.ast.NewArray
+  [x] (Call (Name "newArray") [(unEx (.size x))]))

 ;; FIXME: ugly, better solution?
 (defmethod tree minijava.ast.Not
@@ -87,7 +88,7 @@
             f (label)
             d (label)
             r (minijava.ir.temp.Temp.)]
-        (ExpSeq [(unCx (tree (.e x)) (Name t) (Name f))
+        (ExpSeq [(-> x .e tree (unCx (Name t) (Name f)))
                  (Label t)
                  (Move (Const 0) (Temp r))
                  (Jump d)
@@ -98,6 +99,9 @@

 (defmethod tree minijava.ast.Plus
   [x] (binop :+ x))
+
+(defmethod tree minijava.ast.Print
+  [x] (Call (Name "print") [(-> x .exp tree unEx)]))

 ;; (defmethod tree minijava.ast.This
 ;;   [x] )
@@ -113,9 +117,9 @@
             test (label)
             f    (label)]
         (Seq [(Label test)
-              (unCx (tree (.tst x)) (Name t) (Name f))
+              (-> x .tst tree (unCx (Name t) (Name f)))
               (Label t)
-              (unNx (tree (.body x)))
+              (-> x .body tree unNx)
               (Jump test)
               (Label f)])))


fix index.html redirect handler

fix index.html redirect handler

--- src/clj/ws_ldn_2/core.clj
+++ src/clj/ws_ldn_2/core.clj
@@ -70,7 +70,7 @@
                                            [:get "/" (constantly
                                                       (fn [req]
                                                         {:status 302
-                                                         :header {"Location" "/index.html"}}))]]}
+                                                         :headers {"Location" "/index.html"}}))]]}
                  :log     {:fn (fn [_ _] (fn [_]))}})]
     (taoensso.timbre/set-level! :info)
     (clojure.pprint/pprint config)


Contacts

Contacts

--- src/cljs/my_app/core.cljs
+++ src/cljs/my_app/core.cljs
@@ -4,14 +4,32 @@

 (enable-console-print!)

-(defonce app-state (atom {:text "Hello Chestnut!"}))
+(defonce app-state
+  (atom
+   {:contacts
+    [{:first "Ben" :last "Bitdiddle" :email "benb@mit.edu"}
+     {:first "Lem" :middle-initial "E" :last "Tweakit" :email "morebugs@mit.edu"}]}))
+
+(defn display-name [{:keys [first last] :as contact}]
+    (str last ", " first))
+
+(defn contact-view [contact owner]
+  (reify
+    om/IRender
+    (render [this]
+      (dom/li nil (display-name contact)))))
+
+(defn contacts-view [data owner]
+  (reify
+    om/IRender
+    (render [this]
+      (dom/div nil
+        (dom/h2 nil "Contact list")
+        (apply dom/ul nil
+          (om/build-all contact-view (:contacts data)))))))

 (defn main []
   (om/root
-    (fn [app owner]
-      (reify
-        om/IRender
-        (render [_]
-          (dom/h1 nil (:text app)))))
+    contacts-view
     app-state
     {:target (. js/document (getElementById "app"))}))


Refactor timestamp deserialization condition

--- src/clojure_pf/binary.clj
+++ src/clojure_pf/binary.clj
@@ -15,20 +15,17 @@
         (.limit (+ index size)))))

 (defn- deserialize-timestamp [buffer boundary]
-  "Deserializes a BPF header timestamp if boundary is defined."
-  (if boundary
-    (let [buffer (-> (bounded-buffer buffer boundary)
-                     (.order ByteOrder/LITTLE_ENDIAN))]
-      (try
-        (let [seconds       (-> (.getInt buffer)
-                                (bit-and 0xFFFFFFFF))
-              microseconds  (-> (.getInt buffer)
-                                (bit-and 0xFFFFFFFF)
-                                (mod (* 1000 1000)))]
-          {:seconds       seconds
-           :microseconds  microseconds})
-        (catch Exception e
-          (println "deserialize-timestamp: " (.getMessage e)))))))
+  "Deserializes a BPF header timestamp."
+  (let [buffer (-> (bounded-buffer buffer boundary)
+                   (.order ByteOrder/LITTLE_ENDIAN))]
+    (try
+      (let [seconds       (-> (.getInt buffer)
+                              (bit-and 0xFFFFFFFF))
+            microseconds  (-> (.getInt buffer)
+                              (bit-and 0xFFFFFFFF)
+                              (mod (* 1000 1000)))]
+        {:seconds       seconds
+         :microseconds  microseconds}))))

 (defn- deserialize-value [buffer entry]
   "Deserializes a value from a buffer according to a form entry."
@@ -41,12 +38,10 @@
              1 (.get buffer)
              2 (.getShort buffer)
              4 (.getInt buffer)
-             8 (.getLong buffer)))
-    (catch Exception e
-      (println "deserialize-value: " (.getMessage e)))))
+             8 (.getLong buffer)))))

 (defn- deserialize-payload [buffer boundary entries]
-  "Deserializes a packet payload according to given boundary and form entries."
+  "Deserializes a packet payload according to a given boundary and form entries."
   (let [buffer (bounded-buffer buffer boundary)]
     (loop [entries entries
            payload {}]
@@ -61,7 +56,7 @@

 (defn deserialize [raw-packet entries]
   "Deserializes one or more packets from a RawPacket according
-  to given entries. Returns a list of Packet objects on success."
+  to given entries. Returns a list of destructured packets on success."
   (let [buffer (-> (.data raw-packet)
                    (ByteBuffer/wrap)
                    .asReadOnlyBuffer)]
@@ -72,8 +67,8 @@
         packets
         (let [header-boundary   (first header-boundaries)
               payload-boundary  (first payload-boundaries)
-              timestamp         (deserialize-timestamp buffer
-                                                       header-boundary)
+              timestamp         (if header-boundary
+                                  (deserialize-timestamp buffer header-boundary))
               payload           (deserialize-payload buffer
                                                      payload-boundary
                                                      entries)


Add triple equals to String instance

Add triple equals to String instance

--- src/clojure_ruby/core.clj
+++ src/clojure_ruby/core.clj
@@ -70,7 +70,10 @@
                       (create-number (count (:data this))))
              "[]" (fn string-bracket [this idx]
                     (let [idx (host-send idx :number)]
-                      (create-string (subs (:data this) idx (inc idx)))))}
+                      (create-string (subs (:data this) idx (inc idx)))))
+             "===" (fn string-triple-equal [this other]
+                     (let [other (host-send other :string)]
+                       (= (:data this) other)))}
    :host-methods {:string (fn string-host-string [this] (:data this))}})

 (def Array


- renamed match-type|pattern to type-type|pattern as per de rooover's suggestion.

--- damp.ekeko.aspectj.plugin/src/damp/ekeko/aspectj/weaverworld.clj
+++ damp.ekeko.aspectj.plugin/src/damp/ekeko/aspectj/weaverworld.clj
@@ -2303,7 +2303,7 @@
 ;;pointcut type matching

 (defn
-  match-type|pattern
+  type-type|pattern
   "non relational match to a type given a type pattern"
   [?type ?pat]
   (fresh
@@ -2312,7 +2312,7 @@
     (type ?type)
     (weaverworld ?w)
     (equals ?pattern (.parseTypePattern (new PatternParser ?pat)))
-    (equals (lvar) (.resolve ?pattern ?w)) ;;Witness the horror (How do you invoke void methods?)
+    (perform (.resolve ?pattern ?w))
     (equals true (.matchesStatically ?pattern ?type))))


[scrabble] update cortex deps, drop spurious dep

--- examples/scrabble/project.clj
+++ examples/scrabble/project.clj
@@ -1,5 +1,4 @@
 (defproject scrabble "0.1.1-SNAPSHOT"
   :dependencies [[org.clojure/clojure "1.8.0"]
-                 [thinktopic/cortex "0.1.1-SNAPSHOT"]
-                 [thi.ng/ndarray "0.3.2"]]
+                 [thinktopic/cortex "0.2.1-SNAPSHOT"]]
   :main scrabble.core)


crashing

crashing

--- Assets/game/board.clj
+++ Assets/game/board.clj
@@ -127,7 +127,7 @@
         forward-speed (.z local-velocity)
         max-speed 15.0
         max-turn (max 16 (min 42 (turn-limit forward-speed)))]
-
+   (when-not (state o :speed) (set-state! o :speed forward-speed))
    (fall-check o)
    (reset! IN-AIR (and (not grounded) (not @TOUCHING)))
    (if (and (not was-in-air) @IN-AIR)
@@ -139,9 +139,13 @@
                grounded) )
      (do (tally-tricks o)))

+   (when (< 1.0 (abs (- (abs forward-speed) (abs (state o :speed)))))
+    (detach-skater o))
+
    (text! (the debug)
      (str :steerage "   " @steerage "\n"
        :forward-speed "  " forward-speed "\n"
+       :delta-speed "  " (- (abs forward-speed) (abs (state o :speed))) "\n"
        :max-turn "  " max-turn "\n"
        :in-air "  " @IN-AIR "\n"
        :touching "  " @TOUCHING "\n"
@@ -151,11 +155,14 @@

    (update-state! o :total-euler
          #(v3+ % (delta-euler (state o :rotation) rotation)))
-
    (set-state! o :rotation (.eulerAngles (.transform o)))
+   (set-state! o :speed forward-speed)
+
+
    (when (key-down? "escape")
     (destroy-immediate @game.data/player)
     (@game.data/selection-fn))
+
    (when @STANDING
    (cond
      (and (key? "w") (wheel-contact? o))


use an atom for groups table

use an atom for groups table

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

--- acqEngine/src/org/micromanager/config_editor.clj
+++ acqEngine/src/org/micromanager/config_editor.clj
@@ -4,7 +4,7 @@
            [javax.swing.event CellEditorListener ListSelectionListener]
            [javax.swing.table AbstractTableModel]
            [java.awt Color Dimension])
-  (:use [org.micromanager.mm :only [load-mm core edt get-config]]))
+  (:use [org.micromanager.mm :only [load-mm gui core edt get-config]]))

 (declare update-presets-table)

@@ -13,17 +13,17 @@

 (defn add-group [components group]
   (core defineConfigGroup group)
-  (update-groups-table (:groups-table components))
+ ; (update-groups-table (:groups-table components))
   )

 (defn rename-group [components group-old group-new]
   (core renameConfigGroup group-old group-new)
-  (update-groups-table (:groups-table components))
+  ;(update-groups-table (:groups-table components))
   )

 (defn delete-group [components group]
   (core deleteConfigGroup group)
-  (update-groups-table (:groups-table components))
+  ;(update-groups-table (:groups-table components))
   )

 ;; editing presets
@@ -83,21 +83,11 @@

 (load-mm)

-(defn update-list [list data]
-  (let [model (.getModel list)]
-    (.clear model)
-    (doseq [datum data]
-      (.addElement model datum)))
-  list)
-
-(defn groups []
-  (sort (seq (core getAvailableConfigGroups))))
-
-(defn update-group-list [list]
-  (update-list list (sort (seq (core getAvailableConfigGroups)))))
-
-(defn group-list []
-  (update-group-list (JList. (DefaultListModel.))))
+(def groups (atom nil))
+
+(defn update-groups []
+  (reset! groups (seq (core getAvailableConfigGroups)))
+  (.refreshGUI gui))

 (defn presets [group]
   (when-not (empty? group)
@@ -177,14 +167,15 @@

 (defn group-table-model []
   (proxy [AbstractTableModel] []
+    (getColumnName [_] "Groups")
     (getColumnCount [] 1)
-    (getRowCount [] (count (groups)))
+    (getRowCount [] (count @groups))
     (isCellEditable [_ _] true)
-    (getValueAt [row column] (nth (groups) row))
+    (getValueAt [row column] (nth @groups row))
     (setValueAt [val row column]
-      (let [old-val (nth (groups) row)]
-        (println old-val val row column)
-        (core renameConfigGroup old-val val)))))
+      (let [old-val (nth @groups row)]
+        (core renameConfigGroup old-val val)
+        (update-groups)))))

 (defn show []
   (let [f (JFrame. "Micro-Manager Configuration Preset Editor")
@@ -250,5 +241,6 @@
     (start nil))
   ([group]
     (let [components (show)]
+      (update-groups)
       (activate-groups-table components)
       components)))


Hard code entity size for now

Hard code entity size for now

--- dungeon-crawler/desktop/src-common/dungeon_crawler/utils.clj
+++ dungeon-crawler/desktop/src-common/dungeon_crawler/utils.clj
@@ -10,6 +10,7 @@
 (def ^:const deceleration 0.9)
 (def ^:const map-width 40)
 (def ^:const map-height 40)
+(def ^:const entity-size 0.25)
 (def ^:const aggro-distance 2)
 (def ^:const attack-distance 0.25)
 (def ^:const grid-tile-size 256)
@@ -47,13 +48,11 @@
 (defn near-entity?
   [{:keys [x y x-feet y-feet id] :as e} e2 min-distance]
   (let [x-diff (- (+ x x-feet) (+ (:x e2) (:x-feet e2)))
-        y-diff (- (+ y y-feet) (+ (:y e2) (:y-feet e2)))
-        x-distance (+ (max (entity-width e) (entity-width e2)) min-distance)
-        y-distance (+ (max (entity-height e) (entity-height e2)) min-distance)]
+        y-diff (- (+ y y-feet) (+ (:y e2) (:y-feet e2)))]
     (and (not= id (:id e2))
          (> (:health e2) 0)
-         (< (Math/abs (double x-diff)) x-distance)
-         (< (Math/abs (double y-diff)) y-distance))))
+         (< (Math/abs (double x-diff)) (+ entity-size min-distance))
+         (< (Math/abs (double y-diff)) (+ entity-size min-distance)))))

 (defn near-entities?
   [entities entity min-distance]
@@ -94,20 +93,18 @@
        :else y-velocity)]))

 (defn ^:private get-npc-axis-velocity
-  [{:keys [max-velocity]} diff distance]
+  [{:keys [max-velocity]} diff]
   (cond
-    (> diff distance) (* -1 max-velocity)
-    (< diff (* -1 distance)) max-velocity
+    (> diff entity-size) (* -1 max-velocity)
+    (< diff (* -1 entity-size)) max-velocity
     :else 0))

 (defn ^:private get-npc-aggro-velocity
   [{:keys [x y x-feet y-feet] :as npc} me]
   (let [x-diff (- (+ x x-feet) (+ (:x me) (:x-feet me)))
-        y-diff (- (+ y y-feet) (+ (:y me) (:y-feet me)))
-        x-dist (+ (max (entity-width npc) (entity-width me)) attack-distance)
-        y-dist (+ (max (entity-height npc) (entity-height me)) attack-distance)]
-    [(get-npc-axis-velocity npc x-diff x-dist)
-     (get-npc-axis-velocity npc y-diff y-dist)]))
+        y-diff (- (+ y y-feet) (+ (:y me) (:y-feet me)))]
+    [(get-npc-axis-velocity npc x-diff)
+     (get-npc-axis-velocity npc y-diff)]))

 (defn ^:private get-npc-velocity
   [entities {:keys [last-attack attack-interval


Update cljs and core.async

Update cljs and core.async

--- build.boot
+++ build.boot
@@ -1,8 +1,8 @@
 (set-env!
  :source-paths   #{"src"}
  :resource-paths #{"resources"}
- :dependencies '[[org.clojure/clojurescript     "1.9.473"]
-                 [org.clojure/core.async        "0.2.395"]
+ :dependencies '[[org.clojure/clojurescript     "1.9.494"]
+                 [org.clojure/core.async        "0.3.441"]
                  [reagent                       "0.6.0"]
                  [re-frame                      "0.9.2"]
                  [org.martinklepsch/boot-garden "1.3.2-0"]


Update com.stuartsierra/component to 0.3.2

--- build.boot
+++ build.boot
@@ -9,7 +9,7 @@
   :developers {"James Laver" "james@seriesofpipes.com"}
   :license {"MIT" "https://en.wikipedia.org/MIT_License"}
   :dependencies '[[org.clojure/clojure "1.9.0-alpha15"          :scope "provided"]
-                  [com.stuartsierra/component "0.3.1"]
+                  [com.stuartsierra/component "0.3.2"]
                   [org.clojure/clojurescript "1.9.293"          :scope "test"]
                   [adzerk/boot-cljs "1.7.228-2"                 :scope "test"]
                   [adzerk/boot-test "1.1.2"                     :scope "test"]


Update boot-cljs-repl

Update boot-cljs-repl

--- build.boot
+++ build.boot
@@ -4,7 +4,7 @@
   :dependencies '[[org.clojure/clojure    "1.7.0"]
                   [org.clojure/clojurescript "1.7.48"]
                   [adzerk/boot-cljs       "1.7.48-5-SNAPSHOT" :scope "test"]
-                  [adzerk/boot-cljs-repl  "0.1.10-SNAPSHOT" :scope "test"]
+                  [adzerk/boot-cljs-repl  "0.2.0"      :scope "test"]
                   [adzerk/boot-reload     "0.3.3-SNAPSHOT" :scope "test"]
                   [deraen/boot-less       "0.4.1"      :scope "test"]
                   [deraen/boot-sass       "0.1.0"      :scope "test"]


use envs from system

use envs from system

--- build.boot
+++ build.boot
@@ -22,8 +22,8 @@
        :version "0.2.0"}
   s3-sync {
     :bucket "podviaznikov.com"
-    :access-key ""
-    :secret-key ""
+    :access-key (System/getenv "AWS_ACCESS_KEY")
+    :secret-key (System/getenv "AWS_SECRET_KEY")
     :source "public"
     :options {"Cache-Control" "max-age=315360000, no-transform, public"}})

@@ -70,7 +70,9 @@
         (render
           :renderer 'com.podviaznikov.book/render
           :filterer (fn [file] (= "book" (:type file))))
-        (collection :renderer 'com.podviaznikov.index/render :page "index.html")
+        (collection
+          :renderer 'com.podviaznikov.index/render
+           :page "index.html")
         (collection
           :renderer 'com.podviaznikov.essays/render
           :page "essays.html"


Split boot options from pipeline for clojars (WIP)

--- build.boot
+++ build.boot
@@ -40,7 +40,7 @@
       default-version)))

 (def project 'com.frereth/cp)
-(def version #_"0.0.3" (deduce-version-from-git))
+#_(def version #_"0.0.3" (deduce-version-from-git))

 ;; TODO: Add a dependency on weald and refactor away the local copy
 ;; of shared.logging.
@@ -77,10 +77,8 @@

 (task-options!
  aot {:namespace   #{'frereth-cp.server 'frereth-cp.client}}
- jar {:main        'frereth-cp.server
-      :file        (str "frereth-cp-" version ".jar")}
+ jar {:main        'frereth-cp.server}
  pom {:project     project
-      :version     version
       :description "Implement CurveCP in clojure"
       ;; TODO: Add a real website
       :url         "https://github.com/jimrthy/frereth-cp"
@@ -88,7 +86,10 @@
       ;; Q: Should this go into public domain like the rest
       ;; of the pieces?
       :license     {"Eclipse Public License"
-                    "http://www.eclipse.org/legal/epl-v10.html"}})
+                    "http://www.eclipse.org/legal/epl-v10.html"}}
+ ;; This might not be generally warranted.
+ ;; Then again...it seems like it only matters for "real" releases.
+ push {:ensure-branch nil})

 (require '[adzerk.bootlaces :refer [bootlaces! build-jar push-snapshot push-release]]
          '[adzerk.boot-test :refer [test]]
@@ -97,7 +98,14 @@
          '[samestep.boot-refresh :refer [refresh]]
          '[tolitius.boot-check :as check])

-(bootlaces! version :dont-modify-paths? true)
+(deftask set-version
+  []
+  (let [version (deduce-version-from-git)]
+    (task-options!
+     jar {:file (str "frereth-cp-" version ".jar")}
+     pom {:version version})
+    (bootlaces! version :dont-modify-paths? true))
+  identity)

 (deftask build
   "Build the project locally as a JAR."
@@ -107,7 +115,7 @@
   ;; TODO: Eliminate this discrepancy (not that it matters for
   ;; a library)
   (let [dir (if (seq dir) dir #{"target"})]
-    (comp (javac) (aot) (pom) (jar) (target :dir dir))))
+    (comp (set-version) (javac) (aot) (pom) (jar) (target :dir dir))))

 (deftask check-conflicts
   "Verify there are no dependency conflicts."
@@ -152,71 +160,42 @@
   (let [port (or port 32767)]
     (comp (dev) (testing) (check-conflicts) (cider) (javac) (repl :port port :bind "0.0.0.0"))))

-(deftask publish-from-branch
-  "Publish to clojars from your current branch"
-  []
-  (task-options! push {:ensure-branch nil})
-  (let [old-version version
-        version (str old-version "-SNAPSHOT")]
+(deftask to-clojars
+  "Publish"
+  []
+  (comp (set-version) (javac) (build-jar) (push-release)))
+
+(deftask from-snapshot
+  "Allow publishing a snapshot version"
+  ;; TODO: Split this into 2 tasks.
+  ;; One to wrap, pushing/popping options without updating the
+  ;; fileset.
+  ;; The other should do the actual changes in the pipeline
+  []
+
+  (let [old-version (deduce-version-from-git)
+        version (str old-version "-SNAPSHOT")
+        ;old-pom-options pom
+        old-push-options push
+        ]
     (comp
      ;; Q: Should fileset be a vector like this?
      ;; (it doesn't seem to make any difference. I've seen examples
      ;; both ways)
-     (with-pre-wrap [fileset]
+     (with-pre-wrap fileset
        (println "Setting bootlaces to publish version" version)
        ;; Note that this is really just setting the options to
        ;; push, which is part of boot.task.built-in.
        ;; Actually, the bootlaces task is just a wrapper around
        ;; that.
+       (task-options! )
+       ;(task-options! pom {:version version})
        (bootlaces! version :dont-modify-paths? true)
-       (println "Compiling")
-       #_(let [a ((javac) fileset)
-             _ (println "Java files compiled")
-             b (build-jar a)
-             _ (println "JAR built")
-             c (push-snapshot b)]
-         (println "Snapshot pushed")
-         c)
-
-       ;; Note that the javac step is vital, although not normally needed
-       ;; for a clojure-only bootlaces publish.
-       #_(-> fileset
-           javac
-           build-jar
-           push-snapshot)
-       ;; This fails: TmpFileSet cannot be cast to a java.lang.CharSequence
-       #_(boot/commit! ((comp javac build-jar push-snapshot) fileset))
-       ;; This cannot work: We must commit
-       #_((comp javac build-jar push-snapshot) fileset)
-       ;; Fails: no implementation of commit!
-       ;; of protocol: #'boot.tmpdir/ITmpFileSet found for class:
-       ;; boot.task.built_in$fn__2586$fn__2587$fn__2592$fn__2593
-       #_(boot/commit! (comp (javac) (build-jar) (push-snapshot)) fileset)
-       ;; Fails: Arguments must be either all strings or all fns
-       (boot/commit! (boot (comp (javac) (build-jar) (push-snapshot)) fileset)))
+       fileset)
      (with-post-wrap fileset
-       (bootlaces! old-version :dont-modify-paths? true)))
-    #_(fn middleware [next-handler]
-      (fn handler [fileset]
-        (bootlaces! version :dont-modify-paths? true)
-        (println "doing interesting things to fileset")
-        (let [fileset' #_((comp (javac) (build-jar) (push-snapshot)))
-              (let [a ((javac) fileset)
-                    _ (println "compiled" fileset "to" a)
-                    b ((build-jar) a)
-                    _ (println "built-jar into" b)
-                    c ((push-snapshot) b)
-                    _ (println "Snapshot pushed:" c)]
-                c)
-              #_[fileset' (fileset' fileset)]
-              _ (println "Commiting" fileset')
-              fileset' (boot/commit! (boot fileset'))
-              _ (println "Calling wrapper")
-              result (next-handler fileset')]
-          (println "Restoring previous settings")
-          (bootlaces! old-version :dont-modify-paths? true)
-          (println "Returning result")
-          result)))))
+       (bootlaces! old-version :dont-modify-paths? true)
+       ;(task-options! pom old-pom-options)
+       (task-options! push old-push-options)))))

 (deftask run
   "Run the project."


build.boot

build.boot

--- build.boot
+++ build.boot
@@ -1,3 +1,4 @@
+
 (set-env!
   :project 'irresponsible/unscrew
   :version "0.1.0"
@@ -8,7 +9,6 @@
   :scm {:url "https://github.com/irresponsible/unscrew.git"}
   :developers {"James Laver" "james@seriesofpipes.com"}
   :license {"MIT" "https://en.wikipedia.org/MIT_License"}
-  :repositories [["clojars" {:url "https://clojars.org/repo/"}]]
   :dependencies '[[org.clojure/clojure "1.8.0" :scope "provided"]
                   [byte-streams "0.2.1-alpha1"]
                   [me.raynes/fs     "1.4.6"    :scope "test"]
@@ -32,7 +32,7 @@
         :ensure-release true
         :ensure-clean   true
         :gpg-sign       true
-        :repositories (get-env :repositories)}
+        :repositories [["clojars" {:url "https://clojars.org/repo/"}]]}
   target  {:dir #{"target"}})

 (deftask tests []


GitHub Issue #45 - fixes bug where the app would crash if projects.json referenced a project.clj file that no longer exists

--- src-cljs/cljsbuild_ui/projects.cljs
+++ src-cljs/cljsbuild_ui/projects.cljs
@@ -7,10 +7,11 @@
     [cljs.reader :refer [read-string]]
     [cljsbuild-ui.cljsbuild.config :refer [extract-options]]
     [cljsbuild-ui.exec :refer [get-cljsbuild-with-profiles]]
-    [cljsbuild-ui.util :refer [path-join
-                               path-dirname]]))
+    [cljsbuild-ui.util :refer [js-log log path-join path-dirname]]))

 (def fs (js/require "fs"))
+
+(declare write-workspace!)

 ;;------------------------------------------------------------------------------
 ;; Project Parsing
@@ -54,8 +55,6 @@
       (assoc project :cljsbuild cljsbuild2))))

 ;; TODO:
-;; - Need to handle files listed in projects.json that no longer exist on disk (GitHub Issue #45)
-;;   (ie: did you remove this file?)
 ;; - need to do some quick validation of project.clj
 ;;   (ie: does it have :cljsbuild?)
 (defn load-project-file [filename]
@@ -90,8 +89,15 @@
   ;; TODO: need to do some quick validation on projects.json format here
   (when-not (.existsSync fs workspace-filename)
     (create-default-projects-file! app-data-path workspace-filename))
-  (let [filenames (js->clj (js/require workspace-filename))]
-    filenames))
+  (let [filenames1 (js->clj (js/require workspace-filename))
+        filenames2 (vec (filter #(.existsSync fs %) filenames1))]
+
+    ;; re-write projects.json if it contains a project.clj file that no longer exists
+    ;; TODO: add some UX around this to inform the user that this has happened, GitHub Issue #45
+    (when (not= filenames1 filenames2)
+      (write-workspace! filenames2))
+
+    filenames2))

 ;;------------------------------------------------------------------------------
 ;; Project Workspace Modification


removed unnecessary prints

removed unnecessary prints

--- src/frontend/uploads.cljs
+++ src/frontend/uploads.cljs
@@ -33,10 +33,6 @@
                                (get (:uploads new-state) upload-id))
         old-upload-state (first upload-diff)
         new-upload-state (second upload-diff)]
-
-    (println upload-diff)
-    (println "old:" old-upload-state)
-    (println "new:" new-upload-state)
     (if (nil? old-upload-state)
       (if (:started? new-upload-state)
         :started
@@ -61,7 +57,6 @@
         blob-stream (.createBlobReadStream js/ss file)
         upload-watch-fn (fn [_ _ old-state new-state]
                           (let [action (get-action old-state new-state upload-id)]
-                            (println "ACTION:" action)
                             (cond
                               (= action :paused)
                                 (.unpipe blob-stream)


Auto set repl when enable reload task

Auto set repl when enable reload task

--- src/npm/boot.cljs
+++ src/npm/boot.cljs
@@ -10,7 +10,7 @@
     (js->clj (js/require (str js/process.env.PWD "/package.json")))
     {"cljs" {"source-paths" ["src"]}}))

-(declare *classpath*)
+(declare reload)

 (defn file-seq [root]
   (tree-seq #(and (js/fs.existsSync %)
@@ -53,14 +53,22 @@
                                    caches)))))]
     (fn [next-handler]
       (fn [fileset]
-        (let [opts (clj->js (concat ["-c"
-                                     (str/join ":" (concat source-paths (:classpath fileset)))]
-                                    opts))]
+        (let [repl (let [idx (inc (.indexOf opts "-n"))]
+                     (when (pos? idx)
+                       (let [[host port] (str/split (nth opts idx) #":")]
+                         {:host host :port (js/parseInt port)})))
+              opts (clj->js (concat
+                             (when (and (not repl) (some #{reload} (:tasks fileset)))
+                               ["-n" "127.0.0.1:5555"])
+                             ["-c" (str/join ":" (concat source-paths (:classpath fileset)))]
+                             opts))]
           (invalid-cache!)
           (some-> @process .kill)
           (reset! process
                   (js/child_process.spawn "lumo" opts #js {:stdio "inherit"}))
-          (next-handler (assoc fileset :invalid-cache! invalid-cache!)))))))
+          (next-handler (assoc fileset
+                               :lumo/invalid-cache! invalid-cache!
+                               :lumo/repl (merge {:host "127.0.0.1" :port 5555} repl))))))))

 (defn ^:export watch [t file]
   (fn [next-handler]
@@ -79,13 +87,13 @@
       (str/replace #"_" "-")
       symbol))

-(defn ^:export reload [host port]
+(defn ^:export reload []
   (fn [next-handler]
     (let [conn (atom nil)]
-      (fn reload* [fileset]
+      (fn reload* [{:keys [lumo/repl] :as fileset}]
         (if-let [conn @conn]
           (when-let [file (:reload fileset)]
-            ((:invalid-cache! fileset))
+            ((:lumo/invalid-cache! fileset))
             (.send conn
                    (str (pr-str `(require '~(file->ns file) :reload))
                         \newline)
@@ -94,12 +102,12 @@
             (doto c
               (.on "ready" (fn [prompt]
                              (reset! conn c)
-                             (reload*)))
+                             (reload* fileset)))
               (.on "data" #(print (str %)))
               (.on "error" (fn [prompt]
-                             (js/setTimeout reload* 500)))
-              (.connect #js {:host        host
-                             :port        (js/parseInt port)
+                             (js/setTimeout #(reload* fileset) 500)))
+              (.connect #js {:host        (:host repl)
+                             :port        (:port repl)
                              :shellPrompt "cljs.user=> "
                              :timeout     1500}))))))))

@@ -124,6 +132,8 @@
 (defn -main [& argv]
   (mvn/async-map mvn/download-dep (map mvn/parse-dep (get-in PACKAGE ["cljs" "dependencies"]))
                  (fn [paths]
-                   (run-task (argv->task argv) (assoc PACKAGE :classpath paths)))))
+                   (run-task (argv->task argv)
+                             (assoc PACKAGE :classpath paths
+                                    :tasks (keep #(aget NS-EXPORTS (munge %)) argv))))))


Fix doc typo and long line.

Fix doc typo and long line.

--- src/afterglow/fixtures/blizzard.clj
+++ src/afterglow/fixtures/blizzard.clj
@@ -44,12 +44,13 @@

   If you are wondering why you are getting no light from a torrent,
   note that you need to explicitly set the shutter to open before the
-  dinner has any effect. Try something like:
+  dimmer has any effect. Try something like:

 ```clojure
 (show/add-function! :torrent-shutter
                     (afterglow.effects.channel/function-cue
-                     \"Torrent Shutter Open\" :shutter-open 50 (show/fixtures-named \"torrent\")))
+                    \"Torrent Shutter Open\" :shutter-open 50
+                    (show/fixtures-named \"torrent\")))
 ```"
   {:doc/format :markdown}
   []


Change error message

Change error message

--- frontend/src/cruncher/communication/main.cljs
+++ frontend/src/cruncher/communication/main.cljs
@@ -17,7 +17,7 @@
   "Generic error handler for ajax requests."
   [{:keys [status status-text]}]
   (lib/loading! false)
-  (.log js/console (str "I feel a disturbance in the Force... " status " " status-text)))
+  (.log js/console (str "Seems like you're not catching 'em all any more... " status " " status-text)))

 (defn success-handler
   "React on response after sending a new statement. Reset atom and call newly received url."


Fail on missing :ring-handler-provider

Fail on missing :ring-handler-provider

--- modules/http-kit/src/modular/http_kit.clj
+++ modules/http-kit/src/modular/http_kit.clj
@@ -26,12 +26,14 @@
 (defrecord Webserver [port]
   component/Lifecycle
   (start [this]
-    (let [h (handler (:ring-handler-provider this))]
-      (assert handler)
-      (if port
-        (infof "port is %d" port)
-        (warnf "port is nil, using default of %d" default-port))
-      (assoc this :server (run-server h {:port (or port default-port)}))))
+    (if-let [ring-handler-provider (:ring-handler-provider this)]
+      (let [h (handler ring-handler-provider)]
+        (assert handler)
+        (if port
+          (infof "port is %d" port)
+          (warnf "port is nil, using default of %d" default-port))
+        (assoc this :server (run-server h {:port (or port default-port)})))
+      (throw (ex-info "http-kit module requires that :ring-handler-provider be added to the system map by a component" {}))))

   (stop [this]
     (when-let [server (:server this)]


Issue 9729: Added fixtures to document mapper tests

git-svn-id: b7e9aa1d6cd963481915708f70423d437278b157@18138 bd66a97b-2aff-0310-9095-89ca5cabf5a6

--- src/test/clojure/com/imcode/imcms/mapping/DocumentMapperTest.clj
+++ src/test/clojure/com/imcode/imcms/mapping/DocumentMapperTest.clj
@@ -33,26 +33,32 @@
 (def *text-no* 1000)
 (def *content-loop-no* 1000)
 (def *working-version-no* 0)
+(def *superadmin*)

-(use-fixtures :once init-imcms-fixture)
+
+(defn bind-users-fixture
+  "Binds imcms users (*superadmin*)."
+  [f]
+  (binding [*superadmin* (rt/login :admin :admin)]
+    (f)))
+
+(use-fixtures :once init-imcms-fixture bind-users-fixture)

 (deftest test-save-text
   (testing "with new text"
-    (let [user (rt/login :admin :admin)
-          text-doc (rt/get-working-doc *text-doc-id* *lang*)
+    (let [text-doc (rt/get-working-doc *text-doc-id* *lang*)
           text (factory/new-text *text-doc-id* *working-version-no* *text-no* "test")]

       (.setLanguage text (.getLanguage text-doc))
-      (.saveText (rt/get-doc-mapper) text-doc text user)))
+      (.saveText (rt/get-doc-mapper) text-doc text *superadmin*)))

   (testing "with existings text"
-    (let [user (rt/login :admin :admin)
-          text-doc (rt/get-working-doc *text-doc-id* *lang*)
+    (let [text-doc (rt/get-working-doc *text-doc-id* *lang*)
           text (.getText text-doc *text-no*)]

       (.setText text "new text")
-      (.saveText (rt/get-doc-mapper) text-doc text user))))
+      (.saveText (rt/get-doc-mapper) text-doc text *superadmin*))))

 ;(defn test-insert-text-with-create-loop


using only ip to access remote hosts

using only ip to access remote hosts

--- src/celestial/puppet_standalone.clj
+++ src/celestial/puppet_standalone.clj
@@ -73,10 +73,11 @@
 (defrecord Standalone [remote type]
   Provision
   (apply- [this]
+    (println remote)
     (let [puppet-std (type :puppet-std) module (puppet-std :module)]
         (execute puppet-provision {:module module :type type} :web :env {:roles {:web #{remote}}}))))

 (defmethod pconstruct :puppet-std [type {:keys [machine] :as spec}]
-  (let [remote {:host (or (machine :ip) (machine :ssh-host)) :user (or (machine :user) "root")}]
+  (let [remote {:host (machine :ip) :user (or (machine :user) "root")}]
     (Standalone. remote (assoc type :hostname (machine :hostname)))))


Memoize most often called pure view functions

--- src/cljs/asciinema_player/view.cljs
+++ src/cljs/asciinema_player/view.cljs
@@ -23,11 +23,15 @@
         classes (remove nil? [fg-class bg-class bold-class underline-class cursor-class])]
     (string/join " " classes)))

+(def part-class-name-memoized (memoize part-class-name))
+
 (defn part [[text attrs] cursor-on]
-  [:span {:class-name (part-class-name attrs cursor-on)} text])
+  [:span {:class-name (part-class-name-memoized attrs cursor-on)} text])
+
+(def part-memoized (memoize part))

 (defn line [parts cursor-on]
-  [:span.line (map-indexed (fn [idx p] ^{:key idx} [part p cursor-on]) parts)])
+  [:span.line (map-indexed (fn [idx p] ^{:key idx} [part-memoized p cursor-on]) parts)])

 (defn split-part-with-cursor [[text attrs] position]
   (let [left-chars (take position text)


deck edit area placeholder

deck edit area placeholder

--- src/cljs/netrunner/deckbuilder.cljs
+++ src/cljs/netrunner/deckbuilder.cljs
@@ -164,6 +164,7 @@
               [:button {:on-click #()} "Add to deck"]]]
             [:h4 "Decklist"]
             [:textarea {:ref "deck-edit" :value (:deck-edit state)
+                        :placeholder "Copy & paste a decklist. Or start typing."
                         :on-change #(handle-edit owner)}]]]]]]))))

 (om/root deck-builder app-state {:target (. js/document (getElementById "deckbuilder"))})


Implement Clojure wrapper.

Implement Clojure wrapper.

--- src/clojure/com/hypirion/primes.clj
+++ src/clojure/com/hypirion/primes.clj
@@ -1,6 +1,15 @@
-(ns com.hypirion.primes)
+(ns com.hypirion.primes
+  (:import [com.hypirion.primes Primes])
+  (:refer-clojure :exclude [take get]))

-(defn foo
-  "I don't do a whole lot."
-  [x]
-  (println x "Hello, World!"))
+(defn prime? [n]
+  (Primes/isPrime n))
+
+(defn take [n]
+  (Primes/take n))
+
+(defn get [n]
+  (Primes/get n))
+
+(defn take-below [n]
+  (Primes/takeUnder n))


playing with HTML generation

playing with HTML generation

--- src/clojure_getting_started/web.clj
+++ src/clojure_getting_started/web.clj
@@ -10,7 +10,9 @@
 (defn splash []
   {:status 200
    :headers {"Content-Type" "text/html"}
-   :body (str "
Hier gibt's noch nix zu gucken, geh spielen ...
")})
+   :body (str "
Hier gibt's noch nix zu gucken, "
+              "geh spielen ...
"
+              "")})

 (defroutes app
   (GET "/camel" {{input :input} :params}


Minor reformat.

Minor reformat.

--- src/clojush/instructions/genome.clj
+++ src/clojush/instructions/genome.clj
@@ -1,4 +1,4 @@
- (ns clojush.instructions.genome
+(ns clojush.instructions.genome
   (:use [clojush pushstate globals args random]
         clojush.instructions.common
         clojush.pushgp.genetic-operators))


format docstring

format docstring

--- src/overtone/sc/synth.clj
+++ src/overtone/sc/synth.clj
@@ -517,7 +517,8 @@
   "Decompile a parsed SuperCollider synth definition back into clojure code
   that could be used to generate an identical synth.

-  While this probably won't create a synth definition that can directly compile, it can still be helpful when trying to reverse engineer a synth."
+  While this probably won't create a synth definition that can directly compile,
+  it can still be helpful when trying to reverse engineer a synth."
   [{:keys [name constants params pnames ugens] :as sdef}]
   (let [sname (symbol name)
         param-vec (param-vector params pnames)